LUCENE-9905: Fix check in TestPerFieldKnnVectorsFormat#testMergeUsesNewFormat

Before the assertion checked if two sets were equal, which resulted in rare
failures. Now we use 'contains' from hamcrest matchers.
This commit is contained in:
Julie Tibshirani 2022-03-18 15:38:30 -07:00
parent 18f9d31608
commit a4b30b4cf4
1 changed files with 3 additions and 2 deletions

View File

@ -16,6 +16,7 @@
*/
package org.apache.lucene.codecs.perfield;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.equalTo;
import java.io.IOException;
@ -154,8 +155,8 @@ public class TestPerFieldKnnVectorsFormat extends BaseKnnVectorsFormatTestCase {
}
// Check that the new format was used while merging
MatcherAssert.assertThat(format1.fieldsWritten, equalTo(Set.of("field1")));
MatcherAssert.assertThat(format2.fieldsWritten, equalTo(Set.of("field2")));
MatcherAssert.assertThat(format1.fieldsWritten, contains("field1"));
MatcherAssert.assertThat(format2.fieldsWritten, contains("field2"));
}
}