Search in sources :

Example 16 with SingularityTaskHealthcheckResult

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

the class SingularityHealthchecksTest method testMaxHealthcheckRetries.

@Test
public void testMaxHealthcheckRetries() {
    initRequest();
    final String deployId = "retry_test";
    HealthcheckOptions options = new HealthcheckOptionsBuilder("http://uri").setMaxRetries(Optional.of(2)).build();
    SingularityDeployBuilder db = new SingularityDeployBuilder(requestId, deployId).setHealthcheck(Optional.of(options));
    SingularityDeploy deploy = initDeploy(db, System.currentTimeMillis());
    deployChecker.checkDeploys();
    Assert.assertTrue(!deployManager.getDeployResult(requestId, deployId).isPresent());
    SingularityTask task = launchTask(request, deploy, System.currentTimeMillis(), 1, TaskState.TASK_RUNNING);
    deployChecker.checkDeploys();
    Assert.assertTrue(!deployManager.getDeployResult(requestId, deployId).isPresent());
    taskManager.saveHealthcheckResult(new SingularityTaskHealthcheckResult(Optional.of(503), Optional.of(1000L), System.currentTimeMillis(), Optional.<String>absent(), Optional.<String>absent(), task.getTaskId(), Optional.<Boolean>absent()));
    taskManager.saveHealthcheckResult(new SingularityTaskHealthcheckResult(Optional.of(503), Optional.of(1000L), System.currentTimeMillis() + 1, Optional.<String>absent(), Optional.<String>absent(), task.getTaskId(), Optional.<Boolean>absent()));
    deployChecker.checkDeploys();
    Assert.assertTrue(!deployManager.getDeployResult(requestId, deployId).isPresent());
    taskManager.saveHealthcheckResult(new SingularityTaskHealthcheckResult(Optional.of(503), Optional.of(1000L), System.currentTimeMillis() + 1, Optional.<String>absent(), Optional.<String>absent(), task.getTaskId(), Optional.<Boolean>absent()));
    deployChecker.checkDeploys();
    Assert.assertEquals(DeployState.FAILED, deployManager.getDeployResult(requestId, deployId).get().getDeployState());
}
Also used : SingularityTaskHealthcheckResult(com.hubspot.singularity.SingularityTaskHealthcheckResult) SingularityTask(com.hubspot.singularity.SingularityTask) HealthcheckOptions(com.hubspot.deploy.HealthcheckOptions) SingularityDeployBuilder(com.hubspot.singularity.SingularityDeployBuilder) HealthcheckOptionsBuilder(com.hubspot.deploy.HealthcheckOptionsBuilder) SingularityDeploy(com.hubspot.singularity.SingularityDeploy) Test(org.junit.Test)

Example 17 with SingularityTaskHealthcheckResult

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

the class SingularityHealthchecksTest method testHealthchecksSuccess.

@Test
public void testHealthchecksSuccess() {
    initRequest();
    final String deployId = "hc_test";
    HealthcheckOptions options = new HealthcheckOptionsBuilder("http://uri").setMaxRetries(Optional.of(2)).build();
    SingularityDeployBuilder db = new SingularityDeployBuilder(requestId, deployId).setHealthcheck(Optional.of(options));
    SingularityDeploy deploy = initDeploy(db, System.currentTimeMillis());
    deployChecker.checkDeploys();
    Assert.assertTrue(!deployManager.getDeployResult(requestId, deployId).isPresent());
    SingularityTask task = launchTask(request, deploy, System.currentTimeMillis(), 1, TaskState.TASK_RUNNING);
    deployChecker.checkDeploys();
    Assert.assertTrue(!deployManager.getDeployResult(requestId, deployId).isPresent());
    taskManager.saveHealthcheckResult(new SingularityTaskHealthcheckResult(Optional.of(503), Optional.of(1000L), System.currentTimeMillis(), Optional.<String>absent(), Optional.<String>absent(), task.getTaskId(), Optional.<Boolean>absent()));
    deployChecker.checkDeploys();
    Assert.assertTrue(!deployManager.getDeployResult(requestId, deployId).isPresent());
    taskManager.saveHealthcheckResult(new SingularityTaskHealthcheckResult(Optional.of(200), Optional.of(1000L), System.currentTimeMillis() + 1, Optional.<String>absent(), Optional.<String>absent(), task.getTaskId(), Optional.<Boolean>absent()));
    deployChecker.checkDeploys();
    Assert.assertEquals(DeployState.SUCCEEDED, deployManager.getDeployResult(requestId, deployId).get().getDeployState());
}
Also used : SingularityTaskHealthcheckResult(com.hubspot.singularity.SingularityTaskHealthcheckResult) SingularityTask(com.hubspot.singularity.SingularityTask) HealthcheckOptions(com.hubspot.deploy.HealthcheckOptions) SingularityDeployBuilder(com.hubspot.singularity.SingularityDeployBuilder) HealthcheckOptionsBuilder(com.hubspot.deploy.HealthcheckOptionsBuilder) SingularityDeploy(com.hubspot.singularity.SingularityDeploy) Test(org.junit.Test)

Example 18 with SingularityTaskHealthcheckResult

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

the class SingularityHealthchecksTest method testStartupDoesNotCountTowardsRetries.

@Test
public void testStartupDoesNotCountTowardsRetries() {
    initRequest();
    final String deployId = "retry_test";
    HealthcheckOptions options = new HealthcheckOptionsBuilder("http://uri").setMaxRetries(Optional.of(1)).build();
    SingularityDeployBuilder db = new SingularityDeployBuilder(requestId, deployId).setHealthcheck(Optional.of(options));
    SingularityDeploy deploy = initDeploy(db, System.currentTimeMillis());
    deployChecker.checkDeploys();
    Assert.assertTrue(!deployManager.getDeployResult(requestId, deployId).isPresent());
    SingularityTask task = launchTask(request, deploy, System.currentTimeMillis(), 1, TaskState.TASK_RUNNING);
    deployChecker.checkDeploys();
    Assert.assertTrue(!deployManager.getDeployResult(requestId, deployId).isPresent());
    taskManager.saveHealthcheckResult(new SingularityTaskHealthcheckResult(Optional.<Integer>absent(), Optional.of(1000L), System.currentTimeMillis(), Optional.<String>absent(), Optional.of("ConnectionRefused"), task.getTaskId(), Optional.of(true)));
    taskManager.saveHealthcheckResult(new SingularityTaskHealthcheckResult(Optional.<Integer>absent(), Optional.of(1000L), System.currentTimeMillis() + 1, Optional.<String>absent(), Optional.of("ConnectionRefused"), task.getTaskId(), Optional.of(true)));
    deployChecker.checkDeploys();
    Assert.assertTrue(!deployManager.getDeployResult(requestId, deployId).isPresent());
    taskManager.saveHealthcheckResult(new SingularityTaskHealthcheckResult(Optional.of(503), Optional.of(1000L), System.currentTimeMillis() + 1, Optional.<String>absent(), Optional.<String>absent(), task.getTaskId(), Optional.<Boolean>absent()));
    deployChecker.checkDeploys();
    Assert.assertTrue(!deployManager.getDeployResult(requestId, deployId).isPresent());
    taskManager.saveHealthcheckResult(new SingularityTaskHealthcheckResult(Optional.of(200), Optional.of(1000L), System.currentTimeMillis() + 1, Optional.<String>absent(), Optional.<String>absent(), task.getTaskId(), Optional.<Boolean>absent()));
    deployChecker.checkDeploys();
    Assert.assertEquals(DeployState.SUCCEEDED, deployManager.getDeployResult(requestId, deployId).get().getDeployState());
}
Also used : SingularityTaskHealthcheckResult(com.hubspot.singularity.SingularityTaskHealthcheckResult) SingularityTask(com.hubspot.singularity.SingularityTask) HealthcheckOptions(com.hubspot.deploy.HealthcheckOptions) SingularityDeployBuilder(com.hubspot.singularity.SingularityDeployBuilder) HealthcheckOptionsBuilder(com.hubspot.deploy.HealthcheckOptionsBuilder) SingularityDeploy(com.hubspot.singularity.SingularityDeploy) Test(org.junit.Test)

Aggregations

SingularityTaskHealthcheckResult (com.hubspot.singularity.SingularityTaskHealthcheckResult)18 SingularityTask (com.hubspot.singularity.SingularityTask)11 Test (org.junit.Test)10 SingularityDeployBuilder (com.hubspot.singularity.SingularityDeployBuilder)8 HealthcheckOptions (com.hubspot.deploy.HealthcheckOptions)7 HealthcheckOptionsBuilder (com.hubspot.deploy.HealthcheckOptionsBuilder)7 SingularityDeploy (com.hubspot.singularity.SingularityDeploy)7 SingularityTaskId (com.hubspot.singularity.SingularityTaskId)5 SingularityRequestHistory (com.hubspot.singularity.SingularityRequestHistory)3 SingularityDeployFailure (com.hubspot.singularity.SingularityDeployFailure)2 SingularityLoadBalancerUpdate (com.hubspot.singularity.SingularityLoadBalancerUpdate)2 SingularityRequest (com.hubspot.singularity.SingularityRequest)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 LoadBalancerRequestId (com.hubspot.singularity.LoadBalancerRequestType.LoadBalancerRequestId)1 SingularityDeployMarker (com.hubspot.singularity.SingularityDeployMarker)1 SingularityRequestCleanup (com.hubspot.singularity.SingularityRequestCleanup)1 SingularityShellCommand (com.hubspot.singularity.SingularityShellCommand)1 SingularityTaskHistory (com.hubspot.singularity.SingularityTaskHistory)1 SingularityTaskHistoryUpdate (com.hubspot.singularity.SingularityTaskHistoryUpdate)1 SimplifiedTaskState (com.hubspot.singularity.SingularityTaskHistoryUpdate.SimplifiedTaskState)1