aboutsummaryrefslogtreecommitdiffstats
path: root/controller-server/src/test/java/com
diff options
context:
space:
mode:
authorHarald Musum <musum@yahooinc.com>2023-10-13 13:29:05 +0200
committerHarald Musum <musum@yahooinc.com>2023-10-13 13:29:05 +0200
commit247535e91dee2dbf6fd28484e702d9371ff8892a (patch)
tree4496876a31def1bf14ea48fa2c60a5211508bcdb /controller-server/src/test/java/com
parent499b9d9198b90349d07f7519545835950de9403d (diff)
Test pricing API with 2 apps
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.java49
1 files changed, 47 insertions, 2 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 8fc8fd25384..321e582437a 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
@@ -141,6 +141,41 @@ public class PricingApiHandlerTest extends ControllerContainerCloudTest {
}
@Test
+ void testPricingInfoCommercialEnclave2Apps() {
+ ContainerTester tester = new ContainerTester(container, responseFiles);
+ assertEquals(SystemName.Public, tester.controller().system());
+
+ var request = request("/pricing/v1/pricing?" + urlEncodedPriceInformation2AppsEnclave(COMMERCIAL));
+ tester.assertJsonResponse(request, """
+ {
+ "applications": [
+ {
+ "name": "app1",
+ "priceInfo": [
+ {"description": "Commercial support unit price", "amount": "2000.00"},
+ {"description": "Enclave", "amount": "-15.12"},
+ {"description": "Volume discount", "amount": "-5.64"}
+ ]
+ },
+ {
+ "name": "app2",
+ "priceInfo": [
+ {"description": "Commercial support unit price", "amount": "2000.00"},
+ {"description": "Enclave", "amount": "-15.12"},
+ {"description": "Volume discount", "amount": "-5.64"}
+ ]
+ }
+ ],
+ "priceInfo": [
+ {"description": "Committed spend", "amount": "-1.23"}
+ ],
+ "totalAmount": "3957.24"
+ }
+ """,
+ 200);
+ }
+
+ @Test
void testInvalidRequests() {
ContainerTester tester = new ContainerTester(container, responseFiles);
assertEquals(SystemName.Public, tester.controller().system());
@@ -185,7 +220,7 @@ public class PricingApiHandlerTest extends ControllerContainerCloudTest {
* price will be 20000 + 2000 + 200
*/
String urlEncodedPriceInformation1App(PricingInfo.SupportLevel supportLevel) {
- return "application=" + URLEncoder.encode("name=myapp,vcpu=2,memoryGb=2,diskGb=20,gpuMemoryGb=0", UTF_8) +
+ return "application=" + URLEncoder.encode("name=app1,vcpu=2,memoryGb=2,diskGb=20,gpuMemoryGb=0", UTF_8) +
"&supportLevel=" + supportLevel.name().toLowerCase() + "&committedSpend=100";
}
@@ -195,8 +230,18 @@ public class PricingApiHandlerTest extends ControllerContainerCloudTest {
* price will be 20000 + 2000 + 200
*/
String urlEncodedPriceInformation1AppEnclave(PricingInfo.SupportLevel supportLevel) {
- return "application=" + URLEncoder.encode("name=myapp,enclaveVcpu=2,enclaveMemoryGb=2,enclaveDiskGb=20,enclaveGpuMemoryGb=0", UTF_8) +
+ return "application=" + URLEncoder.encode("name=app1,enclaveVcpu=2,enclaveMemoryGb=2,enclaveDiskGb=20,enclaveGpuMemoryGb=0", UTF_8) +
"&supportLevel=" + supportLevel.name().toLowerCase() + "&committedSpend=100";
}
+ /**
+ * 2 apps, with 1 cluster (with total resources for all clusters with each having
+ * 1 node, with 1 vcpu, 1 Gb memory, 10 Gb disk and no GPU
+ */
+ String urlEncodedPriceInformation2AppsEnclave(PricingInfo.SupportLevel supportLevel) {
+ return "application=" + URLEncoder.encode("name=app1,enclaveVcpu=1,enclaveMemoryGb=1,enclaveDiskGb=10,enclaveGpuMemoryGb=0", UTF_8) +
+ "&application=" + URLEncoder.encode("name=app2,enclaveVcpu=1,enclaveMemoryGb=1,enclaveDiskGb=10,enclaveGpuMemoryGb=0", UTF_8) +
+ "&supportLevel=" + supportLevel.name().toLowerCase() + "&committedSpend=0";
+ }
+
}