Skip to content

Commit

Permalink
OpenTelemetry: improve stability of PeriodicAsyncMeasurementTest #2
Browse files Browse the repository at this point in the history
  • Loading branch information
brunokoeferli committed Jun 7, 2024
1 parent 97f8d78 commit 34a304b
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,10 @@ public void testActiveOnThisNode() throws Exception {

final long asyncObservationInterval = 100;
Callable<Long> callable = mockCallable();
Mockito.when(callable.call()).thenReturn(111L);
Mockito.when(callable.call()).then(invocation -> {
Thread.sleep(3); // simulate "db access"
return 111L;
});
AtomicBoolean activeOnThisNode = new AtomicBoolean(false);
try (PeriodicAsyncMeasurement<Long> asyncMeasurement = new PeriodicAsyncMeasurement<>("testActiveOnThisNode", callable, () -> RunContexts.empty(), () -> activeOnThisNode.get(), asyncObservationInterval)) {

Expand All @@ -238,7 +241,6 @@ public void testActiveOnThisNode() throws Exception {
assertNull(asyncMeasurement.getAndNext());
assertAsyncJobTrigger(callable, 0);

Thread.sleep(20);
activeOnThisNode.set(Boolean.TRUE);

// forth observation --> no measurement, but trigger async job
Expand Down

0 comments on commit 34a304b

Please sign in to comment.