@Test
    public void testBootstrapWhenRedeploymentFails() throws Exception {
        ConfigserverConfig configserverConfig = createConfigserverConfig(temporaryFolder);
        DeployTester tester = new DeployTester.Builder(temporaryFolder).modelFactory(createHostedModelFactory())
                .configserverConfig(configserverConfig).build();
        tester.deployApp("src/test/apps/hosted/");

        // Manipulate application package so that it will fail deployment when config server starts
        java.nio.file.Files.delete(Paths.get(configserverConfig.configServerDBDir())
                                           .resolve("tenants/")
                                           .resolve(tester.tenant().getName().value())
                                           .resolve("sessions/2/services.xml"));

        RpcServer rpcServer = createRpcServer(configserverConfig);
        Bootstrapper bootstrap = createBootstrapper(tester, rpcServer, VIP_STATUS_PROGRAMMATICALLY);
        assertTrue(bootstrap.isUpgraded());
        assertFalse(bootstrap.vipStatus().isInRotation());
        // Call method directly, to be sure that it is finished redeploying all applications and we can check status
        bootstrap.doStart();
        // 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, bootstrap.status());
        assertTrue(rpcServer.isRunning());
        assertFalse(rpcServer.isServingConfigRequests());
        assertFalse(bootstrap.vipStatus().isInRotation());

        bootstrap.deconstruct();
    }
@author Ulf Lilleengen
@author Harald Musum
configserver/src/test/java/com/yahoo/vespa/config/server/ConfigServerBootstrapTest.java