From 48d51cdd253eddc6d3ff8b9db8cac87b4632fb11 Mon Sep 17 00:00:00 2001 From: Guillaume Smet Date: Mon, 23 Dec 2024 15:41:10 +0100 Subject: [PATCH] Make sure configAnnotation entry is always added Otherwise we were comparing items with and without this entry, leading to us restarting Quarkus a lot more often than necessary. Spotted while playing with a modified version of @WithKubernetesTestServer/ --- .../test/common/TestResourceManager.java | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/test-framework/common/src/main/java/io/quarkus/test/common/TestResourceManager.java b/test-framework/common/src/main/java/io/quarkus/test/common/TestResourceManager.java index b7dc8f2467de3..92439a7a1559a 100644 --- a/test-framework/common/src/main/java/io/quarkus/test/common/TestResourceManager.java +++ b/test-framework/common/src/main/java/io/quarkus/test/common/TestResourceManager.java @@ -106,8 +106,7 @@ public TestResourceManager(Class testClass, this.testResourceComparisonInfo = new HashSet<>(); for (TestResourceClassEntry uniqueEntry : uniqueEntries) { - testResourceComparisonInfo.add(new TestResourceComparisonInfo( - uniqueEntry.testResourceLifecycleManagerClass().getName(), uniqueEntry.getScope(), uniqueEntry.args)); + testResourceComparisonInfo.add(prepareTestResourceComparisonInfo(uniqueEntry)); } Set remainingUniqueEntries = initParallelTestResources(uniqueEntries); @@ -331,7 +330,7 @@ private Set uniqueTestResourceClassEntries(Path testClas } /** - * Allows Quarkus to extra basic information about which test resources a test class will require + * Allows Quarkus to extract basic information about which test resources a test class will require */ public static Set testResourceComparisonInfo(Class testClass, Path testClassLocation, List entriesFromProfile) { @@ -343,16 +342,24 @@ public static Set testResourceCo allEntries.addAll(entriesFromProfile); Set result = new HashSet<>(allEntries.size()); for (TestResourceClassEntry entry : allEntries) { - Map args = new HashMap<>(entry.args); - if (entry.configAnnotation != null) { - args.put("configAnnotation", entry.configAnnotation.annotationType().getName()); - } - result.add(new TestResourceComparisonInfo(entry.testResourceLifecycleManagerClass().getName(), entry.getScope(), - args)); + result.add(prepareTestResourceComparisonInfo(entry)); } return result; } + private static TestResourceComparisonInfo prepareTestResourceComparisonInfo(TestResourceClassEntry entry) { + Map args; + if (entry.configAnnotation != null) { + args = new HashMap<>(entry.args); + args.put("configAnnotation", entry.configAnnotation.annotationType().getName()); + } else { + args = entry.args; + } + + return new TestResourceComparisonInfo(entry.testResourceLifecycleManagerClass().getName(), entry.getScope(), + args); + } + private static Set getUniqueTestResourceClassEntries(Class testClass, Path testClassLocation, Consumer> afterMetaAnnotationAction) {