use of com.hubspot.singularity.SingularityTaskId 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.SingularityTaskId in project Singularity by HubSpot.
the class SingularityDeploysTest method testDeployWithImmediateRunSchedulesAfterRunningImmediately.
@Test
public void testDeployWithImmediateRunSchedulesAfterRunningImmediately() {
initRequestWithType(RequestType.SCHEDULED, false);
String deployId = "d1";
SingularityRunNowRequest runNowRequest = new SingularityRunNowRequestBuilder().setMessage("Message").build();
SingularityDeploy deploy = new SingularityDeployBuilder(requestId, deployId).setRunImmediately(Optional.of(runNowRequest)).setCommand(Optional.of("printenv > tmp.txt")).build();
SingularityDeployRequest deployRequest = new SingularityDeployRequest(deploy, Optional.absent(), Optional.absent());
deployResource.deploy(deployRequest, singularityUser);
deployChecker.checkDeploys();
scheduler.drainPendingQueue();
resourceOffers();
SingularityTaskId taskId = taskManager.getActiveTaskIdsForDeploy(requestId, deployId).get(0);
SingularityTask task = taskManager.getTask(taskId).get();
statusUpdate(task, TaskState.TASK_RUNNING);
statusUpdate(task, TaskState.TASK_FINISHED);
scheduler.drainPendingQueue();
resourceOffers();
Assert.assertEquals(0, taskManager.getNumActiveTasks());
Assert.assertEquals(1, taskManager.getNumScheduledTasks());
}
use of com.hubspot.singularity.SingularityTaskId 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.SingularityTaskId 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.SingularityTaskId 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