Skip to content

Commit

Permalink
Make sure configAnnotation entry is always added
Browse files Browse the repository at this point in the history
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/
  • Loading branch information
gsmet committed Dec 23, 2024
1 parent 4340d69 commit 48d51cd
Showing 1 changed file with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<TestResourceClassEntry> remainingUniqueEntries = initParallelTestResources(uniqueEntries);
Expand Down Expand Up @@ -331,7 +330,7 @@ private Set<TestResourceClassEntry> 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<TestResourceManager.TestResourceComparisonInfo> testResourceComparisonInfo(Class<?> testClass,
Path testClassLocation, List<TestResourceClassEntry> entriesFromProfile) {
Expand All @@ -343,16 +342,24 @@ public static Set<TestResourceManager.TestResourceComparisonInfo> testResourceCo
allEntries.addAll(entriesFromProfile);
Set<TestResourceManager.TestResourceComparisonInfo> result = new HashSet<>(allEntries.size());
for (TestResourceClassEntry entry : allEntries) {
Map<String, String> 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<String, String> 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<TestResourceClassEntry> getUniqueTestResourceClassEntries(Class<?> testClass,
Path testClassLocation,
Consumer<Set<TestResourceClassEntry>> afterMetaAnnotationAction) {
Expand Down

0 comments on commit 48d51cd

Please sign in to comment.