use of com.hubspot.singularity.SingularityPendingRequest in project Singularity by HubSpot.
the class ZkMigrationTest method testPendingRequestWithRunIdRewrite.
@Test
public void testPendingRequestWithRunIdRewrite() throws Exception {
metadataManager.setZkDataVersion("10");
long now = System.currentTimeMillis();
SingularityPendingRequest immediateRequest = new SingularityPendingRequest("immediateRequest", "immediateDeploy", now, Optional.empty(), PendingType.IMMEDIATE, Optional.empty(), Optional.of("run1"), Optional.empty(), Optional.empty(), Optional.empty());
SingularityPendingRequest newDeploy = new SingularityPendingRequest("newDeployRequest", "newDeploy", now, Optional.empty(), PendingType.NEW_DEPLOY, Optional.empty(), Optional.empty());
SingularityPendingRequest oneOffRequest = new SingularityPendingRequest("oneOffRequest", "oneOffDeploy", now, Optional.empty(), PendingType.ONEOFF, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty());
curator.create().creatingParentsIfNeeded().forPath(String.format("%s%s", "/requests/pending/immediateRequest-immediateDeploy", now), objectMapper.writeValueAsBytes(immediateRequest));
curator.create().creatingParentsIfNeeded().forPath("/requests/pending/newDeployRequest-newDeploy", objectMapper.writeValueAsBytes(newDeploy));
curator.create().creatingParentsIfNeeded().forPath(String.format("%s%s", "/requests/pending/oneOffRequest-oneOffDeploy", now), objectMapper.writeValueAsBytes(oneOffRequest));
Assertions.assertThat(requestManager.getPendingRequests().size()).isEqualTo(3);
System.out.println(curator.getChildren().forPath("/requests/pending"));
migrationRunner.checkMigrations();
System.out.println(curator.getChildren().forPath("/requests/pending"));
Assertions.assertThat(requestManager.getPendingRequests().size()).isEqualTo(3);
System.out.println(curator.getChildren().forPath("/requests/pending"));
requestManager.deletePendingRequest(newDeploy);
Assertions.assertThat(requestManager.getPendingRequests()).as("Non-renamed, non-timestamped nodes can be deleted").hasSize(2).extracting(SingularityPendingRequest::toString).doesNotContain(newDeploy.toString()).contains(oneOffRequest.toString(), immediateRequest.toString());
requestManager.deletePendingRequest(oneOffRequest);
Assertions.assertThat(requestManager.getPendingRequests()).as("Non-renamed immediate (i.e., run-now scheduled without a runId) nodes can be deleted").hasSize(1).extracting(SingularityPendingRequest::toString).doesNotContain(oneOffRequest.toString()).contains(immediateRequest.toString());
requestManager.deletePendingRequest(immediateRequest);
Assertions.assertThat(requestManager.getPendingRequests()).as("Renamed one-off (i.e., run-now on-demand) nodes can be deleted").hasSize(0);
}
use of com.hubspot.singularity.SingularityPendingRequest in project Singularity by HubSpot.
the class SingularitySchedulerTest method testObsoletePendingRequestsRemoved.
@Test
public void testObsoletePendingRequestsRemoved() {
initRequest();
initFirstDeploy();
SingularityTask taskOne = startTask(firstDeploy);
requestResource.pause(requestId, Optional.empty(), singularityUser);
requestManager.addToPendingQueue(new SingularityPendingRequest(requestId, firstDeployId, System.currentTimeMillis(), Optional.<String>empty(), PendingType.NEW_DEPLOY, Optional.<Boolean>empty(), Optional.<String>empty()));
Assertions.assertEquals(requestManager.getPendingRequests().size(), 1);
scheduler.drainPendingQueue();
Assertions.assertEquals(requestManager.getPendingRequests().size(), 0);
}
use of com.hubspot.singularity.SingularityPendingRequest in project Singularity by HubSpot.
the class ValidatorTest method whenRunNowIfRunIdSetItWillBePropagated.
@Test
public void whenRunNowIfRunIdSetItWillBePropagated() {
String deployID = "deploy";
Optional<String> userEmail = Optional.empty();
SingularityRequest request = new SingularityRequestBuilder("request2", RequestType.ON_DEMAND).build();
Optional<SingularityRunNowRequest> runNowRequest = Optional.of(runNowRequest("runId"));
SingularityPendingRequest pendingRequest = validator.checkRunNowRequest(deployID, userEmail, request, runNowRequest, 0, 0);
Assertions.assertEquals("runId", pendingRequest.getRunId().get());
}
use of com.hubspot.singularity.SingularityPendingRequest in project Singularity by HubSpot.
the class SingularityStartupTest method testOnDemandDoesntGetRescheduled.
@Test
public void testOnDemandDoesntGetRescheduled() {
saveRequest(new SingularityRequestBuilder(requestId, RequestType.ON_DEMAND).build());
deploy(firstDeployId);
deployChecker.checkDeploys();
Assertions.assertTrue(requestManager.getPendingRequests().isEmpty());
Assertions.assertTrue(taskManager.getPendingTaskIds().isEmpty());
CompletableFutures.allOf(startup.checkSchedulerForInconsistentState(executorService)).join();
Assertions.assertTrue(requestManager.getPendingRequests().isEmpty());
Assertions.assertTrue(taskManager.getPendingTaskIds().isEmpty());
requestManager.addToPendingQueue(new SingularityPendingRequest(requestId, firstDeployId, System.currentTimeMillis(), Optional.<String>empty(), PendingType.ONEOFF, Optional.<Boolean>empty(), Optional.<String>empty()));
CompletableFutures.allOf(startup.checkSchedulerForInconsistentState(executorService)).join();
Assertions.assertTrue(requestManager.getPendingRequests().get(0).getPendingType() == PendingType.ONEOFF);
}
use of com.hubspot.singularity.SingularityPendingRequest in project Singularity by HubSpot.
the class SingularityCachedOffersTest method testOfferCombination.
@Test
public void testOfferCombination() {
configuration.setOfferCacheSize(2);
// Each are half of needed memory
Offer offer1 = createOffer(1, 64, 1024, "agent1", "host1");
Offer offer2 = createOffer(1, 64, 1024, "agent1", "host1");
sms.resourceOffers(ImmutableList.of(offer1, offer2)).join();
initRequest();
initFirstDeploy();
requestManager.addToPendingQueue(new SingularityPendingRequest(requestId, firstDeployId, System.currentTimeMillis(), Optional.empty(), PendingType.TASK_DONE, Optional.empty(), Optional.empty()));
schedulerPoller.runActionOnPoll();
Assertions.assertEquals(1, taskManager.getActiveTasks().size());
Assertions.assertEquals(2, taskManager.getActiveTasks().get(0).getOffers().size());
}
Aggregations