Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Record files from one Before* method failure to same directory #524

Merged
merged 1 commit into from
Feb 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)}
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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;
}
}
}