use of com.palantir.atlasdb.transaction.impl.InstrumentedTimelockService in project atlasdb by palantir.
the class MetricsBasedTimelockHealthCheckTest method getFreshInstrumentedTimelockService.
private static TimelockService getFreshInstrumentedTimelockService() {
// Remove previously set metrics
AtlasDbMetrics.getMetricRegistry().remove(AtlasDbMetricNames.TIMELOCK_FAILED_REQUEST);
AtlasDbMetrics.getMetricRegistry().remove(AtlasDbMetricNames.TIMELOCK_SUCCESSFUL_REQUEST);
timelockService = mock(TimelockService.class);
TimelockService instrumentedTimelockService = new InstrumentedTimelockService(timelockService, AtlasDbMetrics.getMetricRegistry());
return instrumentedTimelockService;
}
use of com.palantir.atlasdb.transaction.impl.InstrumentedTimelockService in project atlasdb by palantir.
the class MetricsBasedTimelockHealthCheckTest method timlockIsUnhealthyAfterOneSuccessMultipleFailures.
@Test
public void timlockIsUnhealthyAfterOneSuccessMultipleFailures() {
TimelockService instrumentedTimelockService = getFreshInstrumentedTimelockService();
when(timelockService.getFreshTimestamp()).thenReturn(0L).thenThrow(new RuntimeException());
tryGetFreshTimestamp(instrumentedTimelockService, 10);
waitForClockTick();
assertThat(timelockHealthCheck.getStatus().isHealthy()).isFalse();
}
use of com.palantir.atlasdb.transaction.impl.InstrumentedTimelockService in project atlasdb by palantir.
the class MetricsBasedTimelockHealthCheckTest method timelockIsHealthyAfterSuccessfulRequests.
@Test
public void timelockIsHealthyAfterSuccessfulRequests() {
TimelockService instrumentedTimelockService = getFreshInstrumentedTimelockService();
when(timelockService.getFreshTimestamp()).thenReturn(0L);
tryGetFreshTimestamp(instrumentedTimelockService, 10);
waitForClockTick();
assertThat(timelockHealthCheck.getStatus().isHealthy()).isTrue();
}
use of com.palantir.atlasdb.transaction.impl.InstrumentedTimelockService in project atlasdb by palantir.
the class MetricsBasedTimelockHealthCheckTest method timlockIsHealthyAfterOneFailureMultipleSuccesses.
@Test
public void timlockIsHealthyAfterOneFailureMultipleSuccesses() {
TimelockService instrumentedTimelockService = getFreshInstrumentedTimelockService();
when(timelockService.getFreshTimestamp()).thenThrow(new RuntimeException()).thenReturn(0L);
tryGetFreshTimestamp(instrumentedTimelockService, 10);
waitForClockTick();
assertThat(timelockHealthCheck.getStatus().isHealthy()).isTrue();
}
use of com.palantir.atlasdb.transaction.impl.InstrumentedTimelockService in project atlasdb by palantir.
the class MetricsBasedTimelockHealthCheckTest method timelockIsUnhealthyAfterFailedRequests.
@Test
public void timelockIsUnhealthyAfterFailedRequests() {
TimelockService instrumentedTimelockService = getFreshInstrumentedTimelockService();
when(timelockService.getFreshTimestamp()).thenThrow(new RuntimeException());
tryGetFreshTimestamp(instrumentedTimelockService, 10);
waitForClockTick();
assertThat(timelockHealthCheck.getStatus().isHealthy()).isFalse();
}
Aggregations