diff options
author | Jon Bratseth <bratseth@yahoo-inc.com> | 2017-05-10 13:00:02 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@yahoo-inc.com> | 2017-05-10 13:00:02 +0200 |
commit | 039194cc029121f012aea95517caaf766db3d362 (patch) | |
tree | 6527795023c1efc9042f83d2dbefee1a1e6a59df /configserver | |
parent | 4f36cf1ae65ceaac515c7a3828fef4bd093ddff7 (diff) |
Propagate version
Diffstat (limited to 'configserver')
4 files changed, 28 insertions, 5 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/Deployment.java b/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/Deployment.java index d5ac57e479e..c27efb2caa2 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/Deployment.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/Deployment.java @@ -99,7 +99,11 @@ public class Deployment implements com.yahoo.config.provision.Deployment { TimeoutBudget timeoutBudget = new TimeoutBudget(clock, timeout); session.prepare(logger, /** Assumes that session has already set application id, see {@link com.yahoo.vespa.config.server.session.SessionFactoryImpl}. */ - new PrepareParams.Builder().applicationId(session.getApplicationId()).timeoutBudget(timeoutBudget).ignoreValidationErrors( ! validate).build(), + new PrepareParams.Builder().applicationId(session.getApplicationId()) + .timeoutBudget(timeoutBudget) + .ignoreValidationErrors( ! validate) + .vespaVersion(session.getVespaVersion().toString()) + .build(), Optional.empty(), tenantPath); this.prepared = true; @@ -154,6 +158,9 @@ public class Deployment implements com.yahoo.config.provision.Deployment { hostProvisioner.get().restart(session.getApplicationId(), filter); } + /** Exposes the session of this for testing only */ + public LocalSession session() { return session; } + private long validateSessionStatus(LocalSession localSession) { long sessionId = localSession.getSessionId(); if (Session.Status.NEW.equals(localSession.getStatus())) { diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionZooKeeperClient.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionZooKeeperClient.java index dd74270c817..eadf1655d47 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionZooKeeperClient.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionZooKeeperClient.java @@ -30,13 +30,16 @@ import java.util.concurrent.TimeUnit; /** * Zookeeper client for a specific session. Can be used to read and write session status * and create and get prepare and active barrier. - * + * * @author lulf * @since 5.1 */ public class SessionZooKeeperClient { private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(SessionZooKeeperClient.class.getName()); + + // NOTE: Any state added here MUST also be propagated in com.yahoo.vespa.config.server.deploy.Deployment.prepare() + static final String APPLICATION_ID_PATH = "applicationId"; static final String VERSION_PATH = "version"; static final String CREATE_TIME_PATH = "createTime"; diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/DeployTester.java b/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/DeployTester.java index 8e20f190c5b..a1b8b4192c8 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/DeployTester.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/DeployTester.java @@ -108,7 +108,7 @@ public class DeployTester { /** * Do the initial "deploy" with the existing API-less code as the deploy API doesn't support first deploys yet. */ - public ApplicationId deployApp(String appName){ + public ApplicationId deployApp(String appName) { return deployApp(appName, Optional.empty()); } @@ -116,7 +116,7 @@ public class DeployTester { * Do the initial "deploy" with the existing API-less code as the deploy API doesn't support first deploys yet. */ public ApplicationId deployApp(String appName, Optional<String> vespaVersion) { - final Tenant tenant = tenant(); + Tenant tenant = tenant(); LocalSession session = tenant.getSessionFactory().createSession(testApp, appName, new TimeoutBudget(Clock.systemUTC(), Duration.ofSeconds(60))); ApplicationId id = ApplicationId.from(tenant.getName(), ApplicationName.from(appName), InstanceName.defaultName()); PrepareParams.Builder paramsBuilder = new PrepareParams.Builder() @@ -134,7 +134,7 @@ public class DeployTester { } public ProvisionInfo getProvisionInfoFromDeployedApp(ApplicationId applicationId) { - final Tenant tenant = tenant(); + Tenant tenant = tenant(); LocalSession session = tenant.getLocalSessionRepo().getSession(tenant.getApplicationRepo() .getSessionIdForApplication(applicationId)); return session.getProvisionInfo(); diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/HostedDeployTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/HostedDeployTest.java index 22db3a6e1c2..83b9a30b946 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/HostedDeployTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/HostedDeployTest.java @@ -24,10 +24,23 @@ import static org.junit.Assert.fail; * @author bratseth */ public class HostedDeployTest { + private static final String dockerRegistry = "foo.com:4443"; private static final String dockerVespaBaseImage = "/vespa/ci"; @Test + public void testRedeployWithVersion() throws InterruptedException, IOException { + DeployTester tester = new DeployTester("src/test/apps/hosted/", createConfigserverConfig()); + tester.deployApp("myApp", Optional.of("4.5.6")); + + Optional<com.yahoo.config.provision.Deployment> deployment = tester.redeployFromLocalActive(); + assertTrue(deployment.isPresent()); + deployment.get().prepare(); + deployment.get().activate(); + assertEquals("4.5.6", ((Deployment)deployment.get()).session().getVespaVersion().toString()); + } + + @Test public void testRedeploy() throws InterruptedException, IOException { DeployTester tester = new DeployTester("src/test/apps/hosted/", createConfigserverConfig()); tester.deployApp("myApp"); |