Search in sources :

Example 1 with RemoveDeploymentGroupResponse

use of com.spotify.helios.common.protocol.RemoveDeploymentGroupResponse in project helios by spotify.

the class DeploymentGroupResourceTest method testRemoveDeploymentGroup.

@Test
public void testRemoveDeploymentGroup() throws Exception {
    final Response response = resource.removeDeploymentGroup("foo");
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    assertEquals(new RemoveDeploymentGroupResponse(RemoveDeploymentGroupResponse.Status.REMOVED), response.getEntity());
}
Also used : RemoveDeploymentGroupResponse(com.spotify.helios.common.protocol.RemoveDeploymentGroupResponse) RollingUpdateResponse(com.spotify.helios.common.protocol.RollingUpdateResponse) CreateDeploymentGroupResponse(com.spotify.helios.common.protocol.CreateDeploymentGroupResponse) Response(javax.ws.rs.core.Response) RemoveDeploymentGroupResponse(com.spotify.helios.common.protocol.RemoveDeploymentGroupResponse) Test(org.junit.Test)

Example 2 with RemoveDeploymentGroupResponse

use of com.spotify.helios.common.protocol.RemoveDeploymentGroupResponse in project helios by spotify.

the class DeploymentGroupRemoveCommand method run.

@Override
int run(final Namespace options, final HeliosClient client, final PrintStream out, final boolean json, final BufferedReader stdin) throws ExecutionException, InterruptedException, IOException {
    final String name = options.getString(nameArg.getDest());
    final RemoveDeploymentGroupResponse status = client.removeDeploymentGroup(name).get();
    if (status == null) {
        throw new RuntimeException("The Helios master could not remove the given deployment group.");
    }
    final boolean failed = status.getStatus() != RemoveDeploymentGroupResponse.Status.REMOVED;
    if (json) {
        out.println(status.toJsonString());
    } else {
        if (failed) {
            out.println(format("Failed to remove deployment-group %s, status: %s", name, status.getStatus()));
        } else {
            out.println(format("Deployment-group %s removed", name));
        }
    }
    return failed ? 1 : 0;
}
Also used : RemoveDeploymentGroupResponse(com.spotify.helios.common.protocol.RemoveDeploymentGroupResponse)

Example 3 with RemoveDeploymentGroupResponse

use of com.spotify.helios.common.protocol.RemoveDeploymentGroupResponse in project helios by spotify.

the class DeploymentGroupRemoveCommandTest method testRemoveDeploymentGroupNotFoundJson.

@Test
public void testRemoveDeploymentGroupNotFoundJson() throws Exception {
    when(client.removeDeploymentGroup(GROUP_NAME)).thenReturn(immediateFuture(new RemoveDeploymentGroupResponse(Status.DEPLOYMENT_GROUP_NOT_FOUND)));
    final int ret = command.run(options, client, out, true, null);
    final String output = baos.toString();
    verify(client).removeDeploymentGroup(GROUP_NAME);
    assertEquals(1, ret);
    final RemoveDeploymentGroupResponse res = Json.read(output, new TypeReference<RemoveDeploymentGroupResponse>() {
    });
    assertEquals(new RemoveDeploymentGroupResponse(Status.DEPLOYMENT_GROUP_NOT_FOUND), res);
}
Also used : RemoveDeploymentGroupResponse(com.spotify.helios.common.protocol.RemoveDeploymentGroupResponse) Test(org.junit.Test)

Example 4 with RemoveDeploymentGroupResponse

use of com.spotify.helios.common.protocol.RemoveDeploymentGroupResponse in project helios by spotify.

the class DeploymentGroupTest method testRemoveDeploymentGroupActive.

@Test
public void testRemoveDeploymentGroupActive() throws Exception {
    final String host = testHost();
    startDefaultAgent(host, "--labels", TEST_LABEL);
    // Wait for agent to come up
    final HeliosClient client = defaultClient();
    awaitHostStatus(client, testHost(), UP, LONG_WAIT_SECONDS, SECONDS);
    // Use an invalid image to make sure the DG doesn't succeed (this ensure the DG will be active
    // for 5+ minutes, which is plenty of time).
    final JobId jobId = createJob(testJobName, testJobVersion, "invalid_image", IDLE_COMMAND);
    cli("create-deployment-group", "--json", TEST_GROUP, TEST_LABEL);
    cli("rolling-update", "--async", "--migrate", testJobNameAndVersion, TEST_GROUP);
    final RemoveDeploymentGroupResponse response = defaultClient().removeDeploymentGroup(TEST_GROUP).get();
    assertEquals(RemoveDeploymentGroupResponse.Status.REMOVED, response.getStatus());
}
Also used : Matchers.containsString(org.hamcrest.Matchers.containsString) HeliosClient(com.spotify.helios.client.HeliosClient) RemoveDeploymentGroupResponse(com.spotify.helios.common.protocol.RemoveDeploymentGroupResponse) JobId(com.spotify.helios.common.descriptors.JobId) Test(org.junit.Test)

Example 5 with RemoveDeploymentGroupResponse

use of com.spotify.helios.common.protocol.RemoveDeploymentGroupResponse in project helios by spotify.

the class DeploymentGroupTest method testRemoveDeploymentGroupInactive.

@Test
public void testRemoveDeploymentGroupInactive() throws Exception {
    cli("create-deployment-group", "--json", TEST_GROUP, TEST_LABEL);
    cli("rolling-update", "--async", "--migrate", testJobNameAndVersion, TEST_GROUP);
    final RemoveDeploymentGroupResponse response = defaultClient().removeDeploymentGroup(TEST_GROUP).get();
    assertEquals(RemoveDeploymentGroupResponse.Status.REMOVED, response.getStatus());
}
Also used : RemoveDeploymentGroupResponse(com.spotify.helios.common.protocol.RemoveDeploymentGroupResponse) Test(org.junit.Test)

Aggregations

RemoveDeploymentGroupResponse (com.spotify.helios.common.protocol.RemoveDeploymentGroupResponse)7 Test (org.junit.Test)6 CreateDeploymentGroupResponse (com.spotify.helios.common.protocol.CreateDeploymentGroupResponse)2 RollingUpdateResponse (com.spotify.helios.common.protocol.RollingUpdateResponse)2 Response (javax.ws.rs.core.Response)2 HeliosClient (com.spotify.helios.client.HeliosClient)1 JobId (com.spotify.helios.common.descriptors.JobId)1 DeploymentGroupDoesNotExistException (com.spotify.helios.master.DeploymentGroupDoesNotExistException)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1