Search in sources :

Example 11 with SingularityScaleRequest

use of com.hubspot.singularity.api.SingularityScaleRequest in project Singularity by HubSpot.

the class SingularitySchedulerTest method testScaleWithBounceDoesNotLaunchExtraInstances.

@Test
public void testScaleWithBounceDoesNotLaunchExtraInstances() {
    initRequest();
    initFirstDeploy();
    launchTask(request, firstDeploy, 1, TaskState.TASK_RUNNING);
    requestResource.scale(requestId, new SingularityScaleRequest(Optional.of(5), Optional.of(1L), Optional.absent(), Optional.absent(), Optional.absent(), Optional.of(true), Optional.absent(), Optional.absent()), singularityUser);
    Assert.assertEquals(1, requestManager.getCleanupRequests().size());
    cleaner.drainCleanupQueue();
    Assert.assertEquals(1, taskManager.getNumCleanupTasks());
    scheduler.drainPendingQueue();
    Assert.assertEquals(5, taskManager.getPendingTaskIds().size());
}
Also used : SingularityScaleRequest(com.hubspot.singularity.api.SingularityScaleRequest) Test(org.junit.Test)

Example 12 with SingularityScaleRequest

use of com.hubspot.singularity.api.SingularityScaleRequest in project Singularity by HubSpot.

the class SingularitySchedulerTest method testScaleDownTakesHighestInstances.

@Test
public void testScaleDownTakesHighestInstances() {
    initRequest();
    initFirstDeploy();
    saveAndSchedule(request.toBuilder().setInstances(Optional.of(5)));
    resourceOffers();
    Assert.assertEquals(5, taskManager.getActiveTaskIds().size());
    requestResource.scale(requestId, new SingularityScaleRequest(Optional.of(2), Optional.absent(), Optional.absent(), Optional.absent(), Optional.absent(), Optional.absent(), Optional.absent(), Optional.absent()), singularityUser);
    resourceOffers();
    cleaner.drainCleanupQueue();
    Assert.assertEquals(3, taskManager.getKilledTaskIdRecords().size());
    for (SingularityKilledTaskIdRecord taskId : taskManager.getKilledTaskIdRecords()) {
        Assert.assertTrue(taskId.getTaskId().getInstanceNo() > 2);
        scheduler.drainPendingQueue();
    }
}
Also used : SingularityKilledTaskIdRecord(com.hubspot.singularity.SingularityKilledTaskIdRecord) SingularityScaleRequest(com.hubspot.singularity.api.SingularityScaleRequest) Test(org.junit.Test)

Aggregations

SingularityScaleRequest (com.hubspot.singularity.api.SingularityScaleRequest)12 Test (org.junit.Test)11 SingularityTaskId (com.hubspot.singularity.SingularityTaskId)3 MesosTaskMonitorObject (com.hubspot.mesos.json.MesosTaskMonitorObject)2 SingularitySlaveUsage (com.hubspot.singularity.SingularitySlaveUsage)2 ResourceUsageType (com.hubspot.singularity.SingularitySlaveUsage.ResourceUsageType)2 SingularityTask (com.hubspot.singularity.SingularityTask)2 SingularityBounceRequest (com.hubspot.singularity.api.SingularityBounceRequest)2 HashMap (java.util.HashMap)2 Offer (org.apache.mesos.v1.Protos.Offer)2 SingularityKilledTaskIdRecord (com.hubspot.singularity.SingularityKilledTaskIdRecord)1 SingularityDeleteRequestRequest (com.hubspot.singularity.api.SingularityDeleteRequestRequest)1