Search in sources :

Example 11 with CrashLoopInfo

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

the class SingularityCrashLoopTest method itDetectsTooManyOoms.

@Test
public void itDetectsTooManyOoms() {
    initRequestWithType(RequestType.WORKER, false);
    initFirstDeploy();
    long now = System.currentTimeMillis();
    createTaskFailure(1, now - TimeUnit.MINUTES.toMillis(1), TaskFailureType.OOM);
    createTaskFailure(1, now - TimeUnit.MINUTES.toMillis(11), TaskFailureType.OOM);
    createTaskFailure(1, now - TimeUnit.MINUTES.toMillis(16), TaskFailureType.OOM);
    createTaskFailure(1, now - TimeUnit.MINUTES.toMillis(20), TaskFailureType.OOM);
    SingularityDeployStatistics deployStatistics = deployManager.getDeployStatistics(requestId, firstDeployId).get();
    List<CrashLoopInfo> active = crashLoops.getActiveCrashLoops(deployStatistics);
    Assertions.assertTrue(active.size() > 1);
    Assertions.assertTrue(active.stream().map(CrashLoopInfo::getType).anyMatch(l -> l == CrashLoopType.OOM));
}
Also used : TaskStatus(org.apache.mesos.v1.Protos.TaskStatus) CrashLoopType(com.hubspot.singularity.CrashLoopType) SingularityTask(com.hubspot.singularity.SingularityTask) Iterables(com.google.common.collect.Iterables) SingularityTaskCleanup(com.hubspot.singularity.SingularityTaskCleanup) Reason(org.apache.mesos.v1.Protos.TaskStatus.Reason) TaskState(org.apache.mesos.v1.Protos.TaskState) TaskFailureType(com.hubspot.singularity.TaskFailureType) Inject(com.google.inject.Inject) SingularityDeployStatistics(com.hubspot.singularity.SingularityDeployStatistics) TimeUnit(java.util.concurrent.TimeUnit) Test(org.junit.jupiter.api.Test) List(java.util.List) TaskCleanupType(com.hubspot.singularity.TaskCleanupType) CrashLoopInfo(com.hubspot.singularity.CrashLoopInfo) MesosProtosUtils(com.hubspot.singularity.helpers.MesosProtosUtils) Assertions(org.junit.jupiter.api.Assertions) Optional(java.util.Optional) RequestType(com.hubspot.singularity.RequestType) CrashLoopInfo(com.hubspot.singularity.CrashLoopInfo) SingularityDeployStatistics(com.hubspot.singularity.SingularityDeployStatistics) Test(org.junit.jupiter.api.Test)

Example 12 with CrashLoopInfo

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

the class SingularityCrashLoopTest method itSavesSubsequentLoopsOfSameType.

@Test
public void itSavesSubsequentLoopsOfSameType() {
    requestManager.saveCrashLoop(new CrashLoopInfo(requestId, firstDeployId, System.currentTimeMillis() - 60000, Optional.of(System.currentTimeMillis() - 30000), CrashLoopType.FAST_FAILURE_LOOP));
    itDetectsFastFailureLoopsForNonLongRunning();
}
Also used : CrashLoopInfo(com.hubspot.singularity.CrashLoopInfo) Test(org.junit.jupiter.api.Test)

Example 13 with CrashLoopInfo

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

the class SingularityCrashLoopTest method itDoesNotTriggerSlowFailureLoopForFailuresConfinedToASmallTimeRange.

@Test
public void itDoesNotTriggerSlowFailureLoopForFailuresConfinedToASmallTimeRange() {
    initRequestWithType(RequestType.WORKER, false);
    initFirstDeploy();
    long now = System.currentTimeMillis();
    // Five minutes ago, should have already cleared
    createTaskFailure(1, now - 1000 - 300000, TaskFailureType.BAD_EXIT_CODE);
    createTaskFailure(1, now - 10000 - 300000, TaskFailureType.BAD_EXIT_CODE);
    createTaskFailure(1, now - 20000 - 300000, TaskFailureType.BAD_EXIT_CODE);
    createTaskFailure(1, now - 30000 - 300000, TaskFailureType.BAD_EXIT_CODE);
    createTaskFailure(1, now - 45000 - 300000, TaskFailureType.BAD_EXIT_CODE);
    SingularityDeployStatistics deployStatistics = deployManager.getDeployStatistics(requestId, firstDeployId).get();
    List<CrashLoopInfo> active = crashLoops.getActiveCrashLoops(deployStatistics);
    Assertions.assertEquals(0, active.size());
}
Also used : CrashLoopInfo(com.hubspot.singularity.CrashLoopInfo) SingularityDeployStatistics(com.hubspot.singularity.SingularityDeployStatistics) Test(org.junit.jupiter.api.Test)

Example 14 with CrashLoopInfo

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

the class SingularityCrashLoopTest method itDetectsASingleInstanceFailureLoop.

@Test
public void itDetectsASingleInstanceFailureLoop() {
    initRequestWithType(RequestType.WORKER, false);
    initFirstDeploy();
    long now = System.currentTimeMillis();
    createTaskFailure(1, now - TimeUnit.MINUTES.toMillis(1), TaskFailureType.BAD_EXIT_CODE);
    createTaskFailure(1, now - TimeUnit.MINUTES.toMillis(6), TaskFailureType.OOM);
    createTaskFailure(1, now - TimeUnit.MINUTES.toMillis(11), TaskFailureType.OUT_OF_DISK_SPACE);
    createTaskFailure(1, now - TimeUnit.MINUTES.toMillis(16), TaskFailureType.OUT_OF_DISK_SPACE);
    createTaskFailure(1, now - TimeUnit.MINUTES.toMillis(21), TaskFailureType.OOM);
    SingularityDeployStatistics deployStatistics = deployManager.getDeployStatistics(requestId, firstDeployId).get();
    List<CrashLoopInfo> active = crashLoops.getActiveCrashLoops(deployStatistics);
    Assertions.assertEquals(1, active.size());
    Assertions.assertEquals(CrashLoopType.SINGLE_INSTANCE_FAILURE_LOOP, Iterables.getOnlyElement(active).getType());
}
Also used : CrashLoopInfo(com.hubspot.singularity.CrashLoopInfo) SingularityDeployStatistics(com.hubspot.singularity.SingularityDeployStatistics) Test(org.junit.jupiter.api.Test)

Aggregations

CrashLoopInfo (com.hubspot.singularity.CrashLoopInfo)14 SingularityDeployStatistics (com.hubspot.singularity.SingularityDeployStatistics)10 Test (org.junit.jupiter.api.Test)9 Inject (com.google.inject.Inject)3 SingularityTask (com.hubspot.singularity.SingularityTask)3 SingularityTaskCleanup (com.hubspot.singularity.SingularityTaskCleanup)3 List (java.util.List)3 Optional (java.util.Optional)3 CrashLoopType (com.hubspot.singularity.CrashLoopType)2 SingularityRequestWithState (com.hubspot.singularity.SingularityRequestWithState)2 TaskFailureType (com.hubspot.singularity.TaskFailureType)2 SingularityConfiguration (com.hubspot.singularity.config.SingularityConfiguration)2 DeployManager (com.hubspot.singularity.data.DeployManager)2 RequestManager (com.hubspot.singularity.data.RequestManager)2 Comparator (java.util.Comparator)2 Map (java.util.Map)2 Collectors (java.util.stream.Collectors)2 Singleton (javax.inject.Singleton)2 Logger (org.slf4j.Logger)2 LoggerFactory (org.slf4j.LoggerFactory)2