You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "tkalkirill (via GitHub)" <gi...@apache.org> on 2023/03/06 12:36:07 UTC
[GitHub] [ignite-3] tkalkirill commented on a diff in pull request #1753: IGNITE-18970 Allow WorkDirectoryExtension to preserve work directories of specific tests
tkalkirill commented on code in PR #1753:
URL: https://github.com/apache/ignite-3/pull/1753#discussion_r1126356262
##########
modules/core/src/testFixtures/java/org/apache/ignite/internal/testframework/WorkDirectoryExtension.java:
##########
@@ -212,11 +230,69 @@ private static Path getTestClassDir(ExtensionContext context) {
/**
* Removes a previously created work directory.
*/
- private static void removeWorkDir(ExtensionContext context) {
+ private static void cleanupWorkDir(ExtensionContext context) {
Path workDir = context.getStore(NAMESPACE).remove(context.getUniqueId(), Path.class);
- if (workDir != null && shouldRemoveDir()) {
- IgniteUtils.deleteIfExists(workDir);
+ String testClassName = context.getRequiredTestClass().getSimpleName();
+
+ String testName = context.getTestMethod().map(method -> testClassName + "." + method.getName()).orElse(testClassName);
+
+ if (workDir != null) {
+ if (shouldKeepWorkDir(testName)) {
+ String artifactDir = IgniteSystemProperties.getString(ARTIFACT_DIR_PROPERTY);
+
+ if (artifactDir != null) {
+ Path artifactDirPath = Paths.get(artifactDir, testName + ".zip");
+
+ zipDirectory(workDir, artifactDirPath);
+
+ IgniteUtils.deleteIfExists(workDir);
+ }
+ } else {
+ IgniteUtils.deleteIfExists(workDir);
+ }
+ }
+ }
+
+ private static boolean shouldKeepWorkDir(String testName) {
+ String keepWorkDirStr = IgniteSystemProperties.getString(KEEP_WORK_DIR_PROPERTY);
+
+ Set<String> keepWorkDirForTests;
+
+ if (keepWorkDirStr != null) {
+ keepWorkDirForTests = Arrays.stream(keepWorkDirStr.split(",")).collect(toSet());
Review Comment:
Can we check the format?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org