aboutsummaryrefslogtreecommitdiffstats
path: root/controller-server
diff options
context:
space:
mode:
authorJon Marius Venstad <venstad@gmail.com>2019-11-04 10:27:45 +0100
committerJon Marius Venstad <venstad@gmail.com>2019-11-04 10:27:45 +0100
commitf3808f84558c8306c3e5541f8c1c4c860fd01c2a (patch)
tree87ef9f03b3c81f0b13b4664cfe15982430afaef0 /controller-server
parent84eed8ecc98150c2e2bdb654fcfb819eb0c2b05c (diff)
Allow creation of a ControllerTester on top of a ContainerTester
Diffstat (limited to 'controller-server')
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java2
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTester.java22
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/RoutingPoliciesTest.java2
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ContainerTester.java6
4 files changed, 26 insertions, 6 deletions
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java
index c374787aaa4..4015ac0452b 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java
@@ -30,7 +30,6 @@ import com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobError;
import com.yahoo.vespa.hosted.controller.application.DeploymentMetrics;
import com.yahoo.vespa.hosted.controller.application.JobStatus;
import com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder;
-import com.yahoo.vespa.hosted.controller.deployment.BuildJob;
import com.yahoo.vespa.hosted.controller.deployment.DeploymentContext;
import com.yahoo.vespa.hosted.controller.deployment.DeploymentTester;
import com.yahoo.vespa.hosted.controller.integration.ZoneApiMock;
@@ -384,7 +383,6 @@ public class ControllerTest {
var west = ZoneId.from("prod", "us-west-1");
var central = ZoneId.from("prod", "us-central-1");
var east = ZoneId.from("prod", "us-east-3");
- var buildNumber = BuildJob.defaultBuildNumber;
// Application is deployed with endpoint pointing to 2/3 zones
ApplicationPackage applicationPackage = new ApplicationPackageBuilder()
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTester.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTester.java
index 351b139f747..35b79cdbf8f 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTester.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTester.java
@@ -37,6 +37,8 @@ import com.yahoo.vespa.hosted.controller.integration.ServiceRegistryMock;
import com.yahoo.vespa.hosted.controller.integration.ZoneRegistryMock;
import com.yahoo.vespa.hosted.controller.persistence.CuratorDb;
import com.yahoo.vespa.hosted.controller.persistence.MockCuratorDb;
+import com.yahoo.vespa.hosted.controller.restapi.ContainerControllerTester;
+import com.yahoo.vespa.hosted.controller.restapi.ContainerTester;
import com.yahoo.vespa.hosted.controller.security.AthenzCredentials;
import com.yahoo.vespa.hosted.controller.security.AthenzTenantSpec;
import com.yahoo.vespa.hosted.controller.security.Credentials;
@@ -73,6 +75,7 @@ public final class ControllerTester {
public static final int availableRotations = 10;
+ private final boolean inContainer;
private final AthenzDbMock athenzDb;
private final ManualClock clock;
private final ZoneRegistryMock zoneRegistry;
@@ -106,11 +109,12 @@ public final class ControllerTester {
this(defaultRotationsConfig(), new MockCuratorDb());
}
- private ControllerTester(AthenzDbMock athenzDb,
+ private ControllerTester(AthenzDbMock athenzDb, boolean inContainer,
ZoneRegistryMock zoneRegistry,
CuratorDb curator, RotationsConfig rotationsConfig,
ServiceRegistryMock serviceRegistry, Controller controller) {
this.athenzDb = athenzDb;
+ this.inContainer = inContainer;
this.clock = serviceRegistry.clock();
this.zoneRegistry = zoneRegistry;
this.serviceRegistry = serviceRegistry;
@@ -130,10 +134,22 @@ public final class ControllerTester {
ZoneRegistryMock zoneRegistry,
CuratorDb curator, RotationsConfig rotationsConfig,
ServiceRegistryMock serviceRegistry) {
- this(athenzDb, zoneRegistry, curator, rotationsConfig, serviceRegistry,
+ this(athenzDb, false, zoneRegistry, curator, rotationsConfig, serviceRegistry,
createController(curator, rotationsConfig, zoneRegistry, athenzDb, serviceRegistry));
}
+ /** Creates a ControllerTester built on the ContainerTester's controller. This controller can not be recreated. */
+ public ControllerTester(ContainerTester tester) {
+ this(tester.athenzClientFactory().getSetup(),
+ true,
+ tester.serviceRegistry().zoneRegistryMock(),
+ tester.controller().curator(),
+ null,
+ tester.serviceRegistry(),
+ tester.controller());
+ }
+
+
public void configureDefaultLogHandler(Consumer<Handler> configureFunc) {
Arrays.stream(Logger.getLogger("").getHandlers())
// Do not mess with log configuration if a custom one has been set
@@ -179,6 +195,8 @@ public final class ControllerTester {
/** Create a new controller instance. Useful to verify that controller state is rebuilt from persistence */
public final void createNewController() {
+ if (inContainer)
+ throw new UnsupportedOperationException("Cannot recreate this controller");
controller = createController(curator, rotationsConfig, zoneRegistry, athenzDb, serviceRegistry);
}
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/RoutingPoliciesTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/RoutingPoliciesTest.java
index f5f1605a699..bc184715589 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/RoutingPoliciesTest.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/RoutingPoliciesTest.java
@@ -14,7 +14,6 @@ import com.yahoo.vespa.hosted.controller.api.integration.dns.RecordName;
import com.yahoo.vespa.hosted.controller.application.ApplicationPackage;
import com.yahoo.vespa.hosted.controller.application.RoutingPolicy;
import com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder;
-import com.yahoo.vespa.hosted.controller.deployment.BuildJob;
import com.yahoo.vespa.hosted.controller.deployment.DeploymentContext;
import com.yahoo.vespa.hosted.controller.deployment.DeploymentTester;
import org.junit.Test;
@@ -53,7 +52,6 @@ public class RoutingPoliciesTest {
@Test
public void maintains_global_routing_policies() {
- long buildNumber = BuildJob.defaultBuildNumber;
int clustersPerZone = 2;
int numberOfDeployments = 2;
var applicationPackage = new ApplicationPackageBuilder()
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ContainerTester.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ContainerTester.java
index 300eddd6291..55249670c5c 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ContainerTester.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ContainerTester.java
@@ -11,9 +11,11 @@ import com.yahoo.container.http.filter.FilterChainRepository;
import com.yahoo.jdisc.http.filter.SecurityRequestFilter;
import com.yahoo.jdisc.http.filter.SecurityRequestFilterChain;
import com.yahoo.vespa.hosted.controller.Controller;
+import com.yahoo.vespa.hosted.controller.api.integration.athenz.AthenzClientFactoryMock;
import com.yahoo.vespa.hosted.controller.application.SystemApplication;
import com.yahoo.vespa.hosted.controller.integration.ConfigServerMock;
import com.yahoo.vespa.hosted.controller.integration.ServiceRegistryMock;
+import com.yahoo.vespa.hosted.controller.integration.ZoneRegistryMock;
import com.yahoo.vespa.hosted.controller.versions.ControllerVersion;
import com.yahoo.vespa.hosted.controller.versions.VersionStatus;
import org.junit.ComparisonFailure;
@@ -58,6 +60,10 @@ public class ContainerTester {
return serviceRegistry().configServerMock();
}
+ public AthenzClientFactoryMock athenzClientFactory() {
+ return (AthenzClientFactoryMock) container.components().getComponent(AthenzClientFactoryMock.class.getName());
+ }
+
public ServiceRegistryMock serviceRegistry() {
return (ServiceRegistryMock) container.components().getComponent(ServiceRegistryMock.class.getName());
}