use of com.hubspot.singularity.api.SingularityDeployRequest in project Singularity by HubSpot.
the class SingularitySchedulerTest method testRunOnceRunOnlyOnce.
@Test
public void testRunOnceRunOnlyOnce() {
SingularityRequestBuilder bldr = new SingularityRequestBuilder(requestId, RequestType.RUN_ONCE);
request = bldr.build();
saveRequest(request);
deployResource.deploy(new SingularityDeployRequest(new SingularityDeployBuilder(requestId, "d1").setCommand(Optional.of("cmd")).build(), Optional.absent(), Optional.absent()), singularityUser);
scheduler.drainPendingQueue();
deployChecker.checkDeploys();
resourceOffers();
Assert.assertTrue(deployManager.getRequestDeployState(requestId).get().getActiveDeploy().isPresent());
Assert.assertTrue(!deployManager.getRequestDeployState(requestId).get().getPendingDeploy().isPresent());
Assert.assertEquals(1, taskManager.getActiveTaskIds().size());
statusUpdate(taskManager.getActiveTasks().get(0), TaskState.TASK_LOST);
resourceOffers();
Assert.assertTrue(taskManager.getActiveTaskIds().isEmpty());
deployResource.deploy(new SingularityDeployRequest(new SingularityDeployBuilder(requestId, "d2").setCommand(Optional.of("cmd")).build(), Optional.absent(), Optional.absent()), singularityUser);
scheduler.drainPendingQueue();
deployChecker.checkDeploys();
resourceOffers();
Assert.assertTrue(deployManager.getRequestDeployState(requestId).get().getActiveDeploy().isPresent());
Assert.assertTrue(!deployManager.getRequestDeployState(requestId).get().getPendingDeploy().isPresent());
Assert.assertEquals(1, taskManager.getActiveTaskIds().size());
statusUpdate(taskManager.getActiveTasks().get(0), TaskState.TASK_FINISHED);
resourceOffers();
Assert.assertTrue(taskManager.getActiveTaskIds().isEmpty());
}
use of com.hubspot.singularity.api.SingularityDeployRequest in project Singularity by HubSpot.
the class SingularityDeploysTest method testDeployWithImmediateRunIsLaunchedImmediately.
@Test
public void testDeployWithImmediateRunIsLaunchedImmediately() {
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();
Assert.assertEquals(1, taskManager.getNumActiveTasks());
Assert.assertEquals(0, taskManager.getNumScheduledTasks());
SingularityTaskId taskId = taskManager.getActiveTaskIdsForDeploy(requestId, deployId).get(0);
SingularityTask task = taskManager.getTask(taskId).get();
Map<String, Object> command = (Map<String, Object>) task.getMesosTask().getAllOtherFields().get("command");
Assert.assertEquals("printenv > tmp.txt", (String) command.get("value"));
}
use of com.hubspot.singularity.api.SingularityDeployRequest in project Singularity by HubSpot.
the class SingularitySchedulerTestBase method startAndDeploySecondRequest.
protected SingularityRequest startAndDeploySecondRequest() {
SingularityRequest request = new SingularityRequestBuilder(requestId + "2", RequestType.SERVICE).build();
saveRequest(request);
SingularityDeploy deploy = new SingularityDeployBuilder(request.getId(), "d1").setCommand(Optional.of("sleep 1")).build();
deployResource.deploy(new SingularityDeployRequest(deploy, Optional.absent(), Optional.absent()), singularityUser);
return request;
}
Aggregations