Search in sources :

Example 26 with SingularityDeployStatistics

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

the class SingularitySchedulerTest method testRunNowOnDemandJobDoesNotRetryAfterUserInitiatedKill.

@Test
public void testRunNowOnDemandJobDoesNotRetryAfterUserInitiatedKill() {
    initRequestWithType(RequestType.ON_DEMAND, false);
    SingularityRequest request = requestResource.getRequest(requestId, singularityUser).getRequest();
    SingularityRequest newRequest = request.toBuilder().setNumRetriesOnFailure(Optional.of(2)).build();
    requestResource.postRequest(newRequest, singularityUser);
    initFirstDeploy();
    requestResource.scheduleImmediately(singularityUser, requestId, new SingularityRunNowRequestBuilder().setMessage("foo bar").build());
    scheduler.drainPendingQueue();
    resourceOffers();
    SingularityTask task = taskManager.getActiveTasks().get(0);
    taskManager.saveTaskHistoryUpdate(new SingularityTaskHistoryUpdate(task.getTaskId(), System.currentTimeMillis(), ExtendedTaskState.TASK_CLEANING, Optional.of("USER_REQUESTED"), Optional.empty(), Collections.emptySet()));
    statusUpdate(task, TaskState.TASK_KILLED);
    scheduler.drainPendingQueue();
    SingularityDeployStatistics deployStatistics = deployManager.getDeployStatistics(task.getTaskId().getRequestId(), task.getTaskId().getDeployId()).get();
    Assertions.assertEquals(MesosTaskState.TASK_KILLED, deployStatistics.getLastTaskState().get().toTaskState().get());
    Assertions.assertEquals(0, taskManager.getPendingTaskIds().size());
    Assertions.assertEquals(0, deployStatistics.getNumFailures());
    Assertions.assertEquals(0, deployStatistics.getNumSequentialRetries());
}
Also used : SingularityRunNowRequestBuilder(com.hubspot.singularity.SingularityRunNowRequestBuilder) SingularityTask(com.hubspot.singularity.SingularityTask) SingularityTaskHistoryUpdate(com.hubspot.singularity.SingularityTaskHistoryUpdate) SingularityRequest(com.hubspot.singularity.SingularityRequest) SingularityDeployStatistics(com.hubspot.singularity.SingularityDeployStatistics) Test(org.junit.jupiter.api.Test)

Aggregations

SingularityDeployStatistics (com.hubspot.singularity.SingularityDeployStatistics)26 Test (org.junit.jupiter.api.Test)14 CrashLoopInfo (com.hubspot.singularity.CrashLoopInfo)10 SingularityTask (com.hubspot.singularity.SingularityTask)9 SingularityRequest (com.hubspot.singularity.SingularityRequest)7 SingularityRunNowRequestBuilder (com.hubspot.singularity.SingularityRunNowRequestBuilder)5 Inject (com.google.inject.Inject)4 SingularityDeployKey (com.hubspot.singularity.SingularityDeployKey)4 SingularityRequestDeployState (com.hubspot.singularity.SingularityRequestDeployState)4 SingularityTaskId (com.hubspot.singularity.SingularityTaskId)4 List (java.util.List)4 Optional (java.util.Optional)4 SingularityRequestWithState (com.hubspot.singularity.SingularityRequestWithState)3 SingularityTaskCleanup (com.hubspot.singularity.SingularityTaskCleanup)3 SingularityTaskHistoryUpdate (com.hubspot.singularity.SingularityTaskHistoryUpdate)3 SingularityConfiguration (com.hubspot.singularity.config.SingularityConfiguration)3 DeployManager (com.hubspot.singularity.data.DeployManager)3 ArrayList (java.util.ArrayList)3 Map (java.util.Map)3 TimeUnit (java.util.concurrent.TimeUnit)3