Skip to content
Merged
Changes from 2 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 @@ -202,11 +202,11 @@ public void tearDown() throws IOException, InterruptedException {
}

private void verifyLocalFileDeletion(
LogAggregationService logAggregationService) throws Exception {
LogAggregationService logAggregationService, Long clusterTimeStamp) throws Exception {
logAggregationService.init(this.conf);
logAggregationService.start();

ApplicationId application1 = BuilderUtils.newApplicationId(1234, 1);
ApplicationId application1 = BuilderUtils.newApplicationId(clusterTimeStamp, 1);

// AppLogDir should be created
File app1LogDir =
Expand Down Expand Up @@ -252,7 +252,7 @@ private void verifyLocalFileDeletion(
count = 0;
while ((f.exists()) && (count < maxAttempts)) {
count++;
Thread.sleep(100);
Thread.sleep(1000);
Copy link
Member

Choose a reason for hiding this comment

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

Is there some scope to change this hard-coded sleep with GenericTestUtils.waitFor?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you very much for your help reviewing the code, I will use GenericTestUtils.waitFor for code refactoring.

}
Assert.assertFalse("File [" + f + "] was not deleted", f.exists());
}
Expand Down Expand Up @@ -310,7 +310,7 @@ public void testLocalFileDeletionAfterUpload() throws Exception {
LogAggregationService logAggregationService = spy(
new LogAggregationService(dispatcher, this.context, this.delSrvc,
super.dirsHandler));
verifyLocalFileDeletion(logAggregationService);
verifyLocalFileDeletion(logAggregationService, 1234L);
}

@Test
Expand All @@ -324,7 +324,7 @@ public void testLocalFileRemainsAfterUploadOnCleanupDisable() throws Exception {
this.remoteRootLogDir.getAbsolutePath());
LogAggregationService logAggregationService = spy(
new LogAggregationService(dispatcher, this.context, this.delSrvc, super.dirsHandler));
verifyLocalFileDeletion(logAggregationService);
verifyLocalFileDeletion(logAggregationService, 4321L);
Copy link
Member

Choose a reason for hiding this comment

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

Is there some logic behind these numbers? If not I think we should generate random numbers instead, else someone adding a new tests, unaware of these numbers will landup into the same mess. But I am ok to do the present way if others feel this is better approach

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the suggestion, I also think it would be better to use random numbers.

}

@Test
Expand All @@ -344,7 +344,7 @@ public void testLocalFileDeletionOnDiskFull() throws Exception {
LogAggregationService logAggregationService = spy(
new LogAggregationService(dispatcher, this.context, this.delSrvc,
dirsHandler));
verifyLocalFileDeletion(logAggregationService);
verifyLocalFileDeletion(logAggregationService, 5678L);
}

/* Test to verify fix for YARN-3793 */
Expand Down