From 2ebcdb059a6e9d7af8fbaf84e3e07b08750799a3 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Tue, 5 Sep 2023 18:46:36 -0700 Subject: [PATCH] Tweak Pulsar smoke test timeouts See gh-34763 --- .../SampleReactivePulsarApplicationTests.java | 14 ++++++++++---- .../pulsar/SamplePulsarApplicationTests.java | 14 ++++++++++---- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-pulsar-reactive/src/test/java/smoketest/pulsar/reactive/SampleReactivePulsarApplicationTests.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-pulsar-reactive/src/test/java/smoketest/pulsar/reactive/SampleReactivePulsarApplicationTests.java index eb13dc4280..48643ab308 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-pulsar-reactive/src/test/java/smoketest/pulsar/reactive/SampleReactivePulsarApplicationTests.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-pulsar-reactive/src/test/java/smoketest/pulsar/reactive/SampleReactivePulsarApplicationTests.java @@ -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); } } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-pulsar/src/test/java/smoketest/pulsar/SamplePulsarApplicationTests.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-pulsar/src/test/java/smoketest/pulsar/SamplePulsarApplicationTests.java index 4918a58ba4..5877370ba7 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-pulsar/src/test/java/smoketest/pulsar/SamplePulsarApplicationTests.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-pulsar/src/test/java/smoketest/pulsar/SamplePulsarApplicationTests.java @@ -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); } }