diff options
3 files changed, 54 insertions, 44 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/MockPricingController.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/MockPricingController.java index 6fe7017e3b7..ee0df3adbfb 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/MockPricingController.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/MockPricingController.java @@ -17,20 +17,25 @@ import static java.math.BigDecimal.valueOf; public class MockPricingController implements PricingController { + private static final BigDecimal cpuCost = new BigDecimal("1.00"); + private static final BigDecimal memoryCost = new BigDecimal("0.10"); + private static final BigDecimal diskCost = new BigDecimal("0.005"); + @Override public Prices priceForApplications(List<ApplicationResources> applicationResources, PricingInfo pricingInfo, Plan plan) { ApplicationResources resources = applicationResources.get(0); - BigDecimal listPrice = resources.vcpu().multiply(valueOf(1000)) - .add(resources.memoryGb().multiply(valueOf(100))) - .add(resources.diskGb().multiply(valueOf(10))) - .add(resources.enclaveVcpu().multiply(valueOf(1000)) - .add(resources.enclaveMemoryGb().multiply(valueOf(100))) - .add(resources.enclaveDiskGb().multiply(valueOf(10)))); - - BigDecimal supportLevelCost = pricingInfo.supportLevel() == BASIC ? new BigDecimal("-160.00") : new BigDecimal("800.00"); + + BigDecimal listPrice = resources.vcpu().multiply(cpuCost) + .add(resources.memoryGb().multiply(memoryCost) + .add(resources.diskGb().multiply(diskCost)) + .add(resources.enclaveVcpu().multiply(cpuCost) + .add(resources.enclaveMemoryGb().multiply(memoryCost)) + .add(resources.enclaveDiskGb().multiply(diskCost)))); + + BigDecimal supportLevelCost = pricingInfo.supportLevel() == BASIC ? new BigDecimal("-1.00") : new BigDecimal("8.00"); BigDecimal listPriceWithSupport = listPrice.add(supportLevelCost); - BigDecimal enclaveDiscount = isEnclave(resources) ? new BigDecimal("-15.1234") : BigDecimal.ZERO; - BigDecimal volumeDiscount = new BigDecimal("-5.64315634"); + BigDecimal enclaveDiscount = isEnclave(resources) ? new BigDecimal("-0.15") : BigDecimal.ZERO; + BigDecimal volumeDiscount = new BigDecimal("-0.1"); BigDecimal appTotalAmount = listPrice.add(supportLevelCost).add(enclaveDiscount).add(volumeDiscount); List<PriceInformation> appPrices = applicationResources.stream() @@ -42,9 +47,12 @@ public class MockPricingController implements PricingController { .toList(); PriceInformation sum = PriceInformation.sum(appPrices); - var committedAmountDiscount = new BigDecimal("-1.23"); + var committedAmountDiscount = new BigDecimal("-0.2"); var totalAmount = sum.totalAmount().add(committedAmountDiscount); - var totalPrice = new PriceInformation(ZERO, ZERO, committedAmountDiscount, ZERO, totalAmount); + var enclave = ZERO; + if (resources.enclave() && totalAmount.compareTo(new BigDecimal("14.00")) < 0) + enclave = new BigDecimal("14.00").subtract(totalAmount); + var totalPrice = new PriceInformation(ZERO, ZERO, committedAmountDiscount, enclave, totalAmount); return new Prices(appPrices, totalPrice); } diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/pricing/PricingApiHandler.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/pricing/PricingApiHandler.java index 6ef247c5b41..0a43ec599d5 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/pricing/PricingApiHandler.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/pricing/PricingApiHandler.java @@ -204,7 +204,7 @@ public class PricingApiHandler extends ThreadedHttpRequestHandler { applicationPrices(applicationsArray, prices.priceInformationApplications(), priceParameters); var priceInfoArray = cursor.setArray("priceInfo"); - addItem(priceInfoArray, "Enclave", prices.totalPriceInformation().enclaveDiscount()); + addItem(priceInfoArray, "Enclave (minimum $10k per month)", prices.totalPriceInformation().enclaveDiscount()); addItem(priceInfoArray, "Committed spend", prices.totalPriceInformation().committedAmountDiscount()); setBigDecimal(cursor, "totalAmount", prices.totalPriceInformation().totalAmount()); 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 63636b3ff20..c4b5a771725 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 @@ -27,15 +27,15 @@ public class PricingApiHandlerTest extends ControllerContainerCloudTest { "applications": [ { "priceInfo": [ - {"description": "Basic support unit price", "amount": "2240.00"}, - {"description": "Volume discount", "amount": "-5.64"} + {"description": "Basic support unit price", "amount": "4.30"}, + {"description": "Volume discount", "amount": "-0.10"} ] } ], "priceInfo": [ - {"description": "Committed spend", "amount": "-1.23"} + {"description": "Committed spend", "amount": "-0.20"} ], - "totalAmount": "2233.13" + "totalAmount": "4.00" } """, 200); @@ -49,16 +49,17 @@ public class PricingApiHandlerTest extends ControllerContainerCloudTest { "applications": [ { "priceInfo": [ - {"description": "Basic support unit price", "amount": "2240.00"}, - {"description": "Enclave", "amount": "-15.12"}, - {"description": "Volume discount", "amount": "-5.64"} + {"description": "Basic support unit price", "amount": "4.30"}, + {"description": "Enclave", "amount": "-0.15"}, + {"description": "Volume discount", "amount": "-0.10"} ] } ], "priceInfo": [ - {"description": "Committed spend", "amount": "-1.23"} + {"description": "Enclave (minimum $10k per month)", "amount": "10.15"}, + {"description": "Committed spend", "amount": "-0.20"} ], - "totalAmount": "2218.00" + "totalAmount": "3.85" } """, 200); @@ -72,16 +73,17 @@ public class PricingApiHandlerTest extends ControllerContainerCloudTest { "applications": [ { "priceInfo": [ - {"description": "Commercial support unit price", "amount": "3200.00"}, - {"description": "Enclave", "amount": "-15.12"}, - {"description": "Volume discount", "amount": "-5.64"} + {"description": "Commercial support unit price", "amount": "13.30"}, + {"description": "Enclave", "amount": "-0.15"}, + {"description": "Volume discount", "amount": "-0.10"} ] } ], "priceInfo": [ - {"description": "Committed spend", "amount": "-1.23"} + {"description": "Enclave (minimum $10k per month)", "amount": "1.15"}, + {"description": "Committed spend", "amount": "-0.20"} ], - "totalAmount": "3178.00" + "totalAmount": "12.85" } """, 200); @@ -95,23 +97,23 @@ public class PricingApiHandlerTest extends ControllerContainerCloudTest { "applications": [ { "priceInfo": [ - {"description": "Commercial support unit price", "amount": "2000.00"}, - {"description": "Enclave", "amount": "-15.12"}, - {"description": "Volume discount", "amount": "-5.64"} + {"description": "Commercial support unit price", "amount": "13.30"}, + {"description": "Enclave", "amount": "-0.15"}, + {"description": "Volume discount", "amount": "-0.10"} ] }, { "priceInfo": [ - {"description": "Commercial support unit price", "amount": "2000.00"}, - {"description": "Enclave", "amount": "-15.12"}, - {"description": "Volume discount", "amount": "-5.64"} + {"description": "Commercial support unit price", "amount": "13.30"}, + {"description": "Enclave", "amount": "-0.15"}, + {"description": "Volume discount", "amount": "-0.10"} ] } ], "priceInfo": [ - {"description": "Committed spend", "amount": "-1.23"} + {"description": "Committed spend", "amount": "-0.20"} ], - "totalAmount": "3957.24" + "totalAmount": "25.90" } """, 200); @@ -151,31 +153,31 @@ public class PricingApiHandlerTest extends ControllerContainerCloudTest { /** * 1 app, with 2 clusters (with total resources for all clusters with each having - * 1 node, with 1 vcpu, 1 Gb memory, 10 Gb disk and no GPU, + * 1 node, with 4 vcpu, 8 Gb memory, 100 Gb disk and no GPU, * price will be 20000 + 2000 + 200 */ String urlEncodedPriceInformation1App(PricingInfo.SupportLevel supportLevel) { - return "application=" + URLEncoder.encode("vcpu=2,memoryGb=2,diskGb=20,gpuMemoryGb=0", UTF_8) + - "&supportLevel=" + supportLevel.name().toLowerCase() + "&committedSpend=100"; + return "application=" + URLEncoder.encode("vcpu=4,memoryGb=8,diskGb=100,gpuMemoryGb=0", UTF_8) + + "&supportLevel=" + supportLevel.name().toLowerCase() + "&committedSpend=20"; } /** * 1 app, with 2 clusters (with total resources for all clusters with each having - * 1 node, with 1 vcpu, 1 Gb memory, 10 Gb disk and no GPU, + * 1 node, with 4 vcpu, 8 Gb memory, 100 Gb disk and no GPU, * price will be 20000 + 2000 + 200 */ String urlEncodedPriceInformation1AppEnclave(PricingInfo.SupportLevel supportLevel) { - return "application=" + URLEncoder.encode("enclaveVcpu=2,enclaveMemoryGb=2,enclaveDiskGb=20,enclaveGpuMemoryGb=0", UTF_8) + - "&supportLevel=" + supportLevel.name().toLowerCase() + "&committedSpend=100"; + return "application=" + URLEncoder.encode("enclaveVcpu=4,enclaveMemoryGb=8,enclaveDiskGb=100,enclaveGpuMemoryGb=0", UTF_8) + + "&supportLevel=" + supportLevel.name().toLowerCase() + "&committedSpend=20"; } /** * 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 + * 1 node, with 4 vcpu, 8 Gb memory, 100 Gb disk and no GPU, */ String urlEncodedPriceInformation2AppsEnclave(PricingInfo.SupportLevel supportLevel) { - return "application=" + URLEncoder.encode("enclaveVcpu=1,enclaveMemoryGb=1,enclaveDiskGb=10,enclaveGpuMemoryGb=0", UTF_8) + - "&application=" + URLEncoder.encode("enclaveVcpu=1,enclaveMemoryGb=1,enclaveDiskGb=10,enclaveGpuMemoryGb=0", UTF_8) + + return "application=" + URLEncoder.encode("enclaveVcpu=4,enclaveMemoryGb=8,enclaveDiskGb=100,enclaveGpuMemoryGb=0", UTF_8) + + "&application=" + URLEncoder.encode("enclaveVcpu=4,enclaveMemoryGb=8,enclaveDiskGb=100,enclaveGpuMemoryGb=0", UTF_8) + "&supportLevel=" + supportLevel.name().toLowerCase() + "&committedSpend=0"; } |