From 99d1ccefcd7dddf35ca6e891fe8062458924c047 Mon Sep 17 00:00:00 2001 From: Simon Willnauer Date: Wed, 9 May 2018 22:29:58 +0200 Subject: [PATCH] [TEST]: Account for docs that randomly never got added --- .../apache/lucene/index/TestMixedDocValuesUpdates.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lucene/core/src/test/org/apache/lucene/index/TestMixedDocValuesUpdates.java b/lucene/core/src/test/org/apache/lucene/index/TestMixedDocValuesUpdates.java index 0927dcd203b..4315af28535 100644 --- a/lucene/core/src/test/org/apache/lucene/index/TestMixedDocValuesUpdates.java +++ b/lucene/core/src/test/org/apache/lucene/index/TestMixedDocValuesUpdates.java @@ -595,7 +595,7 @@ public class TestMixedDocValuesUpdates extends LuceneTestCase { IndexWriter writer = new IndexWriter(dir, conf); int numDocs = 10 + random().nextInt(50); int currentSeqId = 0; - int[] seqId = new int[5]; + int[] seqId = new int[] {-1, -1, -1, -1, -1}; for (int i = 0; i < numDocs; i++) { Document doc = new Document(); int id = random().nextInt(5); @@ -615,11 +615,17 @@ public class TestMixedDocValuesUpdates extends LuceneTestCase { if (random().nextBoolean()) { writer.commit(); } + int numHits = 0; // check if every doc has been selected at least once + for (int i : seqId) { + if (i > -1) { + numHits++; + } + } try(DirectoryReader reader = writer.getReader()) { IndexSearcher searcher = new IndexSearcher(reader); TopDocs is_live = searcher.search(new DocValuesFieldExistsQuery("is_live"), 5); - assertEquals(5, is_live.totalHits); + assertEquals(numHits, is_live.totalHits); for (ScoreDoc doc : is_live.scoreDocs) { int id = Integer.parseInt(reader.document(doc.doc).get("id")); int i = ReaderUtil.subIndex(doc.doc, reader.leaves());