diff options
Diffstat (limited to 'controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentContext.java')
-rw-r--r-- | controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentContext.java | 58 |
1 files changed, 37 insertions, 21 deletions
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentContext.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentContext.java index 3765f815e49..ad6a987d42b 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentContext.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentContext.java @@ -21,7 +21,6 @@ import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId; import com.yahoo.vespa.hosted.controller.api.integration.configserver.ConfigServerException; import com.yahoo.vespa.hosted.controller.api.integration.configserver.NodeFilter; -import com.yahoo.vespa.hosted.controller.api.integration.deployment.ApplicationVersion; import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobId; import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType; import com.yahoo.vespa.hosted.controller.api.integration.deployment.RevisionId; @@ -78,6 +77,28 @@ import static org.junit.Assert.assertTrue; */ public class DeploymentContext { + public static final JobType systemTest = JobType.deploymentTo(ZoneId.from("test", "us-east-1")); + public static final JobType stagingTest = JobType.deploymentTo(ZoneId.from("staging", "us-east-3")); + public static final JobType productionUsEast3 = JobType.prod("us-east-3"); + public static final JobType testUsEast3 = JobType.test("us-east-3"); + public static final JobType productionUsWest1 = JobType.prod("us-west-1"); + public static final JobType testUsWest1 = JobType.test("us-west-1"); + public static final JobType productionUsCentral1 = JobType.prod("us-central-1"); + public static final JobType testUsCentral1 = JobType.test("us-central-1"); + public static final JobType productionApNortheast1 = JobType.prod("ap-northeast-1"); + public static final JobType testApNortheast1 = JobType.test("ap-northeast-1"); + public static final JobType productionApNortheast2 = JobType.prod("ap-northeast-2"); + public static final JobType testApNortheast2 = JobType.test("ap-northeast-2"); + public static final JobType productionApSoutheast1 = JobType.prod("ap-southeast-1"); + public static final JobType testApSoutheast1 = JobType.test("ap-southeast-1"); + public static final JobType productionEuWest1 = JobType.prod("eu-west-1"); + public static final JobType testEuWest1 = JobType.test("eu-west-1"); + public static final JobType productionAwsUsEast1a = JobType.prod("aws-us-east-1a"); + public static final JobType testAwsUsEast1a = JobType.test("aws-us-east-1a"); + public static final JobType devUsEast1 = JobType.dev("us-east-1"); + public static final JobType devAwsUsEast2a = JobType.dev("aws-us-east-2a"); + public static final JobType perfUsEast3 = JobType.perf("us-east-3"); + private final AtomicLong salt = new AtomicLong(); // Application packages are expensive to construct, and a given test typically only needs to the test in the context @@ -198,10 +219,10 @@ public class DeploymentContext { .allMatch(deployment -> deployment.version().equals(version)))); for (var spec : application().deploymentSpec().instances()) - for (JobType type : new DeploymentSteps(spec, tester.controller()::system).productionJobs()) + for (JobType type : new DeploymentSteps(spec, tester.controller().zoneRegistry()).productionJobs()) assertTrue(tester.configServer().nodeRepository() - .list(type.zone(tester.controller().system()), - NodeFilter.all().applications(applicationId.defaultInstance())).stream() // TODO jonmv: support more + .list(type.zone(), + NodeFilter.all().applications(applicationId.defaultInstance())).stream() .allMatch(node -> node.currentVersion().equals(version))); assertFalse(instance().change().hasTargets()); @@ -395,7 +416,7 @@ public class DeploymentContext { /** Runs a deployment of the given package to the given manually deployable zone. */ public DeploymentContext runJob(ZoneId zone, ApplicationPackage applicationPackage) { - return runJob(JobType.from(tester.controller().system(), zone).get(), applicationPackage, null); + return runJob(JobType.deploymentTo(zone), applicationPackage, null); } /** Pulls the ready job trigger, and then runs the whole of the given job in the instance of this, successfully. */ @@ -417,14 +438,13 @@ public class DeploymentContext { } RunId id = currentRun(job).id(); - ZoneId zone = zone(job); assertEquals(unfinished, jobs.run(id).get().stepStatuses().get(Step.endTests)); tester.cloud().set(noTests ? Status.NO_TESTS : Status.FAILURE); runner.advance(currentRun(job)); assertTrue(jobs.run(id).get().hasEnded()); assertEquals(noTests, jobs.run(id).get().hasSucceeded()); - assertTrue(configServer().nodeRepository().list(zone, NodeFilter.all().applications(TesterId.of(instanceId).id())).isEmpty()); + assertTrue(configServer().nodeRepository().list(job.type().zone(), NodeFilter.all().applications(TesterId.of(instanceId).id())).isEmpty()); return this; } @@ -497,8 +517,8 @@ public class DeploymentContext { tester.readyJobsTrigger().maintain(); if (type.isProduction()) { - runJob(JobType.systemTest); - runJob(JobType.stagingTest); + runJob(systemTest); + runJob(stagingTest); tester.readyJobsTrigger().maintain(); } @@ -511,8 +531,8 @@ public class DeploymentContext { /** Start tests in system test stage */ public RunId startSystemTestTests() { - var id = newRun(JobType.systemTest); - var testZone = JobType.systemTest.zone(tester.controller().system()); + var id = newRun(systemTest); + var testZone = systemTest.zone(); runner.run(); if ( ! deferDnsUpdates) flushDnsUpdates(); @@ -537,7 +557,7 @@ public class DeploymentContext { /** Deploys tester and real app, and completes tester and initial staging installation first if needed. */ private void doDeploy(JobId job) { RunId id = currentRun(job).id(); - ZoneId zone = zone(job); + ZoneId zone = job.type().zone(); DeploymentId deployment = new DeploymentId(job.application(), zone); // First step is always a deployment. @@ -549,7 +569,7 @@ public class DeploymentContext { if (job.type().isTest()) doInstallTester(job); - if (job.type().equals(JobType.stagingTest)) { // Do the initial deployment and installation of the real application. + if (job.type().equals(stagingTest)) { // Do the initial deployment and installation of the real application. assertEquals(unfinished, jobs.run(id).get().stepStatuses().get(Step.installInitialReal)); tester.configServer().nodeRepository().doUpgrade(deployment, Optional.empty(), tester.configServer().application(job.application(), zone).get().version().get()); configServer().convergeServices(id.application(), zone); @@ -571,7 +591,7 @@ public class DeploymentContext { /** Upgrades nodes to target version. */ private void doUpgrade(JobId job) { RunId id = currentRun(job).id(); - ZoneId zone = zone(job); + ZoneId zone = job.type().zone(); DeploymentId deployment = new DeploymentId(job.application(), zone); assertEquals(unfinished, jobs.run(id).get().stepStatuses().get(Step.installReal)); @@ -592,7 +612,7 @@ public class DeploymentContext { /** Lets nodes converge on new application version. */ private void doConverge(JobId job) { RunId id = currentRun(job).id(); - ZoneId zone = zone(job); + ZoneId zone = job.type().zone(); assertEquals(unfinished, jobs.run(id).get().stepStatuses().get(Step.installReal)); configServer().convergeServices(id.application(), zone); @@ -608,7 +628,7 @@ public class DeploymentContext { /** Installs tester and starts tests. */ private void doInstallTester(JobId job) { RunId id = currentRun(job).id(); - ZoneId zone = zone(job); + ZoneId zone = job.type().zone(); assertEquals(unfinished, jobs.run(id).get().stepStatuses().get(Step.installTester)); configServer().nodeRepository().doUpgrade(new DeploymentId(TesterId.of(job.application()).id(), zone), Optional.empty(), tester.configServer().application(id.tester().id(), zone).get().version().get()); @@ -623,7 +643,7 @@ public class DeploymentContext { /** Completes tests with success. */ private void doTests(JobId job) { RunId id = currentRun(job).id(); - ZoneId zone = zone(job); + ZoneId zone = job.type().zone(); // All installation is complete and endpoints are ready, so tests may begin. if (job.type().isDeployment()) @@ -645,10 +665,6 @@ public class DeploymentContext { return new JobId(instanceId, type); } - private ZoneId zone(JobId job) { - return job.type().zone(tester.controller().system()); - } - private ConfigServerMock configServer() { return tester.configServer(); } |