summaryrefslogtreecommitdiffstats
path: root/configserver/src/test/java/com/yahoo/vespa/config/server/ConfigServerBootstrapTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'configserver/src/test/java/com/yahoo/vespa/config/server/ConfigServerBootstrapTest.java')
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/ConfigServerBootstrapTest.java79
1 files changed, 42 insertions, 37 deletions
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/ConfigServerBootstrapTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/ConfigServerBootstrapTest.java
index 69b9d67f84c..babc7b79b65 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/ConfigServerBootstrapTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/ConfigServerBootstrapTest.java
@@ -3,6 +3,7 @@ package com.yahoo.vespa.config.server;
import com.yahoo.cloud.config.ConfigserverConfig;
import com.yahoo.component.Version;
+import com.yahoo.concurrent.maintenance.Maintainer;
import com.yahoo.config.model.provision.Host;
import com.yahoo.config.model.provision.Hosts;
import com.yahoo.config.model.provision.InMemoryProvisioner;
@@ -18,11 +19,13 @@ import com.yahoo.container.jdisc.state.StateMonitor;
import com.yahoo.docproc.jdisc.metric.NullMetric;
import com.yahoo.path.Path;
import com.yahoo.text.Utf8;
+import com.yahoo.vespa.config.server.application.ConfigConvergenceChecker;
import com.yahoo.vespa.config.server.deploy.DeployTester;
import com.yahoo.vespa.config.server.rpc.RpcServer;
import com.yahoo.vespa.config.server.version.VersionState;
import com.yahoo.vespa.curator.Curator;
import com.yahoo.vespa.curator.mock.MockCurator;
+import com.yahoo.vespa.flags.InMemoryFlagSource;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
@@ -37,6 +40,7 @@ import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.function.BooleanSupplier;
+import java.util.stream.Collectors;
import static com.yahoo.vespa.config.server.ConfigServerBootstrap.VipStatusMode.VIP_STATUS_FILE;
import static com.yahoo.vespa.config.server.ConfigServerBootstrap.VipStatusMode.VIP_STATUS_PROGRAMMATICALLY;
@@ -64,28 +68,31 @@ public class ConfigServerBootstrapTest {
.configserverConfig(configserverConfig).hostProvisioner(provisioner).build();
tester.deployApp("src/test/apps/hosted/");
- VersionState versionState = createVersionState();
- assertTrue(versionState.isUpgraded());
-
RpcServer rpcServer = createRpcServer(configserverConfig);
// Take a host away so that there are too few for the application, to verify we can still bootstrap
provisioner.allocations().values().iterator().next().remove(0);
- StateMonitor stateMonitor = StateMonitor.createForTesting();
- VipStatus vipStatus = createVipStatus(stateMonitor);
- ConfigServerBootstrap bootstrap = new ConfigServerBootstrap(tester.applicationRepository(), rpcServer, versionState,
- stateMonitor, vipStatus, VIP_STATUS_PROGRAMMATICALLY);
- assertFalse(vipStatus.isInRotation());
+ ConfigServerBootstrap bootstrap = createBootstrap(tester, rpcServer, VIP_STATUS_PROGRAMMATICALLY);
+ assertEquals(List.of("ApplicationPackageMaintainer", "TenantsMaintainer"),
+ bootstrap.configServerMaintenance().maintainers().stream()
+ .map(Maintainer::name)
+ .sorted().collect(Collectors.toList()));
+ assertFalse(bootstrap.vipStatus().isInRotation());
+
bootstrap.start();
waitUntil(rpcServer::isRunning, "failed waiting for Rpc server running");
assertTrue(rpcServer.isServingConfigRequests());
waitUntil(() -> bootstrap.status() == StateMonitor.Status.up, "failed waiting for status 'up'");
- waitUntil(vipStatus::isInRotation, "failed waiting for server to be in rotation");
+ waitUntil(() -> bootstrap.vipStatus().isInRotation(), "failed waiting for server to be in rotation");
+ assertEquals(List.of("ApplicationPackageMaintainer", "FileDistributionMaintainer", "ReindexingMaintainer", "SessionsMaintainer", "TenantsMaintainer"),
+ bootstrap.configServerMaintenance().maintainers().stream()
+ .map(Maintainer::name)
+ .sorted().collect(Collectors.toList()));
bootstrap.deconstruct();
assertEquals(StateMonitor.Status.down, bootstrap.status());
assertFalse(rpcServer.isRunning());
assertTrue(rpcServer.isServingConfigRequests());
- assertFalse(vipStatus.isInRotation());
+ assertFalse(bootstrap.vipStatus().isInRotation());
}
// Just tests setup, the actual response of accessing /status.html depends on the status
@@ -98,21 +105,15 @@ public class ConfigServerBootstrapTest {
.configserverConfig(configserverConfig).hostProvisioner(provisioner).build();
tester.deployApp("src/test/apps/hosted/");
- VersionState versionState = createVersionState();
- assertTrue(versionState.isUpgraded());
-
RpcServer rpcServer = createRpcServer(configserverConfig);
- StateMonitor stateMonitor = StateMonitor.createForTesting();
- VipStatus vipStatus = createVipStatus(stateMonitor);
- ConfigServerBootstrap bootstrap = new ConfigServerBootstrap(tester.applicationRepository(), rpcServer, versionState,
- stateMonitor, vipStatus, VIP_STATUS_FILE);
- assertTrue(vipStatus.isInRotation()); // default is in rotation when using status file
+ ConfigServerBootstrap bootstrap = createBootstrap(tester, rpcServer, VIP_STATUS_FILE);
+ assertTrue(bootstrap.vipStatus().isInRotation()); // default is in rotation when using status file
bootstrap.start();
waitUntil(rpcServer::isRunning, "failed waiting for Rpc server running");
assertTrue(rpcServer.isServingConfigRequests());
waitUntil(() -> bootstrap.status() == StateMonitor.Status.up, "failed waiting for status 'up'");
- waitUntil(vipStatus::isInRotation, "failed waiting for server to be in rotation");
+ waitUntil(() -> bootstrap.vipStatus().isInRotation(), "failed waiting for server to be in rotation");
bootstrap.deconstruct();
}
@@ -123,9 +124,6 @@ public class ConfigServerBootstrapTest {
.configserverConfig(configserverConfig).build();
tester.deployApp("src/test/apps/hosted/");
- VersionState versionState = createVersionState();
- assertTrue(versionState.isUpgraded());
-
// Manipulate application package so that it will fail deployment when config server starts
java.nio.file.Files.delete(Paths.get(configserverConfig.configServerDBDir())
.resolve("tenants/")
@@ -133,19 +131,16 @@ public class ConfigServerBootstrapTest {
.resolve("sessions/2/services.xml"));
RpcServer rpcServer = createRpcServer(configserverConfig);
- StateMonitor stateMonitor = StateMonitor.createForTesting();
- VipStatus vipStatus = createVipStatus(stateMonitor);
- ConfigServerBootstrap bootstrap = new ConfigServerBootstrap(tester.applicationRepository(), rpcServer, versionState,
- stateMonitor, vipStatus, VIP_STATUS_PROGRAMMATICALLY);
- assertFalse(vipStatus.isInRotation());
+ ConfigServerBootstrap bootstrap = createBootstrap(tester, rpcServer, VIP_STATUS_PROGRAMMATICALLY);
+ assertFalse(bootstrap.vipStatus().isInRotation());
// Call method directly, to be sure that it is finished redeploying all applications and we can check status
bootstrap.start();
// App is invalid, bootstrapping was unsuccessful. Status should be 'initializing',
// rpc server should not be running and it should be out of rotation
- assertEquals(StateMonitor.Status.initializing, stateMonitor.status());
+ assertEquals(StateMonitor.Status.initializing, bootstrap.status());
assertTrue(rpcServer.isRunning());
assertFalse(rpcServer.isServingConfigRequests());
- assertFalse(vipStatus.isInRotation());
+ assertFalse(bootstrap.vipStatus().isInRotation());
bootstrap.deconstruct();
}
@@ -168,24 +163,34 @@ public class ConfigServerBootstrapTest {
tester.deployApp("src/test/apps/app/", vespaVersion);
ApplicationId applicationId = tester.applicationId();
- VersionState versionState = createVersionState();
- assertTrue(versionState.isUpgraded());
-
// Ugly hack, but I see no other way of doing it:
// Manipulate application version in zookeeper so that it is an older version than the model we know, which is
// the case when upgrading on non-hosted installations
curator.set(Path.fromString("/config/v2/tenants/" + applicationId.tenant().value() + "/sessions/2/version"), Utf8.toBytes("1.2.2"));
RpcServer rpcServer = createRpcServer(configserverConfig);
- StateMonitor stateMonitor = StateMonitor.createForTesting();
- VipStatus vipStatus = createVipStatus(stateMonitor);
- ConfigServerBootstrap bootstrap = new ConfigServerBootstrap(tester.applicationRepository(), rpcServer, versionState,
- stateMonitor, vipStatus, VIP_STATUS_PROGRAMMATICALLY);
+ ConfigServerBootstrap bootstrap = createBootstrap(tester, rpcServer, VIP_STATUS_PROGRAMMATICALLY);
bootstrap.start();
waitUntil(rpcServer::isRunning, "failed waiting for Rpc server running");
assertTrue(rpcServer.isServingConfigRequests());
waitUntil(() -> bootstrap.status() == StateMonitor.Status.up, "failed waiting for status 'up'");
- waitUntil(vipStatus::isInRotation, "failed waiting for server to be in rotation");
+ waitUntil(() -> bootstrap.vipStatus().isInRotation(), "failed waiting for server to be in rotation");
+ }
+
+ private ConfigServerBootstrap createBootstrap(DeployTester tester, RpcServer rpcServer, ConfigServerBootstrap.VipStatusMode vipStatusProgrammatically) throws IOException {
+ VersionState versionState = createVersionState();
+ assertTrue(versionState.isUpgraded());
+
+ StateMonitor stateMonitor = StateMonitor.createForTesting();
+ VipStatus vipStatus = createVipStatus(stateMonitor);
+ return new ConfigServerBootstrap(tester.applicationRepository(),
+ rpcServer,
+ versionState,
+ stateMonitor,
+ vipStatus,
+ vipStatusProgrammatically,
+ new InMemoryFlagSource(),
+ new ConfigConvergenceChecker());
}
private void waitUntil(BooleanSupplier booleanSupplier, String messageIfWaitingFails) throws InterruptedException {