use of com.spotify.helios.common.protocol.RollingUpdateResponse in project helios by spotify.
the class RollingUpdateCommandTest method testRollingUpdateFailedJson.
@Test
public void testRollingUpdateFailedJson() 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, true, JOB, null);
final String output = baos.toString();
verify(client).rollingUpdate(GROUP_NAME, JOB_ID, OPTIONS);
assertEquals(1, ret);
assertJsonOutputEquals(output, ImmutableMap.<String, Object>builder().put("status", "FAILED").put("error", "foobar").put("duration", 1.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 testRollingUpdateSuccessOutput.
@Test
public void testRollingUpdateSuccessOutput() 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 String expectedSubstring = "host1 -> RUNNING (1/1)\n" + "\n" + "Done.\n" + "Duration: 0.00 s\n";
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 testCommandLineOptions.
@Test
public void testCommandLineOptions() 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))));
String optionString = "(parallelism=1, timeout=300, overlap=false, token=my_token, " + "ignoreFailures=false, migrate=false)";
command.runWithJob(options, client, out, false, JOB, null);
assertThat(baos.toString(), containsString(optionString));
}
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.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(false).setOverlap(true).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", true).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 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.runWithJob(options, client, out, true, JOB, null);
final String output = baos.toString();
verify(client).rollingUpdate(GROUP_NAME, JOB_ID, OPTIONS);
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).put("ignoreFailures", false).put("migrate", false).build());
}
Aggregations