use of com.spotify.helios.common.protocol.RollingUpdateResponse in project helios by spotify.
the class RollingUpdateCommandTest method testRollingUpdateFailureOutput.
@Test
public void testRollingUpdateFailureOutput() 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.FAILED, "mock failure", makeHostStatus("host1", JOB_ID, TaskStatus.State.RUNNING))));
when(options.getBoolean("overlap")).thenReturn(true);
final String expectedSubstring = "Failed: mock failure\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 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.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", "TIMEOUT").put("duration", 601.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 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.runWithJob(options, client, out, false, JOB, null);
final String output = baos.toString();
verify(client).rollingUpdate(GROUP_NAME, JOB_ID, OPTIONS);
assertEquals(0, ret);
}
use of com.spotify.helios.common.protocol.RollingUpdateResponse in project helios by spotify.
the class RollingUpdateCommandTest method testRollingUpdateAsync.
@Test
public void testRollingUpdateAsync() throws Exception {
when(client.rollingUpdate(anyString(), any(JobId.class), any(RolloutOptions.class))).thenReturn(immediateFuture(new RollingUpdateResponse(RollingUpdateResponse.Status.OK)));
when(options.getBoolean("async")).thenReturn(true);
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(0, ret);
final String expected = "Rolling update (async) started: my_group -> foo:2:1212121 (parallelism=1, timeout=300, " + "overlap=false, token=" + TOKEN + ", ignoreFailures=false, migrate=false)\n";
assertEquals(expected, output);
}
use of com.spotify.helios.common.protocol.RollingUpdateResponse in project helios by spotify.
the class RollingUpdateCommandTest method testFallbackToJobOptions.
@Test
public void testFallbackToJobOptions() throws Exception {
final Namespace cmdlineOptions = mock(Namespace.class);
when(cmdlineOptions.getString("deployment-group-name")).thenReturn(null);
when(cmdlineOptions.getInt("parallelism")).thenReturn(null);
when(cmdlineOptions.getLong("timeout")).thenReturn(null);
when(cmdlineOptions.getLong("rollout_timeout")).thenReturn(10L);
when(cmdlineOptions.getBoolean("async")).thenReturn(true);
when(cmdlineOptions.getBoolean("migrate")).thenReturn(null);
when(cmdlineOptions.getBoolean("overlap")).thenReturn(null);
when(cmdlineOptions.getString("token")).thenReturn("cli_token");
when(cmdlineOptions.getBoolean("ignore_failures")).thenReturn(null);
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=123, timeout=456, overlap=true, " + "token=cli_token, ignoreFailures=true, migrate=true)";
command.runWithJob(cmdlineOptions, client, out, false, JOB, null);
assertThat(baos.toString(), containsString(optionString));
}
Aggregations