Search in sources :

Example 36 with SingularityPendingRequest

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

Example 37 with SingularityPendingRequest

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);
}
Also used : SingularityTask(com.hubspot.singularity.SingularityTask) SingularityPendingRequest(com.hubspot.singularity.SingularityPendingRequest) Test(org.junit.jupiter.api.Test)

Example 38 with SingularityPendingRequest

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

Example 39 with SingularityPendingRequest

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

Example 40 with SingularityPendingRequest

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());
}
Also used : SingularityPendingRequest(com.hubspot.singularity.SingularityPendingRequest) Offer(org.apache.mesos.v1.Protos.Offer) Test(org.junit.jupiter.api.Test)

Aggregations

SingularityPendingRequest (com.hubspot.singularity.SingularityPendingRequest)53 Test (org.junit.jupiter.api.Test)18 SingularityRequest (com.hubspot.singularity.SingularityRequest)12 SingularityRequestWithState (com.hubspot.singularity.SingularityRequestWithState)11 SingularityTask (com.hubspot.singularity.SingularityTask)9 SingularityTaskId (com.hubspot.singularity.SingularityTaskId)9 SingularityCreateResult (com.hubspot.singularity.SingularityCreateResult)8 SingularityTaskCleanup (com.hubspot.singularity.SingularityTaskCleanup)8 SingularityRunNowRequest (com.hubspot.singularity.api.SingularityRunNowRequest)8 ArrayList (java.util.ArrayList)8 List (java.util.List)8 SingularityDeploy (com.hubspot.singularity.SingularityDeploy)7 SingularityPendingDeploy (com.hubspot.singularity.SingularityPendingDeploy)7 SingularityPendingTask (com.hubspot.singularity.SingularityPendingTask)7 SingularityRequestDeployState (com.hubspot.singularity.SingularityRequestDeployState)7 Resources (com.hubspot.mesos.Resources)6 SingularityDeployKey (com.hubspot.singularity.SingularityDeployKey)6 SingularityDeployProgress (com.hubspot.singularity.SingularityDeployProgress)6 PendingType (com.hubspot.singularity.SingularityPendingRequest.PendingType)6 SingularityRequestBuilder (com.hubspot.singularity.SingularityRequestBuilder)6