Skip to content

Commit e9affea

Browse files
authored
Fixing unreferenced file cleanup flaky tests (#10801)
Signed-off-by: RS146BIJAY <[email protected]>
1 parent 0c9fc21 commit e9affea

File tree

1 file changed

+4
-40
lines changed

1 file changed

+4
-40
lines changed

server/src/test/java/org/opensearch/index/engine/InternalEngineTests.java

Lines changed: 4 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
import org.apache.logging.log4j.core.LogEvent;
4141
import org.apache.logging.log4j.core.appender.AbstractAppender;
4242
import org.apache.logging.log4j.core.filter.RegexFilter;
43-
import org.apache.lucene.codecs.LiveDocsFormat;
4443
import org.apache.lucene.document.Field;
4544
import org.apache.lucene.document.KeywordField;
4645
import org.apache.lucene.document.LongPoint;
@@ -3237,22 +3236,10 @@ public void testUnreferencedFileCleanUpOnSegmentMergeFailureWithCleanUpEnabled()
32373236
MockDirectoryWrapper wrapper = newMockDirectory();
32383237
final CountDownLatch cleanupCompleted = new CountDownLatch(1);
32393238
MockDirectoryWrapper.Failure fail = new MockDirectoryWrapper.Failure() {
3240-
public boolean didFail1;
3241-
public boolean didFail2;
3242-
32433239
@Override
32443240
public void eval(MockDirectoryWrapper dir) throws IOException {
3245-
if (!doFail) {
3246-
return;
3247-
}
3248-
3249-
// Fail segment merge with diskfull during merging terms.
3250-
if (callStackContainsAnyOf("mergeTerms") && !didFail1) {
3251-
didFail1 = true;
3252-
throw new IOException("No space left on device");
3253-
}
3254-
if (callStackContains(LiveDocsFormat.class, "writeLiveDocs") && !didFail2) {
3255-
didFail2 = true;
3241+
// Fail segment merge with diskfull during merging terms
3242+
if (callStackContainsAnyOf("mergeTerms")) {
32563243
throw new IOException("No space left on device");
32573244
}
32583245
}
@@ -3325,7 +3312,6 @@ public void onFailedEngine(String reason, Exception e) {
33253312
segments = engine.segments(false);
33263313
assertThat(segments.size(), equalTo(2));
33273314

3328-
fail.setDoFail();
33293315
// IndexWriter can throw either IOException or IllegalStateException depending on whether tragedy is set or not.
33303316
expectThrowsAnyOf(
33313317
Arrays.asList(IOException.class, IllegalStateException.class),
@@ -3345,20 +3331,10 @@ public void testUnreferencedFileCleanUpOnSegmentMergeFailureWithCleanUpDisabled(
33453331
MockDirectoryWrapper wrapper = newMockDirectory();
33463332
final CountDownLatch cleanupCompleted = new CountDownLatch(1);
33473333
MockDirectoryWrapper.Failure fail = new MockDirectoryWrapper.Failure() {
3348-
public boolean didFail1;
3349-
public boolean didFail2;
33503334

33513335
@Override
33523336
public void eval(MockDirectoryWrapper dir) throws IOException {
3353-
if (!doFail) {
3354-
return;
3355-
}
3356-
if (callStackContainsAnyOf("mergeTerms") && !didFail1) {
3357-
didFail1 = true;
3358-
throw new IOException("No space left on device");
3359-
}
3360-
if (callStackContains(LiveDocsFormat.class, "writeLiveDocs") && !didFail2) {
3361-
didFail2 = true;
3337+
if (callStackContainsAnyOf("mergeTerms")) {
33623338
throw new IOException("No space left on device");
33633339
}
33643340
}
@@ -3439,7 +3415,6 @@ public void onFailedEngine(String reason, Exception e) {
34393415
segments = engine.segments(false);
34403416
assertThat(segments.size(), equalTo(2));
34413417

3442-
fail.setDoFail();
34433418
// IndexWriter can throw either IOException or IllegalStateException depending on whether tragedy is set or not.
34443419
expectThrowsAnyOf(
34453420
Arrays.asList(IOException.class, IllegalStateException.class),
@@ -3459,20 +3434,10 @@ public void testUnreferencedFileCleanUpFailsOnSegmentMergeFailureWhenDirectoryCl
34593434
MockDirectoryWrapper wrapper = newMockDirectory();
34603435
final CountDownLatch cleanupCompleted = new CountDownLatch(1);
34613436
MockDirectoryWrapper.Failure fail = new MockDirectoryWrapper.Failure() {
3462-
public boolean didFail1;
3463-
public boolean didFail2;
34643437

34653438
@Override
34663439
public void eval(MockDirectoryWrapper dir) throws IOException {
3467-
if (!doFail) {
3468-
return;
3469-
}
3470-
if (callStackContainsAnyOf("mergeTerms") && !didFail1) {
3471-
didFail1 = true;
3472-
throw new IOException("No space left on device");
3473-
}
3474-
if (callStackContains(LiveDocsFormat.class, "writeLiveDocs") && !didFail2) {
3475-
didFail2 = true;
3440+
if (callStackContainsAnyOf("mergeTerms")) {
34763441
throw new IOException("No space left on device");
34773442
}
34783443
}
@@ -3537,7 +3502,6 @@ public void onFailedEngine(String reason, Exception e) {
35373502
segments = engine.segments(false);
35383503
assertThat(segments.size(), equalTo(2));
35393504

3540-
fail.setDoFail();
35413505
// Close the store so that unreferenced file cleanup will fail.
35423506
store.close();
35433507

0 commit comments

Comments
 (0)