Search in sources :

Example 16 with SingularityDeployRequest

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

Example 17 with SingularityDeployRequest

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"));
}
Also used : SingularityRunNowRequest(com.hubspot.singularity.api.SingularityRunNowRequest) SingularityRunNowRequestBuilder(com.hubspot.singularity.SingularityRunNowRequestBuilder) SingularityDeployRequest(com.hubspot.singularity.api.SingularityDeployRequest) SingularityTask(com.hubspot.singularity.SingularityTask) SingularityDeployBuilder(com.hubspot.singularity.SingularityDeployBuilder) SingularityDeploy(com.hubspot.singularity.SingularityDeploy) SingularityTaskId(com.hubspot.singularity.SingularityTaskId) Map(java.util.Map) Test(org.junit.Test)

Example 18 with SingularityDeployRequest

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;
}
Also used : SingularityRequestBuilder(com.hubspot.singularity.SingularityRequestBuilder) SingularityDeployRequest(com.hubspot.singularity.api.SingularityDeployRequest) SingularityRequest(com.hubspot.singularity.SingularityRequest) SingularityDeployBuilder(com.hubspot.singularity.SingularityDeployBuilder) SingularityDeploy(com.hubspot.singularity.SingularityDeploy)

Aggregations

SingularityDeployRequest (com.hubspot.singularity.api.SingularityDeployRequest)18 SingularityDeployBuilder (com.hubspot.singularity.SingularityDeployBuilder)15 Test (org.junit.Test)14 SingularityDeploy (com.hubspot.singularity.SingularityDeploy)10 SingularityRequestBuilder (com.hubspot.singularity.SingularityRequestBuilder)8 SingularityRequest (com.hubspot.singularity.SingularityRequest)6 SingularityRunNowRequestBuilder (com.hubspot.singularity.SingularityRunNowRequestBuilder)3 SingularityTaskId (com.hubspot.singularity.SingularityTaskId)3 SingularityRunNowRequest (com.hubspot.singularity.api.SingularityRunNowRequest)3 SingularityPendingRequest (com.hubspot.singularity.SingularityPendingRequest)2 SingularityPendingTaskId (com.hubspot.singularity.SingularityPendingTaskId)2 SingularityTask (com.hubspot.singularity.SingularityTask)2 HttpResponse (com.hubspot.horizon.HttpResponse)1 Resources (com.hubspot.mesos.Resources)1 SingularityDeployKey (com.hubspot.singularity.SingularityDeployKey)1 SingularityPendingTask (com.hubspot.singularity.SingularityPendingTask)1 SingularityPriorityFreezeParent (com.hubspot.singularity.SingularityPriorityFreezeParent)1 SingularityRequestParent (com.hubspot.singularity.SingularityRequestParent)1 SingularityPriorityFreeze (com.hubspot.singularity.api.SingularityPriorityFreeze)1 ArrayList (java.util.ArrayList)1