diff options
author | Jon Marius Venstad <venstad@gmail.com> | 2019-10-28 13:01:55 +0100 |
---|---|---|
committer | Jon Marius Venstad <venstad@gmail.com> | 2019-10-28 13:01:55 +0100 |
commit | 52395e14170cff872d79198c3580a2e08d45baa8 (patch) | |
tree | 37d67a40031120e1f8cb00edf59f1a0e13174090 /controller-server/src/test/java/com/yahoo | |
parent | 90a931cc2c59fe3f8202382aff3b76a92060579a (diff) |
Update RotationStatusUpdaterTest
Diffstat (limited to 'controller-server/src/test/java/com/yahoo')
3 files changed, 31 insertions, 27 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 3c3a09bf5a7..c27911be6a4 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 @@ -25,6 +25,7 @@ import com.yahoo.vespa.hosted.controller.api.integration.routing.RoutingEndpoint import com.yahoo.vespa.hosted.controller.api.integration.routing.RoutingGeneratorMock; import com.yahoo.vespa.hosted.controller.api.integration.stubs.MockTesterCloud; import com.yahoo.vespa.hosted.controller.application.ApplicationPackage; +import com.yahoo.vespa.hosted.controller.application.Deployment; import com.yahoo.vespa.hosted.controller.application.TenantAndApplicationId; import com.yahoo.vespa.hosted.controller.integration.ConfigServerMock; import com.yahoo.vespa.hosted.controller.maintenance.JobRunner; @@ -125,6 +126,10 @@ public class DeploymentContext { return tester.controller().applications().requireInstance(instanceId); } + public Deployment deployment(ZoneId zone) { + return instance().deployments().get(zone); + } + public ApplicationId instanceId() { return instanceId; } diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/OsUpgraderTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/OsUpgraderTest.java index 1f15695e974..8a5dc7594f9 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/OsUpgraderTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/OsUpgraderTest.java @@ -10,7 +10,6 @@ import com.yahoo.config.provision.zone.ZoneId; import com.yahoo.vespa.hosted.controller.ControllerTester; import com.yahoo.vespa.hosted.controller.api.integration.configserver.Node; import com.yahoo.vespa.hosted.controller.application.SystemApplication; -import com.yahoo.vespa.hosted.controller.deployment.DeploymentTester; import com.yahoo.vespa.hosted.controller.integration.NodeRepositoryMock; import com.yahoo.vespa.hosted.controller.integration.ZoneApiMock; import com.yahoo.vespa.hosted.controller.versions.NodeVersion; diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/RotationStatusUpdaterTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/RotationStatusUpdaterTest.java index b0201a21de5..127104724a5 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/RotationStatusUpdaterTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/RotationStatusUpdaterTest.java @@ -1,14 +1,17 @@ // Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.controller.maintenance; +import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.Environment; import com.yahoo.config.provision.zone.ZoneId; +import com.yahoo.vespa.hosted.controller.ControllerTester; import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.api.integration.routing.RotationStatus; import com.yahoo.vespa.hosted.controller.application.Deployment; import com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder; import com.yahoo.vespa.hosted.controller.deployment.BuildJob; import com.yahoo.vespa.hosted.controller.deployment.DeploymentTester; +import com.yahoo.vespa.hosted.controller.deployment.InternalDeploymentTester; import com.yahoo.vespa.hosted.controller.rotation.RotationState; import org.junit.Test; @@ -24,11 +27,11 @@ public class RotationStatusUpdaterTest { @Test public void updates_rotation_status() { - var tester = new DeploymentTester(); + var tester = new InternalDeploymentTester(); var globalRotationService = tester.controllerTester().serviceRegistry().globalRoutingServiceMock(); var updater = new RotationStatusUpdater(tester.controller(), Duration.ofDays(1), new JobControl(tester.controller().curator())); - var application = tester.createApplication("app1", "tenant1", 1, 1L); + var context = tester.newDeploymentContext(ApplicationId.from("tenant1", "app1", "default")); var zone1 = ZoneId.from("prod", "us-west-1"); var zone2 = ZoneId.from("prod", "us-east-3"); var zone3 = ZoneId.from("prod", "eu-west-1"); @@ -40,31 +43,27 @@ public class RotationStatusUpdaterTest { .region(zone1.region().value()) .region(zone2.region().value()) .build(); - tester.deployCompletely(application, applicationPackage); - - Supplier<Instance> app = () -> tester.defaultInstance(application.id()); - Supplier<Deployment> deployment1 = () -> app.get().deployments().get(zone1); - Supplier<Deployment> deployment2 = () -> app.get().deployments().get(zone2); - Supplier<Deployment> deployment3 = () -> app.get().deployments().get(zone3); + context.submit(applicationPackage) + .deploy(); // No status gathered yet - var rotation1 = app.get().rotations().get(0).rotationId(); - assertEquals(RotationState.unknown, app.get().rotationStatus().of(rotation1, deployment1.get())); - assertEquals(RotationState.unknown, app.get().rotationStatus().of(rotation1, deployment2.get())); + var rotation1 = context.instance().rotations().get(0).rotationId(); + assertEquals(RotationState.unknown, context.instance().rotationStatus().of(rotation1, context.deployment(zone1))); + assertEquals(RotationState.unknown, context.instance().rotationStatus().of(rotation1, context.deployment(zone2))); // First rotation: One zone out, one in var rotationName1 = "rotation-fqdn-01"; globalRotationService.setStatus(rotationName1, zone1, RotationStatus.IN) .setStatus(rotationName1, zone2, RotationStatus.OUT); updater.maintain(); - assertEquals(RotationState.in, app.get().rotationStatus().of(rotation1, deployment1.get())); - assertEquals(RotationState.out, app.get().rotationStatus().of(rotation1, deployment2.get())); + assertEquals(RotationState.in, context.instance().rotationStatus().of(rotation1, context.deployment(zone1))); + assertEquals(RotationState.out, context.instance().rotationStatus().of(rotation1, context.deployment(zone2))); // First rotation: All zones in globalRotationService.setStatus(rotationName1, zone2, RotationStatus.IN); updater.maintain(); - assertEquals(RotationState.in, app.get().rotationStatus().of(rotation1, deployment1.get())); - assertEquals(RotationState.in, app.get().rotationStatus().of(rotation1, deployment2.get())); + assertEquals(RotationState.in, context.instance().rotationStatus().of(rotation1, context.deployment(zone1))); + assertEquals(RotationState.in, context.instance().rotationStatus().of(rotation1, context.deployment(zone2))); // Another rotation is assigned applicationPackage = new ApplicationPackageBuilder() @@ -75,27 +74,28 @@ public class RotationStatusUpdaterTest { .endpoint("default", "default", "us-east-3", "us-west-1") .endpoint("eu", "default", "eu-west-1") .build(); - tester.deployCompletely(application, applicationPackage, BuildJob.defaultBuildNumber + 1); - assertEquals(2, app.get().rotations().size()); + context.submit(applicationPackage) + .deploy(); + assertEquals(2, context.instance().rotations().size()); // Second rotation: No status gathered yet - var rotation2 = app.get().rotations().get(1).rotationId(); + var rotation2 = context.instance().rotations().get(1).rotationId(); updater.maintain(); - assertEquals(RotationState.unknown, app.get().rotationStatus().of(rotation2, deployment3.get())); + assertEquals(RotationState.unknown, context.instance().rotationStatus().of(rotation2, context.deployment(zone3))); // Status of third zone is retrieved via second rotation var rotationName2 = "rotation-fqdn-02"; globalRotationService.setStatus(rotationName2, zone3, RotationStatus.IN); updater.maintain(); - assertEquals(RotationState.in, app.get().rotationStatus().of(rotation2, deployment3.get())); + assertEquals(RotationState.in, context.instance().rotationStatus().of(rotation2, context.deployment(zone3))); // Each rotation only has status for their configured zones - assertEquals("Rotation " + rotation1 + " does not know about " + deployment3.get(), RotationState.unknown, - app.get().rotationStatus().of(rotation1, deployment3.get())); - assertEquals("Rotation " + rotation2 + " does not know about " + deployment1.get(), RotationState.unknown, - app.get().rotationStatus().of(rotation2, deployment1.get())); - assertEquals("Rotation " + rotation2 + " does not know about " + deployment2.get(), RotationState.unknown, - app.get().rotationStatus().of(rotation2, deployment2.get())); + assertEquals("Rotation " + rotation1 + " does not know about " + context.deployment(zone3), RotationState.unknown, + context.instance().rotationStatus().of(rotation1, context.deployment(zone3))); + assertEquals("Rotation " + rotation2 + " does not know about " + context.deployment(zone1), RotationState.unknown, + context.instance().rotationStatus().of(rotation2, context.deployment(zone1))); + assertEquals("Rotation " + rotation2 + " does not know about " + context.deployment(zone2), RotationState.unknown, + context.instance().rotationStatus().of(rotation2, context.deployment(zone2))); } } |