Skip to content

Commit

Permalink
test(NODE-4605, NODE-4597, NODE-4618): sync latest change stream unif…
Browse files Browse the repository at this point in the history
…ied tests (#3402)
  • Loading branch information
baileympearson committed Sep 12, 2022
1 parent 085471d commit 12e951b
Show file tree
Hide file tree
Showing 6 changed files with 144 additions and 5 deletions.
81 changes: 81 additions & 0 deletions test/spec/change-streams/unified/change-streams-clusterTime.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
"description": "change-streams-clusterTime",
"schemaVersion": "1.3",
"createEntities": [
{
"client": {
"id": "client0",
"useMultipleMongoses": false
}
},
{
"database": {
"id": "database0",
"client": "client0",
"databaseName": "database0"
}
},
{
"collection": {
"id": "collection0",
"database": "database0",
"collectionName": "collection0"
}
}
],
"runOnRequirements": [
{
"minServerVersion": "4.0.0",
"topologies": [
"replicaset",
"sharded-replicaset",
"load-balanced",
"sharded"
]
}
],
"initialData": [
{
"collectionName": "collection0",
"databaseName": "database0",
"documents": []
}
],
"tests": [
{
"description": "clusterTime is present",
"operations": [
{
"name": "createChangeStream",
"object": "collection0",
"arguments": {
"pipeline": []
},
"saveResultAsEntity": "changeStream0"
},
{
"name": "insertOne",
"object": "collection0",
"arguments": {
"document": {
"_id": 1
}
}
},
{
"name": "iterateUntilDocumentOrError",
"object": "changeStream0",
"expectResult": {
"ns": {
"db": "database0",
"coll": "collection0"
},
"clusterTime": {
"$$exists": true
}
}
}
]
}
]
}
40 changes: 40 additions & 0 deletions test/spec/change-streams/unified/change-streams-clusterTime.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
description: "change-streams-clusterTime"
schemaVersion: "1.3"
createEntities:
- client:
id: &client0 client0
useMultipleMongoses: false
- database:
id: &database0 database0
client: *client0
databaseName: *database0
- collection:
id: &collection0 collection0
database: *database0
collectionName: *collection0

runOnRequirements:
- minServerVersion: "4.0.0"
topologies: [ replicaset, sharded-replicaset, load-balanced, sharded ]

initialData:
- collectionName: *collection0
databaseName: *database0
documents: []

tests:
- description: "clusterTime is present"
operations:
- name: createChangeStream
object: *collection0
arguments: { pipeline: [] }
saveResultAsEntity: &changeStream0 changeStream0
- name: insertOne
object: *collection0
arguments:
document: { _id: 1 }
- name: iterateUntilDocumentOrError
object: *changeStream0
expectResult:
ns: { db: *database0, coll: *collection0 }
clusterTime: { $$exists: true }
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"description": "disambiguatedPaths",
"schemaVersion": "1.3",
"schemaVersion": "1.4",
"createEntities": [
{
"client": {
Expand Down Expand Up @@ -31,7 +31,8 @@
"sharded-replicaset",
"load-balanced",
"sharded"
]
],
"serverless": "forbid"
}
],
"initialData": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
description: "disambiguatedPaths"
schemaVersion: "1.3"
schemaVersion: "1.4"
createEntities:
- client:
id: &client0 client0
Expand All @@ -16,6 +16,7 @@ createEntities:
runOnRequirements:
- minServerVersion: "6.1.0"
topologies: [ replicaset, sharded-replicaset, load-balanced, sharded ]
serverless: forbid

initialData:
- collectionName: *collection0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,15 @@
"name": "createChangeStream",
"object": "collection0",
"arguments": {
"pipeline": [],
"pipeline": [
{
"$match": {
"operationType": {
"$ne": "create"
}
}
}
],
"showExpandedEvents": true
},
"saveResultAsEntity": "changeStream0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,15 @@ tests:
- name: createChangeStream
object: *collection0
arguments:
pipeline: []
pipeline:
# On sharded clusters, the create command run when loading initial
# data sometimes is still reported in the change stream. To avoid
# this, we exclude the create command when creating the change
# stream, but specifically don't exclude other events to still catch
# driver errors.
- $match:
operationType:
$ne: create
showExpandedEvents: true
saveResultAsEntity: &changeStream0 changeStream0
- name: createIndex
Expand Down

0 comments on commit 12e951b

Please sign in to comment.