use of com.spotify.helios.common.protocol.RollingUpdateResponse in project helios by spotify.
the class DeploymentGroupResource method rollingUpdate.
@POST
@Path("/{name}/rolling-update")
@Produces(APPLICATION_JSON)
@Timed
@ExceptionMetered
public Response rollingUpdate(@PathParam("name") @Valid final String name, @Valid final RollingUpdateRequest args) {
try {
final DeploymentGroup deploymentGroup = model.getDeploymentGroup(name);
model.rollingUpdate(deploymentGroup, args.getJob(), args.getRolloutOptions());
return Response.ok(new RollingUpdateResponse(RollingUpdateResponse.Status.OK)).build();
} catch (DeploymentGroupDoesNotExistException e) {
return Response.ok(new RollingUpdateResponse(RollingUpdateResponse.Status.DEPLOYMENT_GROUP_NOT_FOUND)).build();
} catch (JobDoesNotExistException e) {
return Response.ok(new RollingUpdateResponse(RollingUpdateResponse.Status.JOB_NOT_FOUND)).build();
}
}
use of com.spotify.helios.common.protocol.RollingUpdateResponse in project helios by spotify.
the class RollingUpdateCommandTest method testRollingUpdateOverlapJson.
@Test
public void testRollingUpdateOverlapJson() throws Exception {
when(client.rollingUpdate(anyString(), any(JobId.class), any(RolloutOptions.class))).thenReturn(immediateFuture(new RollingUpdateResponse(RollingUpdateResponse.Status.OK)));
when(client.deploymentGroupStatus(GROUP_NAME)).then(new ResponseAnswer(statusResponse(DeploymentGroupStatusResponse.Status.ACTIVE, null, makeHostStatus("host1", JOB_ID, TaskStatus.State.RUNNING))));
when(options.getBoolean("overlap")).thenReturn(true);
final int ret = command.runWithJobId(options, client, out, true, JOB_ID, null);
final String output = baos.toString();
// Verify that rollingUpdate() was called with migrate=true
verify(client).rollingUpdate(GROUP_NAME, JOB_ID, new RolloutOptions(TIMEOUT, PARALLELISM, false, true, TOKEN));
assertEquals(0, ret);
assertJsonOutputEquals(output, ImmutableMap.<String, Object>builder().put("status", "DONE").put("duration", 0.00).put("parallelism", PARALLELISM).put("timeout", TIMEOUT).put("overlap", true).put("token", TOKEN).build());
}
use of com.spotify.helios.common.protocol.RollingUpdateResponse in project helios by spotify.
the class RollingUpdateCommandTest method testRollingUpdateFailsIfJobIdChangedDuringRolloutJson.
@Test
public void testRollingUpdateFailsIfJobIdChangedDuringRolloutJson() throws Exception {
when(client.rollingUpdate(anyString(), any(JobId.class), any(RolloutOptions.class))).thenReturn(immediateFuture(new RollingUpdateResponse(RollingUpdateResponse.Status.OK)));
when(client.deploymentGroupStatus(GROUP_NAME)).then(new ResponseAnswer(statusResponse(DeploymentGroupStatusResponse.Status.ROLLING_OUT, null, makeHostStatus("host1", null, null), makeHostStatus("host2", OLD_JOB_ID, TaskStatus.State.RUNNING), makeHostStatus("host3", OLD_JOB_ID, TaskStatus.State.RUNNING)), statusResponse(DeploymentGroupStatusResponse.Status.ROLLING_OUT, NEW_JOB_ID, null, makeHostStatus("host1", JOB_ID, TaskStatus.State.RUNNING), makeHostStatus("host2", JOB_ID, TaskStatus.State.STARTING), makeHostStatus("host3", OLD_JOB_ID, TaskStatus.State.RUNNING))));
final int ret = command.runWithJobId(options, client, out, true, JOB_ID, null);
final String output = baos.toString();
verify(client).rollingUpdate(GROUP_NAME, JOB_ID, new RolloutOptions(TIMEOUT, PARALLELISM, false, false, TOKEN));
assertEquals(1, ret);
assertJsonOutputEquals(output, ImmutableMap.<String, Object>builder().put("status", "FAILED").put("error", "Deployment-group job id changed during rolling-update").put("duration", 1.00).put("parallelism", PARALLELISM).put("timeout", TIMEOUT).put("overlap", false).put("token", TOKEN).build());
}
use of com.spotify.helios.common.protocol.RollingUpdateResponse in project helios by spotify.
the class RollingUpdateCommandTest method testRollingUpdateFailsOnRolloutTimeoutJson.
@Test
public void testRollingUpdateFailsOnRolloutTimeoutJson() throws Exception {
when(client.rollingUpdate(anyString(), any(JobId.class), any(RolloutOptions.class))).thenReturn(immediateFuture(new RollingUpdateResponse(RollingUpdateResponse.Status.OK)));
when(client.deploymentGroupStatus(GROUP_NAME)).then(new ResponseAnswer(statusResponse(DeploymentGroupStatusResponse.Status.ROLLING_OUT, null, makeHostStatus("host1", null, null), makeHostStatus("host2", null, null)), statusResponse(DeploymentGroupStatusResponse.Status.ROLLING_OUT, null, makeHostStatus("host1", JOB_ID, TaskStatus.State.PULLING_IMAGE), makeHostStatus("host2", null, null))));
final int ret = command.runWithJobId(options, client, out, true, JOB_ID, null);
final String output = baos.toString();
verify(client).rollingUpdate(GROUP_NAME, JOB_ID, new RolloutOptions(TIMEOUT, PARALLELISM, false, false, TOKEN));
assertEquals(1, ret);
assertJsonOutputEquals(output, ImmutableMap.<String, Object>builder().put("status", "TIMEOUT").put("duration", 601.00).put("parallelism", PARALLELISM).put("timeout", TIMEOUT).put("overlap", false).put("token", TOKEN).build());
}
use of com.spotify.helios.common.protocol.RollingUpdateResponse in project helios by spotify.
the class RollingUpdateCommandTest method testRollingUpdate.
@Test
public void testRollingUpdate() throws Exception {
when(client.rollingUpdate(anyString(), any(JobId.class), any(RolloutOptions.class))).thenReturn(immediateFuture(new RollingUpdateResponse(RollingUpdateResponse.Status.OK)));
when(client.deploymentGroupStatus(GROUP_NAME)).then(new ResponseAnswer(statusResponse(DeploymentGroupStatusResponse.Status.ROLLING_OUT, null), statusResponse(DeploymentGroupStatusResponse.Status.ROLLING_OUT, null, makeHostStatus("host1", null, null), makeHostStatus("host2", OLD_JOB_ID, TaskStatus.State.RUNNING), makeHostStatus("host3", OLD_JOB_ID, TaskStatus.State.RUNNING)), statusResponse(DeploymentGroupStatusResponse.Status.ROLLING_OUT, null, makeHostStatus("host1", JOB_ID, TaskStatus.State.RUNNING), makeHostStatus("host2", JOB_ID, TaskStatus.State.PULLING_IMAGE), makeHostStatus("host3", OLD_JOB_ID, TaskStatus.State.RUNNING)), statusResponse(DeploymentGroupStatusResponse.Status.ROLLING_OUT, null, makeHostStatus("host1", JOB_ID, TaskStatus.State.RUNNING), makeHostStatus("host2", JOB_ID, TaskStatus.State.RUNNING), makeHostStatus("host3", JOB_ID, TaskStatus.State.CREATING)), statusResponse(DeploymentGroupStatusResponse.Status.ACTIVE, null, makeHostStatus("host1", JOB_ID, TaskStatus.State.RUNNING), makeHostStatus("host2", JOB_ID, TaskStatus.State.RUNNING), makeHostStatus("host3", JOB_ID, TaskStatus.State.RUNNING))));
final int ret = command.runWithJobId(options, client, out, false, JOB_ID, null);
final String output = baos.toString();
verify(client).rollingUpdate(GROUP_NAME, JOB_ID, new RolloutOptions(TIMEOUT, PARALLELISM, false, false, TOKEN));
assertEquals(0, ret);
final String expected = ("Rolling update started: my_group -> foo:2:1212121 (parallelism=1, timeout=300, " + "overlap=false, token=" + TOKEN + ")\n" + "\n" + "host1 -> RUNNING (1/3)\n" + "host2 -> RUNNING (2/3)\n" + "host3 -> RUNNING (3/3)\n" + "\n" + "Done.\n" + "Duration: 4.00 s\n");
assertEquals(expected, output.replaceAll("\\p{Blank}+|(?:\\p{Blank})$", " "));
}
Aggregations