Search in sources :

Example 1 with HealthCheck

use of io.vertigo.commons.analytics.health.HealthCheck in project vertigo by KleeGroup.

the class DaemonManagerTest method testSimple.

@Test
public void testSimple() throws Exception {
    DaemonStat daemonStat = daemonManager.getStats().stream().filter(stat -> FakeComponent.SIMPLE_DAEMON_NAME.equals(stat.getDaemonName())).findFirst().get();
    assertEquals(0, daemonStat.getCount());
    assertEquals(0, daemonStat.getFailures());
    assertEquals(0, daemonStat.getSuccesses());
    assertEquals(DaemonStat.Status.pending, daemonStat.getStatus());
    assertEquals(0, fakeComponent.getExecutionCount());
    // -----
    // soit deux execs
    Thread.sleep(5000);
    daemonStat = daemonManager.getStats().stream().filter(stat -> FakeComponent.SIMPLE_DAEMON_NAME.equals(stat.getDaemonName())).findFirst().get();
    assertEquals(2, daemonStat.getCount());
    assertEquals(1, daemonStat.getFailures());
    assertEquals(1, daemonStat.getSuccesses());
    assertEquals(DaemonStat.Status.pending, daemonStat.getStatus());
    assertTrue(fakeComponent.getExecutionCount() > 0);
    final HealthCheck daemonsExecHealthCheck = analyticsManager.getHealthChecks().stream().filter(healtChk -> "daemons".equals(healtChk.getFeature()) && "lastExecs".equals(healtChk.getName())).findFirst().get();
    assertTrue(daemonsExecHealthCheck.getMeasure().getStatus() == HealthStatus.GREEN);
}
Also used : Inject(javax.inject.Inject) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) HealthCheck(io.vertigo.commons.analytics.health.HealthCheck) AbstractTestCaseJU4(io.vertigo.AbstractTestCaseJU4) Test(org.junit.Test) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) AnalyticsManager(io.vertigo.commons.analytics.AnalyticsManager) HealthStatus(io.vertigo.commons.analytics.health.HealthStatus) HealthCheck(io.vertigo.commons.analytics.health.HealthCheck) Test(org.junit.Test)

Example 2 with HealthCheck

use of io.vertigo.commons.analytics.health.HealthCheck in project vertigo by KleeGroup.

the class HealthAnalyticsUtil method aggregate.

public static HealthStatus aggregate(final List<HealthCheck> healthChecks) {
    Assertion.checkNotNull(healthChecks);
    // ---
    int nbGreen = 0;
    int nbYellow = 0;
    int nbRed = 0;
    for (final HealthCheck healthCheck : healthChecks) {
        switch(healthCheck.getMeasure().getStatus()) {
            case GREEN:
                nbGreen++;
                break;
            case YELLOW:
                nbYellow++;
                break;
            case RED:
                nbRed++;
                break;
            default:
                break;
        }
    }
    return generateStatus(nbGreen, nbYellow, nbRed);
}
Also used : HealthCheck(io.vertigo.commons.analytics.health.HealthCheck)

Aggregations

HealthCheck (io.vertigo.commons.analytics.health.HealthCheck)2 AbstractTestCaseJU4 (io.vertigo.AbstractTestCaseJU4)1 AnalyticsManager (io.vertigo.commons.analytics.AnalyticsManager)1 HealthStatus (io.vertigo.commons.analytics.health.HealthStatus)1 Inject (javax.inject.Inject)1 Test (org.junit.Test)1 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)1 Assertions.assertTrue (org.junit.jupiter.api.Assertions.assertTrue)1