Skip to content

Commit 13921be

Browse files
christophstroblmp911de
authored andcommitted
Retry flakey vector search tests.
Upgrade junit-pioneer along the way
1 parent 8f7fef4 commit 13921be

File tree

4 files changed

+21
-18
lines changed

4 files changed

+21
-18
lines changed

spring-data-mongodb/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@
264264
<dependency>
265265
<groupId>org.junit-pioneer</groupId>
266266
<artifactId>junit-pioneer</artifactId>
267-
<version>0.5.3</version>
267+
<version>2.3.0</version>
268268
<scope>test</scope>
269269
</dependency>
270270

spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/ReactiveMongoTemplateIndexTests.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import static org.assertj.core.data.Index.atIndex;
2020
import static org.springframework.data.mongodb.test.util.Assertions.*;
2121

22+
import org.junit.jupiter.api.RepeatedTest;
23+
import org.junitpioneer.jupiter.RetryingTest;
2224
import reactor.core.publisher.Flux;
2325
import reactor.test.StepVerifier;
2426

@@ -30,7 +32,6 @@
3032
import org.bson.Document;
3133
import org.junit.jupiter.api.AfterEach;
3234
import org.junit.jupiter.api.BeforeEach;
33-
import org.junitpioneer.jupiter.RepeatFailedTest;
3435

3536
import org.springframework.dao.DataIntegrityViolationException;
3637
import org.springframework.data.annotation.Id;
@@ -80,7 +81,7 @@ void setUp() {
8081
@AfterEach
8182
void cleanUp() {}
8283

83-
@RepeatFailedTest(3) // DATAMONGO-1444
84+
@RetryingTest(3) // DATAMONGO-1444
8485
void testEnsureIndexShouldCreateIndex() {
8586

8687
Person p1 = new Person("Oliver");
@@ -116,7 +117,7 @@ void testEnsureIndexShouldCreateIndex() {
116117
}).verifyComplete();
117118
}
118119

119-
@RepeatFailedTest(3) // DATAMONGO-1444
120+
@RetryingTest(3) // DATAMONGO-1444
120121
void getIndexInfoShouldReturnCorrectIndex() {
121122

122123
Person p1 = new Person("Oliver");
@@ -146,7 +147,7 @@ void getIndexInfoShouldReturnCorrectIndex() {
146147
}).verifyComplete();
147148
}
148149

149-
@RepeatFailedTest(3) // DATAMONGO-1444, DATAMONGO-2264
150+
@RetryingTest(3) // DATAMONGO-1444, DATAMONGO-2264
150151
void testReadIndexInfoForIndicesCreatedViaMongoShellCommands() {
151152

152153
template.indexOps(Person.class).dropAllIndexes() //
@@ -196,7 +197,7 @@ void testReadIndexInfoForIndicesCreatedViaMongoShellCommands() {
196197
}).verifyComplete();
197198
}
198199

199-
@RepeatFailedTest(3) // DATAMONGO-1928
200+
@RetryingTest(3) // DATAMONGO-1928
200201
void shouldCreateIndexOnAccess() {
201202

202203
template.getCollection("indexedSample").flatMapMany(it -> it.listIndexes(Document.class)) //
@@ -216,7 +217,7 @@ void shouldCreateIndexOnAccess() {
216217
.verifyComplete();
217218
}
218219

219-
@RepeatFailedTest(3) // DATAMONGO-1928, DATAMONGO-2264
220+
@RetryingTest(3) // DATAMONGO-1928, DATAMONGO-2264
220221
void indexCreationShouldFail() throws InterruptedException {
221222

222223
factory.getMongoDatabase() //

spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/messaging/ChangeStreamTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838
import org.junit.jupiter.api.BeforeEach;
3939
import org.junit.jupiter.api.Disabled;
4040
import org.junit.jupiter.api.Test;
41-
import org.junitpioneer.jupiter.RepeatFailedTest;
4241

42+
import org.junitpioneer.jupiter.RetryingTest;
4343
import org.springframework.data.annotation.Id;
4444
import org.springframework.data.mongodb.core.ChangeStreamOptions;
4545
import org.springframework.data.mongodb.core.CollectionOptions;
@@ -195,7 +195,7 @@ void useAggregationToFilterMessages() throws InterruptedException {
195195
assertThat(messageBodies).hasSize(2).doesNotContain(sugarSplashy);
196196
}
197197

198-
@RepeatFailedTest(3) // DATAMONGO-1803
198+
@RetryingTest(3) // DATAMONGO-1803
199199
void mapsTypedAggregationToFilterMessages() throws InterruptedException {
200200

201201
CollectingMessageListener<ChangeStreamDocument<Document>, User> messageListener = new CollectingMessageListener<>();

spring-data-mongodb/src/test/java/org/springframework/data/mongodb/repository/aot/MongoRepositoryContributorTests.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import org.junit.jupiter.api.BeforeAll;
3737
import org.junit.jupiter.api.BeforeEach;
3838
import org.junit.jupiter.api.Test;
39+
import org.junitpioneer.jupiter.RetryingTest;
3940
import org.springframework.beans.factory.annotation.Autowired;
4041
import org.springframework.context.annotation.Bean;
4142
import org.springframework.context.annotation.Configuration;
@@ -143,9 +144,10 @@ private static void initializeVectorIndex() {
143144

144145
// wait for search index to be queryable
145146

146-
Awaitility.await().atMost(Duration.ofSeconds(120)).pollInterval(Duration.ofMillis(200)).until(() -> {
147-
return MongoTestUtils.isSearchIndexReady(indexName, client, DB_NAME, COLLECTION_NAME);
148-
});
147+
Awaitility.await().atLeast(Duration.ofMillis(50)).atMost(Duration.ofSeconds(120))
148+
.pollInterval(Duration.ofMillis(250)).until(() -> {
149+
return MongoTestUtils.isSearchIndexReady(indexName, client, DB_NAME, COLLECTION_NAME);
150+
});
149151

150152
Document $vectorSearch = new Document("$vectorSearch",
151153
new Document("index", indexName).append("limit", 1).append("numCandidates", 20).append("path", "embedding")
@@ -812,7 +814,7 @@ void testNearReturningGeoPage() {
812814
assertThat(page2.hasNext()).isFalse();
813815
}
814816

815-
@Test
817+
@RetryingTest(3)
816818
@EnableIfVectorSearchAvailable(database = DB_NAME, collection = User.class)
817819
void vectorSearchFromAnnotation() {
818820

@@ -824,7 +826,7 @@ void vectorSearchFromAnnotation() {
824826
assertThat(results).hasSize(1);
825827
}
826828

827-
@Test
829+
@RetryingTest(3)
828830
@EnableIfVectorSearchAvailable(database = DB_NAME, collection = User.class)
829831
void vectorSearchWithDerivedQuery() {
830832

@@ -837,7 +839,7 @@ void vectorSearchWithDerivedQuery() {
837839
assertThat(results).hasSize(1);
838840
}
839841

840-
@Test
842+
@RetryingTest(3)
841843
@EnableIfVectorSearchAvailable(database = DB_NAME, collection = User.class)
842844
void vectorSearchReturningResultsAsList() {
843845

@@ -849,7 +851,7 @@ void vectorSearchReturningResultsAsList() {
849851
assertThat(results).hasSize(2);
850852
}
851853

852-
@Test
854+
@RetryingTest(3)
853855
@EnableIfVectorSearchAvailable(database = DB_NAME, collection = User.class)
854856
void vectorSearchWithLimitFromAnnotation() {
855857

@@ -862,7 +864,7 @@ void vectorSearchWithLimitFromAnnotation() {
862864
assertThat(results).hasSize(1);
863865
}
864866

865-
@Test
867+
@RetryingTest(3)
866868
@EnableIfVectorSearchAvailable(database = DB_NAME, collection = User.class)
867869
void vectorSearchWithSorting() {
868870

@@ -875,7 +877,7 @@ void vectorSearchWithSorting() {
875877
assertThat(results).hasSize(2);
876878
}
877879

878-
@Test
880+
@RetryingTest(3)
879881
@EnableIfVectorSearchAvailable(database = DB_NAME, collection = User.class)
880882
void vectorSearchWithLimitFromDerivedQuery() {
881883

0 commit comments

Comments
 (0)