Skip to content

Commit

Permalink
Fix flakiness in JmsInstrumentationTests.shouldInstrumentMessageListe…
Browse files Browse the repository at this point in the history
…ner() (#5899)

Signed-off-by: Johnny Lim <izeye@naver.com>
  • Loading branch information
izeye authored Feb 7, 2025
1 parent 20d0a9e commit f879d3a
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package io.micrometer.core.instrument.binder.jms;

import java.time.Duration;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.stream.Stream;
Expand All @@ -35,6 +36,7 @@

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.awaitility.Awaitility.await;

/**
* Tests for {@link JmsInstrumentation}.
Expand Down Expand Up @@ -134,10 +136,11 @@ void shouldInstrumentMessageListener() throws Exception {
MessageProducer producer = session.createProducer(topic);
producer.send(session.createTextMessage("test send"));
assertThat(latch.await(2, TimeUnit.SECONDS)).isTrue();
TestObservationRegistryAssert.assertThat(registry)
.hasObservationWithNameEqualTo("jms.message.process")
.that()
.hasContextualNameEqualTo("test.send process");
await().atMost(Duration.ofSeconds(1))
.untilAsserted(() -> TestObservationRegistryAssert.assertThat(registry)
.hasObservationWithNameEqualTo("jms.message.process")
.that()
.hasContextualNameEqualTo("test.send process"));
}
}

Expand Down

0 comments on commit f879d3a

Please sign in to comment.