From 2fee17ab269d6e6ee0701c7ce9ad2628edf65c9f Mon Sep 17 00:00:00 2001 From: evanchooly Date: Mon, 19 Oct 2026 23:33:27 -0400 Subject: [PATCH 1/2] Test against the requested MongoDB version; skip releases that can't start MongoExtension and withSharding built the image tag from the major version only, so every 8.x matrix entry (8.3.13, 8.2.12, 8.0.34) and the 8.0.0 default ran mongo:8. That tag moved to 8.3.13, which refuses to start on Linux 6.19 and newer (SERVER-121912), failing every test class. The image tag is now the requested version as given, and the default is 8.2, whose current release starts. The build matrix skips the 8.0 and 8.3 lines, whose current releases have the same startup check, until a fixed release ships. --- .github/BuildMatrix.java | 3 ++ .../java/dev/morphia/test/MongoExtension.java | 31 ++++++++++++++++--- .../test/java/dev/morphia/test/TestBase.java | 8 ++--- 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/.github/BuildMatrix.java b/.github/BuildMatrix.java index 9268703569b..30a10ce914b 100755 --- a/.github/BuildMatrix.java +++ b/.github/BuildMatrix.java @@ -34,6 +34,9 @@ public static void main(String... args) throws Exception { .map(Semver::parse) .filter(it -> it.getPreRelease().isEmpty() || it.getPreRelease().get(0).equals("")) .filter(it -> it.isGreaterThanOrEqualTo("7.0.0")) + // the current 8.0 and 8.3 releases refuse to start on Linux 6.19 and newer, which the runners use + // (https://jira.mongodb.org/browse/SERVER-121912). Remove this once a fixed release ships. + .filter(it -> !(it.getMajor() == 8 && (it.getMinor() == 0 || it.getMinor() == 3))) .map(it -> format("'%s'", it)) .collect(Collectors.toList()); System.out.println(result); diff --git a/core/src/test/java/dev/morphia/test/MongoExtension.java b/core/src/test/java/dev/morphia/test/MongoExtension.java index 25e26c175f3..917c4c8b003 100644 --- a/core/src/test/java/dev/morphia/test/MongoExtension.java +++ b/core/src/test/java/dev/morphia/test/MongoExtension.java @@ -10,7 +10,6 @@ import org.junit.jupiter.api.extension.AfterAllCallback; import org.junit.jupiter.api.extension.BeforeAllCallback; import org.junit.jupiter.api.extension.ExtensionContext; -import org.semver4j.Semver; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.testcontainers.containers.MongoDBContainer; @@ -25,21 +24,43 @@ public class MongoExtension implements BeforeAllCallback, AfterAllCallback { private static MongoDBContainer container; private static MongoClient mongoClient; + /** + * The server version to test against when {@code -Dmongodb} isn't given. A version without a patch number uses that + * release line's latest image. Not 8.0 or 8.3: their current releases refuse to start on Linux 6.19 and newer + * (SERVER-121912). + */ + static final String DEFAULT_MONGODB = "8.2"; + + /** + * @return the server version to test against, from {@code -Dmongodb}: a version such as {@code 8.2.12} or + * {@code 8.2}, or {@code local} + */ + static String mongodbVersion() { + return System.getProperty("mongodb", DEFAULT_MONGODB); + } + + /** + * @param version a server version such as {@code 8.2.12}, or {@code 8.2} for that line's latest release + * @return the image for exactly that version + */ + static DockerImageName imageName(String version) { + return DockerImageName.parse("mongo:" + version) + .asCompatibleSubstituteFor("mongo"); + } + @Override public void beforeAll(ExtensionContext context) { synchronized (LOCK) { if (mongoClient != null) { return; } - String mongodb = System.getProperty("mongodb", "8.0.0"); + String mongodb = mongodbVersion(); String connectionString; if ("local".equals(mongodb)) { LOG.info("'local' mongodb property specified. Using local server."); connectionString = "mongodb://localhost:27017/"; } else { - int version = Semver.parse(mongodb).getMajor(); - DockerImageName imageName = DockerImageName.parse("mongo:" + version) - .asCompatibleSubstituteFor("mongo"); + DockerImageName imageName = imageName(mongodb); LOG.info("Running tests using " + imageName); container = new MongoDBContainer(imageName); container.start(); diff --git a/core/src/test/java/dev/morphia/test/TestBase.java b/core/src/test/java/dev/morphia/test/TestBase.java index b714014f85d..99330c12952 100644 --- a/core/src/test/java/dev/morphia/test/TestBase.java +++ b/core/src/test/java/dev/morphia/test/TestBase.java @@ -60,7 +60,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.testcontainers.containers.MongoDBContainer; -import org.testcontainers.utility.DockerImageName; import static com.mongodb.MongoClientSettings.builder; import static dev.morphia.internal.MorphiaInternals.proxyClassesPresent; @@ -267,17 +266,14 @@ protected void withSharding(Runnable body) { var savedDatastore = datastore; var savedDatabase = database; try { - String mongodb = System.getProperty("mongodb", "8.0.0"); + String mongodb = MongoExtension.mongodbVersion(); if ("local".equals(mongodb)) { morphiaConfig = MorphiaConfig.load(); datastore = null; database = null; body.run(); } else { - int version = Semver.parse(mongodb).getMajor(); - DockerImageName imageName = DockerImageName.parse("mongo:" + version) - .asCompatibleSubstituteFor("mongo"); - MongoDBContainer shardedContainer = new MongoDBContainer(imageName).withSharding(); + MongoDBContainer shardedContainer = new MongoDBContainer(MongoExtension.imageName(mongodb)).withSharding(); shardedContainer.start(); try (MongoClient shardedClient = MongoClients.create(builder() .uuidRepresentation(UuidRepresentation.STANDARD) From 495c9173d96bd718cde1528a0b005c7fc0b245a6 Mon Sep 17 00:00:00 2001 From: evanchooly Date: Mon, 19 Oct 2026 23:47:31 -0400 Subject: [PATCH 2/2] Skip only the exact MongoDB releases that can't start Filter 8.0.34 and 8.3.13 by version instead of skipping the whole 8.0 and 8.3 lines, so fixed patch releases are picked up automatically. --- .github/BuildMatrix.java | 6 +++--- core/src/test/java/dev/morphia/test/MongoExtension.java | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/BuildMatrix.java b/.github/BuildMatrix.java index 30a10ce914b..d90ec4bd37e 100755 --- a/.github/BuildMatrix.java +++ b/.github/BuildMatrix.java @@ -34,9 +34,9 @@ public static void main(String... args) throws Exception { .map(Semver::parse) .filter(it -> it.getPreRelease().isEmpty() || it.getPreRelease().get(0).equals("")) .filter(it -> it.isGreaterThanOrEqualTo("7.0.0")) - // the current 8.0 and 8.3 releases refuse to start on Linux 6.19 and newer, which the runners use - // (https://jira.mongodb.org/browse/SERVER-121912). Remove this once a fixed release ships. - .filter(it -> !(it.getMajor() == 8 && (it.getMinor() == 0 || it.getMinor() == 3))) + // these releases refuse to start on Linux 6.19 and newer, which the runners use + // (https://jira.mongodb.org/browse/SERVER-121912). Later patch releases are picked up automatically. + .filter(it -> !it.isEqualTo("8.0.34") && !it.isEqualTo("8.3.13")) .map(it -> format("'%s'", it)) .collect(Collectors.toList()); System.out.println(result); diff --git a/core/src/test/java/dev/morphia/test/MongoExtension.java b/core/src/test/java/dev/morphia/test/MongoExtension.java index 917c4c8b003..15737b0fc28 100644 --- a/core/src/test/java/dev/morphia/test/MongoExtension.java +++ b/core/src/test/java/dev/morphia/test/MongoExtension.java @@ -26,7 +26,7 @@ public class MongoExtension implements BeforeAllCallback, AfterAllCallback { /** * The server version to test against when {@code -Dmongodb} isn't given. A version without a patch number uses that - * release line's latest image. Not 8.0 or 8.3: their current releases refuse to start on Linux 6.19 and newer + * release line's latest image. Not 8.0 or 8.3: 8.0.34 and 8.3.13 refuse to start on Linux 6.19 and newer * (SERVER-121912). */ static final String DEFAULT_MONGODB = "8.2";