Skip to content

Commit

Permalink
Merge pull request #45160 from gsmet/test-mongodb-70
Browse files Browse the repository at this point in the history
Update version of MongoDB used for testing to 7.0
  • Loading branch information
gsmet authored Dec 28, 2024
2 parents 283659c + 01060f2 commit df371c2
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -42,7 +43,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);

Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -32,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;

Expand All @@ -47,7 +47,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);
}
Expand Down Expand Up @@ -93,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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@
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;

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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@
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;
import com.mongodb.reactivestreams.client.MongoClients;

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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -55,7 +56,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);

Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -46,7 +47,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);
}
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -39,7 +40,7 @@ public static IFeatureAwareVersion version(Map<String, String> initArgs) {
return versionArg.<IFeatureAwareVersion> 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() {
Expand Down Expand Up @@ -68,6 +69,8 @@ public Map<String, String> 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));
Expand Down

0 comments on commit df371c2

Please sign in to comment.