PYTHON-3189 Change Stream event document missing to field for rename events (#924)

This commit is contained in:
Steven Silvester 2022-05-06 16:48:02 -05:00 committed by GitHub
parent 3e57bde2ee
commit 21ead3a7e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 317 additions and 7 deletions

View File

@ -3,6 +3,7 @@
"schemaVersion": "1.0",
"runOnRequirements": [
{
"minServerVersion": "3.6",
"topologies": [
"replicaset",
"sharded-replicaset"
@ -167,7 +168,6 @@
"description": "Test with document comment - pre 4.4",
"runOnRequirements": [
{
"minServerVersion": "3.6.0",
"maxServerVersion": "4.2.99"
}
],
@ -211,11 +211,6 @@
},
{
"description": "Test with string comment",
"runOnRequirements": [
{
"minServerVersion": "3.6.0"
}
],
"operations": [
{
"name": "createChangeStream",
@ -343,7 +338,6 @@
"description": "Test that comment is not set on getMore - pre 4.4",
"runOnRequirements": [
{
"minServerVersion": "3.6.0",
"maxServerVersion": "4.3.99",
"topologies": [
"replicaset"
@ -426,6 +420,320 @@
]
}
]
},
{
"description": "to field is set in a rename change event",
"runOnRequirements": [
{
"minServerVersion": "4.0.1"
}
],
"operations": [
{
"name": "createChangeStream",
"object": "collection0",
"arguments": {
"pipeline": []
},
"saveResultAsEntity": "changeStream0"
},
{
"name": "dropCollection",
"object": "database0",
"arguments": {
"collection": "collection1"
}
},
{
"name": "rename",
"object": "collection0",
"arguments": {
"to": "collection1"
}
},
{
"name": "iterateUntilDocumentOrError",
"object": "changeStream0",
"expectResult": {
"operationType": "rename",
"ns": {
"db": "database0",
"coll": "collection0"
},
"to": {
"db": "database0",
"coll": "collection1"
}
}
}
]
},
{
"description": "Test unknown operationType MUST NOT err",
"operations": [
{
"name": "createChangeStream",
"object": "collection0",
"arguments": {
"pipeline": [
{
"$project": {
"operationType": "addedInFutureMongoDBVersion",
"ns": 1
}
}
]
},
"saveResultAsEntity": "changeStream0"
},
{
"name": "insertOne",
"object": "collection0",
"arguments": {
"document": {
"_id": 1,
"a": 1
}
}
},
{
"name": "iterateUntilDocumentOrError",
"object": "changeStream0",
"expectResult": {
"operationType": "addedInFutureMongoDBVersion",
"ns": {
"db": "database0",
"coll": "collection0"
}
}
}
]
},
{
"description": "Test newField added in response MUST NOT err",
"operations": [
{
"name": "createChangeStream",
"object": "collection0",
"arguments": {
"pipeline": [
{
"$project": {
"operationType": 1,
"ns": 1,
"newField": "newFieldValue"
}
}
]
},
"saveResultAsEntity": "changeStream0"
},
{
"name": "insertOne",
"object": "collection0",
"arguments": {
"document": {
"_id": 1,
"a": 1
}
}
},
{
"name": "iterateUntilDocumentOrError",
"object": "changeStream0",
"expectResult": {
"operationType": "insert",
"ns": {
"db": "database0",
"coll": "collection0"
},
"newField": "newFieldValue"
}
}
]
},
{
"description": "Test new structure in ns document MUST NOT err",
"runOnRequirements": [
{
"minServerVersion": "3.6",
"maxServerVersion": "5.2"
},
{
"minServerVersion": "6.0"
}
],
"operations": [
{
"name": "createChangeStream",
"object": "collection0",
"arguments": {
"pipeline": [
{
"$project": {
"operationType": "insert",
"ns.viewOn": "db.coll"
}
}
]
},
"saveResultAsEntity": "changeStream0"
},
{
"name": "insertOne",
"object": "collection0",
"arguments": {
"document": {
"_id": 1,
"a": 1
}
}
},
{
"name": "iterateUntilDocumentOrError",
"object": "changeStream0",
"expectResult": {
"operationType": "insert",
"ns": {
"viewOn": "db.coll"
}
}
}
]
},
{
"description": "Test modified structure in ns document MUST NOT err",
"operations": [
{
"name": "createChangeStream",
"object": "collection0",
"arguments": {
"pipeline": [
{
"$project": {
"operationType": "insert",
"ns": {
"db": "$ns.db",
"coll": "$ns.coll",
"viewOn": "db.coll"
}
}
}
]
},
"saveResultAsEntity": "changeStream0"
},
{
"name": "insertOne",
"object": "collection0",
"arguments": {
"document": {
"_id": 1,
"a": 1
}
}
},
{
"name": "iterateUntilDocumentOrError",
"object": "changeStream0",
"expectResult": {
"operationType": "insert",
"ns": {
"db": "database0",
"coll": "collection0",
"viewOn": "db.coll"
}
}
}
]
},
{
"description": "Test server error on projecting out _id",
"runOnRequirements": [
{
"minServerVersion": "4.2"
}
],
"operations": [
{
"name": "createChangeStream",
"object": "collection0",
"arguments": {
"pipeline": [
{
"$project": {
"_id": 0
}
}
]
},
"saveResultAsEntity": "changeStream0"
},
{
"name": "insertOne",
"object": "collection0",
"arguments": {
"document": {
"_id": 1,
"a": 1
}
}
},
{
"name": "iterateUntilDocumentOrError",
"object": "changeStream0",
"expectError": {
"errorCode": 280,
"errorCodeName": "ChangeStreamFatalError",
"errorLabelsContain": [
"NonResumableChangeStreamError"
]
}
}
]
},
{
"description": "Test projection in change stream returns expected fields",
"operations": [
{
"name": "createChangeStream",
"object": "collection0",
"arguments": {
"pipeline": [
{
"$project": {
"optype": "$operationType",
"ns": 1,
"newField": "value"
}
}
]
},
"saveResultAsEntity": "changeStream0"
},
{
"name": "insertOne",
"object": "collection0",
"arguments": {
"document": {
"_id": 1,
"a": 1
}
}
},
{
"name": "iterateUntilDocumentOrError",
"object": "changeStream0",
"expectResult": {
"optype": "insert",
"ns": {
"db": "database0",
"coll": "collection0"
},
"newField": "value"
}
}
]
}
]
}

View File

@ -1080,5 +1080,7 @@ def prepare_spec_arguments(spec, arguments, opname, entity_map, with_txn_callbac
arguments["keys"] = list(arguments.pop(arg_name).items())
elif opname == "drop_index" and arg_name == "name":
arguments["index_or_name"] = arguments.pop(arg_name)
elif opname == "rename" and arg_name == "to":
arguments["new_name"] = arguments.pop(arg_name)
else:
arguments[c2s] = arguments.pop(arg_name)