Search in sources :

Example 21 with SingularityRequest

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

the class SingularityDeploysTest method testDeployFailsForInvalidRequestState.

@Test
public void testDeployFailsForInvalidRequestState() {
    initRequest();
    SingularityRequest request = requestResource.getRequest(requestId, singularityUser).getRequest();
    initFirstDeploy();
    deploy(secondDeployId, Optional.<Boolean>absent(), Optional.of(1), Optional.of(false), false);
    requestManager.pause(request, System.currentTimeMillis(), Optional.<String>absent(), Optional.<String>absent());
    deployChecker.checkDeploys();
    Assert.assertEquals(DeployState.FAILED, deployManager.getDeployResult(requestId, secondDeployId).get().getDeployState());
}
Also used : SingularityRequest(com.hubspot.singularity.SingularityRequest) Test(org.junit.Test)

Example 22 with SingularityRequest

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

the class SingularityDeploysTest method testCancelDeploy.

@Test
public void testCancelDeploy() {
    initRequest();
    SingularityRequest request = requestResource.getRequest(requestId, singularityUser).getRequest();
    initFirstDeploy();
    SingularityTask firstTask = launchTask(request, firstDeploy, 1, TaskState.TASK_RUNNING);
    deploy(secondDeployId, Optional.<Boolean>absent(), Optional.of(1), Optional.of(false), false);
    deployChecker.checkDeploys();
    scheduler.drainPendingQueue();
    Assert.assertEquals(1, taskManager.getPendingTaskIds().size());
    resourceOffers();
    Assert.assertEquals(1, taskManager.getActiveTaskIdsForDeploy(requestId, secondDeployId).size());
    SingularityTaskId firstNewTaskId = taskManager.getActiveTaskIdsForDeploy(requestId, secondDeployId).get(0);
    statusUpdate(taskManager.getTask(firstNewTaskId).get(), TaskState.TASK_RUNNING);
    deployResource.cancelDeploy(singularityUser, requestId, secondDeployId);
    deployChecker.checkDeploys();
    Assert.assertTrue(taskManager.getCleanupTaskIds().contains(firstNewTaskId));
    Assert.assertFalse(taskManager.getCleanupTaskIds().contains(firstTask.getTaskId()));
    Assert.assertEquals(DeployState.CANCELED, deployManager.getDeployResult(requestId, secondDeployId).get().getDeployState());
}
Also used : SingularityTask(com.hubspot.singularity.SingularityTask) SingularityRequest(com.hubspot.singularity.SingularityRequest) SingularityTaskId(com.hubspot.singularity.SingularityTaskId) Test(org.junit.Test)

Example 23 with SingularityRequest

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

the class SingularityDeploysTest method testDeployAllInstancesAtOnce.

@Test
public void testDeployAllInstancesAtOnce() {
    initRequest();
    SingularityRequest request = requestResource.getRequest(requestId, singularityUser).getRequest();
    requestResource.postRequest(request.toBuilder().setInstances(Optional.of(2)).build(), singularityUser);
    initFirstDeploy();
    launchTask(request, firstDeploy, 1, TaskState.TASK_RUNNING);
    launchTask(request, firstDeploy, 2, TaskState.TASK_RUNNING);
    deploy(secondDeployId);
    deployChecker.checkDeploys();
    scheduler.drainPendingQueue();
    Assert.assertEquals(2, taskManager.getActiveTaskIds().size());
    Assert.assertEquals(2, taskManager.getPendingTaskIds().size());
    resourceOffers();
    Assert.assertEquals(2, taskManager.getActiveTaskIdsForDeploy(requestId, secondDeployId).size());
    for (SingularityTaskId taskId : taskManager.getActiveTaskIdsForDeploy(requestId, secondDeployId)) {
        statusUpdate(taskManager.getTask(taskId).get(), TaskState.TASK_RUNNING);
    }
    deployChecker.checkDeploys();
    Assert.assertEquals(2, taskManager.getCleanupTaskIds().size());
    Assert.assertEquals(DeployState.SUCCEEDED, deployManager.getDeployResult(requestId, secondDeployId).get().getDeployState());
    Assert.assertEquals(2, taskManager.getActiveTaskIdsForDeploy(requestId, secondDeployId).size());
}
Also used : SingularityRequest(com.hubspot.singularity.SingularityRequest) SingularityTaskId(com.hubspot.singularity.SingularityTaskId) Test(org.junit.Test)

Example 24 with SingularityRequest

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

the class SingularityDeploysTest method testScaleDownDuringDeploy.

@Test
public void testScaleDownDuringDeploy() {
    initRequest();
    SingularityRequest request = requestResource.getRequest(requestId, singularityUser).getRequest();
    requestResource.postRequest(request.toBuilder().setInstances(Optional.of(2)).build(), singularityUser);
    initFirstDeploy();
    launchTask(request, firstDeploy, 1, TaskState.TASK_RUNNING);
    launchTask(request, firstDeploy, 2, TaskState.TASK_RUNNING);
    deploy(secondDeployId);
    deployChecker.checkDeploys();
    scheduler.drainPendingQueue();
    resourceOffers();
    Assert.assertEquals(2, taskManager.getActiveTaskIdsForDeploy(requestId, secondDeployId).size());
    for (SingularityTaskId taskId : taskManager.getActiveTaskIdsForDeploy(requestId, secondDeployId)) {
        statusUpdate(taskManager.getTask(taskId).get(), TaskState.TASK_RUNNING);
    }
    requestResource.postRequest(request.toBuilder().setInstances(Optional.of(1)).build(), singularityUser);
    scheduler.drainPendingQueue();
    Assert.assertEquals(1, taskManager.getCleanupTaskIds().size());
    deployChecker.checkDeploys();
    Assert.assertEquals(2, taskManager.getCleanupTaskIds().size());
    // Extra task from the new deploy should get cleaned up as well
    scheduler.drainPendingQueue();
    Assert.assertEquals(3, taskManager.getCleanupTaskIds().size());
}
Also used : SingularityRequest(com.hubspot.singularity.SingularityRequest) SingularityTaskId(com.hubspot.singularity.SingularityTaskId) Test(org.junit.Test)

Example 25 with SingularityRequest

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

the class SingularityDeploysTest method testDeployFails.

@Test
public void testDeployFails() {
    initRequest();
    SingularityRequest request = requestResource.getRequest(requestId, singularityUser).getRequest();
    initFirstDeploy();
    SingularityTask firstTask = launchTask(request, firstDeploy, 1, TaskState.TASK_RUNNING);
    deploy(secondDeployId, Optional.<Boolean>absent(), Optional.of(1), Optional.of(false), false);
    deployChecker.checkDeploys();
    scheduler.drainPendingQueue();
    Assert.assertEquals(1, taskManager.getPendingTaskIds().size());
    resourceOffers();
    Assert.assertEquals(1, taskManager.getActiveTaskIdsForDeploy(requestId, secondDeployId).size());
    SingularityTaskId firstNewTaskId = taskManager.getActiveTaskIdsForDeploy(requestId, secondDeployId).get(0);
    statusUpdate(taskManager.getTask(firstNewTaskId).get(), TaskState.TASK_FAILED);
    deployChecker.checkDeploys();
    Assert.assertFalse(taskManager.getCleanupTaskIds().contains(firstTask.getTaskId()));
    Assert.assertEquals(DeployState.FAILED, deployManager.getDeployResult(requestId, secondDeployId).get().getDeployState());
}
Also used : SingularityTask(com.hubspot.singularity.SingularityTask) SingularityRequest(com.hubspot.singularity.SingularityRequest) SingularityTaskId(com.hubspot.singularity.SingularityTaskId) Test(org.junit.Test)

Aggregations

SingularityRequest (com.hubspot.singularity.SingularityRequest)83 Test (org.junit.Test)57 SingularityRequestBuilder (com.hubspot.singularity.SingularityRequestBuilder)37 SingularityDeploy (com.hubspot.singularity.SingularityDeploy)29 SingularityTaskId (com.hubspot.singularity.SingularityTaskId)25 SingularityDeployBuilder (com.hubspot.singularity.SingularityDeployBuilder)16 SingularityTask (com.hubspot.singularity.SingularityTask)15 SingularityPendingTaskId (com.hubspot.singularity.SingularityPendingTaskId)14 SingularityRequestWithState (com.hubspot.singularity.SingularityRequestWithState)14 SingularityTaskRequest (com.hubspot.singularity.SingularityTaskRequest)11 SingularityRunNowRequest (com.hubspot.singularity.api.SingularityRunNowRequest)10 SingularityDeployProgress (com.hubspot.singularity.SingularityDeployProgress)8 SingularityPendingRequest (com.hubspot.singularity.SingularityPendingRequest)8 SingularityMesosTaskHolder (com.hubspot.singularity.helpers.SingularityMesosTaskHolder)8 SingularityPendingDeploy (com.hubspot.singularity.SingularityPendingDeploy)7 SingularityDeployRequest (com.hubspot.singularity.api.SingularityDeployRequest)6 ArrayList (java.util.ArrayList)6 Resources (com.hubspot.mesos.Resources)5 SingularityRequestDeployState (com.hubspot.singularity.SingularityRequestDeployState)5 SingularityContainerInfo (com.hubspot.mesos.SingularityContainerInfo)4