Skip to content

Commit 0261c36

Browse files
authored
GODRIVER-3523 Drop support for MongoDB 4.0. (#2221)
1 parent f01f780 commit 0261c36

File tree

14 files changed

+29
-141
lines changed

14 files changed

+29
-141
lines changed

.evergreen/config.yml

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1741,10 +1741,6 @@ axes:
17411741
display_name: "4.2"
17421742
variables:
17431743
VERSION: "4.2"
1744-
- id: "4.0"
1745-
display_name: "4.0"
1746-
variables:
1747-
VERSION: "4.0"
17481744
- id: "rapid"
17491745
display_name: "rapid"
17501746
variables:
@@ -2170,19 +2166,6 @@ buildvariants:
21702166
tasks:
21712167
- name: ".goleak"
21722168

2173-
- matrix_name: "tests-rhel-40-with-snappy-support"
2174-
tags: ["pullrequest"]
2175-
matrix_spec: { version: ["4.0"], os-ssl-40: ["rhel87-64"] }
2176-
display_name: "${version} ${os-ssl-40}"
2177-
tasks:
2178-
- name: ".test !.enterprise-auth !.zlib !.zstd"
2179-
2180-
- matrix_name: "tests-windows-40-with-snappy-support"
2181-
matrix_spec: { version: ["4.0"], os-ssl-40: ["windows-64"] }
2182-
display_name: "${version} ${os-ssl-40}"
2183-
tasks:
2184-
- name: ".test !.enterprise-auth !.zlib !.zstd"
2185-
21862169
- matrix_name: "tests-rhel-44-plus-zlib-zstd-support"
21872170
tags: ["pullrequest"]
21882171
matrix_spec: { version: ["4.2", "4.4", "5.0", "6.0", "7.0", "8.0"], os-ssl-40: ["rhel87-64"] }

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ The MongoDB Go driver follows [semantic versioning](https://semver.org/) for its
2424

2525
- Go 1.19 or higher. We aim to support the latest versions of Go.
2626
- Go 1.23 or higher is required to run the driver test suite.
27-
- MongoDB 4.0 and higher.
27+
- MongoDB 4.2 and higher.
2828

2929
## Installation
3030

internal/docexamples/examples_test.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,8 @@ func TestDocumentationExamples(t *testing.T) {
131131
docexamples.ChangeStreamExamples(mt.T, csdb)
132132
})
133133

134-
// Causal consistency examples cannot run on 4.0.
135-
// TODO(GODRIVER-2238): Remove version filtering once failures on 4.0 sharded clusters are fixed.
136-
mtOpts = mtest.NewOptions().MinServerVersion("4.2").Topologies(mtest.ReplicaSet)
137-
mt.RunOpts("CausalConsistencyExamples/post4.2", mtOpts, func(mt *mtest.T) {
138-
docexamples.CausalConsistencyExamples(mt.Client)
139-
})
140-
mtOpts = mtest.NewOptions().MaxServerVersion("4.0").Topologies(mtest.ReplicaSet)
141-
mt.RunOpts("CausalConsistencyExamples/pre4.0", mtOpts, func(mt *mtest.T) {
134+
mtOpts = mtest.NewOptions().Topologies(mtest.ReplicaSet)
135+
mt.RunOpts("CausalConsistencyExamples", mtOpts, func(mt *mtest.T) {
142136
docexamples.CausalConsistencyExamples(mt.Client)
143137
})
144138
}

internal/driverutil/description.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
)
2222

2323
const (
24-
MinWireVersion = 7
24+
MinWireVersion = 8
2525
MaxWireVersion = 25
2626
)
2727

internal/integration/change_stream_test.go

Lines changed: 0 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -259,34 +259,6 @@ func TestChangeStream_ReplicaSet(t *testing.T) {
259259
assert.Nil(mt, cs.Err(), "change stream error: %v", cs.Err())
260260
})
261261

262-
startAtOpTimeOpts := mtest.NewOptions().MinServerVersion("4.0").MaxServerVersion("4.0.6")
263-
mt.RunOpts("include startAtOperationTime", startAtOpTimeOpts, func(mt *mtest.T) {
264-
// $changeStream stage for ChangeStream against a server >=4.0 and <4.0.7 that has not received any results yet
265-
// MUST include a startAtOperationTime option when resuming a changestream.
266-
267-
cs, err := mt.Coll.Watch(context.Background(), mongo.Pipeline{})
268-
assert.Nil(mt, err, "Watch error: %v", err)
269-
defer closeStream(cs)
270-
271-
generateEvents(mt, 1)
272-
// kill cursor to force resumable error
273-
killChangeStreamCursor(mt, cs)
274-
275-
mt.ClearEvents()
276-
// change stream should resume once and get new change
277-
assert.True(mt, cs.Next(context.Background()), "expected Next to return true, got false")
278-
// Next should cause getMore, killCursors, and aggregate to run
279-
assert.NotNil(mt, mt.GetStartedEvent(), "expected getMore event, got nil")
280-
assert.NotNil(mt, mt.GetStartedEvent(), "expected killCursors event, got nil")
281-
aggEvent := mt.GetStartedEvent()
282-
assert.NotNil(mt, aggEvent, "expected aggregate event, got nil")
283-
assert.Equal(mt, "aggregate", aggEvent.CommandName, "expected command name 'aggregate', got '%v'", aggEvent.CommandName)
284-
285-
// check for startAtOperationTime in pipeline
286-
csStage := aggEvent.Command.Lookup("pipeline").Array().Index(0).Document() // $changeStream stage
287-
_, err = csStage.Lookup("$changeStream").Document().LookupErr("startAtOperationTime")
288-
assert.Nil(mt, err, "startAtOperationTime not included in aggregate command")
289-
})
290262
mt.RunOpts("decode does not panic", noClientOpts, func(mt *mtest.T) {
291263
testCases := []struct {
292264
name string
@@ -418,53 +390,6 @@ func TestChangeStream_ReplicaSet(t *testing.T) {
418390
})
419391
}
420392
})
421-
422-
noPbrtOpts := mtest.NewOptions().MaxServerVersion("4.0.6")
423-
mt.RunOpts("without PBRT support", noPbrtOpts, func(mt *mtest.T) {
424-
collName := mt.Coll.Name()
425-
dbName := mt.Coll.Database().Name()
426-
cs, err := mt.Coll.Watch(context.Background(), mongo.Pipeline{})
427-
assert.Nil(mt, err, "Watch error: %v", err)
428-
defer closeStream(cs)
429-
430-
compareResumeTokens(mt, cs, nil) // should be no resume token because no PBRT
431-
numEvents := 5
432-
generateEvents(mt, numEvents)
433-
// iterate once to get a resume token
434-
assert.True(mt, cs.Next(context.Background()), "expected Next to return true, got false")
435-
token := cs.ResumeToken()
436-
assert.NotNil(mt, token, "expected resume token, got nil")
437-
438-
testCases := []struct {
439-
name string
440-
opts *options.ChangeStreamOptionsBuilder
441-
iterateStream bool // whether or not resulting change stream should be iterated
442-
initialToken bson.Raw
443-
numDocsExpected int
444-
}{
445-
{"resumeAfter", options.ChangeStream().SetResumeAfter(token), true, token, numEvents - 1},
446-
{"no options", nil, false, nil, 0},
447-
}
448-
for _, tc := range testCases {
449-
mt.Run(tc.name, func(mt *mtest.T) {
450-
coll := mt.Client.Database(dbName).Collection(collName)
451-
cs, err := coll.Watch(context.Background(), mongo.Pipeline{}, tc.opts)
452-
assert.Nil(mt, err, "Watch error: %v", err)
453-
defer closeStream(cs)
454-
455-
compareResumeTokens(mt, cs, tc.initialToken)
456-
if !tc.iterateStream {
457-
return
458-
}
459-
460-
for i := 0; i < tc.numDocsExpected; i++ {
461-
assert.True(mt, cs.Next(context.Background()), "expected Next to return true, got false")
462-
// current resume token should always equal _id of current document
463-
compareResumeTokens(mt, cs, cs.Current.Lookup("_id").Document())
464-
}
465-
})
466-
}
467-
})
468393
})
469394
})
470395
mt.RunOpts("try next", noClientOpts, func(mt *mtest.T) {
@@ -826,17 +751,6 @@ func generateEvents(mt *mtest.T, numEvents int) {
826751
}
827752
}
828753

829-
func killChangeStreamCursor(mt *mtest.T, cs *mongo.ChangeStream) {
830-
mt.Helper()
831-
832-
db := mt.Coll.Database().Client().Database("admin")
833-
err := db.RunCommand(context.Background(), bson.D{
834-
{"killCursors", mt.Coll.Name()},
835-
{"cursors", bson.A{cs.ID()}},
836-
}).Err()
837-
assert.Nil(mt, err, "killCursors error: %v", err)
838-
}
839-
840754
// returns pbrt, operationTime from aggregate command response
841755
func getAggregateResponseInfo(mt *mtest.T) (bson.Raw, bson.Timestamp) {
842756
mt.Helper()

internal/integration/primary_stepdown_test.go

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -55,25 +55,16 @@ func TestConnectionsSurvivePrimaryStepDown(t *testing.T) {
5555
})
5656
mt.RunOpts("server errors", noClientOpts, func(mt *mtest.T) {
5757
testCases := []struct {
58-
name string
59-
minVersion, maxVersion string
60-
errCode int32
61-
poolCleared bool
58+
name string
59+
errCode int32
60+
poolCleared bool
6261
}{
63-
{"notPrimary keep pool", "4.2", "", errorNotPrimary, false},
64-
{"notPrimary reset pool", "4.0", "4.0", errorNotPrimary, true},
65-
{"shutdown in progress reset pool", "4.0", "", errorShutdownInProgress, true},
66-
{"interrupted at shutdown reset pool", "4.0", "", errorInterruptedAtShutdown, true},
62+
{"notPrimary keep pool", errorNotPrimary, false},
63+
{"shutdown in progress reset pool", errorShutdownInProgress, true},
64+
{"interrupted at shutdown reset pool", errorInterruptedAtShutdown, true},
6765
}
6866
for _, tc := range testCases {
69-
opts := mtest.NewOptions()
70-
if tc.minVersion != "" {
71-
opts.MinServerVersion(tc.minVersion)
72-
}
73-
if tc.maxVersion != "" {
74-
opts.MaxServerVersion(tc.maxVersion)
75-
}
76-
mt.RunOpts(tc.name, opts, func(mt *mtest.T) {
67+
mt.Run(tc.name, func(mt *mtest.T) {
7768
tpm := eventtest.NewTestPoolMonitor()
7869
mt.ResetClient(options.Client().
7970
SetRetryWrites(false).

internal/integration/sdam_error_handling_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ func TestSDAMErrorHandling(t *testing.T) {
3636
baseMtOpts := func() *mtest.Options {
3737
mtOpts := mtest.NewOptions().
3838
Topologies(mtest.ReplicaSet, mtest.Single). // Don't run on sharded clusters to avoid complexity of sharded failpoints.
39-
MinServerVersion("4.0"). // 4.0+ is required to use failpoints on replica sets.
4039
ClientOptions(baseClientOpts())
4140

4241
if mtest.ClusterTopologyKind() == mtest.Sharded {
@@ -241,7 +240,6 @@ func TestSDAMErrorHandling(t *testing.T) {
241240
// This causes the SDAM error handling code path to think we've already handled this state change and
242241
// ignore the error because it's stale. To avoid this altogether, we cap the test to <= 4.2.
243242
serverErrorsMtOpts := baseMtOpts().
244-
MinServerVersion("4.0"). // failCommand support
245243
MaxServerVersion("4.2").
246244
ClientOptions(baseClientOpts().SetRetryWrites(false))
247245

internal/spectest/skip.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,18 @@ var skipTests = map[string][]string{
841841
"Support queryable encryption in Client.BulkWrite (GODRIVER-3403)": {
842842
"TestUnifiedSpec/crud/tests/unified/client-bulkWrite-qe.json",
843843
},
844+
845+
// Pre-4.2 SDAM tests
846+
"Pre-4.2 SDAM tests": {
847+
"TestSDAMSpec/errors/pre-42-InterruptedAtShutdown.json",
848+
"TestSDAMSpec/errors/pre-42-InterruptedDueToReplStateChange.json",
849+
"TestSDAMSpec/errors/pre-42-LegacyNotPrimary.json",
850+
"TestSDAMSpec/errors/pre-42-NotPrimaryNoSecondaryOk.json",
851+
"TestSDAMSpec/errors/pre-42-NotPrimaryOrSecondary.json",
852+
"TestSDAMSpec/errors/pre-42-NotWritablePrimary.json",
853+
"TestSDAMSpec/errors/pre-42-PrimarySteppedDown.json",
854+
"TestSDAMSpec/errors/pre-42-ShutdownInProgress.json",
855+
},
844856
}
845857

846858
// CheckSkip checks if the fully-qualified test name matches a list of skipped test names for a given reason.

mongo/options/changestreamoptions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ func (cso *ChangeStreamOptionsBuilder) SetShowExpandedEvents(see bool) *ChangeSt
135135
}
136136

137137
// SetStartAtOperationTime sets the value for the StartAtOperationTime field. If specified, the change stream
138-
// will only return changes that occurred at or after the given timestamp. This MongoDB versions >= 4.0.
138+
// will only return changes that occurred at or after the given timestamp.
139139
// If this is specified, ResumeAfter and StartAfter must not be set.
140140
func (cso *ChangeStreamOptionsBuilder) SetStartAtOperationTime(t *bson.Timestamp) *ChangeStreamOptionsBuilder {
141141
cso.Opts = append(cso.Opts, func(opts *ChangeStreamOptions) error {

mongo/options/listcollectionsoptions.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ func (lc *ListCollectionsOptionsBuilder) SetBatchSize(size int32) *ListCollectio
6565

6666
// SetAuthorizedCollections sets the value for the AuthorizedCollections field. If true, and
6767
// NameOnly is true, limits the documents returned to only contain collections the user is
68-
// authorized to use. The default value is false. This option is only valid for MongoDB server
69-
// versions >= 4.0. Server versions < 4.0 ignore this option.
68+
// authorized to use. The default value is false.
7069
func (lc *ListCollectionsOptionsBuilder) SetAuthorizedCollections(b bool) *ListCollectionsOptionsBuilder {
7170
lc.Opts = append(lc.Opts, func(opts *ListCollectionsOptions) error {
7271
opts.AuthorizedCollections = &b

0 commit comments

Comments
 (0)