[TEST] Don't delete data dirs after test - only delete their content.

Closes #5815
This commit is contained in:
Simon Willnauer 2014-04-15 15:06:33 +02:00
parent 9898eed30c
commit c5c87c4a48
2 changed files with 15 additions and 11 deletions

View File

@ -74,20 +74,23 @@ public class FileSystemUtils {
return false;
}
public static boolean deleteRecursively(File[] roots) {
/**
* Deletes the given files recursively. if <tt>deleteRoots</tt> is set to <code>true</code>
* the given root files will be deleted as well. Otherwise only their content is deleted.
*/
public static boolean deleteRecursively(File[] roots, boolean deleteRoots) {
boolean deleted = true;
for (File root : roots) {
deleted &= deleteRecursively(root);
deleted &= deleteRecursively(root, deleteRoots);
}
return deleted;
}
public static boolean deleteRecursively(File root) {
return deleteRecursively(root, true);
}
private static boolean innerDeleteRecursively(File root) {
return deleteRecursively(root, true);
/**
* Deletes the given files recursively including the given roots.
*/
public static boolean deleteRecursively(File... roots) {
return deleteRecursively(roots, true);
}
/**
@ -105,7 +108,7 @@ public class FileSystemUtils {
File[] children = root.listFiles();
if (children != null) {
for (File aChildren : children) {
innerDeleteRecursively(aChildren);
deleteRecursively(aChildren, true);
}
}
}

View File

@ -762,10 +762,11 @@ public final class TestCluster extends ImmutableTestCluster {
private void wipeDataDirectories() {
if (!dataDirToClean.isEmpty()) {
logger.info("Wipe data directory for all nodes locations: {}", this.dataDirToClean);
boolean deleted = false;
try {
FileSystemUtils.deleteRecursively(dataDirToClean.toArray(new File[dataDirToClean.size()]));
deleted = FileSystemUtils.deleteRecursively(dataDirToClean.toArray(new File[dataDirToClean.size()]), false);
} finally {
logger.info("Wipe data directory for all nodes locations: {} success: {}", this.dataDirToClean, deleted);
this.dataDirToClean.clear();
}
}