Search in sources :

Example 6 with DeploymentGroup

use of com.spotify.helios.common.descriptors.DeploymentGroup in project helios by spotify.

the class RollingUpdatePlannerTest method testParallelRollout.

@Test
public void testParallelRollout() {
    final DeploymentGroup deploymentGroup = DeploymentGroup.newBuilder().setRolloutOptions(RolloutOptions.newBuilder().setParallelism(2).build()).build();
    final RolloutPlanner rolloutPlanner = RollingUpdatePlanner.of(deploymentGroup);
    final List<RolloutTask> tasks = rolloutPlanner.plan(HOSTS);
    final List<RolloutTask> expected = Lists.newArrayList(RolloutTask.of(RolloutTask.Action.UNDEPLOY_OLD_JOBS, "agent1"), RolloutTask.of(RolloutTask.Action.DEPLOY_NEW_JOB, "agent1"), RolloutTask.of(RolloutTask.Action.UNDEPLOY_OLD_JOBS, "agent2"), RolloutTask.of(RolloutTask.Action.DEPLOY_NEW_JOB, "agent2"), RolloutTask.of(RolloutTask.Action.AWAIT_RUNNING, "agent1"), RolloutTask.of(RolloutTask.Action.AWAIT_RUNNING, "agent2"), RolloutTask.of(RolloutTask.Action.UNDEPLOY_OLD_JOBS, "agent3"), RolloutTask.of(RolloutTask.Action.DEPLOY_NEW_JOB, "agent3"), RolloutTask.of(RolloutTask.Action.UNDEPLOY_OLD_JOBS, "agent4"), RolloutTask.of(RolloutTask.Action.DEPLOY_NEW_JOB, "agent4"), RolloutTask.of(RolloutTask.Action.AWAIT_RUNNING, "agent3"), RolloutTask.of(RolloutTask.Action.AWAIT_RUNNING, "agent4"));
    assertEquals(expected, tasks);
}
Also used : RolloutTask(com.spotify.helios.common.descriptors.RolloutTask) DeploymentGroup(com.spotify.helios.common.descriptors.DeploymentGroup) Test(org.junit.Test)

Example 7 with DeploymentGroup

use of com.spotify.helios.common.descriptors.DeploymentGroup in project helios by spotify.

the class RollingUpdatePlannerTest method testOverlapParallelRollout.

@Test
public void testOverlapParallelRollout() {
    final DeploymentGroup deploymentGroup = DeploymentGroup.newBuilder().setRolloutOptions(RolloutOptions.newBuilder().setOverlap(true).setParallelism(2).build()).build();
    final RolloutPlanner rolloutPlanner = RollingUpdatePlanner.of(deploymentGroup);
    final List<RolloutTask> tasks = rolloutPlanner.plan(HOSTS);
    final List<RolloutTask> expected = Lists.newArrayList(RolloutTask.of(RolloutTask.Action.DEPLOY_NEW_JOB, "agent1"), RolloutTask.of(RolloutTask.Action.DEPLOY_NEW_JOB, "agent2"), RolloutTask.of(RolloutTask.Action.AWAIT_RUNNING, "agent1"), RolloutTask.of(RolloutTask.Action.AWAIT_RUNNING, "agent2"), RolloutTask.of(RolloutTask.Action.UNDEPLOY_OLD_JOBS, "agent1"), RolloutTask.of(RolloutTask.Action.UNDEPLOY_OLD_JOBS, "agent2"), RolloutTask.of(RolloutTask.Action.DEPLOY_NEW_JOB, "agent3"), RolloutTask.of(RolloutTask.Action.DEPLOY_NEW_JOB, "agent4"), RolloutTask.of(RolloutTask.Action.AWAIT_RUNNING, "agent3"), RolloutTask.of(RolloutTask.Action.AWAIT_RUNNING, "agent4"), RolloutTask.of(RolloutTask.Action.UNDEPLOY_OLD_JOBS, "agent3"), RolloutTask.of(RolloutTask.Action.UNDEPLOY_OLD_JOBS, "agent4"));
    assertEquals(expected, tasks);
}
Also used : RolloutTask(com.spotify.helios.common.descriptors.RolloutTask) DeploymentGroup(com.spotify.helios.common.descriptors.DeploymentGroup) Test(org.junit.Test)

Example 8 with DeploymentGroup

use of com.spotify.helios.common.descriptors.DeploymentGroup in project helios by spotify.

the class DeploymentGroupCreateCommand method run.

@Override
int run(final Namespace options, final HeliosClient client, final PrintStream out, final boolean json, final BufferedReader stdin) throws ExecutionException, InterruptedException, IOException {
    final String name = options.getString(nameArg.getDest());
    final List<HostSelector> hostSelectors = Utils.parseHostSelectors(options, hostSelectorsArg);
    final boolean quiet = options.getBoolean(quietArg.getDest());
    final DeploymentGroup deploymentGroup = DeploymentGroup.newBuilder().setName(name).setHostSelectors(hostSelectors).build();
    if (!quiet && !json) {
        out.println("Creating deployment group: " + deploymentGroup.toJsonString());
    }
    final CreateDeploymentGroupResponse status = client.createDeploymentGroup(deploymentGroup).get();
    if (status == null) {
        throw new RuntimeException("The Helios master could not create a deployment group.");
    }
    if (status.getStatus() != CreateDeploymentGroupResponse.Status.CONFLICT) {
        out.println(status.toJsonString());
        return 0;
    } else {
        if (!quiet && !json) {
            out.println("Failed: " + status);
        } else if (json) {
            out.println(status.toJsonString());
        }
        return 1;
    }
}
Also used : CreateDeploymentGroupResponse(com.spotify.helios.common.protocol.CreateDeploymentGroupResponse) HostSelector(com.spotify.helios.common.descriptors.HostSelector) DeploymentGroup(com.spotify.helios.common.descriptors.DeploymentGroup)

Example 9 with DeploymentGroup

use of com.spotify.helios.common.descriptors.DeploymentGroup in project helios by spotify.

the class DeploymentGroupInspectCommand method run.

@Override
int run(final Namespace options, final HeliosClient client, final PrintStream out, final boolean json, final BufferedReader stdin) throws ExecutionException, InterruptedException, IOException {
    final String name = options.getString(nameArg.getDest());
    final DeploymentGroup deploymentGroup = client.deploymentGroup(name).get();
    if (deploymentGroup == null) {
        if (json) {
            final Map<String, Object> output = Maps.newHashMap();
            output.put("status", "DEPLOYMENT_GROUP_NOT_FOUND");
            out.print(Json.asStringUnchecked(output));
        } else {
            out.printf("Unknown deployment group: %s%n", name);
        }
        return 1;
    }
    if (json) {
        out.println(Json.asPrettyStringUnchecked(deploymentGroup));
    } else {
        out.printf("Name: %s%n", deploymentGroup.getName());
        out.printf("Host selectors:%n");
        for (final HostSelector hostSelector : deploymentGroup.getHostSelectors()) {
            out.printf("  %s%n", hostSelector.toPrettyString());
        }
        out.printf("Job: %s%n", deploymentGroup.getJobId());
    }
    return 0;
}
Also used : HostSelector(com.spotify.helios.common.descriptors.HostSelector) DeploymentGroup(com.spotify.helios.common.descriptors.DeploymentGroup)

Example 10 with DeploymentGroup

use of com.spotify.helios.common.descriptors.DeploymentGroup in project helios by spotify.

the class DeploymentGroupInspectCommandTest method testDeploymentGroupInspectCommandJson.

@Test
public void testDeploymentGroupInspectCommandJson() throws Exception {
    when(options.getString("name")).thenReturn(NAME);
    final int ret = command.run(options, client, out, true, null);
    assertEquals(0, ret);
    final DeploymentGroup output = Json.read(baos.toString(), DeploymentGroup.class);
    assertEquals(DEPLOYMENT_GROUP, output);
}
Also used : DeploymentGroup(com.spotify.helios.common.descriptors.DeploymentGroup) Test(org.junit.Test)

Aggregations

DeploymentGroup (com.spotify.helios.common.descriptors.DeploymentGroup)30 Test (org.junit.Test)18 RolloutTask (com.spotify.helios.common.descriptors.RolloutTask)10 ZooKeeperClient (com.spotify.helios.servicescommon.coordination.ZooKeeperClient)10 HeliosRuntimeException (com.spotify.helios.common.HeliosRuntimeException)6 ZooKeeperOperation (com.spotify.helios.servicescommon.coordination.ZooKeeperOperation)6 Job (com.spotify.helios.common.descriptors.Job)4 CreateDeploymentGroupResponse (com.spotify.helios.common.protocol.CreateDeploymentGroupResponse)4 RollingUpdateResponse (com.spotify.helios.common.protocol.RollingUpdateResponse)4 KeeperException (org.apache.zookeeper.KeeperException)4 NoNodeException (org.apache.zookeeper.KeeperException.NoNodeException)4 DeploymentGroupStatus (com.spotify.helios.common.descriptors.DeploymentGroupStatus)3 HostStatus (com.spotify.helios.common.descriptors.HostStatus)3 JobId (com.spotify.helios.common.descriptors.JobId)3 RemoveDeploymentGroupResponse (com.spotify.helios.common.protocol.RemoveDeploymentGroupResponse)3 DefaultZooKeeperClient (com.spotify.helios.servicescommon.coordination.DefaultZooKeeperClient)3 IOException (java.io.IOException)3 Response (javax.ws.rs.core.Response)3 ExceptionMetered (com.codahale.metrics.annotation.ExceptionMetered)2 Timed (com.codahale.metrics.annotation.Timed)2