Search in sources :

Example 1 with SingularityKillTaskRequest

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());
}
Also used : SingularityKillTaskRequest(com.hubspot.singularity.api.SingularityKillTaskRequest) SingularityTask(com.hubspot.singularity.SingularityTask) Test(org.junit.Test)

Example 2 with SingularityKillTaskRequest

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());
}
Also used : SingularityKillTaskRequest(com.hubspot.singularity.api.SingularityKillTaskRequest) SingularityTask(com.hubspot.singularity.SingularityTask) Test(org.junit.Test)

Example 3 with SingularityKillTaskRequest

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());
}
Also used : SingularityKillTaskRequest(com.hubspot.singularity.api.SingularityKillTaskRequest) SingularityTask(com.hubspot.singularity.SingularityTask) SingularityTaskCleanup(com.hubspot.singularity.SingularityTaskCleanup) Test(org.junit.Test)

Aggregations

SingularityTask (com.hubspot.singularity.SingularityTask)3 SingularityKillTaskRequest (com.hubspot.singularity.api.SingularityKillTaskRequest)3 Test (org.junit.Test)3 SingularityTaskCleanup (com.hubspot.singularity.SingularityTaskCleanup)1