use of com.spotify.helios.common.protocol.RollingUpdateResponse in project helios by spotify.
the class RollingUpdateCommandTest method testRollingUpdateMigrateJson.
@Test
public void testRollingUpdateMigrateJson() 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("migrate")).thenReturn(true);
final int ret = command.runWithJob(options, client, out, true, JOB, null);
final String output = baos.toString();
// Verify that rollingUpdate() was called with migrate=true
final RolloutOptions rolloutOptions = RolloutOptions.newBuilder().setTimeout(TIMEOUT).setParallelism(PARALLELISM).setMigrate(true).setOverlap(false).setToken(TOKEN).setIgnoreFailures(false).build();
verify(client).rollingUpdate(GROUP_NAME, JOB_ID, rolloutOptions);
assertEquals(0, ret);
assertJsonOutputEquals(output, ImmutableMap.<String, Object>builder().put("status", "DONE").put("duration", 0.00).put("parallelism", PARALLELISM).put("timeout", TIMEOUT).put("overlap", false).put("token", TOKEN).put("ignoreFailures", false).put("migrate", true).build());
}
use of com.spotify.helios.common.protocol.RollingUpdateResponse in project helios by spotify.
the class RollingUpdateCommandTest method testTimeoutDuringRolloutOutput.
@Test
public void testTimeoutDuringRolloutOutput() 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)), statusResponse(DeploymentGroupStatusResponse.Status.ROLLING_OUT, null, makeHostStatus("host1", null, null))));
final String expectedSubstring = "Timed out! (rolling-update still in progress)";
command.runWithJob(options, client, out, false, JOB, null);
assertThat(baos.toString(), containsString(expectedSubstring));
}
use of com.spotify.helios.common.protocol.RollingUpdateResponse in project helios by spotify.
the class RollingUpdateCommandTest method testRollingUpdateFailsIfJobIdChangedDuringRollout.
@Test
public void testRollingUpdateFailsIfJobIdChangedDuringRollout() 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, 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, 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.runWithJob(options, client, out, false, JOB, null);
final String output = baos.toString();
verify(client).rollingUpdate(GROUP_NAME, JOB_ID, OPTIONS);
assertEquals(1, ret);
}
use of com.spotify.helios.common.protocol.RollingUpdateResponse in project helios by spotify.
the class RollingUpdateCommandTest method testRollingUpdateJson.
// ----------------------------
@Test
public void testRollingUpdateJson() 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), makeHostStatus("host2", JOB_ID, TaskStatus.State.RUNNING), makeHostStatus("host3", JOB_ID, TaskStatus.State.RUNNING))));
final int ret = command.runWithJob(options, client, out, true, JOB, null);
final String output = baos.toString();
verify(client).rollingUpdate(GROUP_NAME, JOB_ID, OPTIONS);
assertEquals(0, ret);
assertJsonOutputEquals(output, ImmutableMap.<String, Object>builder().put("status", "DONE").put("duration", 0.00).put("parallelism", PARALLELISM).put("timeout", TIMEOUT).put("overlap", false).put("token", TOKEN).put("ignoreFailures", false).put("migrate", false).build());
}
use of com.spotify.helios.common.protocol.RollingUpdateResponse in project helios by spotify.
the class RollingUpdateCommandTest method testRollingUpdateFailed.
@Test
public void testRollingUpdateFailed() 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", JOB_ID, TaskStatus.State.PULLING_IMAGE), makeHostStatus("host2", null, null)), statusResponse(DeploymentGroupStatusResponse.Status.FAILED, "foobar", makeHostStatus("host1", JOB_ID, TaskStatus.State.RUNNING), makeHostStatus("host2", null, null))));
final int ret = command.runWithJob(options, client, out, false, JOB, null);
final String output = baos.toString();
verify(client).rollingUpdate(GROUP_NAME, JOB_ID, OPTIONS);
assertEquals(1, ret);
}
Aggregations