use of com.hubspot.singularity.api.SingularityKillTaskRequest in project Singularity by HubSpot.
the class SingularitySchedulerTest method testTaskDestroy.
@Test
public void testTaskDestroy() {
initRequest();
initFirstDeploy();
SingularityTask firstTask = startTask(firstDeploy, 1);
SingularityTask secondTask = startTask(firstDeploy, 2);
SingularityTask thirdTask = startTask(firstDeploy, 3);
taskResource.killTask(secondTask.getTaskId().getId(), Optional.of(new SingularityKillTaskRequest(Optional.of(true), Optional.of("kill -9 bb"), Optional.absent(), Optional.absent(), Optional.absent())), singularityUser);
cleaner.drainCleanupQueue();
killKilledTasks();
Assert.assertEquals(2, taskManager.getNumActiveTasks());
System.out.println(requestManager.getCleanupRequests());
Assert.assertEquals(0, requestManager.getCleanupRequests().size());
Assert.assertEquals(RequestState.ACTIVE, requestManager.getRequest(requestId).get().getState());
}
use of com.hubspot.singularity.api.SingularityKillTaskRequest in project Singularity by HubSpot.
the class SingularitySchedulerTest method testTaskBounce.
@Test
public void testTaskBounce() {
initRequest();
initFirstDeploy();
SingularityTask firstTask = startTask(firstDeploy);
taskResource.killTask(firstTask.getTaskId().getId(), Optional.of(new SingularityKillTaskRequest(Optional.absent(), Optional.of("msg"), Optional.absent(), Optional.of(true), Optional.absent())), singularityUser);
cleaner.drainCleanupQueue();
killKilledTasks();
Assert.assertEquals(1, taskManager.getNumCleanupTasks());
Assert.assertEquals(0, taskManager.getKilledTaskIdRecords().size());
resourceOffers();
runLaunchedTasks();
Assert.assertEquals(1, taskManager.getNumCleanupTasks());
Assert.assertEquals(0, taskManager.getKilledTaskIdRecords().size());
Assert.assertEquals(2, taskManager.getNumActiveTasks());
cleaner.drainCleanupQueue();
killKilledTasks();
Assert.assertEquals(0, taskManager.getNumCleanupTasks());
Assert.assertEquals(1, taskManager.getNumActiveTasks());
}
use of com.hubspot.singularity.api.SingularityKillTaskRequest in project Singularity by HubSpot.
the class SingularitySchedulerTest method testDeployCleanupOverwritesTaskBounceCleanup.
@Test
public void testDeployCleanupOverwritesTaskBounceCleanup() {
initRequest();
initFirstDeploy();
final SingularityTask oldTask = startTask(firstDeploy);
taskResource.killTask(oldTask.getTaskId().getId(), Optional.of(new SingularityKillTaskRequest(Optional.absent(), Optional.absent(), Optional.absent(), Optional.of(true), Optional.absent())), singularityUser);
final Optional<SingularityTaskCleanup> taskCleanup = taskManager.getTaskCleanup(oldTask.getTaskId().getId());
Assert.assertTrue(taskCleanup.isPresent());
Assert.assertEquals(TaskCleanupType.USER_REQUESTED_TASK_BOUNCE, taskCleanup.get().getCleanupType());
initSecondDeploy();
startTask(secondDeploy);
deployChecker.checkDeploys();
Assert.assertEquals(DeployState.SUCCEEDED, deployManager.getDeployResult(requestId, secondDeployId).get().getDeployState());
Assert.assertEquals(TaskCleanupType.DEPLOY_STEP_FINISHED, taskManager.getTaskCleanup(oldTask.getTaskId().getId()).get().getCleanupType());
cleaner.drainCleanupQueue();
Assert.assertFalse(taskManager.getTaskCleanup(oldTask.getTaskId().getId()).isPresent());
}
Aggregations