aboutsummaryrefslogtreecommitdiffstats
path: root/controller-server/src/test/java
diff options
context:
space:
mode:
authorMartin Polden <mpolden@mpolden.no>2019-09-05 10:03:00 +0200
committerMartin Polden <mpolden@mpolden.no>2019-09-05 13:11:32 +0200
commit5c3885c99f97bd4ab03e5e82087696fac193ccd0 (patch)
tree3bda6f740066557ff799ac8764562a7900e71284 /controller-server/src/test/java
parent26842f3a79578c35d74c9f83526a02c3f665fd8b (diff)
Move CostReportConsumer to ServiceRegistry
Diffstat (limited to 'controller-server/src/test/java')
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ServiceRegistryMock.java8
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/CostReportMaintainerTest.java27
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ControllerContainerTest.java1
3 files changed, 19 insertions, 17 deletions
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ServiceRegistryMock.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ServiceRegistryMock.java
index 0d15d863ab6..2b1cd2f17e8 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ServiceRegistryMock.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ServiceRegistryMock.java
@@ -16,6 +16,7 @@ import com.yahoo.vespa.hosted.controller.api.integration.organization.Mailer;
import com.yahoo.vespa.hosted.controller.api.integration.organization.MockContactRetriever;
import com.yahoo.vespa.hosted.controller.api.integration.organization.MockIssueHandler;
import com.yahoo.vespa.hosted.controller.api.integration.organization.OwnershipIssues;
+import com.yahoo.vespa.hosted.controller.api.integration.resource.CostReportConsumer;
import com.yahoo.vespa.hosted.controller.api.integration.resource.MeteringClient;
import com.yahoo.vespa.hosted.controller.api.integration.routing.GlobalRoutingService;
import com.yahoo.vespa.hosted.controller.api.integration.routing.MemoryGlobalRoutingService;
@@ -24,6 +25,7 @@ import com.yahoo.vespa.hosted.controller.api.integration.stubs.DummyOwnershipIss
import com.yahoo.vespa.hosted.controller.api.integration.stubs.LoggingDeploymentIssues;
import com.yahoo.vespa.hosted.controller.api.integration.stubs.MockMailer;
import com.yahoo.vespa.hosted.controller.api.integration.stubs.MockMeteringClient;
+import com.yahoo.vespa.hosted.controller.restapi.cost.CostReportConsumerMock;
/**
* A mock implementation of a {@link ServiceRegistry} for testing purposes.
@@ -45,6 +47,7 @@ public class ServiceRegistryMock extends AbstractComponent implements ServiceReg
private final DummyOwnershipIssues dummyOwnershipIssues = new DummyOwnershipIssues();
private final LoggingDeploymentIssues loggingDeploymentIssues = new LoggingDeploymentIssues();
private final MemoryEntityService memoryEntityService = new MemoryEntityService();
+ private final CostReportConsumerMock costReportConsumerMock = new CostReportConsumerMock();
@Override
public ConfigServer configServer() {
@@ -102,6 +105,11 @@ public class ServiceRegistryMock extends AbstractComponent implements ServiceReg
}
@Override
+ public CostReportConsumer costReportConsumer() {
+ return costReportConsumerMock;
+ }
+
+ @Override
public NameService nameService() {
return memoryNameService;
}
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/CostReportMaintainerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/CostReportMaintainerTest.java
index 892da281667..bc68491d8dd 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/CostReportMaintainerTest.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/CostReportMaintainerTest.java
@@ -1,13 +1,15 @@
package com.yahoo.vespa.hosted.controller.maintenance;
import com.yahoo.vespa.hosted.controller.ControllerTester;
+import com.yahoo.vespa.hosted.controller.api.identifiers.Property;
+import com.yahoo.vespa.hosted.controller.api.integration.resource.ResourceAllocation;
import com.yahoo.vespa.hosted.controller.integration.ZoneApiMock;
-import com.yahoo.vespa.hosted.controller.restapi.cost.CostReportConsumer;
-import com.yahoo.vespa.hosted.controller.restapi.cost.config.SelfHostedCostConfig;
+import com.yahoo.vespa.hosted.controller.restapi.cost.CostReportConsumerMock;
import org.junit.Test;
import java.time.Duration;
import java.time.Instant;
+import java.util.Map;
import static org.junit.Assert.assertEquals;
@@ -28,21 +30,15 @@ public class CostReportMaintainerTest {
ZoneApiMock.newBuilder().withId("prod.eu-west-1").withCloud("yahoo").build());
addNodes();
- CostReportConsumer mockConsumer = csv -> assertEquals(
- "Date,Property,Reserved Cpu Cores,Reserved Memory GB,Reserved Disk Space GB,Usage Fraction\n" +
+ CostReportConsumerMock costReportConsumer = new CostReportConsumerMock(
+ (csv) -> assertEquals(
+ "Date,Property,Reserved Cpu Cores,Reserved Memory GB,Reserved Disk Space GB,Usage Fraction\n" +
"1970-01-01,Property1,96.0,96.0,2000.0,0.3055555555555555\n" +
"1970-01-01,Property3,128.0,96.0,2000.0,0.3333333333333333\n" +
"1970-01-01,Property2,160.0,96.0,2000.0,0.3611111111111111",
- csv);
-
- SelfHostedCostConfig costConfig = new SelfHostedCostConfig.Builder()
- .properties(
- new SelfHostedCostConfig.Properties.Builder()
- .name("Property3")
- .cpuCores(256)
- .memoryGb(192)
- .diskGb(4000))
- .build();
+ csv),
+ Map.of(new Property("Property3"), new ResourceAllocation(256, 192, 4000))
+ );
tester.createTenant("tenant1", "app1", 1L);
@@ -50,9 +46,8 @@ public class CostReportMaintainerTest {
CostReportMaintainer maintainer = new CostReportMaintainer(
tester.controller(),
Duration.ofDays(1),
- mockConsumer,
new JobControl(tester.curator()),
- costConfig);
+ costReportConsumer);
maintainer.maintain();
}
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 bc1c0c5013d..d1c7ac5d363 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
@@ -64,7 +64,6 @@ public class ControllerContainerTest {
" <component id='com.yahoo.vespa.curator.mock.MockCurator'/>\n" +
" <component id='com.yahoo.vespa.hosted.controller.persistence.MockCuratorDb'/>\n" +
" <component id='com.yahoo.vespa.hosted.controller.athenz.mock.AthenzClientFactoryMock'/>\n" +
- " <component id='com.yahoo.vespa.hosted.controller.restapi.cost.NoopCostReportConsumer'/>\n" +
" <component id='com.yahoo.vespa.hosted.controller.api.integration.stubs.MockRunDataStore'/>\n" +
" <component id='com.yahoo.vespa.hosted.controller.api.integration.aws.MockAwsEventFetcher' />\n" +
" <component id='com.yahoo.vespa.hosted.controller.api.integration.organization.MockBilling'/>\n" +