use of com.hubspot.singularity.SingularityPendingRequest in project Singularity by HubSpot.
the class SingularityCachedOffersTest method testLeftoverCachedOffersAreReturnedToCache.
@Test
public void testLeftoverCachedOffersAreReturnedToCache() throws Exception {
configuration.setCacheOffers(true);
Offer neededOffer = createOffer(1, 128, 1024, "agent1", "host1", Optional.empty(), Collections.emptyMap(), new String[] { "80:81" });
Offer extraOffer = createOffer(4, 256, 1024, "agent1", "host1", Optional.empty(), Collections.emptyMap(), new String[] { "83:84" });
sms.resourceOffers(ImmutableList.of(neededOffer, extraOffer)).join();
initRequest();
firstDeploy = initAndFinishDeploy(request, new SingularityDeployBuilder(request.getId(), firstDeployId).setCommand(Optional.of("sleep 100")), Optional.of(new Resources(1, 128, 2, 0)));
requestManager.addToPendingQueue(new SingularityPendingRequest(requestId, firstDeployId, System.currentTimeMillis(), Optional.empty(), PendingType.TASK_DONE, Optional.empty(), Optional.empty()));
schedulerPoller.runActionOnPoll();
List<Offer> cachedOffers = offerCache.peekOffers();
Assertions.assertEquals(1, cachedOffers.size());
}
use of com.hubspot.singularity.SingularityPendingRequest in project Singularity by HubSpot.
the class SingularityCachedOffersTest method testLeftoverNewOffersAreCached.
@Test
public void testLeftoverNewOffersAreCached() {
configuration.setCacheOffers(true);
Offer neededOffer = createOffer(1, 128, 1024, "agent1", "host1");
Offer extraOffer = createOffer(4, 256, 0, "agent1", "host1");
initRequest();
initFirstDeploy();
requestManager.addToPendingQueue(new SingularityPendingRequest(requestId, firstDeployId, System.currentTimeMillis(), Optional.empty(), PendingType.TASK_DONE, Optional.empty(), Optional.empty()));
scheduler.drainPendingQueue();
sms.resourceOffers(ImmutableList.of(neededOffer, extraOffer)).join();
List<Offer> cachedOffers = offerCache.peekOffers();
Assertions.assertEquals(1, cachedOffers.size());
}
use of com.hubspot.singularity.SingularityPendingRequest in project Singularity by HubSpot.
the class SingularitySchedulerTest method testNewlyDeployedScheduledTasksAreScheduledAfterStartup.
@Test
public void testNewlyDeployedScheduledTasksAreScheduledAfterStartup() {
initScheduledRequest();
initFirstDeploy();
SingularityTask runningTask = launchTask(request, firstDeploy, 1, TaskState.TASK_RUNNING);
long now = System.currentTimeMillis();
initSecondDeploy();
requestManager.addToPendingQueue(new SingularityPendingRequest(requestId, secondDeployId, now, Optional.empty(), PendingType.STARTUP, Optional.empty(), Optional.empty()));
deployChecker.checkDeploys();
resourceOffers();
// There's an instance running, so we shouldn't schedule a pending task yet
Assertions.assertTrue(taskManager.getPendingTaskIds().isEmpty());
statusUpdate(runningTask, TaskState.TASK_FINISHED);
scheduler.drainPendingQueue();
// Now a pending task should be scheduled with the new deploy
Assertions.assertEquals(1, taskManager.getPendingTaskIds().size());
Assertions.assertEquals(PendingType.NEW_DEPLOY, taskManager.getPendingTaskIds().get(0).getPendingType());
Assertions.assertEquals(secondDeployId, taskManager.getPendingTaskIds().get(0).getDeployId());
}
use of com.hubspot.singularity.SingularityPendingRequest in project Singularity by HubSpot.
the class SingularitySchedulerTestBase method saveAndSchedule.
protected void saveAndSchedule(SingularityRequestBuilder bldr) {
SingularityRequest build = bldr.build();
requestManager.activate(build, RequestHistoryType.UPDATED, System.currentTimeMillis(), Optional.<String>empty(), Optional.<String>empty());
requestManager.addToPendingQueue(new SingularityPendingRequest(build.getId(), firstDeployId, System.currentTimeMillis(), Optional.<String>empty(), PendingType.UPDATED_REQUEST, Optional.<Boolean>empty(), Optional.<String>empty()));
scheduler.drainPendingQueue();
}
use of com.hubspot.singularity.SingularityPendingRequest in project Singularity by HubSpot.
the class SingularitySchedulerTest method testImmediateRequestsAreConsistentlyDeleted.
@Test
public void testImmediateRequestsAreConsistentlyDeleted() {
long now = System.currentTimeMillis();
initRequestWithType(RequestType.SCHEDULED, false);
startFirstDeploy();
SingularityPendingRequest pendingDeployRequest = new SingularityPendingRequest(requestId, firstDeploy.getId(), now, Optional.empty(), PendingType.NEW_DEPLOY, firstDeploy.getSkipHealthchecksOnDeploy(), Optional.empty());
SingularityPendingRequest pendingRunNowRequest = new SingularityPendingRequest(requestId, firstDeploy.getId(), now + 200, Optional.empty(), PendingType.IMMEDIATE, firstDeploy.getSkipHealthchecksOnDeploy(), Optional.empty());
requestManager.addToPendingQueue(pendingDeployRequest);
requestManager.addToPendingQueue(pendingRunNowRequest);
// Pending queue has two requests: NEW_DEPLOY & IMMEDIATE
Assertions.assertEquals(2, requestManager.getPendingRequests().size());
requestManager.deletePendingRequest(pendingDeployRequest);
// Just the immediate run
Assertions.assertEquals(1, requestManager.getPendingRequests().size());
requestManager.deletePendingRequest(pendingRunNowRequest);
// Immediate run was successfully deleted
Assertions.assertEquals(0, requestManager.getPendingRequests().size());
}
Aggregations