Skip to content

Commit 54c9366

Browse files
committed
modify unit tests
1 parent 48eb5d9 commit 54c9366

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/TrashPolicyDefault.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -250,20 +250,17 @@ public Path getCurrentTrashDir(Path path) throws IOException {
250250

251251
@Override
252252
public Runnable getEmptier() throws IOException {
253-
return new Emptier(getConf(), emptierInterval, cleanNonCheckpointUnderTrashRoot);
253+
return new Emptier(getConf(), emptierInterval);
254254
}
255255

256256
protected class Emptier implements Runnable {
257257

258258
private Configuration conf;
259259
private long emptierInterval;
260-
private boolean cleanNonCheckpointUnderTrashRoot;
261260

262-
Emptier(Configuration conf, long emptierInterval,
263-
boolean cleanNonCheckpointUnderTrashRoot) throws IOException {
261+
Emptier(Configuration conf, long emptierInterval) throws IOException {
264262
this.conf = conf;
265263
this.emptierInterval = emptierInterval;
266-
this.cleanNonCheckpointUnderTrashRoot = cleanNonCheckpointUnderTrashRoot;
267264
if (emptierInterval > deletionInterval || emptierInterval <= 0) {
268265
LOG.info("The configured checkpoint interval is " +
269266
(emptierInterval / MSECS_PER_MINUTE) + " minutes." +

hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestTrash.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,7 @@ public void testExistingFileTrash() throws IOException {
579579
conf.setClass("fs.file.impl", TestLFS.class, FileSystem.class);
580580
FileSystem fs = FileSystem.getLocal(conf);
581581
conf.set("fs.defaultFS", fs.getUri().toString());
582+
conf.setBoolean(FS_TRASH_CLEAN_TRASHROOT_ENABLE_KEY, true);
582583
conf.setLong(FS_TRASH_INTERVAL_KEY, 0); // disabled
583584
assertFalse(new Trash(conf).isEnabled());
584585

@@ -635,6 +636,7 @@ public void testNonDefaultFS() throws IOException {
635636
Configuration conf = new Configuration();
636637
conf.setClass("fs.file.impl", TestLFS.class, FileSystem.class);
637638
conf.set("fs.defaultFS", "invalid://host/bar/foo");
639+
conf.setBoolean(FS_TRASH_CLEAN_TRASHROOT_ENABLE_KEY, true);
638640
trashNonDefaultFS(conf);
639641
}
640642

@@ -644,6 +646,7 @@ public void testPluggableTrash() throws IOException {
644646

645647
// Test plugged TrashPolicy
646648
conf.setClass("fs.trash.classname", TestTrashPolicy.class, TrashPolicy.class);
649+
conf.setBoolean(FS_TRASH_CLEAN_TRASHROOT_ENABLE_KEY, true);
647650
Trash trash = new Trash(conf);
648651
assertTrue(trash.getTrashPolicy().getClass().equals(TestTrashPolicy.class));
649652
}
@@ -675,6 +678,7 @@ public void testMoveEmptyDirToTrash() throws Exception {
675678
RawLocalFileSystem.class,
676679
FileSystem.class);
677680
conf.setLong(FS_TRASH_INTERVAL_KEY, 1); // 1 min
681+
conf.setBoolean(FS_TRASH_CLEAN_TRASHROOT_ENABLE_KEY, true);
678682
FileSystem fs = FileSystem.get(conf);
679683
verifyMoveEmptyDirToTrash(fs, conf);
680684
}
@@ -692,6 +696,7 @@ public void testTrashRestarts() throws Exception {
692696
TrashPolicy.class);
693697
conf.setClass("fs.file.impl", TestLFS.class, FileSystem.class);
694698
conf.set(FS_TRASH_INTERVAL_KEY, "50"); // in milliseconds for test
699+
conf.setBoolean(FS_TRASH_CLEAN_TRASHROOT_ENABLE_KEY, true);
695700
Trash trash = new Trash(conf);
696701
// create 5 checkpoints
697702
for(int i=0; i<5; i++) {
@@ -720,6 +725,7 @@ public void testTrashPermission() throws IOException {
720725
TrashPolicy.class);
721726
conf.setClass("fs.file.impl", TestLFS.class, FileSystem.class);
722727
conf.set(FS_TRASH_INTERVAL_KEY, "0.2");
728+
conf.setBoolean(FS_TRASH_CLEAN_TRASHROOT_ENABLE_KEY, true);
723729
verifyTrashPermission(FileSystem.getLocal(conf), conf);
724730
}
725731

@@ -732,6 +738,7 @@ public void testTrashEmptier() throws Exception {
732738
conf.set(FS_TRASH_CHECKPOINT_INTERVAL_KEY, "0.1"); // 6 seconds
733739
FileSystem fs = FileSystem.getLocal(conf);
734740
conf.set("fs.default.name", fs.getUri().toString());
741+
conf.setBoolean(FS_TRASH_CLEAN_TRASHROOT_ENABLE_KEY, true);
735742

736743
Trash trash = new Trash(conf);
737744

0 commit comments

Comments
 (0)