Skip to content

Remove support for MongoDB 3.6 #1375

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions .evergreen/.evg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1802,10 +1802,6 @@ axes:
display_name: "4.0"
variables:
VERSION: "4.0"
- id: "3.6"
display_name: "3.6"
variables:
VERSION: "3.6"
- id: os
display_name: OS
values:
Expand Down Expand Up @@ -2223,7 +2219,7 @@ buildvariants:
- name: "test"

- matrix_name: "tests-jdk8-unsecure"
matrix_spec: { auth: "noauth", ssl: "nossl", jdk: "jdk8", version: ["3.6", "4.0", "4.2", "4.4", "5.0", "6.0", "7.0", "latest"],
matrix_spec: { auth: "noauth", ssl: "nossl", jdk: "jdk8", version: ["4.0", "4.2", "4.4", "5.0", "6.0", "7.0", "latest"],
topology: "*", os: "linux" }
display_name: "${version} ${topology} ${auth} ${ssl} ${jdk} ${os} "
tags: ["tests-variant"]
Expand All @@ -2232,7 +2228,7 @@ buildvariants:

- matrix_name: "tests-jdk-secure"
matrix_spec: { auth: "auth", ssl: "ssl", jdk: [ "jdk8", "jdk17", "jdk21"],
version: [ "3.6", "4.0", "4.2", "4.4", "5.0", "6.0", "7.0", "latest" ],
version: ["4.0", "4.2", "4.4", "5.0", "6.0", "7.0", "latest" ],
topology: "*", os: "linux" }
display_name: "${version} ${topology} ${auth} ${ssl} ${jdk} ${os} "
tags: ["tests-variant"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public class ServerDescription {
* The minimum supported driver wire version
* @since 3.8
*/
public static final int MIN_DRIVER_WIRE_VERSION = 6;
public static final int MIN_DRIVER_WIRE_VERSION = 7;
/**
* The maximum supported driver wire version
* @since 3.8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import static com.mongodb.AuthenticationMechanism.SCRAM_SHA_256;
import static com.mongodb.assertions.Assertions.assertNotNull;
import static com.mongodb.assertions.Assertions.isTrueArgument;
import static com.mongodb.internal.operation.ServerVersionHelper.serverIsLessThanVersionFourDotZero;
import static java.lang.String.format;

class DefaultAuthenticator extends Authenticator implements SpeculativeAuthenticator {
Expand All @@ -48,29 +47,19 @@ class DefaultAuthenticator extends Authenticator implements SpeculativeAuthentic

@Override
void authenticate(final InternalConnection connection, final ConnectionDescription connectionDescription) {
if (serverIsLessThanVersionFourDotZero(connectionDescription)) {
new ScramShaAuthenticator(getMongoCredentialWithCache().withMechanism(SCRAM_SHA_1), getClusterConnectionMode(), getServerApi())
.authenticate(connection, connectionDescription);
} else {
try {
setDelegate(connectionDescription);
delegate.authenticate(connection, connectionDescription);
} catch (Exception e) {
throw wrapException(e);
}
try {
setDelegate(connectionDescription);
delegate.authenticate(connection, connectionDescription);
} catch (Exception e) {
throw wrapException(e);
}
}

@Override
void authenticateAsync(final InternalConnection connection, final ConnectionDescription connectionDescription,
final SingleResultCallback<Void> callback) {
if (serverIsLessThanVersionFourDotZero(connectionDescription)) {
new ScramShaAuthenticator(getMongoCredentialWithCache().withMechanism(SCRAM_SHA_1), getClusterConnectionMode(), getServerApi())
.authenticateAsync(connection, connectionDescription, callback);
} else {
setDelegate(connectionDescription);
delegate.authenticateAsync(connection, connectionDescription, callback);
}
setDelegate(connectionDescription);
delegate.authenticateAsync(connection, connectionDescription, callback);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ public final class ServerVersionHelper {
public static final int SIX_DOT_ZERO_WIRE_VERSION = 17;
private static final int SEVEN_DOT_ZERO_WIRE_VERSION = 21;

public static boolean serverIsAtLeastVersionFourDotZero(final ConnectionDescription description) {
return description.getMaxWireVersion() >= FOUR_DOT_ZERO_WIRE_VERSION;
}

public static boolean serverIsAtLeastVersionFourDotTwo(final ConnectionDescription description) {
return description.getMaxWireVersion() >= FOUR_DOT_TWO_WIRE_VERSION;
}
Expand All @@ -49,10 +45,6 @@ public static boolean serverIsAtLeastVersionFiveDotZero(final ConnectionDescript
return description.getMaxWireVersion() >= FIVE_DOT_ZERO_WIRE_VERSION;
}

public static boolean serverIsLessThanVersionFourDotZero(final ConnectionDescription description) {
return description.getMaxWireVersion() < FOUR_DOT_ZERO_WIRE_VERSION;
}

public static boolean serverIsLessThanVersionFourDotTwo(final ConnectionDescription description) {
return description.getMaxWireVersion() < FOUR_DOT_TWO_WIRE_VERSION;
}
Expand Down
14 changes: 4 additions & 10 deletions driver-core/src/test/functional/com/mongodb/ClusterFixture.java
Original file line number Diff line number Diff line change
Expand Up @@ -330,11 +330,8 @@ public static ReadWriteBinding getBinding(final ReadPreference readPreference) {

private static ReadWriteBinding getBinding(final Cluster cluster, final ReadPreference readPreference) {
if (!BINDING_MAP.containsKey(readPreference)) {
ReadWriteBinding binding = new ClusterBinding(cluster, readPreference, ReadConcern.DEFAULT, getServerApi(),
IgnorableRequestContext.INSTANCE);
if (serverVersionAtLeast(3, 6)) {
binding = new SessionBinding(binding);
}
ReadWriteBinding binding = new SessionBinding(new ClusterBinding(cluster, readPreference, ReadConcern.DEFAULT, getServerApi(),
IgnorableRequestContext.INSTANCE));
BINDING_MAP.put(readPreference, binding);
}
return BINDING_MAP.get(readPreference);
Expand Down Expand Up @@ -367,11 +364,8 @@ public static AsyncReadWriteBinding getAsyncBinding(final ReadPreference readPre

public static AsyncReadWriteBinding getAsyncBinding(final Cluster cluster, final ReadPreference readPreference) {
if (!ASYNC_BINDING_MAP.containsKey(readPreference)) {
AsyncReadWriteBinding binding = new AsyncClusterBinding(cluster, readPreference, ReadConcern.DEFAULT, getServerApi(),
IgnorableRequestContext.INSTANCE);
if (serverVersionAtLeast(3, 6)) {
binding = new AsyncSessionBinding(binding);
}
AsyncReadWriteBinding binding = new AsyncSessionBinding(new AsyncClusterBinding(cluster, readPreference, ReadConcern.DEFAULT,
getServerApi(), IgnorableRequestContext.INSTANCE));
ASYNC_BINDING_MAP.put(readPreference, binding);
}
return ASYNC_BINDING_MAP.get(readPreference);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import java.util.Map;
import java.util.concurrent.TimeUnit;

import static com.mongodb.ClusterFixture.serverVersionAtLeast;
import static com.mongodb.client.CrudTestHelper.replaceTypeAssertionWithActual;
import static java.util.Arrays.asList;
import static org.junit.Assert.assertEquals;
Expand Down Expand Up @@ -90,11 +89,9 @@ public static List<CommandEvent> getExpectedEvents(final BsonArray expectedEvent
}

// Not clear whether these global fields should be included, but also not clear how to efficiently exclude them
if (serverVersionAtLeast(3, 6)) {
commandDocument.put("$db", new BsonString(actualDatabaseName));
if (operation != null && operation.containsKey("read_preference")) {
commandDocument.put("$readPreference", operation.getDocument("read_preference"));
}
commandDocument.put("$db", new BsonString(actualDatabaseName));
if (operation != null && operation.containsKey("read_preference")) {
commandDocument.put("$readPreference", operation.getDocument("read_preference"));
}
commandEvent = new CommandStartedEvent(null, 1, 1, null, actualDatabaseName, commandName,
commandDocument);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"b:27017"
],
"minWireVersion": 0,
"maxWireVersion": 6
"maxWireVersion": 21
}
],
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"b:27017"
],
"minWireVersion": 0,
"maxWireVersion": 6
"maxWireVersion": 21
}
]
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"isWritablePrimary": true,
"msg": "isdbgrid",
"minWireVersion": 0,
"maxWireVersion": 6
"maxWireVersion": 21
}
]
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"helloOk": true,
"isWritablePrimary": true,
"minWireVersion": 0,
"maxWireVersion": 6
"maxWireVersion": 21
}
]
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"description": "Standalone with default maxWireVersion of 0 is upgraded to one with maxWireVersion 6",
"description": "Standalone with default maxWireVersion of 0 is upgraded to one with maxWireVersion 21",
"uri": "mongodb://a",
"phases": [
{
Expand Down Expand Up @@ -35,7 +35,7 @@
"helloOk": true,
"isWritablePrimary": true,
"minWireVersion": 0,
"maxWireVersion": 6
"maxWireVersion": 21
}
]
],
Expand Down
2 changes: 1 addition & 1 deletion driver-legacy/src/main/com/mongodb/MapReduceCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ public long getMaxTime(final TimeUnit timeUnit) {
/**
* Sets the max execution time for this command, in the given time unit.
*
* @param maxTime the maximum execution time. A non-zero value requires a server version &gt;= 2.6
* @param maxTime the maximum execution time.
* @param timeUnit the time unit that maxTime is specified in
* @since 2.12.0
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import static com.mongodb.ClusterFixture.enableMaxTimeFailPoint;
import static com.mongodb.ClusterFixture.isDiscoverableReplicaSet;
import static com.mongodb.ClusterFixture.isSharded;
import static com.mongodb.ClusterFixture.serverVersionAtLeast;
import static com.mongodb.connection.ClusterType.REPLICA_SET;
import static java.util.Arrays.asList;
import static java.util.concurrent.TimeUnit.SECONDS;
Expand Down Expand Up @@ -104,7 +103,6 @@ public List<DBObject> prepareData() {

@Test
public void testExplain() {
assumeTrue(serverVersionAtLeast(3, 6));
List<DBObject> pipeline = new ArrayList<>(prepareData());
CommandResult out = collection.explainAggregate(pipeline, AggregationOptions.builder().build());
assertTrue(out.keySet().iterator().hasNext());
Expand Down Expand Up @@ -133,7 +131,6 @@ public void testMaxTime() {
@Test
public void testWriteConcern() {
assumeThat(isDiscoverableReplicaSet(), is(true));
assumeTrue(serverVersionAtLeast(3, 4));
DBCollection collection = database.getCollection("testWriteConcern");
collection.setWriteConcern(new WriteConcern(5));
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import static com.mongodb.ClusterFixture.disableMaxTimeFailPoint;
import static com.mongodb.ClusterFixture.enableMaxTimeFailPoint;
import static com.mongodb.ClusterFixture.isSharded;
import static com.mongodb.ClusterFixture.serverVersionAtLeast;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
Expand Down Expand Up @@ -394,13 +393,7 @@ public void testSettingACommentInsertsCommentIntoProfileCollectionWhenProfilingI
assertEquals(1, profileCollection.count());

DBObject profileDocument = profileCollection.findOne();
if (serverVersionAtLeast(3, 6)) {
assertEquals(expectedComment, ((DBObject) profileDocument.get("command")).get("comment"));
} else if (serverVersionAtLeast(3, 2)) {
assertEquals(expectedComment, ((DBObject) profileDocument.get("query")).get("comment"));
} else {
assertEquals(expectedComment, ((DBObject) profileDocument.get("query")).get("$comment"));
}
assertEquals(expectedComment, ((DBObject) profileDocument.get("command")).get("comment"));
} finally {
database.command(new BasicDBObject("profile", 0));
profileCollection.drop();
Expand Down
2 changes: 0 additions & 2 deletions driver-legacy/src/test/functional/com/mongodb/DBTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import static com.mongodb.ClusterFixture.getBinding;
import static com.mongodb.ClusterFixture.isDiscoverableReplicaSet;
import static com.mongodb.ClusterFixture.isSharded;
import static com.mongodb.ClusterFixture.serverVersionAtLeast;
import static com.mongodb.DBObjectMatchers.hasFields;
import static com.mongodb.DBObjectMatchers.hasSubdocument;
import static com.mongodb.Fixture.getDefaultDatabaseName;
Expand Down Expand Up @@ -162,7 +161,6 @@ public void shouldThrowErrorIfCreatingACappedCollectionWithANegativeSize() {

@Test
public void shouldCreateCollectionWithTheSetCollation() {
assumeThat(serverVersionAtLeast(3, 4), is(true));
// Given
collection.drop();
Collation collation = Collation.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import static com.mongodb.ClusterFixture.enableMaxTimeFailPoint;
import static com.mongodb.ClusterFixture.isDiscoverableReplicaSet;
import static com.mongodb.ClusterFixture.isSharded;
import static com.mongodb.ClusterFixture.serverVersionAtLeast;
import static com.mongodb.ClusterFixture.serverVersionLessThan;
import static com.mongodb.DBObjectMatchers.hasFields;
import static com.mongodb.DBObjectMatchers.hasSubdocument;
Expand All @@ -48,7 +47,6 @@
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.Assume.assumeThat;
import static org.junit.Assume.assumeTrue;

@SuppressWarnings("deprecation")
public class MapReduceTest extends DatabaseTestCase {
Expand Down Expand Up @@ -108,7 +106,6 @@ public void testMapReduceExecutionTimeout() {
@Test
public void testWriteConcern() {
assumeThat(isDiscoverableReplicaSet(), is(true));
assumeTrue(serverVersionAtLeast(3, 4));
DBCollection collection = database.getCollection("testWriteConcernForMapReduce");
collection.insert(new BasicDBObject("x", new String[]{"a", "b"}).append("s", 1));
collection.setWriteConcern(new WriteConcern(5));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,11 @@
import static com.mongodb.reactivestreams.client.Fixture.drop;
import static com.mongodb.reactivestreams.client.Fixture.getDefaultDatabase;
import static com.mongodb.reactivestreams.client.Fixture.getMongoClient;
import static com.mongodb.reactivestreams.client.Fixture.serverVersionAtLeast;
import static java.lang.String.format;
import static java.util.Arrays.asList;
import static java.util.Collections.singletonList;
import static java.util.stream.IntStream.rangeClosed;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
import static org.junit.jupiter.api.DynamicTest.dynamicTest;

public class BatchCursorPublisherErrorTest {
Expand All @@ -49,7 +47,6 @@ public class BatchCursorPublisherErrorTest {

@BeforeEach
public void setup() {
assumeTrue(serverVersionAtLeast(3, 6));
collection = getDefaultDatabase().getCollection("changeStreamsCancellationTest");
Mono.from(collection.insertMany(rangeClosed(1, 11)
.boxed()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import static com.mongodb.reactivestreams.client.Fixture.drop;
import static com.mongodb.reactivestreams.client.Fixture.getDefaultDatabase;
import static com.mongodb.reactivestreams.client.Fixture.isReplicaSet;
import static com.mongodb.reactivestreams.client.Fixture.serverVersionAtLeast;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assumptions.assumeTrue;

Expand All @@ -37,7 +36,7 @@ public class ChangeStreamsCancellationTest {

@BeforeEach
public void setup() {
assumeTrue(isReplicaSet() && serverVersionAtLeast(3, 6));
assumeTrue(isReplicaSet());
collection = getDefaultDatabase().getCollection("changeStreamsCancellationTest");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,17 @@
import java.util.List;

import static com.mongodb.ClusterFixture.TIMEOUT_DURATION;
import static com.mongodb.ClusterFixture.serverVersionAtLeast;
import static com.mongodb.client.CommandMonitoringTestHelper.assertEventsEquality;
import static com.mongodb.reactivestreams.client.Fixture.getDefaultDatabaseName;
import static com.mongodb.reactivestreams.client.Fixture.getMongoClientBuilderFromConnectionString;
import static java.util.Collections.singletonList;
import static org.junit.Assume.assumeTrue;

public class ReadConcernTest {
private TestCommandListener commandListener;
private MongoClient mongoClient;

@Before
public void setUp() {
assumeTrue(canRunTests());
commandListener = new TestCommandListener();
mongoClient = MongoClients.create(getMongoClientBuilderFromConnectionString()
.addCommandListener(commandListener)
Expand Down Expand Up @@ -74,8 +71,4 @@ public void shouldIncludeReadConcernInCommand() throws InterruptedException {
assertEventsEquality(singletonList(new CommandStartedEvent(null, 1, 1, null, getDefaultDatabaseName(), "find", commandDocument)),
events);
}

private boolean canRunTests() {
return serverVersionAtLeast(3, 2);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import static com.mongodb.ClusterFixture.getServerStatus;
import static com.mongodb.ClusterFixture.isDiscoverableReplicaSet;
import static com.mongodb.ClusterFixture.isSharded;
import static com.mongodb.ClusterFixture.serverVersionAtLeast;
import static com.mongodb.ClusterFixture.serverVersionLessThan;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
Expand Down Expand Up @@ -113,6 +112,6 @@ private boolean canRunTests() {

return ((isSharded() || isDiscoverableReplicaSet())
&& storageEngine != null && storageEngine.get("name").equals("mmapv1")
&& serverVersionAtLeast(3, 6) && serverVersionLessThan(4, 2));
&& serverVersionLessThan(4, 2));
}
}
Loading