Skip to content

Commit

Permalink
Fix broken test testCommitOnCloseThrowsException_decRefStore (opensea…
Browse files Browse the repository at this point in the history
…rch-project#10621)

This test was incorrectly hardcoding a segment to delete to force corruption.
If a merge occurs randomly before segments are copied the expected segment did not exist failing the test.
This will now look for any .si and delete it.

Signed-off-by: Marc Handalian <[email protected]>
Signed-off-by: Shivansh Arora <[email protected]>
  • Loading branch information
mch2 authored and shiv0408 committed Apr 25, 2024
1 parent 872607f commit 126f15a
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicLong;
Expand Down Expand Up @@ -591,7 +592,9 @@ public void testCommitOnCloseThrowsException_decRefStore() throws Exception {
indexOperations(nrtEngine, operations);
// wipe the nrt directory initially so we can sync with primary.
cleanAndCopySegmentsFromPrimary(nrtEngine);
nrtEngineStore.directory().deleteFile("_0.si");
final Optional<String> toDelete = Set.of(nrtEngineStore.directory().listAll()).stream().filter(f -> f.endsWith(".si")).findAny();
assertTrue(toDelete.isPresent());
nrtEngineStore.directory().deleteFile(toDelete.get());
assertEquals(2, nrtEngineStore.refCount());
nrtEngine.close();
assertEquals(1, nrtEngineStore.refCount());
Expand Down

0 comments on commit 126f15a

Please sign in to comment.