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.
This commit is contained in:
Quentin Pradet 2021-12-14 13:49:58 +04:00 committed by GitHub
parent 5207aae527
commit 9974f6ac34
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -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));