From 89ef82dc4a255ef4bfab07351d3ba0839cf225f0 Mon Sep 17 00:00:00 2001 From: Guillaume Smet Date: Tue, 17 Dec 2024 09:37:41 +0100 Subject: [PATCH 1/3] Update version of MongoDB used for testing to 7.0 It is not the latest (8.0 was released in November) but it's probably the most common used and also it's consistent with the version used as a container. Hopefully, this will be compatible with Ubuntu 22 and 24. --- .../src/test/java/io/quarkus/mongodb/MongoTestBase.java | 2 +- .../java/io/quarkus/mongodb/MongoWithReplicasTestBase.java | 3 +-- .../test/java/io/quarkus/mongodb/reactive/MongoTestBase.java | 2 +- .../io/quarkus/mongodb/reactive/MongoWithReplicasTestBase.java | 2 +- .../main/java/io/quarkus/test/mongodb/MongoTestResource.java | 2 +- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/extensions/mongodb-client/deployment/src/test/java/io/quarkus/mongodb/MongoTestBase.java b/extensions/mongodb-client/deployment/src/test/java/io/quarkus/mongodb/MongoTestBase.java index 11ec3e6ed53d1..34844524c8a9e 100644 --- a/extensions/mongodb-client/deployment/src/test/java/io/quarkus/mongodb/MongoTestBase.java +++ b/extensions/mongodb-client/deployment/src/test/java/io/quarkus/mongodb/MongoTestBase.java @@ -42,7 +42,7 @@ public static void startMongoDatabase() throws IOException { String uri = getConfiguredConnectionString(); // This switch allow testing against a running mongo database. if (uri == null) { - Version.Main version = Version.Main.V4_4; + Version.Main version = Version.Main.V7_0; int port = 27018; LOGGER.infof("Starting Mongo %s on port %s", version, port); diff --git a/extensions/mongodb-client/deployment/src/test/java/io/quarkus/mongodb/MongoWithReplicasTestBase.java b/extensions/mongodb-client/deployment/src/test/java/io/quarkus/mongodb/MongoWithReplicasTestBase.java index 56c7417a7ce77..eb123a8432f10 100644 --- a/extensions/mongodb-client/deployment/src/test/java/io/quarkus/mongodb/MongoWithReplicasTestBase.java +++ b/extensions/mongodb-client/deployment/src/test/java/io/quarkus/mongodb/MongoWithReplicasTestBase.java @@ -1,7 +1,6 @@ package io.quarkus.mongodb; import static io.quarkus.mongodb.MongoTestBase.getConfiguredConnectionString; -import static org.awaitility.Awaitility.await; import static org.awaitility.Durations.ONE_MINUTE; import static org.awaitility.Durations.ONE_SECOND; @@ -47,7 +46,7 @@ public static void startMongoDatabase() { // This switch allow testing against a running mongo database. if (uri == null) { - startedServers = startReplicaSet(Version.Main.V4_4, 27018, "test001"); + startedServers = startReplicaSet(Version.Main.V7_0, 27018, "test001"); } else { LOGGER.infof("Using existing Mongo %s", uri); } diff --git a/extensions/mongodb-client/runtime/src/test/java/io/quarkus/mongodb/reactive/MongoTestBase.java b/extensions/mongodb-client/runtime/src/test/java/io/quarkus/mongodb/reactive/MongoTestBase.java index e47ac6b585c9b..03e75e7b7bfaa 100644 --- a/extensions/mongodb-client/runtime/src/test/java/io/quarkus/mongodb/reactive/MongoTestBase.java +++ b/extensions/mongodb-client/runtime/src/test/java/io/quarkus/mongodb/reactive/MongoTestBase.java @@ -55,7 +55,7 @@ public static void startMongoDatabase() throws IOException { String uri = getConfiguredConnectionString(); // This switch allow testing against a running mongo database. if (uri == null) { - Version.Main version = Version.Main.V4_4; + Version.Main version = Version.Main.V7_0; int port = 27018; LOGGER.infof("Starting Mongo %s on port %s", version, port); diff --git a/extensions/mongodb-client/runtime/src/test/java/io/quarkus/mongodb/reactive/MongoWithReplicasTestBase.java b/extensions/mongodb-client/runtime/src/test/java/io/quarkus/mongodb/reactive/MongoWithReplicasTestBase.java index 5aae65b71a4a7..391e1c52dd091 100644 --- a/extensions/mongodb-client/runtime/src/test/java/io/quarkus/mongodb/reactive/MongoWithReplicasTestBase.java +++ b/extensions/mongodb-client/runtime/src/test/java/io/quarkus/mongodb/reactive/MongoWithReplicasTestBase.java @@ -46,7 +46,7 @@ public static void startMongoDatabase() { // This switch allow testing against a running mongo database. if (uri == null) { - startedServers = startReplicaSet(Version.Main.V4_4, 27018, "test001"); + startedServers = startReplicaSet(Version.Main.V7_0, 27018, "test001"); } else { LOGGER.infof("Using existing Mongo %s", uri); } diff --git a/test-framework/mongodb/src/main/java/io/quarkus/test/mongodb/MongoTestResource.java b/test-framework/mongodb/src/main/java/io/quarkus/test/mongodb/MongoTestResource.java index a8ca2e2ee3186..860474515a477 100644 --- a/test-framework/mongodb/src/main/java/io/quarkus/test/mongodb/MongoTestResource.java +++ b/test-framework/mongodb/src/main/java/io/quarkus/test/mongodb/MongoTestResource.java @@ -39,7 +39,7 @@ public static IFeatureAwareVersion version(Map initArgs) { return versionArg. map(Version.Main::valueOf) .orElseGet(() -> versionArg.map( versionStr -> Versions.withFeatures(de.flapdoodle.embed.process.distribution.Version.of(versionStr))) - .orElse(Version.Main.V4_4)); + .orElse(Version.Main.V7_0)); } public static void forceExtendedSocketOptionsClassInit() { From 4593572e4fde95574f2b07b149b1dc6169f26f2e Mon Sep 17 00:00:00 2001 From: Guillaume Smet Date: Wed, 18 Dec 2024 16:28:07 +0100 Subject: [PATCH 2/3] Raise stop timeout hoping it will solve the Windows issue... --- .../src/test/java/io/quarkus/mongodb/MongoTestBase.java | 4 ++++ .../java/io/quarkus/mongodb/MongoWithReplicasTestBase.java | 6 +++++- .../java/io/quarkus/mongodb/reactive/MongoTestBase.java | 4 ++++ .../quarkus/mongodb/reactive/MongoWithReplicasTestBase.java | 6 +++++- .../java/io/quarkus/test/mongodb/MongoTestResource.java | 3 +++ 5 files changed, 21 insertions(+), 2 deletions(-) diff --git a/extensions/mongodb-client/deployment/src/test/java/io/quarkus/mongodb/MongoTestBase.java b/extensions/mongodb-client/deployment/src/test/java/io/quarkus/mongodb/MongoTestBase.java index 34844524c8a9e..c7359fa000824 100644 --- a/extensions/mongodb-client/deployment/src/test/java/io/quarkus/mongodb/MongoTestBase.java +++ b/extensions/mongodb-client/deployment/src/test/java/io/quarkus/mongodb/MongoTestBase.java @@ -11,6 +11,7 @@ import de.flapdoodle.embed.mongo.distribution.Version; import de.flapdoodle.embed.mongo.transitions.Mongod; import de.flapdoodle.embed.mongo.transitions.RunningMongodProcess; +import de.flapdoodle.embed.process.types.ProcessConfig; import de.flapdoodle.reverse.TransitionWalker; import de.flapdoodle.reverse.transitions.Start; @@ -53,6 +54,9 @@ public static void startMongoDatabase() throws IOException { .build())) .withMongodArguments(Start.to(MongodArguments.class) .initializedWith(MongodArguments.defaults().withUseNoJournal(false))) + .withProcessConfig( + Start.to(ProcessConfig.class) + .initializedWith(ProcessConfig.defaults().withStopTimeoutInMillis(15_000))) .start(version); } else { diff --git a/extensions/mongodb-client/deployment/src/test/java/io/quarkus/mongodb/MongoWithReplicasTestBase.java b/extensions/mongodb-client/deployment/src/test/java/io/quarkus/mongodb/MongoWithReplicasTestBase.java index eb123a8432f10..d2c39cc1e6e12 100644 --- a/extensions/mongodb-client/deployment/src/test/java/io/quarkus/mongodb/MongoWithReplicasTestBase.java +++ b/extensions/mongodb-client/deployment/src/test/java/io/quarkus/mongodb/MongoWithReplicasTestBase.java @@ -31,6 +31,7 @@ import de.flapdoodle.embed.mongo.transitions.Mongod; import de.flapdoodle.embed.mongo.transitions.RunningMongodProcess; import de.flapdoodle.embed.process.io.ProcessOutput; +import de.flapdoodle.embed.process.types.ProcessConfig; import de.flapdoodle.reverse.TransitionWalker; import de.flapdoodle.reverse.transitions.Start; @@ -92,7 +93,10 @@ private static Mongod mongodWithPort(int port, String replicaSet) { .withProcessOutput(Start.to(ProcessOutput.class).initializedWith(ProcessOutput.silent())) .withMongodArguments(Start.to(MongodArguments.class).initializedWith( MongodArguments.defaults().withArgs(Map.of("--replSet", replicaSet)).withSyncDelay(10) - .withUseSmallFiles(true).withUseNoJournal(false))); + .withUseSmallFiles(true).withUseNoJournal(false))) + .withProcessConfig( + Start.to(ProcessConfig.class) + .initializedWith(ProcessConfig.defaults().withStopTimeoutInMillis(15_000))); } @AfterAll diff --git a/extensions/mongodb-client/runtime/src/test/java/io/quarkus/mongodb/reactive/MongoTestBase.java b/extensions/mongodb-client/runtime/src/test/java/io/quarkus/mongodb/reactive/MongoTestBase.java index 03e75e7b7bfaa..a153208a266e5 100644 --- a/extensions/mongodb-client/runtime/src/test/java/io/quarkus/mongodb/reactive/MongoTestBase.java +++ b/extensions/mongodb-client/runtime/src/test/java/io/quarkus/mongodb/reactive/MongoTestBase.java @@ -21,6 +21,7 @@ import de.flapdoodle.embed.mongo.distribution.Version; import de.flapdoodle.embed.mongo.transitions.Mongod; import de.flapdoodle.embed.mongo.transitions.RunningMongodProcess; +import de.flapdoodle.embed.process.types.ProcessConfig; import de.flapdoodle.reverse.TransitionWalker; import de.flapdoodle.reverse.transitions.Start; import io.smallrye.mutiny.Uni; @@ -66,6 +67,9 @@ public static void startMongoDatabase() throws IOException { .build())) .withMongodArguments(Start.to(MongodArguments.class) .initializedWith(MongodArguments.defaults().withUseNoJournal(false))) + .withProcessConfig( + Start.to(ProcessConfig.class) + .initializedWith(ProcessConfig.defaults().withStopTimeoutInMillis(15_000))) .start(version); } else { diff --git a/extensions/mongodb-client/runtime/src/test/java/io/quarkus/mongodb/reactive/MongoWithReplicasTestBase.java b/extensions/mongodb-client/runtime/src/test/java/io/quarkus/mongodb/reactive/MongoWithReplicasTestBase.java index 391e1c52dd091..a6829f9a95af7 100644 --- a/extensions/mongodb-client/runtime/src/test/java/io/quarkus/mongodb/reactive/MongoWithReplicasTestBase.java +++ b/extensions/mongodb-client/runtime/src/test/java/io/quarkus/mongodb/reactive/MongoWithReplicasTestBase.java @@ -31,6 +31,7 @@ import de.flapdoodle.embed.mongo.transitions.Mongod; import de.flapdoodle.embed.mongo.transitions.RunningMongodProcess; import de.flapdoodle.embed.process.io.ProcessOutput; +import de.flapdoodle.embed.process.types.ProcessConfig; import de.flapdoodle.reverse.TransitionWalker; import de.flapdoodle.reverse.transitions.Start; @@ -92,7 +93,10 @@ private static Mongod mongodWithPort(int port, String replicaSet) { .withProcessOutput(Start.to(ProcessOutput.class).initializedWith(ProcessOutput.silent())) .withMongodArguments(Start.to(MongodArguments.class).initializedWith( MongodArguments.defaults().withArgs(Map.of("--replSet", replicaSet)).withSyncDelay(10) - .withUseSmallFiles(true).withUseNoJournal(false))); + .withUseSmallFiles(true).withUseNoJournal(false))) + .withProcessConfig( + Start.to(ProcessConfig.class) + .initializedWith(ProcessConfig.defaults().withStopTimeoutInMillis(15_000))); } @AfterAll diff --git a/test-framework/mongodb/src/main/java/io/quarkus/test/mongodb/MongoTestResource.java b/test-framework/mongodb/src/main/java/io/quarkus/test/mongodb/MongoTestResource.java index 860474515a477..2481e8b1822f2 100644 --- a/test-framework/mongodb/src/main/java/io/quarkus/test/mongodb/MongoTestResource.java +++ b/test-framework/mongodb/src/main/java/io/quarkus/test/mongodb/MongoTestResource.java @@ -13,6 +13,7 @@ import de.flapdoodle.embed.mongo.distribution.Versions; import de.flapdoodle.embed.mongo.transitions.Mongod; import de.flapdoodle.embed.mongo.transitions.RunningMongodProcess; +import de.flapdoodle.embed.process.types.ProcessConfig; import de.flapdoodle.reverse.TransitionWalker; import de.flapdoodle.reverse.transitions.Start; import io.quarkus.test.common.QuarkusTestResourceLifecycleManager; @@ -68,6 +69,8 @@ public Map start() { .initializedWith(Net.builder().from(Net.defaults()).port(port).build())) .withMongodArguments(Start.to(MongodArguments.class) .initializedWith(MongodArguments.defaults().withUseNoJournal(false))) + .withProcessConfig( + Start.to(ProcessConfig.class).initializedWith(ProcessConfig.defaults().withStopTimeoutInMillis(15_000))) .start(version); return Collections.singletonMap("quarkus.mongodb.hosts", String.format("127.0.0.1:%d", port)); From 01060f2c897984dffe83bcf2ef9b8ead23c605eb Mon Sep 17 00:00:00 2001 From: Guillaume Smet Date: Thu, 26 Dec 2024 14:39:45 +0100 Subject: [PATCH 3/3] Disable tests using replicas on Windows It seems that the replicas are not correctly shut down and it leads to job timeouts. --- .../quarkus/mongodb/DefaultAndNamedMongoClientConfigTest.java | 3 +++ .../java/io/quarkus/mongodb/DefaultMongoClientConfigTest.java | 3 +++ .../test/java/io/quarkus/mongodb/MongoClientConfigTest.java | 3 +++ .../java/io/quarkus/mongodb/NamedMongoClientConfigTest.java | 3 +++ .../io/quarkus/mongodb/NamedReactiveMongoClientConfigTest.java | 3 +++ .../quarkus/mongodb/reactive/ConnectionToReplicaSetTest.java | 3 +++ .../java/io/quarkus/mongodb/reactive/ListDatabaseTest.java | 3 +++ 7 files changed, 21 insertions(+) diff --git a/extensions/mongodb-client/deployment/src/test/java/io/quarkus/mongodb/DefaultAndNamedMongoClientConfigTest.java b/extensions/mongodb-client/deployment/src/test/java/io/quarkus/mongodb/DefaultAndNamedMongoClientConfigTest.java index 9c8d367e1bc4a..61f1c87a8f5b6 100644 --- a/extensions/mongodb-client/deployment/src/test/java/io/quarkus/mongodb/DefaultAndNamedMongoClientConfigTest.java +++ b/extensions/mongodb-client/deployment/src/test/java/io/quarkus/mongodb/DefaultAndNamedMongoClientConfigTest.java @@ -11,6 +11,8 @@ import org.eclipse.microprofile.health.HealthCheckResponse; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledOnOs; +import org.junit.jupiter.api.condition.OS; import org.junit.jupiter.api.extension.RegisterExtension; import com.mongodb.client.MongoClient; @@ -21,6 +23,7 @@ import io.quarkus.mongodb.health.MongoHealthCheck; import io.quarkus.test.QuarkusUnitTest; +@DisabledOnOs(value = OS.WINDOWS, disabledReason = "Flapdoodle doesn't work very well on Windows with replicas") public class DefaultAndNamedMongoClientConfigTest extends MongoWithReplicasTestBase { @RegisterExtension diff --git a/extensions/mongodb-client/deployment/src/test/java/io/quarkus/mongodb/DefaultMongoClientConfigTest.java b/extensions/mongodb-client/deployment/src/test/java/io/quarkus/mongodb/DefaultMongoClientConfigTest.java index 45f9e74bb0a6b..bc9b08b54e5c8 100644 --- a/extensions/mongodb-client/deployment/src/test/java/io/quarkus/mongodb/DefaultMongoClientConfigTest.java +++ b/extensions/mongodb-client/deployment/src/test/java/io/quarkus/mongodb/DefaultMongoClientConfigTest.java @@ -11,6 +11,8 @@ import org.eclipse.microprofile.health.HealthCheckResponse; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledOnOs; +import org.junit.jupiter.api.condition.OS; import org.junit.jupiter.api.extension.RegisterExtension; import com.mongodb.client.MongoClient; @@ -19,6 +21,7 @@ import io.quarkus.mongodb.reactive.ReactiveMongoClient; import io.quarkus.test.QuarkusUnitTest; +@DisabledOnOs(value = OS.WINDOWS, disabledReason = "Flapdoodle doesn't work very well on Windows with replicas") public class DefaultMongoClientConfigTest extends MongoWithReplicasTestBase { @RegisterExtension diff --git a/extensions/mongodb-client/deployment/src/test/java/io/quarkus/mongodb/MongoClientConfigTest.java b/extensions/mongodb-client/deployment/src/test/java/io/quarkus/mongodb/MongoClientConfigTest.java index 3708be970d06e..97161fe578bfb 100644 --- a/extensions/mongodb-client/deployment/src/test/java/io/quarkus/mongodb/MongoClientConfigTest.java +++ b/extensions/mongodb-client/deployment/src/test/java/io/quarkus/mongodb/MongoClientConfigTest.java @@ -8,6 +8,8 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledOnOs; +import org.junit.jupiter.api.condition.OS; import org.junit.jupiter.api.extension.RegisterExtension; import com.mongodb.ReadConcern; @@ -21,6 +23,7 @@ import io.quarkus.mongodb.reactive.ReactiveMongoClient; import io.quarkus.test.QuarkusUnitTest; +@DisabledOnOs(value = OS.WINDOWS, disabledReason = "Flapdoodle doesn't work very well on Windows with replicas") public class MongoClientConfigTest extends MongoWithReplicasTestBase { @RegisterExtension diff --git a/extensions/mongodb-client/deployment/src/test/java/io/quarkus/mongodb/NamedMongoClientConfigTest.java b/extensions/mongodb-client/deployment/src/test/java/io/quarkus/mongodb/NamedMongoClientConfigTest.java index 6dae624333538..39cb46564542d 100644 --- a/extensions/mongodb-client/deployment/src/test/java/io/quarkus/mongodb/NamedMongoClientConfigTest.java +++ b/extensions/mongodb-client/deployment/src/test/java/io/quarkus/mongodb/NamedMongoClientConfigTest.java @@ -13,6 +13,8 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledOnOs; +import org.junit.jupiter.api.condition.OS; import org.junit.jupiter.api.extension.RegisterExtension; import com.mongodb.client.MongoClient; @@ -23,6 +25,7 @@ import io.quarkus.mongodb.health.MongoHealthCheck; import io.quarkus.test.QuarkusUnitTest; +@DisabledOnOs(value = OS.WINDOWS, disabledReason = "Flapdoodle doesn't work very well on Windows with replicas") public class NamedMongoClientConfigTest extends MongoWithReplicasTestBase { @RegisterExtension static final QuarkusUnitTest config = new QuarkusUnitTest() diff --git a/extensions/mongodb-client/deployment/src/test/java/io/quarkus/mongodb/NamedReactiveMongoClientConfigTest.java b/extensions/mongodb-client/deployment/src/test/java/io/quarkus/mongodb/NamedReactiveMongoClientConfigTest.java index a5b2909d53d1d..97129aecc5c13 100644 --- a/extensions/mongodb-client/deployment/src/test/java/io/quarkus/mongodb/NamedReactiveMongoClientConfigTest.java +++ b/extensions/mongodb-client/deployment/src/test/java/io/quarkus/mongodb/NamedReactiveMongoClientConfigTest.java @@ -14,6 +14,8 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledOnOs; +import org.junit.jupiter.api.condition.OS; import org.junit.jupiter.api.extension.RegisterExtension; import com.mongodb.reactivestreams.client.MongoClient; @@ -28,6 +30,7 @@ import io.quarkus.mongodb.reactive.ReactiveMongoClient; import io.quarkus.test.QuarkusUnitTest; +@DisabledOnOs(value = OS.WINDOWS, disabledReason = "Flapdoodle doesn't work very well on Windows with replicas") public class NamedReactiveMongoClientConfigTest extends MongoWithReplicasTestBase { @RegisterExtension diff --git a/extensions/mongodb-client/runtime/src/test/java/io/quarkus/mongodb/reactive/ConnectionToReplicaSetTest.java b/extensions/mongodb-client/runtime/src/test/java/io/quarkus/mongodb/reactive/ConnectionToReplicaSetTest.java index e3970981d685a..fc5320a87048a 100644 --- a/extensions/mongodb-client/runtime/src/test/java/io/quarkus/mongodb/reactive/ConnectionToReplicaSetTest.java +++ b/extensions/mongodb-client/runtime/src/test/java/io/quarkus/mongodb/reactive/ConnectionToReplicaSetTest.java @@ -10,6 +10,8 @@ import org.bson.Document; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledOnOs; +import org.junit.jupiter.api.condition.OS; import com.mongodb.client.model.changestream.FullDocument; import com.mongodb.reactivestreams.client.MongoClients; @@ -17,6 +19,7 @@ import io.quarkus.mongodb.ChangeStreamOptions; import io.quarkus.mongodb.impl.ReactiveMongoClientImpl; +@DisabledOnOs(value = OS.WINDOWS, disabledReason = "Flapdoodle doesn't work very well on Windows with replicas") class ConnectionToReplicaSetTest extends MongoWithReplicasTestBase { private ReactiveMongoClient client; diff --git a/extensions/mongodb-client/runtime/src/test/java/io/quarkus/mongodb/reactive/ListDatabaseTest.java b/extensions/mongodb-client/runtime/src/test/java/io/quarkus/mongodb/reactive/ListDatabaseTest.java index a3c8599cc6df9..2131c874d679f 100644 --- a/extensions/mongodb-client/runtime/src/test/java/io/quarkus/mongodb/reactive/ListDatabaseTest.java +++ b/extensions/mongodb-client/runtime/src/test/java/io/quarkus/mongodb/reactive/ListDatabaseTest.java @@ -8,6 +8,8 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledOnOs; +import org.junit.jupiter.api.condition.OS; import com.mongodb.ClientSessionOptions; import com.mongodb.reactivestreams.client.ClientSession; @@ -15,6 +17,7 @@ import io.quarkus.mongodb.impl.ReactiveMongoClientImpl; +@DisabledOnOs(value = OS.WINDOWS, disabledReason = "Flapdoodle doesn't work very well on Windows with replicas") class ListDatabaseTest extends MongoWithReplicasTestBase { private ReactiveMongoClient client;