Skip to content

Commit 335e5bf

Browse files
Revert "Merge branch 'master' into GODRIVER-3493"
This reverts commit a35b7c7, reversing changes made to 8cbcd50.
1 parent 3b40ce0 commit 335e5bf

13 files changed

+232
-257
lines changed

bson/bson_corpus_spec_test.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,11 @@ func runTest(t *testing.T, file string) {
275275
content, err := os.ReadFile(filepath)
276276
require.NoError(t, err)
277277

278-
t.Run(file, func(t *testing.T) {
278+
// Remove ".json" from filename.
279+
file = file[:len(file)-5]
280+
testName := "bson_corpus--" + file
281+
282+
t.Run(testName, func(t *testing.T) {
279283
var test testCase
280284
require.NoError(t, json.Unmarshal(content, &test))
281285

@@ -425,7 +429,7 @@ func runTest(t *testing.T, file string) {
425429
})
426430
}
427431

428-
func TestBSONCorpus(t *testing.T) {
432+
func Test_BsonCorpus(t *testing.T) {
429433
jsonFiles, err := findJSONFilesInDir(dataDir)
430434
require.NoErrorf(t, err, "error finding JSON files in %s: %v", dataDir, err)
431435

bson/bson_test.go

+4-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ package bson
99
import (
1010
"bytes"
1111
"encoding/json"
12-
"errors"
1312
"fmt"
1413
"reflect"
1514
"strconv"
@@ -457,14 +456,13 @@ func TestD_UnmarshalJSON(t *testing.T) {
457456
want := json.Unmarshal([]byte(tc.test), &a)
458457
var b D
459458
got := json.Unmarshal([]byte(tc.test), &b)
460-
w := new(json.UnmarshalTypeError)
461-
if errors.As(want, &w) {
459+
switch w := want.(type) {
460+
case *json.UnmarshalTypeError:
462461
w.Type = reflect.TypeOf(b)
463462
require.IsType(t, want, got)
464-
g := new(json.UnmarshalTypeError)
465-
assert.True(t, errors.As(got, &g))
463+
g := got.(*json.UnmarshalTypeError)
466464
assert.Equal(t, w, g)
467-
} else {
465+
default:
468466
assert.Equal(t, want, got)
469467
}
470468
})

bson/registry_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -369,8 +369,7 @@ func TestRegistry(t *testing.T) {
369369
t.Parallel()
370370

371371
wanterr := tc.wanterr
372-
var ene errNoEncoder
373-
if errors.As(tc.wanterr, &ene) {
372+
if ene, ok := tc.wanterr.(errNoEncoder); ok {
374373
wanterr = errNoDecoder(ene)
375374
}
376375

internal/integration/unified/unified_spec_runner.go

+68-3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,71 @@ import (
2424
)
2525

2626
var (
27+
skippedTests = map[string]string{
28+
// GODRIVER-1773: This test runs a "find" with limit=4 and batchSize=3. It expects batchSize values of three for
29+
// the "find" and one for the "getMore", but we send three for both.
30+
"A successful find event with a getmore and the server kills the cursor (<= 4.4)": "See GODRIVER-1773",
31+
32+
// GODRIVER-2577: The following spec tests require canceling ops immediately, but the current logic clears pools
33+
// and cancels in-progress ops after two the heartbeat failures.
34+
"Connection pool clear uses interruptInUseConnections=true after monitor timeout": "Godriver clears after multiple timeout",
35+
"Error returned from connection pool clear with interruptInUseConnections=true is retryable": "Godriver clears after multiple timeout",
36+
"Error returned from connection pool clear with interruptInUseConnections=true is retryable for write": "Godriver clears after multiple timeout",
37+
38+
// TODO(GODRIVER-2843): Fix and unskip these test cases.
39+
"Find operation with snapshot": "Test fails frequently. See GODRIVER-2843",
40+
"Write commands with snapshot session do not affect snapshot reads": "Test fails frequently. See GODRIVER-2843",
41+
42+
// TODO(GODRIVER-3043): Avoid Appending Write/Read Concern in Atlas Search
43+
// Index Helper Commands.
44+
"dropSearchIndex ignores read and write concern": "Sync GODRIVER-3074, but skip testing bug GODRIVER-3043",
45+
"listSearchIndexes ignores read and write concern": "Sync GODRIVER-3074, but skip testing bug GODRIVER-3043",
46+
"updateSearchIndex ignores the read and write concern": "Sync GODRIVER-3074, but skip testing bug GODRIVER-3043",
47+
48+
// TODO(DRIVERS-2829): Create CSOT Legacy Timeout Analogues and Compatibility Field
49+
"Reset server and pool after network timeout error during authentication": "Uses unsupported socketTimeoutMS",
50+
"Ignore network timeout error on find": "Uses unsupported socketTimeoutMS",
51+
"A successful find with options": "Uses unsupported maxTimeMS",
52+
"estimatedDocumentCount with maxTimeMS": "Uses unsupported maxTimeMS",
53+
"supports configuring getMore maxTimeMS": "Uses unsupported maxTimeMS",
54+
55+
// TODO(GODRIVER-3137): Implement Gossip cluster time"
56+
"unpin after TransientTransactionError error on commit": "Implement GODRIVER-3137",
57+
58+
// TODO(GODRIVER-3034): Drivers should unpin connections when ending a session
59+
"unpin on successful abort": "Implement GODRIVER-3034",
60+
"unpin after non-transient error on abort": "Implement GODRIVER-3034",
61+
"unpin after TransientTransactionError error on abort": "Implement GODRIVER-3034",
62+
"unpin when a new transaction is started": "Implement GODRIVER-3034",
63+
"unpin when a non-transaction write operation uses a session": "Implement GODRIVER-3034",
64+
"unpin when a non-transaction read operation uses a session": "Implement GODRIVER-3034",
65+
66+
// DRIVERS-2722: Setting "maxTimeMS" on a command that creates a cursor
67+
// also limits the lifetime of the cursor. That may be surprising to
68+
// users, so omit "maxTimeMS" from operations that return user-managed
69+
// cursors.
70+
"timeoutMS can be overridden for a find": "maxTimeMS is disabled on find and aggregate. See DRIVERS-2722.",
71+
"timeoutMS can be configured for an operation - find on collection": "maxTimeMS is disabled on find and aggregate. See DRIVERS-2722.",
72+
"timeoutMS can be configured for an operation - aggregate on collection": "maxTimeMS is disabled on find and aggregate. See DRIVERS-2722.",
73+
"timeoutMS can be configured for an operation - aggregate on database": "maxTimeMS is disabled on find and aggregate. See DRIVERS-2722.",
74+
"timeoutMS can be configured on a MongoClient - find on collection": "maxTimeMS is disabled on find and aggregate. See DRIVERS-2722.",
75+
"timeoutMS can be configured on a MongoClient - aggregate on collection": "maxTimeMS is disabled on find and aggregate. See DRIVERS-2722.",
76+
"timeoutMS can be configured on a MongoClient - aggregate on database": "maxTimeMS is disabled on find and aggregate. See DRIVERS-2722.",
77+
"operation is retried multiple times for non-zero timeoutMS - find on collection": "maxTimeMS is disabled on find and aggregate. See DRIVERS-2722.",
78+
"operation is retried multiple times for non-zero timeoutMS - aggregate on collection": "maxTimeMS is disabled on find and aggregate. See DRIVERS-2722.",
79+
"operation is retried multiple times for non-zero timeoutMS - aggregate on database": "maxTimeMS is disabled on find and aggregate. See DRIVERS-2722.",
80+
"timeoutMS applied to find command": "maxTimeMS is disabled on find and aggregate. See DRIVERS-2722.",
81+
82+
// DRIVERS-2953: This test requires that the driver sends a "getMore"
83+
// with "maxTimeMS" set. However, "getMore" can only include "maxTimeMS"
84+
// for tailable awaitData cursors. Including "maxTimeMS" on "getMore"
85+
// for any other cursor type results in a server error:
86+
//
87+
// (BadValue) cannot set maxTimeMS on getMore command for a non-awaitData cursor
88+
//
89+
"Non-tailable cursor lifetime remaining timeoutMS applied to getMore if timeoutMode is unset": "maxTimeMS can't be set on a getMore. See DRIVERS-2953",
90+
}
91+
2792
logMessageValidatorTimeout = 10 * time.Millisecond
2893
lowHeartbeatFrequency = 500 * time.Millisecond
2994
)
@@ -106,8 +171,6 @@ func runTestFile(t *testing.T, filepath string, expectValidFail bool, opts ...*O
106171
CreateClient(false)
107172

108173
mt.RunOpts(testCase.Description, mtOpts, func(mt *mtest.T) {
109-
spectest.CheckSkip(mt.T)
110-
111174
// Skip CSOT spec tests when SKIP_CSOT_TESTS=true. In Evergreen, we
112175
// typically set that environment variable on Windows and macOS
113176
// because the CSOT spec tests are unreliable on those hosts.
@@ -123,7 +186,6 @@ func runTestFile(t *testing.T, filepath string, expectValidFail bool, opts ...*O
123186
}
124187
}
125188
}()
126-
127189
err := testCase.Run(mt)
128190
if expectValidFail {
129191
if err != nil {
@@ -223,6 +285,9 @@ func (tc *TestCase) Run(ls LoggerSkipper) error {
223285
if tc.SkipReason != nil {
224286
ls.Skipf("skipping for reason: %q", *tc.SkipReason)
225287
}
288+
if skipReason, ok := skippedTests[tc.Description]; ok {
289+
ls.Skipf("skipping due to known failure: %q", skipReason)
290+
}
226291

227292
// Validate that we support the schema declared by the test file before attempting to use its contents.
228293
if err := checkSchemaVersion(tc.schemaVersion); err != nil {

internal/integration/unified_spec_test.go

+21-6
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import (
2727
"go.mongodb.org/mongo-driver/v2/internal/failpoint"
2828
"go.mongodb.org/mongo-driver/v2/internal/integration/mtest"
2929
"go.mongodb.org/mongo-driver/v2/internal/integtest"
30-
"go.mongodb.org/mongo-driver/v2/internal/spectest"
3130
"go.mongodb.org/mongo-driver/v2/mongo"
3231
"go.mongodb.org/mongo-driver/v2/mongo/address"
3332
"go.mongodb.org/mongo-driver/v2/mongo/options"
@@ -38,11 +37,26 @@ import (
3837
)
3938

4039
const (
41-
gridFSFiles = "fs.files"
42-
gridFSChunks = "fs.chunks"
40+
gridFSFiles = "fs.files"
41+
gridFSChunks = "fs.chunks"
42+
spec1403SkipReason = "servers less than 4.2 do not have mongocryptd; see SPEC-1403"
43+
godriver2123SkipReason = "failpoints and timeouts together cause failures; see GODRIVER-2123"
4344
)
4445

45-
var defaultHeartbeatInterval = 500 * time.Millisecond
46+
var (
47+
defaultHeartbeatInterval = 500 * time.Millisecond
48+
skippedTestDescriptions = map[string]string{
49+
// SPEC-1403: This test checks to see if the correct error is thrown when auto encrypting with a server < 4.2.
50+
// Currently, the test will fail because a server < 4.2 wouldn't have mongocryptd, so Client construction
51+
// would fail with a mongocryptd spawn error.
52+
"operation fails with maxWireVersion < 8": spec1403SkipReason,
53+
// GODRIVER-2123: The two tests below use a failpoint and a socket or server selection timeout.
54+
// The timeout causes the eventual clearing of the failpoint in the test runner to fail with an
55+
// i/o timeout.
56+
"Ignore network timeout error on find": godriver2123SkipReason,
57+
"Network error on minPoolSize background creation": godriver2123SkipReason,
58+
}
59+
)
4660

4761
type testFile struct {
4862
RunOn []mtest.RunOnBlock `bson:"runOn"`
@@ -240,11 +254,12 @@ func runSpecTestCase(mt *mtest.T, test *testCase, testFile testFile) {
240254

241255
// Start the test without setting client options so the setup will be done with a default client.
242256
mt.RunOpts(test.Description, opts, func(mt *mtest.T) {
243-
spectest.CheckSkip(mt.T)
244-
245257
if len(test.SkipReason) > 0 {
246258
mt.Skip(test.SkipReason)
247259
}
260+
if skipReason, ok := skippedTestDescriptions[test.Description]; ok {
261+
mt.Skipf("skipping due to known failure: %v", skipReason)
262+
}
248263

249264
// work around for SERVER-39704: run a non-transactional distinct against each shard in a sharded cluster
250265
if mtest.ClusterTopologyKind() == mtest.Sharded && test.Description == "distinct" {

internal/serverselector/server_selector_test.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,11 @@ func runTest(t *testing.T, testsDir string, directory string, filename string) {
296296
content, err := ioutil.ReadFile(filepath)
297297
require.NoError(t, err)
298298

299-
t.Run(directory+"/"+filename, func(t *testing.T) {
299+
// Remove ".json" from filename.
300+
filename = filename[:len(filename)-5]
301+
testName := directory + "/" + filename + ":"
302+
303+
t.Run(testName, func(t *testing.T) {
300304
var test testCase
301305
require.NoError(t, bson.UnmarshalExtJSON(content, true, &test))
302306

0 commit comments

Comments
 (0)