use of com.spotify.helios.master.DeploymentGroupDoesNotExistException in project helios by spotify.
the class DeploymentGroupResourceTest method testRollingUpdateDeploymentGroupDoesNotExist.
@Test
public void testRollingUpdateDeploymentGroupDoesNotExist() throws Exception {
doThrow(new DeploymentGroupDoesNotExistException("")).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.newBuilder().build()));
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
assertEquals(new RollingUpdateResponse(RollingUpdateResponse.Status.DEPLOYMENT_GROUP_NOT_FOUND), response.getEntity());
}
use of com.spotify.helios.master.DeploymentGroupDoesNotExistException in project helios by spotify.
the class DeploymentGroupResource method rollingUpdate.
@POST
@Path("/{name}/rolling-update")
@Produces(APPLICATION_JSON)
@Timed
@ExceptionMetered
public Response rollingUpdate(@PathParam("name") @Valid final String name, @Valid final RollingUpdateRequest args) {
try {
final DeploymentGroup deploymentGroup = model.getDeploymentGroup(name);
model.rollingUpdate(deploymentGroup, args.getJob(), args.getRolloutOptions());
return Response.ok(new RollingUpdateResponse(RollingUpdateResponse.Status.OK)).build();
} catch (DeploymentGroupDoesNotExistException e) {
return Response.ok(new RollingUpdateResponse(RollingUpdateResponse.Status.DEPLOYMENT_GROUP_NOT_FOUND)).build();
} catch (JobDoesNotExistException e) {
return Response.ok(new RollingUpdateResponse(RollingUpdateResponse.Status.JOB_NOT_FOUND)).build();
}
}
use of com.spotify.helios.master.DeploymentGroupDoesNotExistException in project helios by spotify.
the class DeploymentGroupResource method getDeploymentGroupStatus.
@GET
@Path("/{name}/status")
@Produces(APPLICATION_JSON)
@Timed
@ExceptionMetered
public Response getDeploymentGroupStatus(@PathParam("name") @Valid final String name) {
try {
final DeploymentGroup deploymentGroup = model.getDeploymentGroup(name);
final DeploymentGroupStatus deploymentGroupStatus = model.getDeploymentGroupStatus(name);
final List<String> hosts = model.getDeploymentGroupHosts(name);
final List<DeploymentGroupStatusResponse.HostStatus> result = Lists.newArrayList();
for (final String host : hosts) {
final HostStatus hostStatus = model.getHostStatus(host);
JobId deployedJobId = null;
TaskStatus.State state = null;
if (hostStatus != null && hostStatus.getStatus().equals(HostStatus.Status.UP)) {
for (final Map.Entry<JobId, Deployment> entry : hostStatus.getJobs().entrySet()) {
if (name.equals(entry.getValue().getDeploymentGroupName())) {
deployedJobId = entry.getKey();
final TaskStatus taskStatus = hostStatus.getStatuses().get(deployedJobId);
if (taskStatus != null) {
state = taskStatus.getState();
}
break;
}
}
result.add(new DeploymentGroupStatusResponse.HostStatus(host, deployedJobId, state));
}
}
final DeploymentGroupStatusResponse.Status status;
if (deploymentGroupStatus == null) {
status = DeploymentGroupStatusResponse.Status.IDLE;
} else if (deploymentGroupStatus.getState() == DeploymentGroupStatus.State.FAILED) {
status = DeploymentGroupStatusResponse.Status.FAILED;
} else if (deploymentGroupStatus.getState() == DeploymentGroupStatus.State.ROLLING_OUT) {
status = DeploymentGroupStatusResponse.Status.ROLLING_OUT;
} else {
status = DeploymentGroupStatusResponse.Status.ACTIVE;
}
final String error = deploymentGroupStatus == null ? "" : deploymentGroupStatus.getError();
return Response.ok(new DeploymentGroupStatusResponse(deploymentGroup, status, error, result, deploymentGroupStatus)).build();
} catch (final DeploymentGroupDoesNotExistException e) {
return Response.status(Response.Status.NOT_FOUND).build();
}
}
use of com.spotify.helios.master.DeploymentGroupDoesNotExistException in project helios by spotify.
the class DeploymentGroupResourceTest method testGetNonExistingDeploymentGroup.
@Test
public void testGetNonExistingDeploymentGroup() throws Exception {
when(model.getDeploymentGroup(anyString())).thenThrow(new DeploymentGroupDoesNotExistException(""));
final Response response = resource.getDeploymentGroup("foobar");
assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatus());
}
use of com.spotify.helios.master.DeploymentGroupDoesNotExistException in project helios by spotify.
the class DeploymentGroupResourceTest method testRemoveNonExistingDeploymentGroup.
@Test
public void testRemoveNonExistingDeploymentGroup() throws Exception {
doThrow(new DeploymentGroupDoesNotExistException("")).when(model).removeDeploymentGroup(anyString());
final Response response = resource.removeDeploymentGroup("foo");
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
assertEquals(new RemoveDeploymentGroupResponse(RemoveDeploymentGroupResponse.Status.DEPLOYMENT_GROUP_NOT_FOUND), response.getEntity());
}
Aggregations