Search in sources :

Example 51 with SingularityPendingRequest

use of com.hubspot.singularity.SingularityPendingRequest in project Singularity by HubSpot.

the class StateManagerTest method itDoesntFlagPendingRequestsForUnderOrOverProvisioning.

@Test
public void itDoesntFlagPendingRequestsForUnderOrOverProvisioning() {
    initRequest();
    initFirstDeploy();
    SingularityRequest request = requestResource.getRequest(requestId, singularityUser).getRequest();
    requestManager.activate(request.toBuilder().setInstances(Optional.of(0)).build(), RequestHistoryType.UPDATED, System.currentTimeMillis(), Optional.<String>empty(), Optional.<String>empty());
    requestManager.addToPendingQueue(new SingularityPendingRequest(request.getId(), firstDeployId, System.currentTimeMillis(), Optional.<String>empty(), PendingType.ONEOFF, Optional.<Boolean>empty(), Optional.<String>empty()));
    Assertions.assertEquals(0, taskManager.getActiveTaskIds().size());
    SingularityState state = stateManager.getState(true, false);
    Assertions.assertEquals(0, state.getOverProvisionedRequests());
    Assertions.assertEquals(0, state.getUnderProvisionedRequests());
}
Also used : SingularityPendingRequest(com.hubspot.singularity.SingularityPendingRequest) SingularityRequest(com.hubspot.singularity.SingularityRequest) SingularityState(com.hubspot.singularity.SingularityState) Test(org.junit.jupiter.api.Test)

Example 52 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 53 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)

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