Search in sources :

Example 31 with SingularityDeploy

use of com.hubspot.singularity.SingularityDeploy 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");
}
Also used : SingularityRequestBuilder(com.hubspot.singularity.SingularityRequestBuilder) WebApplicationException(javax.ws.rs.WebApplicationException) HealthcheckOptions(com.hubspot.deploy.HealthcheckOptions) SingularityRequest(com.hubspot.singularity.SingularityRequest) HealthcheckOptionsBuilder(com.hubspot.deploy.HealthcheckOptionsBuilder) SingularityDeploy(com.hubspot.singularity.SingularityDeploy) Test(org.junit.Test)

Example 32 with SingularityDeploy

use of com.hubspot.singularity.SingularityDeploy 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");
}
Also used : SingularityRequestBuilder(com.hubspot.singularity.SingularityRequestBuilder) WebApplicationException(javax.ws.rs.WebApplicationException) HealthcheckOptions(com.hubspot.deploy.HealthcheckOptions) SingularityRequest(com.hubspot.singularity.SingularityRequest) HealthcheckOptionsBuilder(com.hubspot.deploy.HealthcheckOptionsBuilder) SingularityDeploy(com.hubspot.singularity.SingularityDeploy) Test(org.junit.Test)

Example 33 with SingularityDeploy

use of com.hubspot.singularity.SingularityDeploy 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());
}
Also used : SingularityRunNowRequest(com.hubspot.singularity.api.SingularityRunNowRequest) SingularityRequestBuilder(com.hubspot.singularity.SingularityRequestBuilder) SingularityRequest(com.hubspot.singularity.SingularityRequest) SingularityDeploy(com.hubspot.singularity.SingularityDeploy) Test(org.junit.Test)

Example 34 with SingularityDeploy

use of com.hubspot.singularity.SingularityDeploy 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_.]");
}
Also used : SingularityRequestBuilder(com.hubspot.singularity.SingularityRequestBuilder) WebApplicationException(javax.ws.rs.WebApplicationException) SingularityRequest(com.hubspot.singularity.SingularityRequest) SingularityDeploy(com.hubspot.singularity.SingularityDeploy) Test(org.junit.Test)

Example 35 with SingularityDeploy

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

the class SingularitySchedulerTest method testImmediateRunReplacesScheduledTask.

@Test
public void testImmediateRunReplacesScheduledTask() {
    initScheduledRequest();
    SingularityDeploy deploy = SingularityDeploy.newBuilder(requestId, firstDeployId).setCommand(Optional.of("sleep 100")).build();
    SingularityDeployRequest singularityDeployRequest = new SingularityDeployRequest(deploy, Optional.absent(), Optional.absent(), Optional.absent());
    deployResource.deploy(singularityDeployRequest, singularityUser);
    scheduler.drainPendingQueue();
    SingularityPendingTask task1 = createAndSchedulePendingTask(firstDeployId);
    Assert.assertEquals(1, taskManager.getPendingTaskIds().size());
    Assert.assertEquals(PendingType.NEW_DEPLOY, taskManager.getPendingTaskIds().get(0).getPendingType());
    requestManager.addToPendingQueue(new SingularityPendingRequest(requestId, deploy.getId(), System.currentTimeMillis(), Optional.absent(), PendingType.IMMEDIATE, deploy.getSkipHealthchecksOnDeploy(), Optional.absent()));
    scheduler.drainPendingQueue();
    Assert.assertEquals(1, taskManager.getPendingTaskIds().size());
    Assert.assertEquals(PendingType.IMMEDIATE, taskManager.getPendingTaskIds().get(0).getPendingType());
}
Also used : SingularityDeployRequest(com.hubspot.singularity.api.SingularityDeployRequest) SingularityPendingRequest(com.hubspot.singularity.SingularityPendingRequest) SingularityPendingTask(com.hubspot.singularity.SingularityPendingTask) SingularityDeploy(com.hubspot.singularity.SingularityDeploy) Test(org.junit.Test)

Aggregations

SingularityDeploy (com.hubspot.singularity.SingularityDeploy)52 Test (org.junit.Test)38 SingularityRequest (com.hubspot.singularity.SingularityRequest)30 SingularityDeployBuilder (com.hubspot.singularity.SingularityDeployBuilder)27 SingularityRequestBuilder (com.hubspot.singularity.SingularityRequestBuilder)22 SingularityTask (com.hubspot.singularity.SingularityTask)12 SingularityTaskRequest (com.hubspot.singularity.SingularityTaskRequest)11 SingularityDeployRequest (com.hubspot.singularity.api.SingularityDeployRequest)10 HealthcheckOptions (com.hubspot.deploy.HealthcheckOptions)9 HealthcheckOptionsBuilder (com.hubspot.deploy.HealthcheckOptionsBuilder)9 SingularityTaskId (com.hubspot.singularity.SingularityTaskId)8 SingularityMesosTaskHolder (com.hubspot.singularity.helpers.SingularityMesosTaskHolder)8 SingularityTaskHealthcheckResult (com.hubspot.singularity.SingularityTaskHealthcheckResult)7 Resources (com.hubspot.mesos.Resources)6 SingularityRunNowRequest (com.hubspot.singularity.api.SingularityRunNowRequest)6 SingularityDeployMarker (com.hubspot.singularity.SingularityDeployMarker)5 SingularityPendingTaskId (com.hubspot.singularity.SingularityPendingTaskId)5 SingularityRequestWithState (com.hubspot.singularity.SingularityRequestWithState)5 ArrayList (java.util.ArrayList)5 SingularityContainerInfo (com.hubspot.mesos.SingularityContainerInfo)4