Skip to content

Commit 6a504a3

Browse files
authored
Merge pull request #1985 from matthewdale/godriver3445-refactor-skip-by-desc
GODRIVER-3445 Move all logic for skipping spec tests by description into one place.
2 parents 5540d80 + 08c6865 commit 6a504a3

File tree

9 files changed

+249
-209
lines changed

9 files changed

+249
-209
lines changed

Diff for: bson/bson_corpus_spec_test.go

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

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) {
278+
t.Run(file, func(t *testing.T) {
283279
var test testCase
284280
require.NoError(t, json.Unmarshal(content, &test))
285281

@@ -429,7 +425,7 @@ func runTest(t *testing.T, file string) {
429425
})
430426
}
431427

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

Diff for: internal/integration/unified/unified_spec_runner.go

+3-68
Original file line numberDiff line numberDiff line change
@@ -24,71 +24,6 @@ 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-
9227
logMessageValidatorTimeout = 10 * time.Millisecond
9328
lowHeartbeatFrequency = 500 * time.Millisecond
9429
)
@@ -171,6 +106,8 @@ func runTestFile(t *testing.T, filepath string, expectValidFail bool, opts ...*O
171106
CreateClient(false)
172107

173108
mt.RunOpts(testCase.Description, mtOpts, func(mt *mtest.T) {
109+
spectest.CheckSkip(mt.T)
110+
174111
// Skip CSOT spec tests when SKIP_CSOT_TESTS=true. In Evergreen, we
175112
// typically set that environment variable on Windows and macOS
176113
// because the CSOT spec tests are unreliable on those hosts.
@@ -186,6 +123,7 @@ func runTestFile(t *testing.T, filepath string, expectValidFail bool, opts ...*O
186123
}
187124
}
188125
}()
126+
189127
err := testCase.Run(mt)
190128
if expectValidFail {
191129
if err != nil {
@@ -285,9 +223,6 @@ func (tc *TestCase) Run(ls LoggerSkipper) error {
285223
if tc.SkipReason != nil {
286224
ls.Skipf("skipping for reason: %q", *tc.SkipReason)
287225
}
288-
if skipReason, ok := skippedTests[tc.Description]; ok {
289-
ls.Skipf("skipping due to known failure: %q", skipReason)
290-
}
291226

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

Diff for: internal/integration/unified_spec_test.go

+6-21
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ 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"
3031
"go.mongodb.org/mongo-driver/v2/mongo"
3132
"go.mongodb.org/mongo-driver/v2/mongo/address"
3233
"go.mongodb.org/mongo-driver/v2/mongo/options"
@@ -37,26 +38,11 @@ import (
3738
)
3839

3940
const (
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"
41+
gridFSFiles = "fs.files"
42+
gridFSChunks = "fs.chunks"
4443
)
4544

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-
)
45+
var defaultHeartbeatInterval = 500 * time.Millisecond
6046

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

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

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

Diff for: internal/serverselector/server_selector_test.go

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

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

0 commit comments

Comments
 (0)