Skip to content

Commit

Permalink
Fixing unreferenced file cleanup flaky tests
Browse files Browse the repository at this point in the history
Signed-off-by: RS146BIJAY <rishavsagar4b1@gmail.com>
  • Loading branch information
RS146BIJAY committed Oct 20, 2023
1 parent 1e28738 commit 35ded4c
Showing 1 changed file with 3 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3237,22 +3237,10 @@ public void testUnreferencedFileCleanUpOnSegmentMergeFailureWithCleanUpEnabled()
MockDirectoryWrapper wrapper = newMockDirectory();
final CountDownLatch cleanupCompleted = new CountDownLatch(1);
MockDirectoryWrapper.Failure fail = new MockDirectoryWrapper.Failure() {
public boolean didFail1;
public boolean didFail2;

@Override
public void eval(MockDirectoryWrapper dir) throws IOException {
if (!doFail) {
return;
}

// Fail segment merge with diskfull during merging terms.
if (callStackContainsAnyOf("mergeTerms") && !didFail1) {
didFail1 = true;
throw new IOException("No space left on device");
}
if (callStackContains(LiveDocsFormat.class, "writeLiveDocs") && !didFail2) {
didFail2 = true;
if (callStackContainsAnyOf("mergeTerms")) {
throw new IOException("No space left on device");
}
}
Expand Down Expand Up @@ -3325,7 +3313,6 @@ public void onFailedEngine(String reason, Exception e) {
segments = engine.segments(false);
assertThat(segments.size(), equalTo(2));

fail.setDoFail();
// IndexWriter can throw either IOException or IllegalStateException depending on whether tragedy is set or not.
expectThrowsAnyOf(
Arrays.asList(IOException.class, IllegalStateException.class),
Expand All @@ -3345,20 +3332,10 @@ public void testUnreferencedFileCleanUpOnSegmentMergeFailureWithCleanUpDisabled(
MockDirectoryWrapper wrapper = newMockDirectory();
final CountDownLatch cleanupCompleted = new CountDownLatch(1);
MockDirectoryWrapper.Failure fail = new MockDirectoryWrapper.Failure() {
public boolean didFail1;
public boolean didFail2;

@Override
public void eval(MockDirectoryWrapper dir) throws IOException {
if (!doFail) {
return;
}
if (callStackContainsAnyOf("mergeTerms") && !didFail1) {
didFail1 = true;
throw new IOException("No space left on device");
}
if (callStackContains(LiveDocsFormat.class, "writeLiveDocs") && !didFail2) {
didFail2 = true;
if (callStackContainsAnyOf("mergeTerms")) {
throw new IOException("No space left on device");
}
}
Expand Down Expand Up @@ -3439,7 +3416,6 @@ public void onFailedEngine(String reason, Exception e) {
segments = engine.segments(false);
assertThat(segments.size(), equalTo(2));

fail.setDoFail();
// IndexWriter can throw either IOException or IllegalStateException depending on whether tragedy is set or not.
expectThrowsAnyOf(
Arrays.asList(IOException.class, IllegalStateException.class),
Expand All @@ -3459,20 +3435,10 @@ public void testUnreferencedFileCleanUpFailsOnSegmentMergeFailureWhenDirectoryCl
MockDirectoryWrapper wrapper = newMockDirectory();
final CountDownLatch cleanupCompleted = new CountDownLatch(1);
MockDirectoryWrapper.Failure fail = new MockDirectoryWrapper.Failure() {
public boolean didFail1;
public boolean didFail2;

@Override
public void eval(MockDirectoryWrapper dir) throws IOException {
if (!doFail) {
return;
}
if (callStackContainsAnyOf("mergeTerms") && !didFail1) {
didFail1 = true;
throw new IOException("No space left on device");
}
if (callStackContains(LiveDocsFormat.class, "writeLiveDocs") && !didFail2) {
didFail2 = true;
if (callStackContainsAnyOf("mergeTerms")) {
throw new IOException("No space left on device");
}
}
Expand Down Expand Up @@ -3537,7 +3503,6 @@ public void onFailedEngine(String reason, Exception e) {
segments = engine.segments(false);
assertThat(segments.size(), equalTo(2));

fail.setDoFail();
// Close the store so that unreferenced file cleanup will fail.
store.close();

Expand Down

0 comments on commit 35ded4c

Please sign in to comment.