Skip to content
Merged
Changes from 6 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 @@ -802,6 +802,7 @@ protected void deleteRootDir() throws IOException, InterruptedException {
return;
}
deleteRootRecursively(fileStatuses);
Thread.sleep(500);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we use GenericTestUtils#waitFor instead of Thread.sleep()?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Can we use GenericTestUtils#waitFor instead of Thread.sleep()?

@hemantk-12 thanks for the review, I tried using GenericTestUtils, however this in actual run throwing always TimeOutException and not working in this case.

@hemantk-12 hemantk-12 Aug 28, 2023

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm surprise that Thread.sleep() works fine but GenericTestUtils#waitFor doesn't. Just curious what was lambda used?

I feel this should work if it is just about cleaning dir.

    GenericTestUtils.waitFor(() -> {
      try {
        FileStatus[] fileStatus = fs.listStatus(ROOT);
        return fileStatus != null && fileStatus.length == 0;
      } catch (IOException e) {
       // You can decide if it should be false or throw RTE.
        return false;
      }
    }, 100, 500);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks @hemantk-12 for review. I have handled as per your suggestion.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

How sleep for 500ms solves the problem?
And Who throws TimeoutException in what case make it flaky ?

@hemantk-12 hemantk-12 Aug 28, 2023

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

+1

I don't get either why TimeoutException is added here. May be @devmadhuu forgot to remove it while reverting some change.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Since now GenericTestUtils is being used, I have not removed TimeoutException. This change is not directly related, however many other tests are getting impacted because of deleteRootDIr cleanup, so this is important as part of this test as well.

fileStatuses = fs.listStatus(ROOT);
if (fileStatuses != null) {
Assert.assertEquals(
Expand Down Expand Up @@ -1618,15 +1619,13 @@ public void testGetTrashRoots() throws IOException {
* since fs.rename(src,dst,options) is enabled.
*/
@Test
@Flaky("HDDS-6646")
public void testRenameToTrashEnabled() throws Exception {
Comment thread
sadanand48 marked this conversation as resolved.
Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Was the test removal intended? because earlier commit had fixed the test and description also says so.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Was the test removal intended? because earlier commit had fixed the test and description also says so.

Yes @sadanand48 , as HDDS-6645 will be taking care of testTrash test case fix, so the only assertion which was different from testRenameToTrashEnabled and testTrash has been moved to testTrash and testRenameToTrashEnabled has been removed as per suggestion also from @sumitagrawl

Comment thread
smengcl marked this conversation as resolved.
// Create a file
String testKeyName = "testKey1";
Path path = new Path(OZONE_URI_DELIMITER, testKeyName);
try (FSDataOutputStream stream = fs.create(path)) {
stream.write(1);
}

// Call moveToTrash. We can't call protected fs.rename() directly
trash.moveToTrash(path);

Expand Down