Skip to content

Commit f879d3a

Browse files
authored
Fix flakiness in JmsInstrumentationTests.shouldInstrumentMessageListener() (#5899)
Signed-off-by: Johnny Lim <[email protected]>
1 parent 20d0a9e commit f879d3a

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

micrometer-test/src/test/java/io/micrometer/core/instrument/binder/jms/JmsInstrumentationTests.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package io.micrometer.core.instrument.binder.jms;
1717

18+
import java.time.Duration;
1819
import java.util.concurrent.CountDownLatch;
1920
import java.util.concurrent.TimeUnit;
2021
import java.util.stream.Stream;
@@ -35,6 +36,7 @@
3536

3637
import static org.assertj.core.api.Assertions.assertThat;
3738
import static org.assertj.core.api.Assertions.assertThatThrownBy;
39+
import static org.awaitility.Awaitility.await;
3840

3941
/**
4042
* Tests for {@link JmsInstrumentation}.
@@ -134,10 +136,11 @@ void shouldInstrumentMessageListener() throws Exception {
134136
MessageProducer producer = session.createProducer(topic);
135137
producer.send(session.createTextMessage("test send"));
136138
assertThat(latch.await(2, TimeUnit.SECONDS)).isTrue();
137-
TestObservationRegistryAssert.assertThat(registry)
138-
.hasObservationWithNameEqualTo("jms.message.process")
139-
.that()
140-
.hasContextualNameEqualTo("test.send process");
139+
await().atMost(Duration.ofSeconds(1))
140+
.untilAsserted(() -> TestObservationRegistryAssert.assertThat(registry)
141+
.hasObservationWithNameEqualTo("jms.message.process")
142+
.that()
143+
.hasContextualNameEqualTo("test.send process"));
141144
}
142145
}
143146

0 commit comments

Comments
 (0)