use of com.hubspot.singularity.SingularityRequest in project Singularity by HubSpot.
the class ValidatorTest method itDoesNotAllowOtherRequestTypesToChange.
@Test(expected = WebApplicationException.class)
public void itDoesNotAllowOtherRequestTypesToChange() {
SingularityRequest request = new SingularityRequestBuilder("test", RequestType.ON_DEMAND).build();
SingularityRequest newRequest = new SingularityRequestBuilder("test", RequestType.SCHEDULED).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 itForbidsHealthCheckStartupDelaysLongerThanKillWait.
@Test
public void itForbidsHealthCheckStartupDelaysLongerThanKillWait() {
// Default kill wait time is 10 minutes (600 seconds)
HealthcheckOptions healthCheck = new HealthcheckOptionsBuilder("/").setPortNumber(Optional.of(8080L)).setStartupDelaySeconds(Optional.of(10000)).build();
SingularityDeploy deploy = SingularityDeploy.newBuilder("1234567", "1234567").setHealthcheck(Optional.of(healthCheck)).build();
SingularityRequest request = new SingularityRequestBuilder("1234567", RequestType.SERVICE).build();
WebApplicationException exn = (WebApplicationException) catchThrowable(() -> validator.checkDeploy(request, deploy, Collections.emptyList(), Collections.emptyList()));
assertThat((String) exn.getResponse().getEntity()).contains("Health check startup delay");
}
use of com.hubspot.singularity.SingularityRequest in project Singularity by HubSpot.
the class ValidatorTest method itForbidsHealthCheckGreaterThanMaxTotalHealthCheck.
@Test
public void itForbidsHealthCheckGreaterThanMaxTotalHealthCheck() {
singularityConfiguration.setHealthcheckMaxTotalTimeoutSeconds(Optional.of(100));
createValidator();
// Total wait time on this request is (startup time) + ((interval) + (http timeout)) * (1 + retries)
// = 50 + (5 + 5) * (9 + 1)
// = 150
HealthcheckOptions healthCheck = new HealthcheckOptionsBuilder("/").setPortNumber(Optional.of(8080L)).setStartupTimeoutSeconds(Optional.of(50)).setIntervalSeconds(Optional.of(5)).setResponseTimeoutSeconds(Optional.of(5)).setMaxRetries(Optional.of(9)).build();
SingularityDeploy deploy = SingularityDeploy.newBuilder("1234567", "1234567").setHealthcheck(Optional.of(healthCheck)).setCommand(Optional.of("sleep 100;")).build();
SingularityRequest request = new SingularityRequestBuilder("1234567", RequestType.SERVICE).build();
WebApplicationException exn = (WebApplicationException) catchThrowable(() -> validator.checkDeploy(request, deploy, Collections.emptyList(), Collections.emptyList()));
assertThat((String) exn.getResponse().getEntity()).contains("Max healthcheck time");
}
use of com.hubspot.singularity.SingularityRequest 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.SingularityRequest 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());
}
Aggregations