PYTHON-1877 Fix result assertion in changeStream spec tests

PYTHON-1713 Resync change stream tests to test all new notification types
This commit is contained in:
Prashant Mital 2019-06-28 17:07:53 -07:00
parent 0f30d16554
commit 3ba46a9911
No known key found for this signature in database
GPG Key ID: 3D2DAA9E483ABE51
2 changed files with 372 additions and 2 deletions

View File

@ -45,7 +45,22 @@
}
],
"result": {
"success": []
"success": [
{
"_id": "42",
"documentKey": "42",
"operationType": "insert",
"ns": {
"db": "change-stream-tests",
"coll": "test"
},
"fullDocument": {
"x": {
"$numberInt": "1"
}
}
}
]
}
},
{
@ -440,6 +455,358 @@
}
]
}
},
{
"description": "Test insert, update, replace, and delete event types",
"minServerVersion": "3.6.0",
"target": "collection",
"topology": [
"replicaset"
],
"changeStreamPipeline": [],
"changeStreamOptions": {},
"operations": [
{
"database": "change-stream-tests",
"collection": "test",
"name": "insertOne",
"arguments": {
"document": {
"x": 1
}
}
},
{
"database": "change-stream-tests",
"collection": "test",
"name": "updateOne",
"arguments": {
"filter": {
"x": 1
},
"update": {
"$set": {
"x": 2
}
}
}
},
{
"database": "change-stream-tests",
"collection": "test",
"name": "replaceOne",
"arguments": {
"filter": {
"x": 2
},
"replacement": {
"x": 3
}
}
},
{
"database": "change-stream-tests",
"collection": "test",
"name": "deleteOne",
"arguments": {
"filter": {
"x": 3
}
}
}
],
"expectations": [
{
"command_started_event": {
"command": {
"aggregate": "test",
"cursor": {},
"pipeline": [
{
"$changeStream": {
"fullDocument": "default"
}
}
]
},
"command_name": "aggregate",
"database_name": "change-stream-tests"
}
}
],
"result": {
"success": [
{
"operationType": "insert",
"ns": {
"db": "change-stream-tests",
"coll": "test"
},
"fullDocument": {
"x": {
"$numberInt": "1"
}
}
},
{
"operationType": "update",
"ns": {
"db": "change-stream-tests",
"coll": "test"
},
"updateDescription": {
"updatedFields": {
"x": {
"$numberInt": "2"
}
}
}
},
{
"operationType": "replace",
"ns": {
"db": "change-stream-tests",
"coll": "test"
},
"fullDocument": {
"x": {
"$numberInt": "3"
}
}
},
{
"operationType": "delete",
"ns": {
"db": "change-stream-tests",
"coll": "test"
}
}
]
}
},
{
"description": "Test rename and invalidate event types",
"minServerVersion": "4.0.1",
"target": "collection",
"topology": [
"replicaset"
],
"changeStreamPipeline": [],
"changeStreamOptions": {},
"operations": [
{
"database": "change-stream-tests",
"collection": "test",
"name": "rename",
"arguments": {
"to": "test2"
}
}
],
"expectations": [
{
"command_started_event": {
"command": {
"aggregate": "test",
"cursor": {},
"pipeline": [
{
"$changeStream": {
"fullDocument": "default"
}
}
]
},
"command_name": "aggregate",
"database_name": "change-stream-tests"
}
}
],
"result": {
"success": [
{
"operationType": "rename",
"ns": {
"db": "change-stream-tests",
"coll": "test"
},
"to": {
"db": "change-stream-tests",
"coll": "test2"
}
},
{
"operationType": "invalidate"
}
]
}
},
{
"description": "Test drop and invalidate event types",
"minServerVersion": "4.0.1",
"target": "collection",
"topology": [
"replicaset"
],
"changeStreamPipeline": [],
"changeStreamOptions": {},
"operations": [
{
"database": "change-stream-tests",
"collection": "test",
"name": "drop"
}
],
"expectations": [
{
"command_started_event": {
"command": {
"aggregate": "test",
"cursor": {},
"pipeline": [
{
"$changeStream": {
"fullDocument": "default"
}
}
]
},
"command_name": "aggregate",
"database_name": "change-stream-tests"
}
}
],
"result": {
"success": [
{
"operationType": "drop",
"ns": {
"db": "change-stream-tests",
"coll": "test"
}
},
{
"operationType": "invalidate"
}
]
}
},
{
"description": "Test consecutive resume",
"minServerVersion": "4.1.7",
"target": "collection",
"topology": [
"replicaset"
],
"changeStreamPipeline": [],
"changeStreamOptions": {
"batchSize": 1
},
"failPoint": {
"configureFailPoint": "failCommand",
"mode": {
"times": 2
},
"data": {
"failCommands": [
"getMore"
],
"closeConnection": true
}
},
"operations": [
{
"database": "change-stream-tests",
"collection": "test",
"name": "insertOne",
"arguments": {
"document": {
"x": 1
}
}
},
{
"database": "change-stream-tests",
"collection": "test",
"name": "insertOne",
"arguments": {
"document": {
"x": 2
}
}
},
{
"database": "change-stream-tests",
"collection": "test",
"name": "insertOne",
"arguments": {
"document": {
"x": 3
}
}
}
],
"expectations": [
{
"command_started_event": {
"command": {
"aggregate": "test",
"cursor": {
"batchSize": 1
},
"pipeline": [
{
"$changeStream": {
"fullDocument": "default"
}
}
]
},
"command_name": "aggregate",
"database_name": "change-stream-tests"
}
}
],
"result": {
"success": [
{
"operationType": "insert",
"ns": {
"db": "change-stream-tests",
"coll": "test"
},
"fullDocument": {
"x": {
"$numberInt": "1"
}
}
},
{
"operationType": "insert",
"ns": {
"db": "change-stream-tests",
"coll": "test"
},
"fullDocument": {
"x": {
"$numberInt": "2"
}
}
},
{
"operationType": "insert",
"ns": {
"db": "change-stream-tests",
"coll": "test"
},
"fullDocument": {
"x": {
"$numberInt": "3"
}
}
}
]
}
}
]
}

View File

@ -750,7 +750,10 @@ def get_change_stream(client, scenario_def, test):
def run_operation(client, operation):
# Apply specified operations
opname = camel_to_snake(operation["name"])
arguments = operation["arguments"]
arguments = operation.get("arguments", {})
if opname == 'rename':
# Special case for rename operation.
arguments = {'new_name': arguments["to"]}
cmd = getattr(client.get_database(
operation["database"]).get_collection(
operation["collection"]), opname