From 5d70aaacef55185e92b0e465ffc7fbee5818bfaf Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Fri, 12 Feb 2021 12:02:37 +0100 Subject: [PATCH] Improve diagnostics for flaky ParallelApplicationEventsIntegrationTests --- .../event/ParallelApplicationEventsIntegrationTests.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/event/ParallelApplicationEventsIntegrationTests.java b/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/event/ParallelApplicationEventsIntegrationTests.java index 4944feb3f3..ec7b061c1a 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/event/ParallelApplicationEventsIntegrationTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/event/ParallelApplicationEventsIntegrationTests.java @@ -75,13 +75,16 @@ class ParallelApplicationEventsIntegrationTests { assertThat(payloads).hasSize(10); assertThat(testNames).hasSize(10); + int availableProcessors = Runtime.getRuntime().availableProcessors(); // Skip the following assertion entirely if too few processors are available // to the current JVM. - if (Runtime.getRuntime().availableProcessors() >= 4) { + if (availableProcessors >= 6) { // There are probably 10 different thread names on a developer's machine, // but we really just want to assert that at least two different threads // were used, since the CI server often has fewer threads available. - assertThat(threadNames).hasSizeGreaterThanOrEqualTo(2); + assertThat(threadNames) + .as("number of threads used with " + availableProcessors + " available processors") + .hasSizeGreaterThanOrEqualTo(2); } }