use of com.hubspot.singularity.api.SingularityRunNowRequest in project Singularity by HubSpot.
the class ValidatorTest method whenRunNowItForbidsMoreInstancesForOnDemandThanInRequest.
@Test(expected = WebApplicationException.class)
public void whenRunNowItForbidsMoreInstancesForOnDemandThanInRequest() {
String deployID = "deploy";
Optional<String> userEmail = Optional.absent();
SingularityRequest request = new SingularityRequestBuilder("request2", RequestType.ON_DEMAND).setInstances(Optional.of(1)).build();
Optional<SingularityRunNowRequest> runNowRequest = Optional.absent();
List<SingularityTaskId> activeTasks = Collections.singletonList(activeTask());
List<SingularityPendingTaskId> pendingTasks = Collections.emptyList();
validator.checkRunNowRequest(deployID, userEmail, request, runNowRequest, activeTasks, pendingTasks);
}
use of com.hubspot.singularity.api.SingularityRunNowRequest in project Singularity by HubSpot.
the class ValidatorTest method whenDeployHasRunNowSetAndNotDeployedItWillRunImmediately.
@Test
public void whenDeployHasRunNowSetAndNotDeployedItWillRunImmediately() {
String requestId = "request";
String deployID = "deploy";
SingularityRequest request = new SingularityRequestBuilder(requestId, RequestType.ON_DEMAND).build();
Optional<SingularityRunNowRequest> runNowRequest = Optional.of(runNowRequest());
SingularityDeploy deploy = SingularityDeploy.newBuilder(requestId, deployID).setCommand(Optional.of("printenv")).setRunImmediately(runNowRequest).build();
SingularityDeploy result = validator.checkDeploy(request, deploy, Collections.emptyList(), Collections.emptyList());
Assert.assertTrue(result.getRunImmediately().isPresent());
Assert.assertTrue(result.getRunImmediately().get().getRunId().isPresent());
}
use of com.hubspot.singularity.api.SingularityRunNowRequest 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.api.SingularityRunNowRequest 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.api.SingularityRunNowRequest in project Singularity by HubSpot.
the class SingularityClient method runSingularityRequest.
public SingularityPendingRequestParent runSingularityRequest(String requestId, Optional<SingularityRunNowRequest> runNowRequest) {
final Function<String, String> requestUri = (host) -> String.format(REQUEST_RUN_FORMAT, getApiBase(host), requestId);
final HttpResponse response = post(requestUri, String.format("run of request %s", requestId), runNowRequest);
return response.getAs(SingularityPendingRequestParent.class);
}
Aggregations