use of com.hubspot.singularity.SingularityRunNowRequestBuilder in project Singularity by HubSpot.
the class SingularitySchedulerTest method testOnDemandRunNowJobRespectsSpecifiedRunAtTime.
@Test
public void testOnDemandRunNowJobRespectsSpecifiedRunAtTime() {
initOnDemandRequest();
initFirstDeploy();
long requestedLaunchTime = System.currentTimeMillis() + TimeUnit.MINUTES.toMillis(10);
requestResource.scheduleImmediately(singularityUser, requestId, new SingularityRunNowRequestBuilder().setRunAt(requestedLaunchTime).build());
scheduler.drainPendingQueue();
SingularityPendingTaskId task = taskManager.getPendingTaskIds().get(0);
long runAt = task.getNextRunAt();
Assert.assertEquals(requestedLaunchTime, runAt);
}
use of com.hubspot.singularity.SingularityRunNowRequestBuilder 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.SingularityRunNowRequestBuilder in project Singularity by HubSpot.
the class SingularitySchedulerTest method testScheduledRunNowJobRespectsSpecifiedRunAtTime.
@Test
public void testScheduledRunNowJobRespectsSpecifiedRunAtTime() {
initScheduledRequest();
initFirstDeploy();
long requestedLaunchTime = System.currentTimeMillis() + TimeUnit.MINUTES.toMillis(10);
requestResource.scheduleImmediately(singularityUser, requestId, new SingularityRunNowRequestBuilder().setRunAt(requestedLaunchTime).build());
scheduler.drainPendingQueue();
SingularityPendingTaskId task = taskManager.getPendingTaskIds().get(0);
long runAt = task.getNextRunAt();
Assert.assertEquals(requestedLaunchTime, runAt);
}
use of com.hubspot.singularity.SingularityRunNowRequestBuilder 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"));
}
Aggregations