Skip to content

Commit 6e70957

Browse files
authored
Fix flakiness in JmsInstrumentationTests.shouldInstrumentMessageListener() (#6004)
See gh-5899 Signed-off-by: Johnny Lim <izeye@naver.com>
1 parent 4106963 commit 6e70957

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

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

Lines changed: 6 additions & 3 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;
@@ -34,6 +35,7 @@
3435

3536
import static org.assertj.core.api.Assertions.assertThat;
3637
import static org.assertj.core.api.Assertions.assertThatThrownBy;
38+
import static org.awaitility.Awaitility.await;
3739

3840
/**
3941
* Tests for {@link JmsInstrumentation}.
@@ -131,9 +133,10 @@ void shouldInstrumentMessageListener() throws Exception {
131133
MessageProducer producer = session.createProducer(topic);
132134
producer.send(session.createTextMessage("test send"));
133135
assertThat(latch.await(2, TimeUnit.SECONDS)).isTrue();
134-
assertThat(registry).hasObservationWithNameEqualTo("jms.message.process")
135-
.that()
136-
.hasContextualNameEqualTo("test.send process");
136+
await().atMost(Duration.ofSeconds(1))
137+
.untilAsserted(() -> assertThat(registry).hasObservationWithNameEqualTo("jms.message.process")
138+
.that()
139+
.hasContextualNameEqualTo("test.send process"));
137140
}
138141
}
139142

0 commit comments

Comments
 (0)