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);
}
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);
}
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;
}
}
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;
}
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);
}
Aggregations