Skip to content

Commit ab372cd

Browse files
authored
RUST-1461 Sync clustertime change stream tests (#771)
This also updates update-spec-tests.sh to accept a git hash.
1 parent 86b83ef commit ab372cd

File tree

3 files changed

+137
-7
lines changed

3 files changed

+137
-7
lines changed

etc/update-spec-tests.sh

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
#!/usr/bin/env bash
22

3-
# This script is used to fetch the latest JSON tests for the CRUD spec. It puts the tests in the
4-
# direcory $reporoot/data/crud. It should be run from the root of the repository.
3+
# This script is used to fetch the JSON/YML tests from the drivers specifications repo.
4+
# The first argument is the specification whose tests should be fetched. It is required.
5+
# The second argument is the branch/commit hash that the tests should be synced to. If it
6+
# is omitted, it will default to "master".
7+
#
8+
# This script puts the tests in the directory $reporoot/src/test/spec/json/$specname. It
9+
# must be run from the root of the repository.
510

611
set -o errexit
712
set -o nounset
@@ -11,14 +16,16 @@ if [ ! -d ".git" ]; then
1116
exit 1
1217
fi
1318

14-
if [ $# -ne 1 ]; then
15-
echo "$0: This script must be passed exactly one argument for which tests to sync" >&2
19+
if [ "$#" -eq 0 ]; then
20+
echo "Usage: $0 <specification> [branch/commit hash]"
1621
exit 1
1722
fi
1823

24+
REF="${2:-master}"
25+
1926
tmpdir=`perl -MFile::Temp=tempdir -wle 'print tempdir(TMPDIR => 1, CLEANUP => 0)'`
20-
curl -sL https://github.com/mongodb/specifications/archive/master.zip -o "$tmpdir/specs.zip"
21-
unzip -d "$tmpdir" "$tmpdir/specs.zip" > /dev/null
27+
curl -sL "https://github.com/mongodb/specifications/archive/$REF.zip" -o "$tmpdir/specs.zip"
28+
unzip -q -d "$tmpdir" "$tmpdir/specs.zip"
2229
mkdir -p "src/test/spec/json/$1"
23-
rsync -ah "$tmpdir/specifications-master/source/$1/tests/" "src/test/spec/json/$1" --delete
30+
rsync -ah "$tmpdir/specifications-$REF"*"/source/$1/tests/" "src/test/spec/json/$1" --delete
2431
rm -rf "$tmpdir"
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
{
2+
"description": "change-streams-clusterTime",
3+
"schemaVersion": "1.4",
4+
"createEntities": [
5+
{
6+
"client": {
7+
"id": "client0",
8+
"useMultipleMongoses": false
9+
}
10+
},
11+
{
12+
"database": {
13+
"id": "database0",
14+
"client": "client0",
15+
"databaseName": "database0"
16+
}
17+
},
18+
{
19+
"collection": {
20+
"id": "collection0",
21+
"database": "database0",
22+
"collectionName": "collection0"
23+
}
24+
}
25+
],
26+
"runOnRequirements": [
27+
{
28+
"minServerVersion": "4.0.0",
29+
"topologies": [
30+
"replicaset",
31+
"sharded-replicaset",
32+
"load-balanced",
33+
"sharded"
34+
],
35+
"serverless": "forbid"
36+
}
37+
],
38+
"initialData": [
39+
{
40+
"collectionName": "collection0",
41+
"databaseName": "database0",
42+
"documents": []
43+
}
44+
],
45+
"tests": [
46+
{
47+
"description": "clusterTime is present",
48+
"operations": [
49+
{
50+
"name": "createChangeStream",
51+
"object": "collection0",
52+
"arguments": {
53+
"pipeline": []
54+
},
55+
"saveResultAsEntity": "changeStream0"
56+
},
57+
{
58+
"name": "insertOne",
59+
"object": "collection0",
60+
"arguments": {
61+
"document": {
62+
"_id": 1
63+
}
64+
}
65+
},
66+
{
67+
"name": "iterateUntilDocumentOrError",
68+
"object": "changeStream0",
69+
"expectResult": {
70+
"ns": {
71+
"db": "database0",
72+
"coll": "collection0"
73+
},
74+
"clusterTime": {
75+
"$$exists": true
76+
}
77+
}
78+
}
79+
]
80+
}
81+
]
82+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
description: "change-streams-clusterTime"
2+
schemaVersion: "1.4"
3+
createEntities:
4+
- client:
5+
id: &client0 client0
6+
useMultipleMongoses: false
7+
- database:
8+
id: &database0 database0
9+
client: *client0
10+
databaseName: *database0
11+
- collection:
12+
id: &collection0 collection0
13+
database: *database0
14+
collectionName: *collection0
15+
16+
runOnRequirements:
17+
- minServerVersion: "4.0.0"
18+
topologies: [ replicaset, sharded-replicaset, load-balanced, sharded ]
19+
serverless: forbid
20+
21+
initialData:
22+
- collectionName: *collection0
23+
databaseName: *database0
24+
documents: []
25+
26+
tests:
27+
- description: "clusterTime is present"
28+
operations:
29+
- name: createChangeStream
30+
object: *collection0
31+
arguments: { pipeline: [] }
32+
saveResultAsEntity: &changeStream0 changeStream0
33+
- name: insertOne
34+
object: *collection0
35+
arguments:
36+
document: { _id: 1 }
37+
- name: iterateUntilDocumentOrError
38+
object: *changeStream0
39+
expectResult:
40+
ns: { db: *database0, coll: *collection0 }
41+
clusterTime: { $$exists: true }

0 commit comments

Comments
 (0)