diff options
author | Harald Musum <musum@yahooinc.com> | 2023-10-07 12:37:02 +0200 |
---|---|---|
committer | Harald Musum <musum@yahooinc.com> | 2023-10-07 12:37:02 +0200 |
commit | 95bad6b2f6a6343c556dc2af30d13f76ac289e0b (patch) | |
tree | 581532d23c3aae96ea16976edf75e22e8b0118e5 /controller-server/src/test | |
parent | 178d9d661c4eaebc9803031ec390ff2f9812ad9b (diff) |
Add handler for pricing API
Diffstat (limited to 'controller-server/src/test')
2 files changed, 48 insertions, 0 deletions
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ControllerContainerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ControllerContainerTest.java index 7522f42f91b..8bf16dfd6c7 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ControllerContainerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ControllerContainerTest.java @@ -77,6 +77,7 @@ public class ControllerContainerTest { <component id='com.yahoo.vespa.hosted.controller.Controller'/> <component id='com.yahoo.vespa.hosted.controller.integration.ConfigServerProxyMock'/> <component id='com.yahoo.vespa.hosted.controller.maintenance.ControllerMaintenance'/> + <component id='com.yahoo.vespa.hosted.controller.api.integration.MockPricingController'/> <component id='com.yahoo.vespa.hosted.controller.api.integration.stubs.MockMavenRepository'/> <component id='com.yahoo.vespa.hosted.controller.api.integration.stubs.MockUserManagement'/> <component id='com.yahoo.vespa.hosted.controller.integration.SecretStoreMock'/> @@ -117,6 +118,9 @@ public class ControllerContainerTest { <handler id='com.yahoo.vespa.hosted.controller.restapi.changemanagement.ChangeManagementApiHandler'> <binding>http://localhost/changemanagement/v1/*</binding> </handler> + <handler id='com.yahoo.vespa.hosted.controller.restapi.pricing.PricingApiHandler'> + <binding>http://localhost/pricing/v1/*</binding> + </handler> %s </container> """.formatted(system().value(), variablePartXml()); diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/pricing/PricingApiHandlerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/pricing/PricingApiHandlerTest.java new file mode 100644 index 00000000000..1df9bedf5d6 --- /dev/null +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/pricing/PricingApiHandlerTest.java @@ -0,0 +1,44 @@ +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.vespa.hosted.controller.restapi.pricing; + +import com.yahoo.config.provision.SystemName; +import com.yahoo.vespa.hosted.controller.restapi.ContainerTester; +import com.yahoo.vespa.hosted.controller.restapi.ControllerContainerCloudTest; +import org.junit.jupiter.api.Test; + +import java.net.URLEncoder; + +import static java.nio.charset.StandardCharsets.UTF_8; +import static org.junit.jupiter.api.Assertions.assertEquals; + +/** + * @author hmusum + */ +public class PricingApiHandlerTest extends ControllerContainerCloudTest { + + private static final String responseFiles = "src/test/java/com/yahoo/vespa/hosted/controller/restapi/pricing/responses/"; + + @Test + void testPricingInfo() { + ContainerTester tester = new ContainerTester(container, responseFiles); + assertEquals(SystemName.Public, tester.controller().system()); + + var request = request("/pricing/v1/pricing?" + urlEncodedPriceInformation()); + tester.assertResponse(request, """ + {"listPrice":"2400.00","volumeDiscount":"0.00"}""", + 200); + } + + /** + * 2 clusters, with each having 1 node, with 1 vcpu, 1 Gb memory, 10 Gb disk and no GPU + * price will be 20000 + 2000 + 200 + */ + String urlEncodedPriceInformation() { + var parameters = "supportLevel=standard&committedSpend=0&enclave=false" + + "&resources=nodes=1,vcpu=1,memoryGb=1,diskGb=10,gpuMemoryGb=0" + + "&resources=nodes=1,vcpu=1,memoryGb=1,diskGb=10,gpuMemoryGb=0"; + + return URLEncoder.encode(parameters, UTF_8); + } + +} |