@@ -0,0 +1,2163 @@
+package com.hubspot.singularity.data;%0A%0Aimport org.apache.mesos.Protos.TaskState;%0Aimport org.junit.Assert;%0Aimport org.junit.Test;%0A%0Aimport com.google.common.base.Optional;%0Aimport com.google.inject.Inject;%0Aimport com.hubspot.singularity.SingularityRequest;%0Aimport com.hubspot.singularity.SingularityTask;%0Aimport com.hubspot.singularity.SingularityTaskCleanup;%0Aimport com.hubspot.singularity.TaskCleanupType;%0Aimport com.hubspot.singularity.scheduler.SingularitySchedulerTestBase;%0A%0Apublic class StateManagerTest extends SingularitySchedulerTestBase%7B%0A%0A  protected SingularityRequest request;%0A%0A  @Inject%0A  private StateManager stateManager;%0A%0A  public StateManagerTest() %7B%0A    super(false);%0A  %7D%0A%0A  @Test%0A  public void itDoesntCountCleaningTasks() %7B%0A    initRequest();%0A    initFirstDeploy();%0A%0A    SingularityRequest request = requestResource.getRequest(requestId).getRequest();%0A    saveAndSchedule(request.toBuilder().setInstances(Optional.of(3)));%0A    resourceOffers();%0A%0A    Assert.assertEquals(3, taskManager.getActiveTaskIds().size());%0A    Assert.assertEquals(0, stateManager.getState(true, false).getOverProvisionedRequests());%0A    Assert.assertEquals(0, stateManager.getState(true, false).getUnderProvisionedRequests());%0A%0A%0A    SingularityTask task = taskManager.getActiveTasks().get(0);%0A    statusUpdate(task, TaskState.TASK_KILLED);%0A    taskManager.createTaskCleanup(new SingularityTaskCleanup(Optional.absent(), TaskCleanupType.BOUNCING, 1L, task.getTaskId(), Optional.absent(), Optional.absent(), Optional.absent()));%0A    Assert.assertEquals(2, taskManager.getActiveTaskIds().size());%0A    Assert.assertEquals(0, stateManager.getState(true, false).getOverProvisionedRequests());%0A    Assert.assertEquals(1, stateManager.getState(true, false).getUnderProvisionedRequests());%0A%0A%0A    launchTask(request, firstDeploy, 4, TaskState.TASK_RUNNING);%0A    launchTask(request, firstDeploy, 5, TaskState.TASK_RUNNING);%0A    Assert.assertEquals(4, taskManager.getActiveTaskIds().size());%0A    Assert.assertEquals(0, stateManager.getState(true, false).getUnderProvisionedRequests());%0A    Assert.assertEquals(1, stateManager.getState(true, false).getOverProvisionedRequests());%0A  %7D%0A%7D%0A

test under and over provisioned