use of com.hubspot.singularity.SingularityRequest in project Singularity by HubSpot.
the class SingularityDeploysTest method testDeployMultipleInstancesAtOnce.
@Test
public void testDeployMultipleInstancesAtOnce() {
initRequest();
SingularityRequest request = requestResource.getRequest(requestId, singularityUser).getRequest();
requestResource.postRequest(request.toBuilder().setInstances(Optional.of(4)).build(), singularityUser);
initFirstDeploy();
SingularityTask firstTask = launchTask(request, firstDeploy, 1, TaskState.TASK_RUNNING);
SingularityTask secondTask = launchTask(request, firstDeploy, 2, TaskState.TASK_RUNNING);
SingularityTask thirdTask = launchTask(request, firstDeploy, 3, TaskState.TASK_RUNNING);
SingularityTask fourthTask = launchTask(request, firstDeploy, 4, TaskState.TASK_RUNNING);
deploy(secondDeployId, Optional.<Boolean>absent(), Optional.of(2), Optional.<Boolean>absent(), false);
deployChecker.checkDeploys();
scheduler.drainPendingQueue();
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());
List<SingularityTaskId> cleanupTaskIds = taskManager.getCleanupTaskIds();
Assert.assertTrue(cleanupTaskIds.contains(firstTask.getTaskId()) && cleanupTaskIds.contains(secondTask.getTaskId()));
SingularityDeployProgress deployProgressStepOne = deployManager.getPendingDeploys().get(0).getDeployProgress().get();
Assert.assertTrue(deployProgressStepOne.isStepComplete());
Assert.assertEquals(2, deployProgressStepOne.getTargetActiveInstances());
cleaner.drainCleanupQueue();
statusUpdate(firstTask, TaskState.TASK_KILLED);
statusUpdate(secondTask, TaskState.TASK_KILLED);
deployChecker.checkDeploys();
SingularityDeployProgress deployProgressStepTwo = deployManager.getPendingDeploys().get(0).getDeployProgress().get();
Assert.assertFalse(deployProgressStepTwo.isStepComplete());
Assert.assertEquals(4, deployProgressStepTwo.getTargetActiveInstances());
scheduler.drainPendingQueue();
Assert.assertEquals(2, taskManager.getPendingTaskIds().size());
resourceOffers();
Assert.assertEquals(4, taskManager.getActiveTaskIdsForDeploy(requestId, secondDeployId).size());
for (SingularityTaskId taskId : taskManager.getActiveTaskIdsForDeploy(requestId, secondDeployId)) {
statusUpdate(taskManager.getTask(taskId).get(), TaskState.TASK_RUNNING);
}
deployChecker.checkDeploys();
Assert.assertEquals(4, taskManager.getActiveTaskIdsForDeploy(requestId, secondDeployId).size());
Assert.assertEquals(DeployState.SUCCEEDED, deployManager.getDeployResult(requestId, secondDeployId).get().getDeployState());
}
use of com.hubspot.singularity.SingularityRequest in project Singularity by HubSpot.
the class SingularityDeploysTest method testIncrementalDeployInstanceCounter.
@Test
public void testIncrementalDeployInstanceCounter() {
initRequest();
SingularityRequest request = requestResource.getRequest(requestId, singularityUser).getRequest();
requestResource.postRequest(request.toBuilder().setInstances(Optional.of(4)).build(), singularityUser);
initFirstDeploy();
SingularityTask firstTask = launchTask(request, firstDeploy, 1, TaskState.TASK_RUNNING);
SingularityTask secondTask = launchTask(request, firstDeploy, 2, TaskState.TASK_RUNNING);
SingularityTask thirdTask = launchTask(request, firstDeploy, 3, TaskState.TASK_RUNNING);
deploy(secondDeployId, Optional.<Boolean>absent(), Optional.of(1), Optional.<Boolean>absent(), false);
deployChecker.checkDeploys();
scheduler.drainPendingQueue();
resourceOffers();
SingularityTaskId firstNewTaskId = taskManager.getActiveTaskIdsForDeploy(requestId, secondDeployId).get(0);
statusUpdate(taskManager.getTask(firstNewTaskId).get(), TaskState.TASK_RUNNING);
deployChecker.checkDeploys();
SingularityDeployProgress deployProgress = deployManager.getPendingDeploy(requestId).get().getDeployProgress().get();
Assert.assertEquals(1, deployProgress.getTargetActiveInstances());
Assert.assertEquals(1, deployProgress.getCurrentActiveInstances());
cleaner.drainCleanupQueue();
statusUpdate(firstTask, TaskState.TASK_KILLED);
deployChecker.checkDeploys();
scheduler.drainPendingQueue();
resourceOffers();
for (SingularityTaskId taskId : taskManager.getActiveTaskIdsForDeploy(requestId, secondDeployId)) {
statusUpdate(taskManager.getTask(taskId).get(), TaskState.TASK_RUNNING);
}
deployChecker.checkDeploys();
deployProgress = deployManager.getPendingDeploy(requestId).get().getDeployProgress().get();
Assert.assertEquals(2, deployProgress.getTargetActiveInstances());
Assert.assertEquals(2, deployProgress.getCurrentActiveInstances());
cleaner.drainCleanupQueue();
statusUpdate(secondTask, TaskState.TASK_KILLED);
deployChecker.checkDeploys();
scheduler.drainPendingQueue();
resourceOffers();
for (SingularityTaskId taskId : taskManager.getActiveTaskIdsForDeploy(requestId, secondDeployId)) {
statusUpdate(taskManager.getTask(taskId).get(), TaskState.TASK_RUNNING);
}
deployChecker.checkDeploys();
deployProgress = deployManager.getPendingDeploy(requestId).get().getDeployProgress().get();
Assert.assertEquals(3, deployProgress.getTargetActiveInstances());
Assert.assertEquals(3, deployProgress.getCurrentActiveInstances());
}
use of com.hubspot.singularity.SingularityRequest in project Singularity by HubSpot.
the class SingularityDeploysTest method testCanceledDeployTasksStayActiveUntilReplaced.
@Test
public void testCanceledDeployTasksStayActiveUntilReplaced() {
initRequest();
SingularityRequest request = requestResource.getRequest(requestId, singularityUser).getRequest();
requestResource.postRequest(request.toBuilder().setInstances(Optional.of(2)).build(), singularityUser);
initFirstDeploy();
SingularityTask firstTask = launchTask(request, firstDeploy, 1, TaskState.TASK_RUNNING);
SingularityTask secondTask = launchTask(request, firstDeploy, 2, TaskState.TASK_RUNNING);
deploy(secondDeployId, Optional.<Boolean>absent(), Optional.of(1), Optional.<Boolean>absent(), 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);
deployChecker.checkDeploys();
Assert.assertEquals(1, taskManager.getCleanupTaskIds().size());
Assert.assertTrue(taskManager.getCleanupTaskIds().contains(firstTask.getTaskId()));
SingularityDeployProgress deployProgressStepOne = deployManager.getPendingDeploys().get(0).getDeployProgress().get();
Assert.assertTrue(deployProgressStepOne.isStepComplete());
Assert.assertEquals(1, deployProgressStepOne.getTargetActiveInstances());
cleaner.drainCleanupQueue();
statusUpdate(firstTask, TaskState.TASK_KILLED);
deployChecker.checkDeploys();
deployResource.cancelDeploy(singularityUser, requestId, secondDeployId);
deployChecker.checkDeploys();
scheduler.drainPendingQueue();
List<SingularityPendingTaskId> pendingTaskIds = taskManager.getPendingTaskIds();
Assert.assertEquals(1, pendingTaskIds.size());
Assert.assertEquals(firstDeployId, pendingTaskIds.get(0).getDeployId());
cleaner.drainCleanupQueue();
List<SingularityTaskId> cleanupTaskIds = taskManager.getCleanupTaskIds();
Assert.assertEquals(1, cleanupTaskIds.size());
Assert.assertEquals(secondDeployId, cleanupTaskIds.get(0).getDeployId());
resourceOffers();
for (SingularityTaskId taskId : taskManager.getActiveTaskIdsForDeploy(requestId, firstDeployId)) {
statusUpdate(taskManager.getTask(taskId).get(), TaskState.TASK_RUNNING);
}
cleaner.drainCleanupQueue();
Assert.assertEquals(0, taskManager.getCleanupTaskIds().size());
Assert.assertEquals(2, taskManager.getActiveTaskIdsForDeploy(requestId, firstDeployId).size());
}
use of com.hubspot.singularity.SingularityRequest in project Singularity by HubSpot.
the class SingularityDeploysTest method testDeployOneInstanceAtATime.
@Test
public void testDeployOneInstanceAtATime() {
initRequest();
SingularityRequest request = requestResource.getRequest(requestId, singularityUser).getRequest();
requestResource.postRequest(request.toBuilder().setInstances(Optional.of(2)).build(), singularityUser);
initFirstDeploy();
SingularityTask firstTask = launchTask(request, firstDeploy, 1, TaskState.TASK_RUNNING);
SingularityTask secondTask = launchTask(request, firstDeploy, 2, TaskState.TASK_RUNNING);
deploy(secondDeployId, Optional.<Boolean>absent(), Optional.of(1), Optional.<Boolean>absent(), 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);
deployChecker.checkDeploys();
Assert.assertEquals(1, taskManager.getCleanupTaskIds().size());
Assert.assertTrue(taskManager.getCleanupTaskIds().contains(firstTask.getTaskId()));
SingularityDeployProgress deployProgressStepOne = deployManager.getPendingDeploys().get(0).getDeployProgress().get();
Assert.assertTrue(deployProgressStepOne.isStepComplete());
Assert.assertEquals(1, deployProgressStepOne.getTargetActiveInstances());
cleaner.drainCleanupQueue();
statusUpdate(firstTask, TaskState.TASK_KILLED);
deployChecker.checkDeploys();
SingularityDeployProgress deployProgressStepTwo = deployManager.getPendingDeploys().get(0).getDeployProgress().get();
Assert.assertFalse(deployProgressStepTwo.isStepComplete());
Assert.assertEquals(2, deployProgressStepTwo.getTargetActiveInstances());
scheduler.drainPendingQueue();
Assert.assertEquals(1, 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.getActiveTaskIdsForDeploy(requestId, secondDeployId).size());
Assert.assertEquals(DeployState.SUCCEEDED, deployManager.getDeployResult(requestId, secondDeployId).get().getDeployState());
}
use of com.hubspot.singularity.SingularityRequest in project Singularity by HubSpot.
the class SingularityMesosTaskBuilderTest method testArgumentCommand.
@Test
public void testArgumentCommand() {
final SingularityRequest request = new SingularityRequestBuilder("test", RequestType.WORKER).build();
final SingularityDeploy deploy = new SingularityDeployBuilder("test", "1").setCommand(Optional.of("/bin/echo")).setArguments(Optional.of(Collections.singletonList("wat"))).build();
final SingularityTaskRequest taskRequest = new SingularityTaskRequest(request, deploy, pendingTask);
final SingularityMesosTaskHolder task = builder.buildTask(offerHolder, null, taskRequest, taskResources, executorResources);
assertEquals("/bin/echo", task.getMesosTask().getCommand().getValue());
assertEquals(1, task.getMesosTask().getCommand().getArgumentsCount());
assertEquals("wat", task.getMesosTask().getCommand().getArguments(0));
assertFalse(task.getMesosTask().getCommand().getShell());
}
Aggregations