Search in sources :

Example 21 with RollingUpdateResponse

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());
}
Also used : RolloutOptions(com.spotify.helios.common.descriptors.RolloutOptions) RollingUpdateResponse(com.spotify.helios.common.protocol.RollingUpdateResponse) Matchers.anyString(org.mockito.Matchers.anyString) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) JobId(com.spotify.helios.common.descriptors.JobId) Test(org.junit.Test)

Example 22 with RollingUpdateResponse

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));
}
Also used : RolloutOptions(com.spotify.helios.common.descriptors.RolloutOptions) RollingUpdateResponse(com.spotify.helios.common.protocol.RollingUpdateResponse) Matchers.anyString(org.mockito.Matchers.anyString) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) JobId(com.spotify.helios.common.descriptors.JobId) Test(org.junit.Test)

Example 23 with RollingUpdateResponse

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);
}
Also used : RolloutOptions(com.spotify.helios.common.descriptors.RolloutOptions) RollingUpdateResponse(com.spotify.helios.common.protocol.RollingUpdateResponse) Matchers.anyString(org.mockito.Matchers.anyString) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) JobId(com.spotify.helios.common.descriptors.JobId) Test(org.junit.Test)

Example 24 with RollingUpdateResponse

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());
}
Also used : RolloutOptions(com.spotify.helios.common.descriptors.RolloutOptions) RollingUpdateResponse(com.spotify.helios.common.protocol.RollingUpdateResponse) Matchers.anyString(org.mockito.Matchers.anyString) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) JobId(com.spotify.helios.common.descriptors.JobId) Test(org.junit.Test)

Example 25 with RollingUpdateResponse

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);
}
Also used : RolloutOptions(com.spotify.helios.common.descriptors.RolloutOptions) RollingUpdateResponse(com.spotify.helios.common.protocol.RollingUpdateResponse) Matchers.anyString(org.mockito.Matchers.anyString) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) JobId(com.spotify.helios.common.descriptors.JobId) Test(org.junit.Test)

Aggregations

RollingUpdateResponse (com.spotify.helios.common.protocol.RollingUpdateResponse)25 JobId (com.spotify.helios.common.descriptors.JobId)24 RolloutOptions (com.spotify.helios.common.descriptors.RolloutOptions)24 Test (org.junit.Test)22 Matchers.anyString (org.mockito.Matchers.anyString)19 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)18 DeploymentGroup (com.spotify.helios.common.descriptors.DeploymentGroup)3 TaskStatus (com.spotify.helios.common.descriptors.TaskStatus)2 CreateDeploymentGroupResponse (com.spotify.helios.common.protocol.CreateDeploymentGroupResponse)2 DeploymentGroupStatusResponse (com.spotify.helios.common.protocol.DeploymentGroupStatusResponse)2 RemoveDeploymentGroupResponse (com.spotify.helios.common.protocol.RemoveDeploymentGroupResponse)2 RollingUpdateRequest (com.spotify.helios.common.protocol.RollingUpdateRequest)2 DeploymentGroupDoesNotExistException (com.spotify.helios.master.DeploymentGroupDoesNotExistException)2 JobDoesNotExistException (com.spotify.helios.master.JobDoesNotExistException)2 Response (javax.ws.rs.core.Response)2 ExceptionMetered (com.codahale.metrics.annotation.ExceptionMetered)1 Timed (com.codahale.metrics.annotation.Timed)1 Job (com.spotify.helios.common.descriptors.Job)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1