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());
}
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 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);
}
Aggregations