Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@

/**
* Ozone file system tests that are not covered by contract tests.
*
* Note: When adding new test(s), please append it in testFileSystem() to
* avoid test run time regression.
*/
@RunWith(Parameterized.class)
public class TestOzoneFileSystem {
Expand Down Expand Up @@ -107,7 +110,6 @@ public TestOzoneFileSystem(boolean setDefaultFs) {
private int rootItemCount;
private Trash trash;

@Test(timeout = 300_000)
public void testCreateFileShouldCheckExistenceOfDirWithSameName()
throws Exception {
/*
Expand All @@ -120,7 +122,6 @@ public void testCreateFileShouldCheckExistenceOfDirWithSameName()
*
* Op 3. create file -> /d1/d2/d3 (d3 as a file inside /d1/d2)
*/
setupOzoneFileSystem();

Path parent = new Path("/d1/d2/d3/d4/");
Path file1 = new Path(parent, "key1");
Expand Down Expand Up @@ -154,21 +155,21 @@ public void testCreateFileShouldCheckExistenceOfDirWithSameName()
} catch (FileAlreadyExistsException fae) {
// ignore as its expected
}

// Cleanup
fs.delete(new Path("/d1/"), true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the cleanup be in a finally block? post mkdir if the test fails the directory won't get cleaned up. Wouldn't that affect other tests?

Copy link
Contributor Author

@smengcl smengcl Aug 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking a look at this @ayushtkn .

In this case it doesn't matter IMO. Cause if this test (testCreateFileShouldCheckExistenceOfDirWithSameName) fails and throws, testFileSystem as a whole will fail at this point thus the tests following this one won't even be executed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, correct the following tests will fail. Do you think, thats a good behaviour, Ideally only the affected test should fail. If there is a common cluster, that could have been initialised in a BeforeClass and all other tests could have ran independently.
Anyway not related to what you are doing here. Thanx for confirming.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I also think @BeforeClass is better. Maybe another jira to refactor the test class this way.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

/**
* Make the given file and all non-existent parents into
* directories. Has roughly the semantics of Unix @{code mkdir -p}.
* {@link FileSystem#mkdirs(Path)}
*/
@Test(timeout = 300_000)
public void testMakeDirsWithAnExistingDirectoryPath() throws Exception {
/*
* Op 1. create file -> /d1/d2/d3/d4/k1 (d3 is a sub-dir inside /d1/d2)
* Op 2. create dir -> /d1/d2
*/
setupOzoneFileSystem();

Path parent = new Path("/d1/d2/d3/d4/");
Path file1 = new Path(parent, "key1");
try (FSDataOutputStream outputStream = fs.create(file1, false)) {
Expand All @@ -178,11 +179,11 @@ public void testMakeDirsWithAnExistingDirectoryPath() throws Exception {
Path subdir = new Path("/d1/d2/");
boolean status = fs.mkdirs(subdir);
assertTrue("Shouldn't send error if dir exists", status);
// Cleanup
fs.delete(new Path("/d1"), true);
}

@Test
public void testCreateWithInvalidPaths() throws Exception {
setupOzoneFileSystem();
Path parent = new Path("../../../../../d1/d2/");
Path file1 = new Path(parent, "key1");
checkInvalidPath(file1);
Expand Down Expand Up @@ -212,6 +213,11 @@ public void testFileSystem() throws Exception {
testOzoneFsServiceLoader();
o3fs = (OzoneFileSystem) fs;

testCreateFileShouldCheckExistenceOfDirWithSameName();
testMakeDirsWithAnExistingDirectoryPath();
testCreateWithInvalidPaths();
testListStatusWithIntermediateDir();

testRenameToTrashDisabled();

testGetTrashRoots();
Expand Down Expand Up @@ -459,9 +465,7 @@ private void testListStatus() throws Exception {
3, fileStatuses.length);
}

@Test
public void testListStatusWithIntermediateDir() throws Exception {
setupOzoneFileSystem();
String keyName = "object-dir/object-name";
OmKeyArgs keyArgs = new OmKeyArgs.Builder()
.setVolumeName(volumeName)
Expand Down