From fa6abdfb9125b3713079d81c1de5478c621adff8 Mon Sep 17 00:00:00 2001 From: mocenas Date: Thu, 9 Feb 2023 14:49:04 +0100 Subject: [PATCH] Record files from one Before* method failure to same directory --- .../cz/xtf/junit5/extensions/OpenShiftRecorderService.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/junit5/src/main/java/cz/xtf/junit5/extensions/OpenShiftRecorderService.java b/junit5/src/main/java/cz/xtf/junit5/extensions/OpenShiftRecorderService.java index fc19fc16..3d9c6ece 100644 --- a/junit5/src/main/java/cz/xtf/junit5/extensions/OpenShiftRecorderService.java +++ b/junit5/src/main/java/cz/xtf/junit5/extensions/OpenShiftRecorderService.java @@ -89,6 +89,8 @@ public class OpenShiftRecorderService { private static final String IS_FILTER_BUILDS = "IS_FILTER_BUILDS"; private static final String EVENT_FILTER_BUILDS = "EVENT_FILTER_BUILDS"; + private int uniqueExecutionIdentifier; + /** * Initialize filters by collecting information OCP resources which are relevant for the current test execution * context (e.g.: called by a {@link org.junit.jupiter.api.extension.BeforeAllCallback#beforeAll(ExtensionContext)} @@ -194,6 +196,8 @@ public void updateFilters(ExtensionContext context) { * Retrieves resources identified by filters */ public void recordState(ExtensionContext context) throws IOException { + uniqueExecutionIdentifier = ThreadLocalRandom.current().nextInt(Short.MAX_VALUE); + savePods(context, getFilter(context, POD_FILTER_MASTER), !isMasterAndBuildNamespaceSame() ? getFilter(context, POD_FILTER_BUILDS) : null); saveDCs(context, getFilter(context, DC_FILTER_MASTER)); @@ -536,7 +540,7 @@ private String dirNameForTest(ExtensionContext context) { return context.getTestClass().get().getName() + "." + context.getTestMethod().get().getName() + context.getDisplayName(); } else { - return context.getTestClass().get().getName() + "-" + ThreadLocalRandom.current().nextInt(Short.MAX_VALUE); + return context.getTestClass().get().getName() + "-" + uniqueExecutionIdentifier; } } }