diff options
author | Jon Marius Venstad <jvenstad@yahoo-inc.com> | 2018-08-13 13:42:42 +0200 |
---|---|---|
committer | Jon Marius Venstad <jvenstad@yahoo-inc.com> | 2018-08-13 13:42:42 +0200 |
commit | cc8b636b9f583026b4bd95e1f4c16612464bcd46 (patch) | |
tree | 5e625eaa724ada3c5e259b9a72ee0dbd75b948a3 /controller-server | |
parent | 98eebc5f7ea07dfab4db2f631a0f904554015182 (diff) |
Test restarting is done, and waited for
Diffstat (limited to 'controller-server')
2 files changed, 32 insertions, 3 deletions
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunnerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunnerTest.java index b56cc664376..46cd2f63608 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunnerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunnerTest.java @@ -4,10 +4,12 @@ package com.yahoo.vespa.hosted.controller.deployment; import com.yahoo.component.Version; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.Environment; +import com.yahoo.config.provision.HostName; import com.yahoo.config.provision.SystemName; import com.yahoo.vespa.hosted.controller.Application; import com.yahoo.vespa.hosted.controller.api.application.v4.model.configserverbindings.ConfigChangeActions; import com.yahoo.vespa.hosted.controller.api.application.v4.model.configserverbindings.RefeedAction; +import com.yahoo.vespa.hosted.controller.api.application.v4.model.configserverbindings.RestartAction; import com.yahoo.vespa.hosted.controller.api.application.v4.model.configserverbindings.ServiceInfo; import com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId; import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType; @@ -38,6 +40,7 @@ import java.util.logging.Logger; import static com.yahoo.log.LogLevel.DEBUG; import static com.yahoo.vespa.hosted.controller.deployment.InternalStepRunner.testerOf; import static com.yahoo.vespa.hosted.controller.deployment.Step.Status.failed; +import static com.yahoo.vespa.hosted.controller.deployment.Step.Status.succeeded; import static com.yahoo.vespa.hosted.controller.deployment.Step.Status.unfinished; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -223,12 +226,32 @@ public class InternalStepRunnerTest { runner.run(); assertEquals(failed, jobs.run(id).get().steps().get(Step.deployReal)); - assertTrue(jobs.run(id).get().hasFailed()); } @Test - public void restartsServicesWhenExpectedTo() { + public void restartsServicesAndWaitsForRestart() { + RunId id = newRun(JobType.productionUsWest1); + ZoneId zone = id.type().zone(tester.controller().system()); + HostName host = tester.configServer().hostFor(appId, zone); + tester.configServer().setConfigChangeActions(new ConfigChangeActions(Collections.singletonList(new RestartAction("cluster", + "container", + "search", + Collections.singletonList(new ServiceInfo("queries", + "search", + "config", + host.value())), + Collections.singletonList("Restart it!"))), + Collections.emptyList())); + runner.run(); + assertEquals(succeeded, jobs.run(id).get().steps().get(Step.deployReal)); + tester.configServer().convergeServices(appId, zone); + assertEquals(unfinished, jobs.run(id).get().steps().get(Step.installReal)); + + tester.configServer().nodeRepository().doRestart(new DeploymentId(appId, zone), + Optional.of(host)); + runner.run(); + assertEquals(succeeded, jobs.run(id).get().steps().get(Step.installReal)); } private RunId newRun(JobType type) { diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ConfigServerMock.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ConfigServerMock.java index 54812b6efe3..b21972c3ca4 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ConfigServerMock.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ConfigServerMock.java @@ -60,13 +60,14 @@ public class ConfigServerMock extends AbstractComponent implements ConfigServer bootstrap(zoneRegistry.zones().all().ids(), SystemApplication.all()); } + /** Sets the ConfigChangeActions that will be returned on next deployment. */ public void setConfigChangeActions(ConfigChangeActions configChangeActions) { this.configChangeActions = configChangeActions; } /** Assigns a reserved tenant node to the given deployment, with initial versions. */ public void provision(ZoneId zone, ApplicationId application) { - nodeRepository().putByHostname(zone, new Node(HostName.from("host-" + application.serializedForm()), + nodeRepository().putByHostname(zone, new Node(hostFor(application, zone), Node.State.reserved, NodeType.tenant, Optional.of(application), @@ -74,6 +75,10 @@ public class ConfigServerMock extends AbstractComponent implements ConfigServer initialVersion)); } + public HostName hostFor(ApplicationId application, ZoneId zone) { + return HostName.from("host-" + application.serializedForm() + "-" + zone.value()); + } + public void bootstrap(List<ZoneId> zones, SystemApplication... applications) { bootstrap(zones, Arrays.asList(applications)); } @@ -194,6 +199,7 @@ public class ConfigServerMock extends AbstractComponent implements ConfigServer ? configChangeActions : new ConfigChangeActions(Collections.emptyList(), Collections.emptyList()); + setConfigChangeActions(null); prepareResponse.tenant = new TenantId("tenant"); prepareResponse.log = Collections.emptyList(); return prepareResponse; |