SammyVimes commented on code in PR #1753:
URL: https://github.com/apache/ignite-3/pull/1753#discussion_r1126817287


##########
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:
   Done



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to