Skip to content

Commit 3ecc73c

Browse files
GODRIVER-3445 unified-test-format
1 parent 6feb7ba commit 3ecc73c

File tree

298 files changed

+94976
-108
lines changed

Some content is hidden

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

298 files changed

+94976
-108
lines changed

internal/integration/initial_dns_seedlist_discovery_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"go.mongodb.org/mongo-driver/v2/internal/assert"
2222
"go.mongodb.org/mongo-driver/v2/internal/integration/mtest"
2323
"go.mongodb.org/mongo-driver/v2/internal/serverselector"
24+
"go.mongodb.org/mongo-driver/v2/internal/spectest"
2425
"go.mongodb.org/mongo-driver/v2/mongo"
2526
"go.mongodb.org/mongo-driver/v2/mongo/options"
2627
"go.mongodb.org/mongo-driver/v2/mongo/readpref"
@@ -29,9 +30,7 @@ import (
2930
"go.mongodb.org/mongo-driver/v2/x/mongo/driver/topology"
3031
)
3132

32-
const (
33-
seedlistDiscoveryTestsBaseDir = "../../testdata/initial-dns-seedlist-discovery"
34-
)
33+
var seedlistDiscoveryTestsBaseDir = spectest.TestPath(2, "initial-dns-seedlist-discovery")
3534

3635
type seedlistTest struct {
3736
URI string `bson:"uri"`

internal/integration/unified/unified_spec_test.go

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,41 +8,44 @@ package unified
88

99
import (
1010
"context"
11-
"path"
11+
"strings"
1212
"testing"
13+
14+
"go.mongodb.org/mongo-driver/v2/internal/spectest"
1315
)
1416

1517
var (
1618
passDirectories = []string{
17-
"unified-test-format/valid-pass",
18-
"versioned-api",
19-
"crud/unified",
20-
"change-streams",
21-
"transactions/unified",
22-
"load-balancers",
23-
"collection-management",
24-
"command-monitoring",
25-
"command-monitoring/logging",
26-
"connection-monitoring-and-pooling/logging",
27-
"sessions",
28-
"retryable-reads/unified",
29-
"retryable-writes/unified",
30-
"client-side-encryption/unified",
31-
"client-side-operations-timeout",
32-
"gridfs",
33-
"server-selection/logging",
34-
"server-discovery-and-monitoring/unified",
35-
"run-command",
36-
"index-management",
19+
spectest.TestPath(3, "unified-test-format", "valid-pass"),
20+
//"unified-test-format/valid-pass",
21+
//"versioned-api",
22+
//"crud/unified",
23+
//"change-streams",
24+
//"transactions/unified",
25+
//"load-balancers",
26+
//"collection-management",
27+
//"command-monitoring",
28+
//"command-monitoring/logging",
29+
//"connection-monitoring-and-pooling/logging",
30+
//"sessions",
31+
//"retryable-reads/unified",
32+
//"retryable-writes/unified",
33+
//"client-side-encryption/unified",
34+
//"client-side-operations-timeout",
35+
//"gridfs",
36+
//"server-selection/logging",
37+
//"server-discovery-and-monitoring/unified",
38+
//"run-command",
39+
//"index-management",
3740
}
3841
failDirectories = []string{
39-
"unified-test-format/valid-fail",
42+
//"unified-test-format/valid-fail",
4043
}
4144
)
4245

43-
const (
44-
dataDirectory = "../../../testdata"
45-
)
46+
//const (
47+
// dataDirectory = "../../../testdata"
48+
//)
4649

4750
func TestUnifiedSpec(t *testing.T) {
4851
// Ensure the cluster is in a clean state before test execution begins.
@@ -51,14 +54,17 @@ func TestUnifiedSpec(t *testing.T) {
5154
}
5255

5356
for _, testDir := range passDirectories {
54-
t.Run(testDir, func(t *testing.T) {
55-
runTestDirectory(t, path.Join(dataDirectory, testDir), false)
57+
index := strings.Index(testDir, "testdata/")
58+
testName := testDir[index+len("testdata/"):]
59+
60+
t.Run(testName, func(t *testing.T) {
61+
runTestDirectory(t, testDir, false)
5662
})
5763
}
5864

5965
for _, testDir := range failDirectories {
6066
t.Run(testDir, func(t *testing.T) {
61-
runTestDirectory(t, path.Join(dataDirectory, testDir), true)
67+
runTestDirectory(t, testDir, true)
6268
})
6369
}
6470
}

internal/spectest/skip.go

Lines changed: 87 additions & 77 deletions
Large diffs are not rendered by default.
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
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{
2+
"collection_name": "driverdata",
3+
"database_name": "test",
4+
"tests": [
5+
{
6+
"description": "Find with projection and sort",
7+
"operations": [
8+
{
9+
"object": "collection",
10+
"name": "find",
11+
"arguments": {
12+
"filter": {
13+
"b": {
14+
"$gt": 5
15+
}
16+
},
17+
"projection": {
18+
"_id": 0
19+
},
20+
"sort": {
21+
"a": 1
22+
},
23+
"limit": 5
24+
},
25+
"result": [
26+
{
27+
"a": 5,
28+
"b": 6,
29+
"c": 7
30+
},
31+
{
32+
"a": 6,
33+
"b": 7,
34+
"c": 8
35+
},
36+
{
37+
"a": 7,
38+
"b": 8,
39+
"c": 9
40+
},
41+
{
42+
"a": 8,
43+
"b": 9,
44+
"c": 10
45+
},
46+
{
47+
"a": 9,
48+
"b": 10,
49+
"c": 11
50+
}
51+
]
52+
}
53+
],
54+
"expectations": [
55+
{
56+
"command_started_event": {
57+
"command": {
58+
"find": "driverdata"
59+
}
60+
}
61+
}
62+
]
63+
}
64+
]
65+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
collection_name: &collection_name "driverdata"
2+
database_name: &database_name "test"
3+
4+
tests:
5+
-
6+
description: "Find with projection and sort"
7+
operations:
8+
-
9+
object: collection
10+
name: find
11+
arguments:
12+
filter: { b: { $gt: 5 } }
13+
projection: { _id: 0 }
14+
sort: { a: 1 }
15+
limit: 5
16+
result:
17+
- {"a": 5, "b": 6, "c": 7}
18+
- {"a": 6, "b": 7, "c": 8}
19+
- {"a": 7, "b": 8, "c": 9}
20+
- {"a": 8, "b": 9, "c": 10}
21+
- {"a": 9, "b": 10, "c": 11}
22+
expectations:
23+
-
24+
command_started_event:
25+
command:
26+
find: *collection_name
27+
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{
2+
"collection_name": "driverdata",
3+
"database_name": "test",
4+
"tests": [
5+
{
6+
"description": "A successful find event with getMore",
7+
"operations": [
8+
{
9+
"object": "collection",
10+
"name": "find",
11+
"arguments": {
12+
"filter": {
13+
"a": {
14+
"$gte": 2
15+
}
16+
},
17+
"sort": {
18+
"a": 1
19+
},
20+
"batchSize": 3,
21+
"limit": 4
22+
}
23+
}
24+
],
25+
"expectations": [
26+
{
27+
"command_started_event": {
28+
"command": {
29+
"find": "driverdata",
30+
"filter": {
31+
"a": {
32+
"$gte": 2
33+
}
34+
},
35+
"sort": {
36+
"a": 1
37+
},
38+
"batchSize": 3,
39+
"limit": 4
40+
},
41+
"command_name": "find",
42+
"database_name": "test"
43+
}
44+
},
45+
{
46+
"command_started_event": {
47+
"command": {
48+
"batchSize": 1
49+
},
50+
"command_name": "getMore",
51+
"database_name": "cursors"
52+
}
53+
}
54+
]
55+
}
56+
]
57+
}

0 commit comments

Comments
 (0)