From 34a304b535209a5b257b1ad2802d4a214148e5ec Mon Sep 17 00:00:00 2001 From: Bruno Koeferli Date: Fri, 7 Jun 2024 14:18:00 +0200 Subject: [PATCH] OpenTelemetry: improve stability of PeriodicAsyncMeasurementTest #2 see d539000d --- .../opentelemetry/PeriodicAsyncMeasurementTest.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/org.eclipse.scout.rt.platform.test/src/test/java/org/eclipse/scout/rt/platform/opentelemetry/PeriodicAsyncMeasurementTest.java b/org.eclipse.scout.rt.platform.test/src/test/java/org/eclipse/scout/rt/platform/opentelemetry/PeriodicAsyncMeasurementTest.java index a50504d4409..f8a4888ea2e 100644 --- a/org.eclipse.scout.rt.platform.test/src/test/java/org/eclipse/scout/rt/platform/opentelemetry/PeriodicAsyncMeasurementTest.java +++ b/org.eclipse.scout.rt.platform.test/src/test/java/org/eclipse/scout/rt/platform/opentelemetry/PeriodicAsyncMeasurementTest.java @@ -220,7 +220,10 @@ public void testActiveOnThisNode() throws Exception { final long asyncObservationInterval = 100; Callable 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 asyncMeasurement = new PeriodicAsyncMeasurement<>("testActiveOnThisNode", callable, () -> RunContexts.empty(), () -> activeOnThisNode.get(), asyncObservationInterval)) { @@ -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