Tweak Pulsar smoke test timeouts

See gh-34763
This commit is contained in:
Phillip Webb 2023-09-05 18:46:36 -07:00
parent 975cb27905
commit 2ebcdb059a
2 changed files with 20 additions and 8 deletions

View File

@ -37,6 +37,8 @@ import static org.assertj.core.api.Assertions.assertThat;
@Testcontainers(disabledWithoutDocker = true)
class SampleReactivePulsarApplicationTests {
private static final Integer[] EXPECTED_IDS = IntStream.range(0, 10).boxed().toArray(Integer[]::new);
@Container
private static final PulsarContainer PULSAR_CONTAINER = new PulsarContainer(DockerImageNames.pulsar())
.withStartupAttempts(2)
@ -50,11 +52,15 @@ class SampleReactivePulsarApplicationTests {
@Test
void appProducesAndConsumesSampleMessages(@Autowired SampleMessageConsumer consumer) {
Integer[] expectedIds = IntStream.range(0, 10).boxed().toArray(Integer[]::new);
Awaitility.await()
.atMost(Duration.ofSeconds(20))
.untilAsserted(() -> assertThat(consumer.getConsumed()).extracting(SampleMessage::id)
.containsExactly(expectedIds));
.atMost(Duration.ofMinutes(3))
.with()
.pollInterval(Duration.ofMillis(500))
.untilAsserted(() -> hasExpectedIds(consumer));
}
private void hasExpectedIds(SampleMessageConsumer consumer) {
assertThat(consumer.getConsumed()).extracting(SampleMessage::id).containsExactly(EXPECTED_IDS);
}
}

View File

@ -37,6 +37,8 @@ import static org.assertj.core.api.Assertions.assertThat;
@Testcontainers(disabledWithoutDocker = true)
class SamplePulsarApplicationTests {
private static final Integer[] EXPECTED_IDS = IntStream.range(0, 10).boxed().toArray(Integer[]::new);
@Container
private static final PulsarContainer PULSAR_CONTAINER = new PulsarContainer(DockerImageNames.pulsar())
.withStartupAttempts(2)
@ -50,11 +52,15 @@ class SamplePulsarApplicationTests {
@Test
void appProducesAndConsumesSampleMessages(@Autowired SampleMessageConsumer consumer) {
Integer[] expectedIds = IntStream.range(0, 10).boxed().toArray(Integer[]::new);
Awaitility.await()
.atMost(Duration.ofSeconds(20))
.untilAsserted(() -> assertThat(consumer.getConsumed()).extracting(SampleMessage::id)
.containsExactly(expectedIds));
.atMost(Duration.ofMinutes(3))
.with()
.pollInterval(Duration.ofMillis(500))
.untilAsserted(() -> hasExpectedIds(consumer));
}
private void hasExpectedIds(SampleMessageConsumer consumer) {
assertThat(consumer.getConsumed()).extracting(SampleMessage::id).containsExactly(EXPECTED_IDS);
}
}