From 9974f6ac34ac2f17bfcdf30d6df79476579ff1e0 Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Tue, 14 Dec 2021 13:49:58 +0400 Subject: [PATCH] LUCENE-10085: Fix flaky testQueryMatchesCount (#538) Five times every 10 000 tests, we did not index any documents with i between 0 and 10 (inclusive), which caused the deleted tests to fail. With this commit, we make sure that we always index at least one document between 0 and 10. --- .../apache/lucene/search/TestDocValuesFieldExistsQuery.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lucene/core/src/test/org/apache/lucene/search/TestDocValuesFieldExistsQuery.java b/lucene/core/src/test/org/apache/lucene/search/TestDocValuesFieldExistsQuery.java index 489ee0f35e9..ef400610720 100644 --- a/lucene/core/src/test/org/apache/lucene/search/TestDocValuesFieldExistsQuery.java +++ b/lucene/core/src/test/org/apache/lucene/search/TestDocValuesFieldExistsQuery.java @@ -222,7 +222,8 @@ public class TestDocValuesFieldExistsQuery extends LuceneTestCase { for (int i = 0; i < randomNumDocs; i++) { Document doc = new Document(); - if (random().nextBoolean()) { + // ensure we index at least a document with long between 0 and 10 + if (i == 0 || random().nextBoolean()) { doc.add(new LongPoint("long", i)); doc.add(new NumericDocValuesField("long", i)); doc.add(new StringField("string", "value", Store.NO));