use of com.hubspot.singularity.SingularityTask in project Singularity by HubSpot.
the class SingularitySchedulerTest method testJobRescheduledWhenItFinishesDuringDecommission.
@Test
public void testJobRescheduledWhenItFinishesDuringDecommission() {
initScheduledRequest();
initFirstDeploy();
resourceOffers();
SingularityTask task = launchTask(request, firstDeploy, 1, TaskState.TASK_RUNNING);
slaveManager.changeState("slave1", MachineState.STARTING_DECOMMISSION, Optional.<String>absent(), Optional.of("user1"));
cleaner.drainCleanupQueue();
resourceOffers();
cleaner.drainCleanupQueue();
statusUpdate(task, TaskState.TASK_FINISHED);
scheduler.drainPendingQueue();
Assert.assertTrue(!taskManager.getPendingTaskIds().isEmpty());
}
use of com.hubspot.singularity.SingularityTask 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());
}
use of com.hubspot.singularity.SingularityTask in project Singularity by HubSpot.
the class SingularitySchedulerTest method testAcceptOffersWithRoleForRequestWithRole.
@Test
public void testAcceptOffersWithRoleForRequestWithRole() {
SingularityRequestBuilder bldr = new SingularityRequestBuilder(requestId, RequestType.ON_DEMAND);
bldr.setRequiredRole(Optional.of("test-role"));
requestResource.postRequest(bldr.build(), singularityUser);
deploy("d2");
SingularityRunNowRequest runNowRequest = new SingularityRunNowRequestBuilder().setResources(new Resources(2, 2, 0)).build();
requestResource.scheduleImmediately(singularityUser, requestId, runNowRequest);
scheduler.drainPendingQueue();
SingularityPendingTask pendingTaskWithResources = taskManager.getPendingTasks().get(0);
Assert.assertTrue(pendingTaskWithResources.getResources().isPresent());
Assert.assertEquals(pendingTaskWithResources.getResources().get().getCpus(), 2, 0.0);
sms.resourceOffers(Arrays.asList(createOffer(5, 5, 5)));
pendingTaskWithResources = taskManager.getPendingTasks().get(0);
Assert.assertTrue(pendingTaskWithResources.getResources().isPresent());
Assert.assertEquals(pendingTaskWithResources.getResources().get().getCpus(), 2, 0.0);
sms.resourceOffers(Arrays.asList(createOffer(5, 5, 5, Optional.of("test-role"))));
SingularityTask task = taskManager.getActiveTasks().get(0);
Assert.assertEquals(MesosUtils.getNumCpus(mesosProtosUtils.toResourceList(task.getMesosTask().getResources()), Optional.of("test-role")), 2.0, 0.0);
}
use of com.hubspot.singularity.SingularityTask in project Singularity by HubSpot.
the class SingularitySchedulerTest method testPause.
@Test
public void testPause() {
initRequest();
initFirstDeploy();
SingularityTask taskOne = startTask(firstDeploy);
requestResource.pause(requestId, Optional.absent(), singularityUser);
cleaner.drainCleanupQueue();
Assert.assertEquals(1, taskManager.getKilledTaskIdRecords().size());
statusUpdate(taskOne, TaskState.TASK_KILLED);
resourceOffers();
Assert.assertEquals(0, taskManager.getActiveTaskIds().size());
Assert.assertEquals(0, taskManager.getPendingTasks().size());
Assert.assertEquals(RequestState.PAUSED, requestManager.getRequest(requestId).get().getState());
Assert.assertEquals(requestId, requestManager.getPausedRequests(false).iterator().next().getRequest().getId());
requestResource.unpause(requestId, Optional.absent(), singularityUser);
resourceOffers();
Assert.assertEquals(1, taskManager.getActiveTaskIds().size());
Assert.assertEquals(0, taskManager.getPendingTasks().size());
Assert.assertEquals(RequestState.ACTIVE, requestManager.getRequest(requestId).get().getState());
Assert.assertEquals(requestId, requestManager.getActiveRequests(false).iterator().next().getRequest().getId());
}
use of com.hubspot.singularity.SingularityTask in project Singularity by HubSpot.
the class SingularitySchedulerTest method testTaskOddities.
@Test
public void testTaskOddities() {
// test unparseable status update
TaskStatus.Builder bldr = TaskStatus.newBuilder().setTaskId(TaskID.newBuilder().setValue("task")).setAgentId(AgentID.newBuilder().setValue("slave1")).setState(TaskState.TASK_RUNNING);
// should not throw exception:
sms.statusUpdate(bldr.build()).join();
initRequest();
initFirstDeploy();
SingularityTask taskOne = launchTask(request, firstDeploy, 1, TaskState.TASK_STARTING);
taskManager.deleteTaskHistory(taskOne.getTaskId());
Assert.assertTrue(taskManager.isActiveTask(taskOne.getTaskId().getId()));
statusUpdate(taskOne, TaskState.TASK_RUNNING);
statusUpdate(taskOne, TaskState.TASK_FAILED);
Assert.assertTrue(!taskManager.isActiveTask(taskOne.getTaskId().getId()));
Assert.assertEquals(2, taskManager.getTaskHistoryUpdates(taskOne.getTaskId()).size());
}
Aggregations