use of com.hubspot.singularity.SingularityRequest in project Singularity by HubSpot.
the class SingularityDeploysTest method testDeployFailsForInvalidRequestState.
@Test
public void testDeployFailsForInvalidRequestState() {
initRequest();
SingularityRequest request = requestResource.getRequest(requestId, singularityUser).getRequest();
initFirstDeploy();
deploy(secondDeployId, Optional.<Boolean>absent(), Optional.of(1), Optional.of(false), false);
requestManager.pause(request, System.currentTimeMillis(), Optional.<String>absent(), Optional.<String>absent());
deployChecker.checkDeploys();
Assert.assertEquals(DeployState.FAILED, deployManager.getDeployResult(requestId, secondDeployId).get().getDeployState());
}
use of com.hubspot.singularity.SingularityRequest in project Singularity by HubSpot.
the class SingularityDeploysTest method testCancelDeploy.
@Test
public void testCancelDeploy() {
initRequest();
SingularityRequest request = requestResource.getRequest(requestId, singularityUser).getRequest();
initFirstDeploy();
SingularityTask firstTask = launchTask(request, firstDeploy, 1, TaskState.TASK_RUNNING);
deploy(secondDeployId, Optional.<Boolean>absent(), Optional.of(1), Optional.of(false), false);
deployChecker.checkDeploys();
scheduler.drainPendingQueue();
Assert.assertEquals(1, taskManager.getPendingTaskIds().size());
resourceOffers();
Assert.assertEquals(1, taskManager.getActiveTaskIdsForDeploy(requestId, secondDeployId).size());
SingularityTaskId firstNewTaskId = taskManager.getActiveTaskIdsForDeploy(requestId, secondDeployId).get(0);
statusUpdate(taskManager.getTask(firstNewTaskId).get(), TaskState.TASK_RUNNING);
deployResource.cancelDeploy(singularityUser, requestId, secondDeployId);
deployChecker.checkDeploys();
Assert.assertTrue(taskManager.getCleanupTaskIds().contains(firstNewTaskId));
Assert.assertFalse(taskManager.getCleanupTaskIds().contains(firstTask.getTaskId()));
Assert.assertEquals(DeployState.CANCELED, deployManager.getDeployResult(requestId, secondDeployId).get().getDeployState());
}
use of com.hubspot.singularity.SingularityRequest in project Singularity by HubSpot.
the class SingularityDeploysTest method testDeployAllInstancesAtOnce.
@Test
public void testDeployAllInstancesAtOnce() {
initRequest();
SingularityRequest request = requestResource.getRequest(requestId, singularityUser).getRequest();
requestResource.postRequest(request.toBuilder().setInstances(Optional.of(2)).build(), singularityUser);
initFirstDeploy();
launchTask(request, firstDeploy, 1, TaskState.TASK_RUNNING);
launchTask(request, firstDeploy, 2, TaskState.TASK_RUNNING);
deploy(secondDeployId);
deployChecker.checkDeploys();
scheduler.drainPendingQueue();
Assert.assertEquals(2, taskManager.getActiveTaskIds().size());
Assert.assertEquals(2, taskManager.getPendingTaskIds().size());
resourceOffers();
Assert.assertEquals(2, taskManager.getActiveTaskIdsForDeploy(requestId, secondDeployId).size());
for (SingularityTaskId taskId : taskManager.getActiveTaskIdsForDeploy(requestId, secondDeployId)) {
statusUpdate(taskManager.getTask(taskId).get(), TaskState.TASK_RUNNING);
}
deployChecker.checkDeploys();
Assert.assertEquals(2, taskManager.getCleanupTaskIds().size());
Assert.assertEquals(DeployState.SUCCEEDED, deployManager.getDeployResult(requestId, secondDeployId).get().getDeployState());
Assert.assertEquals(2, taskManager.getActiveTaskIdsForDeploy(requestId, secondDeployId).size());
}
use of com.hubspot.singularity.SingularityRequest in project Singularity by HubSpot.
the class SingularityDeploysTest method testScaleDownDuringDeploy.
@Test
public void testScaleDownDuringDeploy() {
initRequest();
SingularityRequest request = requestResource.getRequest(requestId, singularityUser).getRequest();
requestResource.postRequest(request.toBuilder().setInstances(Optional.of(2)).build(), singularityUser);
initFirstDeploy();
launchTask(request, firstDeploy, 1, TaskState.TASK_RUNNING);
launchTask(request, firstDeploy, 2, TaskState.TASK_RUNNING);
deploy(secondDeployId);
deployChecker.checkDeploys();
scheduler.drainPendingQueue();
resourceOffers();
Assert.assertEquals(2, taskManager.getActiveTaskIdsForDeploy(requestId, secondDeployId).size());
for (SingularityTaskId taskId : taskManager.getActiveTaskIdsForDeploy(requestId, secondDeployId)) {
statusUpdate(taskManager.getTask(taskId).get(), TaskState.TASK_RUNNING);
}
requestResource.postRequest(request.toBuilder().setInstances(Optional.of(1)).build(), singularityUser);
scheduler.drainPendingQueue();
Assert.assertEquals(1, taskManager.getCleanupTaskIds().size());
deployChecker.checkDeploys();
Assert.assertEquals(2, taskManager.getCleanupTaskIds().size());
// Extra task from the new deploy should get cleaned up as well
scheduler.drainPendingQueue();
Assert.assertEquals(3, taskManager.getCleanupTaskIds().size());
}
use of com.hubspot.singularity.SingularityRequest in project Singularity by HubSpot.
the class SingularityDeploysTest method testDeployFails.
@Test
public void testDeployFails() {
initRequest();
SingularityRequest request = requestResource.getRequest(requestId, singularityUser).getRequest();
initFirstDeploy();
SingularityTask firstTask = launchTask(request, firstDeploy, 1, TaskState.TASK_RUNNING);
deploy(secondDeployId, Optional.<Boolean>absent(), Optional.of(1), Optional.of(false), false);
deployChecker.checkDeploys();
scheduler.drainPendingQueue();
Assert.assertEquals(1, taskManager.getPendingTaskIds().size());
resourceOffers();
Assert.assertEquals(1, taskManager.getActiveTaskIdsForDeploy(requestId, secondDeployId).size());
SingularityTaskId firstNewTaskId = taskManager.getActiveTaskIdsForDeploy(requestId, secondDeployId).get(0);
statusUpdate(taskManager.getTask(firstNewTaskId).get(), TaskState.TASK_FAILED);
deployChecker.checkDeploys();
Assert.assertFalse(taskManager.getCleanupTaskIds().contains(firstTask.getTaskId()));
Assert.assertEquals(DeployState.FAILED, deployManager.getDeployResult(requestId, secondDeployId).get().getDeployState());
}
Aggregations