Skip to content

Commit 903b7db

Browse files
GODRIVER-3445 Add testdata back
1 parent a841fab commit 903b7db

File tree

1,846 files changed

+369869
-28
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,846 files changed

+369869
-28
lines changed

internal/integration/unified/unified_spec_runner.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func runTestDirectory(t *testing.T, directoryPath string, expectValidFail bool)
9090

9191
// runTestFile runs the tests in the given file, with expectValidFail determining whether the tests should expect to pass or fail
9292
func runTestFile(t *testing.T, filepath string, expectValidFail bool, opts ...*Options) {
93-
spectest.CheckSkip(t)
93+
//spectest.CheckSkip(t)
9494
content, err := ioutil.ReadFile(filepath)
9595
assert.Nil(t, err, "ReadFile error for file %q: %v", filepath, err)
9696

internal/integration/unified/unified_spec_test.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,17 @@ package unified
88

99
import (
1010
"context"
11+
"path"
1112
"testing"
1213

1314
"go.mongodb.org/mongo-driver/v2/internal/spectest"
1415
)
1516

1617
var (
18+
nonGitSubmodulePassDirectories = []string{
19+
"unified-test-format/valid-pass",
20+
}
1721
passDirectories = []string{
18-
"unified-test-format/tests/valid-pass",
1922
"versioned-api/tests",
2023
"crud/tests/unified",
2124
"change-streams/tests/unified",
@@ -29,20 +32,21 @@ var (
2932
"retryable-reads/tests/unified",
3033
"retryable-writes/tests/unified",
3134
"client-side-encryption/tests/unified",
32-
"client-side-operations-timeout/tests",
35+
//"client-side-operations-timeout/tests",
3336
"gridfs/tests",
3437
"server-selection/tests/logging",
3538
"server-discovery-and-monitoring/tests/unified",
3639
"run-command/tests/unified",
3740
"index-management/tests",
38-
"transactions-convenient-api/tests/unified",
3941
"atlas-data-lake-testing/tests/unified",
4042
}
4143
failDirectories = []string{
4244
"unified-test-format/tests/valid-fail",
4345
}
4446
)
4547

48+
const dataDirectory = "../../../testdata"
49+
4650
func TestUnifiedSpec(t *testing.T) {
4751
// Ensure the cluster is in a clean state before test execution begins.
4852
if err := terminateOpenSessions(context.Background()); err != nil {
@@ -55,6 +59,12 @@ func TestUnifiedSpec(t *testing.T) {
5559
})
5660
}
5761

62+
for _, testDir := range nonGitSubmodulePassDirectories {
63+
t.Run(testDir, func(t *testing.T) {
64+
runTestDirectory(t, path.Join(dataDirectory, testDir), false)
65+
})
66+
}
67+
5868
for _, testDir := range failDirectories {
5969
t.Run(testDir, func(t *testing.T) {
6070
runTestDirectory(t, spectest.Path(testDir), true)

internal/integration/unified_spec_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"fmt"
1414
"io/ioutil"
1515
"os"
16+
"path"
1617
"path/filepath"
1718
"reflect"
1819
"sync"
@@ -161,6 +162,12 @@ var directories = []string{
161162
"read-write-concern/tests/operation",
162163
}
163164

165+
var nonGitSubmodulePassDirectories = []string{
166+
"convenient-transactions",
167+
}
168+
169+
const dataPath string = "../../testdata/"
170+
164171
var checkOutcomeOpts = options.Collection().SetReadPreference(readpref.Primary()).SetReadConcern(readconcern.Local())
165172
var specTestRegistry = func() *bson.Registry {
166173
reg := bson.NewRegistry()
@@ -179,6 +186,17 @@ func TestUnifiedSpecs(t *testing.T) {
179186
}
180187
})
181188
}
189+
190+
for _, specDir := range nonGitSubmodulePassDirectories {
191+
t.Run(specDir, func(t *testing.T) {
192+
for _, fileName := range jsonFilesInDir(t, path.Join(dataPath, specDir)) {
193+
fmt.Println(fileName)
194+
t.Run(fileName, func(t *testing.T) {
195+
runSpecTestFile(t, filepath.Join(dataPath, specDir, fileName))
196+
})
197+
}
198+
})
199+
}
182200
}
183201

184202
// specDir: name of directory for a spec in the data/ folder

internal/spectest/skip.go

Lines changed: 62 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,15 @@ var skipTests = map[string][]string{
124124

125125
// TODO: GODRIVER-3167 - Support assertions on topologyDescriptionChangedEvent in expectEvents.
126126
"Implement GODRIVER-3161": {
127-
"TestUnifiedSpec/unified-test-format/tests/valid-pass/expectedEventsForClient-topologyDescriptionChangedEvent.json/can_assert_on_values_of_newDescription_and_previousDescription_fields",
127+
"TestUnifiedSpec/unified-test-format/valid-pass/expectedEventsForClient-topologyDescriptionChangedEvent.json/can_assert_on_values_of_newDescription_and_previousDescription_fields",
128128
},
129129

130130
// TODO: GODRIVER-3409 - Regression test for "number" alias in $$type operator.
131131
"Implement GODRIVER-3409": {
132-
"TestUnifiedSpec/unified-test-format/tests/valid-pass/operator-type-number_alias.json/type_number_alias_matches_int32",
133-
"TestUnifiedSpec/unified-test-format/tests/valid-pass/operator-type-number_alias.json/type_number_alias_matches_int64",
134-
"TestUnifiedSpec/unified-test-format/tests/valid-pass/operator-type-number_alias.json/type_number_alias_matches_double",
135-
"TestUnifiedSpec/unified-test-format/tests/valid-pass/operator-type-number_alias.json/type_number_alias_matches_decimal128",
132+
"TestUnifiedSpec/unified-test-format/valid-pass/operator-type-number_alias.json/type_number_alias_matches_int32",
133+
"TestUnifiedSpec/unified-test-format/valid-pass/operator-type-number_alias.json/type_number_alias_matches_int64",
134+
"TestUnifiedSpec/unified-test-format/valid-pass/operator-type-number_alias.json/type_number_alias_matches_double",
135+
"TestUnifiedSpec/unified-test-format/valid-pass/operator-type-number_alias.json/type_number_alias_matches_decimal128",
136136
},
137137

138138
// TODO: GODRIVER-3143 - Convert CRUD v1 spec tests to unified test format.
@@ -213,21 +213,13 @@ var skipTests = map[string][]string{
213213
"TestUnifiedSpec/transactions/tests/unified/transaction-options.json/readPreference_inherited_from_client",
214214
"TestUnifiedSpec/transactions/tests/unified/transaction-options.json/readPreference_inherited_from_defaultTransactionOptions",
215215
"TestUnifiedSpec/transactions/tests/unified/transaction-options.json/startTransaction_overrides_readPreference",
216-
"TestUnifiedSpec/transactions-convenient-api/tests/unified/callback-retry.json/callback_succeeds_after_multiple_connection_errors",
217-
"TestUnifiedSpec/transactions-convenient-api/tests/unified/callback-retry.json/callback_is_not_retried_after_non-transient_error_(DuplicateKeyError)",
218-
"TestUnifiedSpec/transactions-convenient-api/tests/unified/commit-retry.json/commit_is_not_retried_after_MaxTimeMSExpired_error",
219-
"TestUnifiedSpec/transactions-convenient-api/tests/unified/commit-writeconcernerror.json/commitTransaction_is_not_retried_after_UnknownReplWriteConcern_error",
220-
"TestUnifiedSpec/transactions-convenient-api/tests/unified/commit-writeconcernerror.json/commitTransaction_is_not_retried_after_UnsatisfiableWriteConcern_error",
221-
"TestUnifiedSpec/transactions-convenient-api/tests/unified/commit-writeconcernerror.json/commitTransaction_is_not_retried_after_MaxTimeMSExpired_error",
222-
"TestUnifiedSpec/transactions-convenient-api/tests/unified/commit-retry.json/commitTransaction_retry_only_overwrites_write_concern_w_option",
223216
"TestUnifiedSpec/transactions/tests/unified/retryable-commit.json/commitTransaction_fails_after_Interrupted",
224217
},
225218

226219
// GODRIVER-1773: Tests related to batch size expectation in "find" and "getMore" events.
227220
"Implement GODRIVER-1773": {
228-
229221
"TestUnifiedSpec/command-logging-and-monitoring/tests/monitoring/find.json/A_successful_find_event_with_a_getmore_and_the_server_kills_the_cursor_(<=_4.4)",
230-
"TestUnifiedSpec/unified-test-format/tests/valid-pass/poc-command-monitoring.json/A_successful_find_event_with_a_getmore_and_the_server_kills_the_cursor_(<=_4.4)",
222+
"TestUnifiedSpec/unified-test-format/valid-pass/poc-command-monitoring.json/A_successful_find_event_with_a_getmore_and_the_server_kills_the_cursor_(<=_4.4)",
231223
},
232224

233225
// GODRIVER-2577: Tests require immediate operation canceling, incompatible with current pool clearing logic.
@@ -389,7 +381,7 @@ var skipTests = map[string][]string{
389381

390382
// TODO: GODRIVER-3486 - Support auto encryption in unified tests.
391383
"Implement GODRIVER-3486": {
392-
"TestUnifiedSpec/unified-test-format/tests/valid-pass/poc-queryable-encryption.json/insert,_replace,_and_find_with_queryable_encryption",
384+
"TestUnifiedSpec/unified-test-format/valid-pass/poc-queryable-encryption.json/insert,_replace,_and_find_with_queryable_encryption",
393385
},
394386

395387
// TODO: DRIVERS-3106 - Support auto encryption in unified tests.
@@ -704,8 +696,57 @@ var skipTests = map[string][]string{
704696
// TODO(GODRIVER-2191): Drivers should retry operations if connection
705697
// handshake fails.
706698
"Implement GODRIVER-2191": {
699+
"TestUnifiedSpec/retryable-reads/tests/unified/handshakeError.json/client.listDatabases_succeeds_after_retryable_handshake_network_error",
700+
"TestUnifiedSpec/retryable-reads/tests/unified/handshakeError.json/client.listDatabases_succeeds_after_retryable_handshake_server_error_(ShutdownInProgress)",
701+
"TestUnifiedSpec/retryable-reads/tests/unified/handshakeError.json/client.listDatabaseNames_succeeds_after_retryable_handshake_network_error",
702+
"TestUnifiedSpec/retryable-reads/tests/unified/handshakeError.json/client.listDatabaseNames_succeeds_after_retryable_handshake_server_error_(ShutdownInProgress)",
703+
"TestUnifiedSpec/retryable-reads/tests/unified/handshakeError.json/client.createChangeStream_succeeds_after_retryable_handshake_network_error",
704+
"TestUnifiedSpec/retryable-reads/tests/unified/handshakeError.json/client.createChangeStream_succeeds_after_retryable_handshake_server_error_(ShutdownInProgress)",
705+
"TestUnifiedSpec/retryable-reads/tests/unified/handshakeError.json/database.aggregate_succeeds_after_retryable_handshake_network_error",
706+
"TestUnifiedSpec/retryable-reads/tests/unified/handshakeError.json/database.aggregate_succeeds_after_retryable_handshake_server_error_(ShutdownInProgress)",
707+
"TestUnifiedSpec/retryable-reads/tests/unified/handshakeError.json/database.listCollections_succeeds_after_retryable_handshake_network_error",
708+
"TestUnifiedSpec/retryable-reads/tests/unified/handshakeError.json/database.listCollections_succeeds_after_retryable_handshake_server_error_(ShutdownInProgress)",
709+
"TestUnifiedSpec/retryable-reads/tests/unified/handshakeError.json/database.listCollectionNames_succeeds_after_retryable_handshake_network_error",
710+
"TestUnifiedSpec/retryable-reads/tests/unified/handshakeError.json/database.listCollectionNames_succeeds_after_retryable_handshake_server_error_(ShutdownInProgress)",
711+
"TestUnifiedSpec/retryable-reads/tests/unified/handshakeError.json/database.createChangeStream_succeeds_after_retryable_handshake_network_error",
712+
"TestUnifiedSpec/retryable-reads/tests/unified/handshakeError.json/database.createChangeStream_succeeds_after_retryable_handshake_server_error_(ShutdownInProgress)",
713+
"TestUnifiedSpec/retryable-reads/tests/unified/handshakeError.json/collection.aggregate_succeeds_after_retryable_handshake_network_error",
714+
"TestUnifiedSpec/retryable-reads/tests/unified/handshakeError.json/collection.aggregate_succeeds_after_retryable_handshake_server_error_(ShutdownInProgress)",
715+
"TestUnifiedSpec/retryable-reads/tests/unified/handshakeError.json/collection.countDocuments_succeeds_after_retryable_handshake_network_error",
716+
"TestUnifiedSpec/retryable-reads/tests/unified/handshakeError.json/collection.countDocuments_succeeds_after_retryable_handshake_server_error_(ShutdownInProgress)",
717+
"TestUnifiedSpec/retryable-reads/tests/unified/handshakeError.json/collection.estimatedDocumentCount_succeeds_after_retryable_handshake_network_error",
718+
"TestUnifiedSpec/retryable-reads/tests/unified/handshakeError.json/collection.estimatedDocumentCount_succeeds_after_retryable_handshake_server_error_(ShutdownInProgress)",
719+
"TestUnifiedSpec/retryable-reads/tests/unified/handshakeError.json/collection.distinct_succeeds_after_retryable_handshake_network_error",
720+
"TestUnifiedSpec/retryable-reads/tests/unified/handshakeError.json/collection.distinct_succeeds_after_retryable_handshake_server_error_(ShutdownInProgress)",
721+
"TestUnifiedSpec/retryable-reads/tests/unified/handshakeError.json/collection.find_succeeds_after_retryable_handshake_network_error",
722+
"TestUnifiedSpec/retryable-reads/tests/unified/handshakeError.json/collection.find_succeeds_after_retryable_handshake_server_error_(ShutdownInProgress)",
723+
"TestUnifiedSpec/retryable-reads/tests/unified/handshakeError.json/collection.findOne_succeeds_after_retryable_handshake_network_error",
724+
"TestUnifiedSpec/retryable-reads/tests/unified/handshakeError.json/collection.findOne_succeeds_after_retryable_handshake_server_error_(ShutdownInProgress)",
725+
"TestUnifiedSpec/retryable-reads/tests/unified/handshakeError.json/collection.listIndexes_succeeds_after_retryable_handshake_network_error",
726+
"TestUnifiedSpec/retryable-reads/tests/unified/handshakeError.json/collection.listIndexes_succeeds_after_retryable_handshake_server_error_(ShutdownInProgress)",
727+
"TestUnifiedSpec/retryable-reads/tests/unified/handshakeError.json/collection.createChangeStream_succeeds_after_retryable_handshake_network_error",
728+
"TestUnifiedSpec/retryable-reads/tests/unified/handshakeError.json/collection.createChangeStream_succeeds_after_retryable_handshake_server_error_(ShutdownInProgress)",
707729
"TestUnifiedSpec/retryable-writes/tests/unified/handshakeError.json",
708-
"TestUnifiedSpec/retryable-reads/tests/unified/handshakeError.json",
730+
"TestUnifiedSpec/retryable-writes/tests/unified/handshakeError.json/client.clientBulkWrite_succeeds_after_retryable_handshake_network_error",
731+
"TestUnifiedSpec/retryable-writes/tests/unified/handshakeError.json/client.clientBulkWrite_succeeds_after_retryable_handshake_server_error_(ShutdownInProgress)",
732+
"TestUnifiedSpec/retryable-writes/tests/unified/handshakeError.json/collection.insertOne_succeeds_after_retryable_handshake_network_error",
733+
"TestUnifiedSpec/retryable-writes/tests/unified/handshakeError.json/collection.insertOne_succeeds_after_retryable_handshake_server_error_(ShutdownInProgress)",
734+
"TestUnifiedSpec/retryable-writes/tests/unified/handshakeError.json/collection.insertMany_succeeds_after_retryable_handshake_network_error",
735+
"TestUnifiedSpec/retryable-writes/tests/unified/handshakeError.json/collection.insertMany_succeeds_after_retryable_handshake_server_error_(ShutdownInProgress)",
736+
"TestUnifiedSpec/retryable-writes/tests/unified/handshakeError.json/collection.deleteOne_succeeds_after_retryable_handshake_network_error",
737+
"TestUnifiedSpec/retryable-writes/tests/unified/handshakeError.json/collection.deleteOne_succeeds_after_retryable_handshake_server_error_(ShutdownInProgress)",
738+
"TestUnifiedSpec/retryable-writes/tests/unified/handshakeError.json/collection.replaceOne_succeeds_after_retryable_handshake_network_error",
739+
"TestUnifiedSpec/retryable-writes/tests/unified/handshakeError.json/collection.replaceOne_succeeds_after_retryable_handshake_server_error_(ShutdownInProgress)",
740+
"TestUnifiedSpec/retryable-writes/tests/unified/handshakeError.json/collection.updateOne_succeeds_after_retryable_handshake_network_error",
741+
"TestUnifiedSpec/retryable-writes/tests/unified/handshakeError.json/collection.updateOne_succeeds_after_retryable_handshake_server_error_(ShutdownInProgress)",
742+
"TestUnifiedSpec/retryable-writes/tests/unified/handshakeError.json/collection.findOneAndDelete_succeeds_after_retryable_handshake_network_error",
743+
"TestUnifiedSpec/retryable-writes/tests/unified/handshakeError.json/collection.findOneAndDelete_succeeds_after_retryable_handshake_server_error_(ShutdownInProgress)",
744+
"TestUnifiedSpec/retryable-writes/tests/unified/handshakeError.json/collection.findOneAndReplace_succeeds_after_retryable_handshake_network_error",
745+
"TestUnifiedSpec/retryable-writes/tests/unified/handshakeError.json/collection.findOneAndReplace_succeeds_after_retryable_handshake_server_error_(ShutdownInProgress)",
746+
"TestUnifiedSpec/retryable-writes/tests/unified/handshakeError.json/collection.findOneAndUpdate_succeeds_after_retryable_handshake_network_error",
747+
"TestUnifiedSpec/retryable-writes/tests/unified/handshakeError.json/collection.findOneAndUpdate_succeeds_after_retryable_handshake_server_error_(ShutdownInProgress)",
748+
"TestUnifiedSpec/retryable-writes/tests/unified/handshakeError.json/collection.bulkWrite_succeeds_after_retryable_handshake_network_error",
749+
"TestUnifiedSpec/retryable-writes/tests/unified/handshakeError.json/collection.bulkWrite_succeeds_after_retryable_handshake_server_error_(ShutdownInProgress)",
709750
},
710751

711752
// TODO(GODRIVER-3524): Change streams expanded events present by default in
@@ -714,6 +755,11 @@ var skipTests = map[string][]string{
714755
"TestUnifiedSpec/change-streams/change-streams-disambiguatedPaths.json/disambiguatedPaths_is_not_present_when_showExpandedEvents_is_false/unset",
715756
"TestUnifiedSpec/change-streams/change-streams.json/Test_insert,_update,_replace,_and_delete_event_types",
716757
},
758+
759+
// TODO(DRIVERS-3153): Re-enable once DRIVERS-3153 is fixed.
760+
"Re-enable once DRIVERS-3153 is fixed": {
761+
"TestUnifiedSpec/atlas-data-lake-testing/tests/unified/getMore.json/A_successful_find_event_with_getMore",
762+
},
717763
}
718764

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

internal/spectest/spectest.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"os"
1111
"path"
1212
"path/filepath"
13-
"runtime"
1413
"testing"
1514

1615
"go.mongodb.org/mongo-driver/v2/internal/require"
@@ -43,13 +42,16 @@ func FindJSONFilesInDir(t *testing.T, dir string) []string {
4342
// Path returns the absolute path to the given specifications repo file or
4443
// subdirectory.
4544
func Path(subdir string) string {
46-
_, file, _, ok := runtime.Caller(0)
47-
if !ok {
48-
panic("unable to get current file path from call stack")
49-
}
50-
51-
// Get the repository root path from the current Go file path.
52-
root := filepath.Dir(filepath.Dir(filepath.Dir(file)))
45+
root := os.Getenv("PROJECT_DIRECTORY")
46+
//if root == "" {
47+
// _, file, _, ok := runtime.Caller(0)
48+
// if !ok {
49+
// panic("unable to get current file path from call stack")
50+
// }
51+
52+
// // Get the repository root path from the current Go file path.
53+
// root = filepath.Dir(filepath.Dir(filepath.Dir(file)))
54+
//}
5355

5456
return filepath.Join(root, "testdata", "specifications", "source", subdir)
5557
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
"collection_name": "driverdata",
3+
"database_name": "test",
4+
"tests": [
5+
{
6+
"description": "Aggregate with pipeline (project, sort, limit)",
7+
"operations": [
8+
{
9+
"object": "collection",
10+
"name": "aggregate",
11+
"arguments": {
12+
"pipeline": [
13+
{
14+
"$project": {
15+
"_id": 0
16+
}
17+
},
18+
{
19+
"$sort": {
20+
"a": 1
21+
}
22+
},
23+
{
24+
"$limit": 2
25+
}
26+
]
27+
},
28+
"result": [
29+
{
30+
"a": 1,
31+
"b": 2,
32+
"c": 3
33+
},
34+
{
35+
"a": 2,
36+
"b": 3,
37+
"c": 4
38+
}
39+
]
40+
}
41+
],
42+
"expectations": [
43+
{
44+
"command_started_event": {
45+
"command": {
46+
"aggregate": "driverdata"
47+
}
48+
}
49+
}
50+
]
51+
}
52+
]
53+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
collection_name: &collection_name "driverdata"
2+
database_name: &database_name "test"
3+
4+
tests:
5+
-
6+
description: "Aggregate with pipeline (project, sort, limit)"
7+
operations:
8+
-
9+
object: collection
10+
name: aggregate
11+
arguments:
12+
pipeline:
13+
- $project: { _id: 0 }
14+
- $sort: { a: 1 }
15+
- $limit: 2
16+
result:
17+
- { a: 1, b: 2, c: 3 }
18+
- { a: 2, b: 3, c: 4 }
19+
expectations:
20+
-
21+
command_started_event:
22+
command:
23+
aggregate: *collection_name
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"collection_name": "driverdata",
3+
"database_name": "test",
4+
"tests": [
5+
{
6+
"description": "estimatedDocumentCount succeeds",
7+
"operations": [
8+
{
9+
"object": "collection",
10+
"name": "estimatedDocumentCount",
11+
"result": 15
12+
}
13+
],
14+
"expectations": [
15+
{
16+
"command_started_event": {
17+
"command": {
18+
"count": "driverdata"
19+
},
20+
"command_name": "count",
21+
"database_name": "test"
22+
}
23+
}
24+
]
25+
}
26+
]
27+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
collection_name: &collection_name "driverdata"
2+
database_name: &database_name "test"
3+
4+
tests:
5+
-
6+
description: "estimatedDocumentCount succeeds"
7+
operations:
8+
-
9+
object: collection
10+
name: estimatedDocumentCount
11+
result: 15
12+
expectations:
13+
-
14+
command_started_event:
15+
command:
16+
count: *collection_name
17+
command_name: count
18+
database_name: *database_name

0 commit comments

Comments
 (0)