use of com.spotify.helios.common.protocol.RollingUpdateResponse in project helios by spotify.
the class RollingUpdateCommandTest method testRollingUpdateMigrate.
@Test
public void testRollingUpdateMigrate() 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.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, true, false, 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", false).put("token", TOKEN).build());
}
use of com.spotify.helios.common.protocol.RollingUpdateResponse in project helios by spotify.
the class DeploymentGroupResourceTest method testRollingUpdateJobDoesNotExist.
@Test
public void testRollingUpdateJobDoesNotExist() throws Exception {
doThrow(new JobDoesNotExistException("")).when(model).rollingUpdate(any(DeploymentGroup.class), any(JobId.class), any(RolloutOptions.class));
final Response response = resource.rollingUpdate("foo", new RollingUpdateRequest(new JobId("foo", "0.3", "1234"), RolloutOptions.getDefault()));
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
assertEquals(new RollingUpdateResponse(RollingUpdateResponse.Status.JOB_NOT_FOUND), response.getEntity());
}
use of com.spotify.helios.common.protocol.RollingUpdateResponse in project helios by spotify.
the class RollingUpdateCommandTest method testRollingUpdateFailsOnRolloutTimeout.
@Test
public void testRollingUpdateFailsOnRolloutTimeout() 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, 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 testJobWithNoOptions.
@Test
public void testJobWithNoOptions() throws Exception {
final JobId jobId = new JobId("bar", "2", "1212121212121212121");
final Job job = Job.newBuilder().setName(jobId.getName()).setVersion(jobId.getVersion()).setHash(jobId.getHash()).build();
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, jobId, null, makeHostStatus("host1", jobId, TaskStatus.State.RUNNING))));
final int ret = command.runWithJob(options, client, out, false, job, null);
assertThat(ret, equalTo(0));
}
use of com.spotify.helios.common.protocol.RollingUpdateResponse in project helios by spotify.
the class RollingUpdateCommandTest method testRollingUpdateAsyncJson.
@Test
public void testRollingUpdateAsyncJson() 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, 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", "OK").put("parallelism", PARALLELISM).put("timeout", TIMEOUT).put("overlap", false).put("token", TOKEN).put("ignoreFailures", false).put("migrate", false).build());
}
Aggregations