diff options
author | Harald Musum <musum@yahooinc.com> | 2023-10-11 11:39:15 +0200 |
---|---|---|
committer | Harald Musum <musum@yahooinc.com> | 2023-10-11 11:39:15 +0200 |
commit | d98dd58e943b0d661c3cfb2b34b155046afc26d0 (patch) | |
tree | d3f1901832cbeec77974159e7ccfec926b1e5147 /controller-server/src/test/java/com | |
parent | e7686cdb6f461699cde8561becd17e0fd1b78fea (diff) |
Add support level cost to pricing API response
Diffstat (limited to 'controller-server/src/test/java/com')
-rw-r--r-- | controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/pricing/PricingApiHandlerTest.java | 34 |
1 files changed, 29 insertions, 5 deletions
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 index 0a3ed0a1442..0ffc2449a2d 100644 --- 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 @@ -2,12 +2,15 @@ package com.yahoo.vespa.hosted.controller.restapi.pricing; import com.yahoo.config.provision.SystemName; +import com.yahoo.vespa.hosted.controller.api.integration.pricing.PricingInfo; 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 com.yahoo.vespa.hosted.controller.api.integration.pricing.PricingInfo.SupportLevel.BASIC; +import static com.yahoo.vespa.hosted.controller.api.integration.pricing.PricingInfo.SupportLevel.COMMERCIAL; import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -19,24 +22,45 @@ public class PricingApiHandlerTest extends ControllerContainerCloudTest { private static final String responseFiles = "src/test/java/com/yahoo/vespa/hosted/controller/restapi/pricing/responses/"; @Test - void testPricingInfo() { + void testPricingInfoBasic() { ContainerTester tester = new ContainerTester(container, responseFiles); assertEquals(SystemName.Public, tester.controller().system()); - var request = request("/pricing/v1/pricing?" + urlEncodedPriceInformation()); + var request = request("/pricing/v1/pricing?" + urlEncodedPriceInformation(BASIC, false)); tester.assertJsonResponse(request, """ { "priceInfo": [ {"description": "List price", "amount": "2400.00"}, + {"description": "Support level", "amount": "-160.00"}, {"description": "Volume discount", "amount": "-5.64"} ], - "totalAmount": "2394.36" + "totalAmount": "2234.36" } """, 200); } @Test + void testPricingInfoCommercialEnclave() { + ContainerTester tester = new ContainerTester(container, responseFiles); + assertEquals(SystemName.Public, tester.controller().system()); + + var request = request("/pricing/v1/pricing?" + urlEncodedPriceInformation(COMMERCIAL, true)); + tester.assertJsonResponse(request, """ + { + "priceInfo": [ + {"description": "List price", "amount": "2400.00"}, + {"description": "Support level", "amount": "800.00"}, + {"description": "Enclave discount", "amount": "-15.12"}, + {"description": "Volume discount", "amount": "-5.64"} + ], + "totalAmount": "3179.23" + } + """, + 200); + } + + @Test void testInvalidRequests() { ContainerTester tester = new ContainerTester(container, responseFiles); assertEquals(SystemName.Public, tester.controller().system()); @@ -68,9 +92,9 @@ public class PricingApiHandlerTest extends ControllerContainerCloudTest { * 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() { + String urlEncodedPriceInformation(PricingInfo.SupportLevel supportLevel, boolean enclave) { String resources = URLEncoder.encode("nodes=1,vcpu=1,memoryGb=1,diskGb=10,gpuMemoryGb=0", UTF_8); - return "supportLevel=basic&committedSpend=0&enclave=false" + + return "supportLevel=" + supportLevel.name().toLowerCase() + "&committedSpend=0&enclave=" + enclave + "&resources=" + resources + "&resources=" + resources; } |