use of com.hubspot.singularity.SingularityRequest in project Singularity by HubSpot.
the class ValidatorTest method whenRunNowIfRunIdSetItWillBePropagated.
@Test
public void whenRunNowIfRunIdSetItWillBePropagated() {
String deployID = "deploy";
Optional<String> userEmail = Optional.absent();
SingularityRequest request = new SingularityRequestBuilder("request2", RequestType.ON_DEMAND).build();
Optional<SingularityRunNowRequest> runNowRequest = Optional.of(runNowRequest("runId"));
List<SingularityTaskId> activeTasks = Collections.emptyList();
List<SingularityPendingTaskId> pendingTasks = Collections.emptyList();
SingularityPendingRequest pendingRequest = validator.checkRunNowRequest(deployID, userEmail, request, runNowRequest, activeTasks, pendingTasks);
Assert.assertEquals("runId", pendingRequest.getRunId().get());
}
use of com.hubspot.singularity.SingularityRequest in project Singularity by HubSpot.
the class ValidatorTest method itDoesNotWorkerToServiceTransitionIfLoadBalanced.
@Test(expected = WebApplicationException.class)
public void itDoesNotWorkerToServiceTransitionIfLoadBalanced() {
SingularityRequest request = new SingularityRequestBuilder("test", RequestType.WORKER).build();
SingularityRequest newRequest = new SingularityRequestBuilder("test", RequestType.SERVICE).setLoadBalanced(Optional.of(true)).build();
validator.checkSingularityRequest(newRequest, Optional.of(request), Optional.absent(), Optional.absent());
}
use of com.hubspot.singularity.SingularityRequest in project Singularity by HubSpot.
the class ValidatorTest method whenRunNowItForbidsTooLongRunIds.
@Test(expected = WebApplicationException.class)
public void whenRunNowItForbidsTooLongRunIds() {
String deployID = "deploy";
Optional<String> userEmail = Optional.absent();
SingularityRequest request = new SingularityRequestBuilder("request2", RequestType.SERVICE).build();
Optional<SingularityRunNowRequest> runNowRequest = Optional.of(runNowRequest(tooLongId()));
List<SingularityTaskId> activeTasks = Collections.emptyList();
List<SingularityPendingTaskId> pendingTasks = Collections.emptyList();
validator.checkRunNowRequest(deployID, userEmail, request, runNowRequest, activeTasks, pendingTasks);
}
use of com.hubspot.singularity.SingularityRequest in project Singularity by HubSpot.
the class ValidatorTest method itForbidsQuotesInDeployIds.
@Test
public void itForbidsQuotesInDeployIds() throws Exception {
final String badDeployId = "deployKey'";
SingularityDeploy singularityDeploy = SingularityDeploy.newBuilder(badDeployId, badDeployId).build();
SingularityRequest singularityRequest = new SingularityRequestBuilder(badDeployId, RequestType.SERVICE).build();
WebApplicationException exn = (WebApplicationException) catchThrowable(() -> validator.checkDeploy(singularityRequest, singularityDeploy, Collections.emptyList(), Collections.emptyList()));
assertThat((String) exn.getResponse().getEntity()).contains("[a-zA-Z0-9_.]");
}
use of com.hubspot.singularity.SingularityRequest in project Singularity by HubSpot.
the class SingularitySchedulerTest method testRunNowScheduledJobDoesNotRetry.
@Test
public void testRunNowScheduledJobDoesNotRetry() {
initScheduledRequest();
SingularityRequest request = requestResource.getRequest(requestId, singularityUser).getRequest();
SingularityRequest newRequest = request.toBuilder().setNumRetriesOnFailure(Optional.of(2)).build();
requestResource.postRequest(newRequest, singularityUser);
initFirstDeploy();
requestResource.scheduleImmediately(singularityUser, requestId, new SingularityRunNowRequestBuilder().build());
resourceOffers();
SingularityTask task = taskManager.getActiveTasks().get(0);
statusUpdate(task, TaskState.TASK_FAILED);
scheduler.drainPendingQueue();
SingularityDeployStatistics deployStatistics = deployManager.getDeployStatistics(task.getTaskId().getRequestId(), task.getTaskId().getDeployId()).get();
Assert.assertEquals(MesosTaskState.TASK_FAILED, deployStatistics.getLastTaskState().get().toTaskState().get());
Assert.assertEquals(PendingType.TASK_DONE, taskManager.getPendingTaskIds().get(0).getPendingType());
Assert.assertEquals(1, deployStatistics.getNumFailures());
Assert.assertEquals(0, deployStatistics.getNumSequentialRetries());
Assert.assertEquals(Optional.<Long>absent(), deployStatistics.getAverageRuntimeMillis());
}
Aggregations