Skip to content

Commit 69f1257

Browse files
committed
Remove support for MongoDB 4.0
* Remove branching code in the driver based on 4.0 version checks * Remove testing of 4.0 * Clean up tests JAVA-5831
1 parent e1eb156 commit 69f1257

File tree

13 files changed

+25
-144
lines changed

13 files changed

+25
-144
lines changed

.evergreen/.evg.yml

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -599,16 +599,6 @@ functions:
599599
LOGIN_CONTEXT_NAME=${LOGIN_CONTEXT_NAME} \
600600
.evergreen/run-gssapi-auth-test.sh
601601
602-
"run mmapv1 storage test":
603-
- command: shell.exec
604-
type: test
605-
params:
606-
silent: true
607-
working_dir: "src"
608-
script: |
609-
${PREPARE_SHELL}
610-
PROJECT_DIRECTORY=${PROJECT_DIRECTORY} JAVA_VERSION=${JAVA_VERSION} TOPOLOGY=${TOPOLOGY} STORAGE_ENGINE=${STORAGE_ENGINE} MONGODB_URI="${MONGODB_URI}" .evergreen/run-mmapv1-storage-test.sh
611-
612602
run socks5 tests:
613603
- command: shell.exec
614604
type: test
@@ -1577,11 +1567,6 @@ tasks:
15771567
TEST_LAMBDA_DIRECTORY: ${PROJECT_DIRECTORY}/driver-lambda/
15781568
AWS_REGION: us-east-1
15791569

1580-
- name: "mmapv1-storage-test"
1581-
commands:
1582-
- func: "bootstrap mongo-orchestration"
1583-
- func: "run mmapv1 storage test"
1584-
15851570
- name: "test-kms-tls-invalid-cert"
15861571
tags: ["kms-tls"]
15871572
commands:
@@ -1762,10 +1747,6 @@ axes:
17621747
# Multiple mongos instances can be specified in the connection string
17631748
# for this version.
17641749
SAFE_FOR_MULTI_MONGOS: true
1765-
- id: "4.0"
1766-
display_name: "4.0"
1767-
variables:
1768-
VERSION: "4.0"
17691750
- id: os
17701751
display_name: OS
17711752
values:
@@ -1886,15 +1867,6 @@ axes:
18861867
variables:
18871868
SCALA: "2.13"
18881869

1889-
# Choice of MongoDB storage engine
1890-
- id: storage-engine
1891-
display_name: Storage
1892-
values:
1893-
- id: mmapv1
1894-
display_name: MMAPv1
1895-
variables:
1896-
STORAGE_ENGINE: "mmapv1"
1897-
18981870
- id: api-version
18991871
display_name: API Version
19001872
values:
@@ -2201,7 +2173,7 @@ buildvariants:
22012173
- name: "test-bson-and-crypt"
22022174

22032175
- matrix_name: "tests-jdk8-unsecure"
2204-
matrix_spec: { auth: "noauth", ssl: "nossl", jdk: "jdk8", version: ["4.0", "4.2", "4.4", "5.0", "6.0", "7.0", "8.0", "latest"],
2176+
matrix_spec: { auth: "noauth", ssl: "nossl", jdk: "jdk8", version: ["4.2", "4.4", "5.0", "6.0", "7.0", "8.0", "latest"],
22052177
topology: "*", os: "linux" }
22062178
display_name: "${version} ${topology} ${auth} ${ssl} ${jdk} ${os} "
22072179
tags: ["tests-variant"]
@@ -2213,7 +2185,7 @@ buildvariants:
22132185

22142186
- matrix_name: "tests-jdk-secure"
22152187
matrix_spec: { auth: "auth", ssl: "ssl", jdk: [ "jdk8", "jdk17", "jdk21"],
2216-
version: ["4.0", "4.2", "4.4", "5.0", "6.0", "7.0", "8.0", "latest" ],
2188+
version: ["4.2", "4.4", "5.0", "6.0", "7.0", "8.0", "latest" ],
22172189
topology: "*", os: "linux" }
22182190
display_name: "${version} ${topology} ${auth} ${ssl} ${jdk} ${os} "
22192191
tags: ["tests-variant"]
@@ -2427,12 +2399,6 @@ buildvariants:
24272399
tasks:
24282400
- name: "publish-release"
24292401

2430-
- matrix_name: "tests-storage-engines"
2431-
matrix_spec: { auth: "noauth", ssl: "nossl", jdk: "jdk8", os: "linux", version: ["4.0"], topology: ["replicaset", "sharded-cluster"], storage-engine: "mmapv1" }
2432-
display_name: "${version} Storage ${storage-engine} ${jdk} ${os} ${topology}"
2433-
tasks:
2434-
- name: "mmapv1-storage-test"
2435-
24362402
- matrix_name: "kms-tls-test"
24372403
matrix_spec: { os: "linux", version: [ "5.0" ], topology: ["standalone"] }
24382404
display_name: "CSFLE KMS TLS"

.evergreen/run-mmapv1-storage-test.sh

Lines changed: 0 additions & 24 deletions
This file was deleted.

driver-core/src/main/com/mongodb/connection/ServerDescription.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ public class ServerDescription {
5555
* The minimum supported driver server version
5656
* @since 3.8
5757
*/
58-
public static final String MIN_DRIVER_SERVER_VERSION = "3.6";
58+
public static final String MIN_DRIVER_SERVER_VERSION = "4.2";
5959
/**
6060
* The minimum supported driver wire version
6161
* @since 3.8
6262
*/
63-
public static final int MIN_DRIVER_WIRE_VERSION = 7;
63+
public static final int MIN_DRIVER_WIRE_VERSION = 8;
6464
/**
6565
* The maximum supported driver wire version
6666
* @since 3.8

driver-core/src/main/com/mongodb/internal/connection/CommandMessage.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@
6060
import static com.mongodb.internal.connection.ByteBufBsonDocument.createList;
6161
import static com.mongodb.internal.connection.ByteBufBsonDocument.createOne;
6262
import static com.mongodb.internal.connection.ReadConcernHelper.getReadConcernDocument;
63-
import static com.mongodb.internal.operation.ServerVersionHelper.FOUR_DOT_TWO_WIRE_VERSION;
64-
import static com.mongodb.internal.operation.ServerVersionHelper.FOUR_DOT_ZERO_WIRE_VERSION;
63+
import static com.mongodb.internal.operation.ServerVersionHelper.EARLIEST_WIRE_VERSION;
6564

6665
/**
6766
* A command message that uses OP_MSG or OP_QUERY to send the command.
@@ -346,7 +345,6 @@ private List<BsonElement> getExtraElements(final OperationContext operationConte
346345

347346
assertFalse(sessionContext.hasActiveTransaction() && sessionContext.isSnapshot());
348347
if (sessionContext.hasActiveTransaction()) {
349-
checkServerVersionForTransactionSupport();
350348
extraElements.add(new BsonElement("txnNumber", new BsonInt64(sessionContext.getTransactionNumber())));
351349
if (firstMessageInTransaction) {
352350
extraElements.add(new BsonElement("startTransaction", BsonBoolean.TRUE));
@@ -381,12 +379,6 @@ private void addServerApiElements(final List<BsonElement> extraElements) {
381379
}
382380
}
383381

384-
private void checkServerVersionForTransactionSupport() {
385-
if (getSettings().getMaxWireVersion() < FOUR_DOT_TWO_WIRE_VERSION && getSettings().getServerType() == SHARD_ROUTER) {
386-
throw new MongoClientException("Transactions are not supported by the MongoDB cluster to which this client is connected.");
387-
}
388-
}
389-
390382

391383
private void addReadConcernDocument(final List<BsonElement> extraElements, final SessionContext sessionContext) {
392384
BsonDocument readConcernDocument = getReadConcernDocument(sessionContext, getSettings().getMaxWireVersion());
@@ -416,7 +408,7 @@ private static OpCode getOpCode(final MessageSettings settings, final ClusterCon
416408
}
417409

418410
private static boolean isServerVersionKnown(final MessageSettings settings) {
419-
return settings.getMaxWireVersion() >= FOUR_DOT_ZERO_WIRE_VERSION;
411+
return settings.getMaxWireVersion() >= EARLIEST_WIRE_VERSION;
420412
}
421413

422414
@FunctionalInterface

driver-core/src/main/com/mongodb/internal/connection/DefaultSdamServerDescriptionManager.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ private void handleException(final SdamIssue sdamIssue, final boolean beforeHand
119119
}
120120
if (sdamIssue.relatedToStateChange()) {
121121
updateDescription(sdamIssue.serverDescription());
122-
if (sdamIssue.serverIsLessThanVersionFourDotTwo() || sdamIssue.relatedToShutdown()) {
122+
if (sdamIssue.relatedToShutdown()) {
123123
connectionPool.invalidate(sdamIssue.exception().orElse(null));
124124
}
125125
serverMonitor.connect();
@@ -130,9 +130,6 @@ private void handleException(final SdamIssue sdamIssue, final boolean beforeHand
130130
serverMonitor.cancelCurrentCheck();
131131
} else if (sdamIssue.relatedToWriteConcern() || !sdamIssue.specific()) {
132132
updateDescription(sdamIssue.serverDescription());
133-
if (sdamIssue.serverIsLessThanVersionFourDotTwo()) {
134-
connectionPool.invalidate(sdamIssue.exception().orElse(null));
135-
}
136133
serverMonitor.connect();
137134
}
138135
}

driver-core/src/main/com/mongodb/internal/connection/SdamServerDescriptionManager.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
import static com.mongodb.assertions.Assertions.assertTrue;
3636
import static com.mongodb.internal.connection.ClusterableServer.SHUTDOWN_CODES;
3737
import static com.mongodb.internal.connection.ServerDescriptionHelper.unknownConnectingServerDescription;
38-
import static com.mongodb.internal.operation.ServerVersionHelper.FOUR_DOT_TWO_WIRE_VERSION;
3938

4039
/**
4140
* See the
@@ -117,10 +116,6 @@ ServerDescription serverDescription() {
117116
return unknownConnectingServerDescription(context.serverId(), exception);
118117
}
119118

120-
boolean serverIsLessThanVersionFourDotTwo() {
121-
return context.serverIsLessThanVersionFourDotTwo();
122-
}
123-
124119
boolean stale(final ConnectionPool connectionPool, final ServerDescription currentServerDescription) {
125120
return context.stale(connectionPool) || stale(exception, currentServerDescription);
126121
}
@@ -192,10 +187,6 @@ static final class Context {
192187
this.serverMaxWireVersion = serverMaxWireVersion;
193188
}
194189

195-
private boolean serverIsLessThanVersionFourDotTwo() {
196-
return serverMaxWireVersion < FOUR_DOT_TWO_WIRE_VERSION;
197-
}
198-
199190
private boolean stale(final ConnectionPool connectionPool) {
200191
return connectionPoolGeneration < connectionPool.getGeneration();
201192
}

driver-core/src/main/com/mongodb/internal/operation/OperationHelper.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646

4747
import static com.mongodb.assertions.Assertions.assertNotNull;
4848
import static com.mongodb.internal.operation.ServerVersionHelper.serverIsLessThanVersionFourDotFour;
49-
import static com.mongodb.internal.operation.ServerVersionHelper.serverIsLessThanVersionFourDotTwo;
5049
import static java.lang.String.format;
5150

5251
/**
@@ -70,10 +69,6 @@ private static void validateArrayFilters(final WriteConcern writeConcern) {
7069
private static void validateWriteRequestHint(final ConnectionDescription connectionDescription, final WriteConcern writeConcern,
7170
final WriteRequest request) {
7271
if (!writeConcern.isAcknowledged()) {
73-
if (request instanceof UpdateRequest && serverIsLessThanVersionFourDotTwo(connectionDescription)) {
74-
throw new IllegalArgumentException(format("Hint not supported by wire version: %s",
75-
connectionDescription.getMaxWireVersion()));
76-
}
7772
if (request instanceof DeleteRequest && serverIsLessThanVersionFourDotFour(connectionDescription)) {
7873
throw new IllegalArgumentException(format("Hint not supported by wire version: %s",
7974
connectionDescription.getMaxWireVersion()));
@@ -82,10 +77,6 @@ private static void validateWriteRequestHint(final ConnectionDescription connect
8277
}
8378

8479
static void validateHintForFindAndModify(final ConnectionDescription connectionDescription, final WriteConcern writeConcern) {
85-
if (serverIsLessThanVersionFourDotTwo(connectionDescription)) {
86-
throw new IllegalArgumentException(format("Hint not supported by wire version: %s",
87-
connectionDescription.getMaxWireVersion()));
88-
}
8980
if (!writeConcern.isAcknowledged() && serverIsLessThanVersionFourDotFour(connectionDescription)) {
9081
throw new IllegalArgumentException(format("Hint not supported by wire version: %s",
9182
connectionDescription.getMaxWireVersion()));

driver-core/src/main/com/mongodb/internal/operation/ServerVersionHelper.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,19 @@
2525
public final class ServerVersionHelper {
2626

2727
public static final int MIN_WIRE_VERSION = 0;
28-
public static final int FOUR_DOT_ZERO_WIRE_VERSION = 7;
2928
public static final int FOUR_DOT_TWO_WIRE_VERSION = 8;
3029
public static final int FOUR_DOT_FOUR_WIRE_VERSION = 9;
3130
public static final int FIVE_DOT_ZERO_WIRE_VERSION = 12;
3231
public static final int SIX_DOT_ZERO_WIRE_VERSION = 17;
3332
public static final int SEVEN_DOT_ZERO_WIRE_VERSION = 21;
34-
public static final int LATEST_WIRE_VERSION = SEVEN_DOT_ZERO_WIRE_VERSION;
33+
public static final int EIGHT_DOT_ZERO_WIRE_VERSION = 21;
34+
public static final int EARLIEST_WIRE_VERSION = FOUR_DOT_TWO_WIRE_VERSION;
35+
public static final int LATEST_WIRE_VERSION = EIGHT_DOT_ZERO_WIRE_VERSION;
3536

3637
public static boolean serverIsAtLeastVersionFourDotFour(final ConnectionDescription description) {
3738
return description.getMaxWireVersion() >= FOUR_DOT_FOUR_WIRE_VERSION;
3839
}
3940

40-
public static boolean serverIsLessThanVersionFourDotTwo(final ConnectionDescription description) {
41-
return description.getMaxWireVersion() < FOUR_DOT_TWO_WIRE_VERSION;
42-
}
43-
4441
public static boolean serverIsLessThanVersionFourDotFour(final ConnectionDescription description) {
4542
return description.getMaxWireVersion() < FOUR_DOT_FOUR_WIRE_VERSION;
4643
}

driver-core/src/test/unit/com/mongodb/internal/connection/CommandMessageSpecification.groovy

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
package com.mongodb.internal.connection
1818

19-
import com.mongodb.MongoClientException
19+
2020
import com.mongodb.MongoNamespace
2121
import com.mongodb.ReadConcern
2222
import com.mongodb.ReadPreference
@@ -43,7 +43,6 @@ import spock.lang.Specification
4343
import java.nio.ByteBuffer
4444

4545
import static com.mongodb.internal.connection.SplittablePayload.Type.INSERT
46-
import static com.mongodb.internal.operation.ServerVersionHelper.FOUR_DOT_ZERO_WIRE_VERSION
4746
import static com.mongodb.internal.operation.ServerVersionHelper.LATEST_WIRE_VERSION
4847

4948
/**
@@ -360,30 +359,6 @@ class CommandMessageSpecification extends Specification {
360359
output.close()
361360
}
362361

363-
def 'should throw if wire version and sharded cluster does not support transactions'() {
364-
given:
365-
def messageSettings = MessageSettings.builder().serverType(ServerType.SHARD_ROUTER)
366-
.maxWireVersion(FOUR_DOT_ZERO_WIRE_VERSION).build()
367-
def payload = new SplittablePayload(INSERT, [new BsonDocument('a', new BsonInt32(1))], true, fieldNameValidator)
368-
def message = new CommandMessage(namespace, command, fieldNameValidator, ReadPreference.primary(), messageSettings,
369-
false, payload, ClusterConnectionMode.MULTIPLE, null)
370-
def output = new ByteBufferBsonOutput(new SimpleBufferProvider())
371-
def sessionContext = Stub(SessionContext) {
372-
getReadConcern() >> ReadConcern.DEFAULT
373-
hasActiveTransaction() >> true
374-
}
375-
376-
when:
377-
message.encode(output, new OperationContext(IgnorableRequestContext.INSTANCE, sessionContext,
378-
Stub(TimeoutContext), null))
379-
380-
then:
381-
thrown(MongoClientException)
382-
383-
cleanup:
384-
output.close()
385-
}
386-
387362
private static BsonDocument getCommandDocument(ByteBufNIO byteBuf, ReplyHeader replyHeader) {
388363
new ReplyMessage<BsonDocument>(new ResponseBuffers(replyHeader, byteBuf), new BsonDocumentCodec(), 0).document
389364
}

driver-core/src/test/unit/com/mongodb/internal/connection/CommandMessageTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
import static com.mongodb.MongoClientSettings.getDefaultCodecRegistry;
4949
import static com.mongodb.client.model.bulk.ClientBulkWriteOptions.clientBulkWriteOptions;
5050
import static com.mongodb.internal.mockito.MongoMockito.mock;
51-
import static com.mongodb.internal.operation.ServerVersionHelper.FOUR_DOT_ZERO_WIRE_VERSION;
5251
import static com.mongodb.internal.operation.ServerVersionHelper.LATEST_WIRE_VERSION;
5352
import static java.util.Arrays.asList;
5453
import static java.util.Collections.singletonList;
@@ -69,7 +68,7 @@ void encodeShouldThrowTimeoutExceptionWhenTimeoutContextIsCalled() {
6968
//given
7069
CommandMessage commandMessage = new CommandMessage(NAMESPACE, COMMAND, NoOpFieldNameValidator.INSTANCE, ReadPreference.primary(),
7170
MessageSettings.builder()
72-
.maxWireVersion(FOUR_DOT_ZERO_WIRE_VERSION)
71+
.maxWireVersion(LATEST_WIRE_VERSION)
7372
.serverType(ServerType.REPLICA_SET_SECONDARY)
7473
.sessionSupported(true)
7574
.build(),
@@ -96,7 +95,7 @@ void encodeShouldNotAddExtraElementsFromTimeoutContextWhenConnectedToMongoCrypt(
9695
//given
9796
CommandMessage commandMessage = new CommandMessage(NAMESPACE, COMMAND, NoOpFieldNameValidator.INSTANCE, ReadPreference.primary(),
9897
MessageSettings.builder()
99-
.maxWireVersion(FOUR_DOT_ZERO_WIRE_VERSION)
98+
.maxWireVersion(LATEST_WIRE_VERSION)
10099
.serverType(ServerType.REPLICA_SET_SECONDARY)
101100
.sessionSupported(true)
102101
.cryptd(true)

driver-core/src/test/unit/com/mongodb/internal/connection/ServerDiscoveryAndMonitoringTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.bson.BsonDocument;
2424
import org.bson.BsonNull;
2525
import org.bson.BsonValue;
26+
import org.junit.Before;
2627
import org.junit.Test;
2728
import org.junit.runner.RunWith;
2829
import org.junit.runners.Parameterized;
@@ -39,16 +40,25 @@
3940
import static org.junit.Assert.assertNull;
4041
import static org.junit.Assert.assertTrue;
4142
import static org.junit.Assert.fail;
43+
import static org.junit.Assume.assumeFalse;
4244

4345
// See https://github.com/mongodb/specifications/tree/master/source/server-discovery-and-monitoring/tests
4446
@RunWith(Parameterized.class)
4547
public class ServerDiscoveryAndMonitoringTest extends AbstractServerDiscoveryAndMonitoringTest {
4648

49+
private final String description;
50+
4751
public ServerDiscoveryAndMonitoringTest(final String description, final BsonDocument definition) {
4852
super(definition);
53+
this.description = description;
4954
init(serverAddress -> NO_OP_SERVER_LISTENER, NO_OP_CLUSTER_LISTENER);
5055
}
5156

57+
@Before
58+
public void setUp() {
59+
assumeFalse(description.startsWith("pre-42"));
60+
}
61+
5262
@Test
5363
public void shouldPassAllOutcomes() {
5464
for (BsonValue phase : getDefinition().getArray("phases")) {

0 commit comments

Comments
 (0)