use of com.hubspot.singularity.SingularityDeployBuilder in project Singularity by HubSpot.
the class SingularityDeploysTest method testDeploySucceedsWithTaskRetries.
@Test
public void testDeploySucceedsWithTaskRetries() {
initRequest();
SingularityDeployBuilder db = new SingularityDeployBuilder(requestId, firstDeployId);
db.setMaxTaskRetries(Optional.of(1));
SingularityDeploy deploy = initDeploy(db, System.currentTimeMillis());
deployChecker.checkDeploys();
Assert.assertTrue(!deployManager.getDeployResult(requestId, firstDeployId).isPresent());
SingularityTask task = launchTask(request, deploy, System.currentTimeMillis(), 1, TaskState.TASK_FAILED);
deployChecker.checkDeploys();
Assert.assertEquals(deployManager.getPendingDeploys().get(0).getCurrentDeployState(), DeployState.WAITING);
SingularityTask taskTryTwo = launchTask(request, deploy, System.currentTimeMillis(), 1, TaskState.TASK_RUNNING);
deployChecker.checkDeploys();
Assert.assertEquals(deployManager.getDeployResult(requestId, firstDeployId).get().getDeployState(), DeployState.SUCCEEDED);
}
use of com.hubspot.singularity.SingularityDeployBuilder in project Singularity by HubSpot.
the class SingularityDeploysTest method testDeployWithImmediateRunIsLaunchedImmediately.
@Test
public void testDeployWithImmediateRunIsLaunchedImmediately() {
initRequestWithType(RequestType.SCHEDULED, false);
String deployId = "d1";
SingularityRunNowRequest runNowRequest = new SingularityRunNowRequestBuilder().setMessage("Message").build();
SingularityDeploy deploy = new SingularityDeployBuilder(requestId, deployId).setRunImmediately(Optional.of(runNowRequest)).setCommand(Optional.of("printenv > tmp.txt")).build();
SingularityDeployRequest deployRequest = new SingularityDeployRequest(deploy, Optional.absent(), Optional.absent());
deployResource.deploy(deployRequest, singularityUser);
deployChecker.checkDeploys();
scheduler.drainPendingQueue();
resourceOffers();
Assert.assertEquals(1, taskManager.getNumActiveTasks());
Assert.assertEquals(0, taskManager.getNumScheduledTasks());
SingularityTaskId taskId = taskManager.getActiveTaskIdsForDeploy(requestId, deployId).get(0);
SingularityTask task = taskManager.getTask(taskId).get();
Map<String, Object> command = (Map<String, Object>) task.getMesosTask().getAllOtherFields().get("command");
Assert.assertEquals("printenv > tmp.txt", (String) command.get("value"));
}
use of com.hubspot.singularity.SingularityDeployBuilder 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());
}
use of com.hubspot.singularity.SingularityDeployBuilder 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());
}
use of com.hubspot.singularity.SingularityDeployBuilder 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());
}
Aggregations