Skip to content

Commit

Permalink
modify unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hfutatzhanghb committed Jun 16, 2023
1 parent 48eb5d9 commit 54c9366
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -250,20 +250,17 @@ public Path getCurrentTrashDir(Path path) throws IOException {

@Override
public Runnable getEmptier() throws IOException {
return new Emptier(getConf(), emptierInterval, cleanNonCheckpointUnderTrashRoot);
return new Emptier(getConf(), emptierInterval);
}

protected class Emptier implements Runnable {

private Configuration conf;
private long emptierInterval;
private boolean cleanNonCheckpointUnderTrashRoot;

Emptier(Configuration conf, long emptierInterval,
boolean cleanNonCheckpointUnderTrashRoot) throws IOException {
Emptier(Configuration conf, long emptierInterval) throws IOException {
this.conf = conf;
this.emptierInterval = emptierInterval;
this.cleanNonCheckpointUnderTrashRoot = cleanNonCheckpointUnderTrashRoot;
if (emptierInterval > deletionInterval || emptierInterval <= 0) {
LOG.info("The configured checkpoint interval is " +
(emptierInterval / MSECS_PER_MINUTE) + " minutes." +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,7 @@ public void testExistingFileTrash() throws IOException {
conf.setClass("fs.file.impl", TestLFS.class, FileSystem.class);
FileSystem fs = FileSystem.getLocal(conf);
conf.set("fs.defaultFS", fs.getUri().toString());
conf.setBoolean(FS_TRASH_CLEAN_TRASHROOT_ENABLE_KEY, true);
conf.setLong(FS_TRASH_INTERVAL_KEY, 0); // disabled
assertFalse(new Trash(conf).isEnabled());

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

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

// Test plugged TrashPolicy
conf.setClass("fs.trash.classname", TestTrashPolicy.class, TrashPolicy.class);
conf.setBoolean(FS_TRASH_CLEAN_TRASHROOT_ENABLE_KEY, true);
Trash trash = new Trash(conf);
assertTrue(trash.getTrashPolicy().getClass().equals(TestTrashPolicy.class));
}
Expand Down Expand Up @@ -675,6 +678,7 @@ public void testMoveEmptyDirToTrash() throws Exception {
RawLocalFileSystem.class,
FileSystem.class);
conf.setLong(FS_TRASH_INTERVAL_KEY, 1); // 1 min
conf.setBoolean(FS_TRASH_CLEAN_TRASHROOT_ENABLE_KEY, true);
FileSystem fs = FileSystem.get(conf);
verifyMoveEmptyDirToTrash(fs, conf);
}
Expand All @@ -692,6 +696,7 @@ public void testTrashRestarts() throws Exception {
TrashPolicy.class);
conf.setClass("fs.file.impl", TestLFS.class, FileSystem.class);
conf.set(FS_TRASH_INTERVAL_KEY, "50"); // in milliseconds for test
conf.setBoolean(FS_TRASH_CLEAN_TRASHROOT_ENABLE_KEY, true);
Trash trash = new Trash(conf);
// create 5 checkpoints
for(int i=0; i<5; i++) {
Expand Down Expand Up @@ -720,6 +725,7 @@ public void testTrashPermission() throws IOException {
TrashPolicy.class);
conf.setClass("fs.file.impl", TestLFS.class, FileSystem.class);
conf.set(FS_TRASH_INTERVAL_KEY, "0.2");
conf.setBoolean(FS_TRASH_CLEAN_TRASHROOT_ENABLE_KEY, true);
verifyTrashPermission(FileSystem.getLocal(conf), conf);
}

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

Trash trash = new Trash(conf);

Expand Down

0 comments on commit 54c9366

Please sign in to comment.