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());
}
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;
}
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);
}
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());
}
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());
}
Aggregations