From 07022a7275f0034b7f229c7e27848718a53a4e85 Mon Sep 17 00:00:00 2001 From: Julia Garland Date: Wed, 24 Jul 2024 14:23:02 +0000 Subject: [PATCH 1/7] Remove tests that run on server <= 3.6 --- ...bulkWrite-replaceOne-dots_and_dollars.json | 152 ---------- .../bulkWrite-update-hint-clientError.json | 284 ------------------ .../unified/deleteMany-hint-clientError.json | 149 --------- .../unified/deleteOne-hint-clientError.json | 133 -------- .../find-allowdiskuse-clientError.json | 79 ----- .../findOneAndReplace-dots_and_dollars.json | 126 -------- .../unified/updateMany-hint-clientError.json | 159 ---------- .../unified/updateOne-hint-clientError.json | 147 --------- 8 files changed, 1229 deletions(-) delete mode 100644 data/crud/unified/bulkWrite-update-hint-clientError.json delete mode 100644 data/crud/unified/deleteMany-hint-clientError.json delete mode 100644 data/crud/unified/deleteOne-hint-clientError.json delete mode 100644 data/crud/unified/find-allowdiskuse-clientError.json delete mode 100644 data/crud/unified/updateMany-hint-clientError.json delete mode 100644 data/crud/unified/updateOne-hint-clientError.json diff --git a/data/crud/unified/bulkWrite-replaceOne-dots_and_dollars.json b/data/crud/unified/bulkWrite-replaceOne-dots_and_dollars.json index fce647d8f4..cbbc30c18c 100644 --- a/data/crud/unified/bulkWrite-replaceOne-dots_and_dollars.json +++ b/data/crud/unified/bulkWrite-replaceOne-dots_and_dollars.json @@ -120,80 +120,6 @@ } ] }, - { - "description": "Replacing document with top-level dotted key on pre-3.6 server yields server-side error", - "runOnRequirements": [ - { - "maxServerVersion": "3.4.99" - } - ], - "operations": [ - { - "name": "bulkWrite", - "object": "collection0", - "arguments": { - "requests": [ - { - "replaceOne": { - "filter": { - "_id": 1 - }, - "replacement": { - "_id": 1, - "a.b": 1 - } - } - } - ] - }, - "expectError": { - "isClientError": false - } - } - ], - "expectEvents": [ - { - "client": "client0", - "events": [ - { - "commandStartedEvent": { - "command": { - "update": "coll0", - "updates": [ - { - "q": { - "_id": 1 - }, - "u": { - "_id": 1, - "a.b": 1 - }, - "multi": { - "$$unsetOrMatches": false - }, - "upsert": { - "$$unsetOrMatches": false - } - } - ] - } - } - } - ] - } - ], - "outcome": [ - { - "collectionName": "coll0", - "databaseName": "crud-tests", - "documents": [ - { - "_id": 1 - } - ] - } - ] - }, { "description": "Replacing document with dollar-prefixed key in embedded doc on 5.0+ server", "runOnRequirements": [ @@ -449,84 +375,6 @@ ] } ] - }, - { - "description": "Replacing document with dotted key in embedded doc on pre-3.6 server yields server-side error", - "runOnRequirements": [ - { - "maxServerVersion": "3.4.99" - } - ], - "operations": [ - { - "name": "bulkWrite", - "object": "collection0", - "arguments": { - "requests": [ - { - "replaceOne": { - "filter": { - "_id": 1 - }, - "replacement": { - "_id": 1, - "a": { - "b.c": 1 - } - } - } - } - ] - }, - "expectError": { - "isClientError": false - } - } - ], - "expectEvents": [ - { - "client": "client0", - "events": [ - { - "commandStartedEvent": { - "command": { - "update": "coll0", - "updates": [ - { - "q": { - "_id": 1 - }, - "u": { - "_id": 1, - "a": { - "b.c": 1 - } - }, - "multi": { - "$$unsetOrMatches": false - }, - "upsert": { - "$$unsetOrMatches": false - } - } - ] - } - } - } - ] - } - ], - "outcome": [ - { - "collectionName": "coll0", - "databaseName": "crud-tests", - "documents": [ - { - "_id": 1 - } - ] - } - ] } ] } diff --git a/data/crud/unified/bulkWrite-update-hint-clientError.json b/data/crud/unified/bulkWrite-update-hint-clientError.json deleted file mode 100644 index d5eb71c29e..0000000000 --- a/data/crud/unified/bulkWrite-update-hint-clientError.json +++ /dev/null @@ -1,284 +0,0 @@ -{ - "description": "bulkWrite-update-hint-clientError", - "schemaVersion": "1.0", - "runOnRequirements": [ - { - "maxServerVersion": "3.3.99" - } - ], - "createEntities": [ - { - "client": { - "id": "client0", - "observeEvents": [ - "commandStartedEvent" - ] - } - }, - { - "database": { - "id": "database0", - "client": "client0", - "databaseName": "crud-v2" - } - }, - { - "collection": { - "id": "collection0", - "database": "database0", - "collectionName": "test_bulkwrite_update_hint" - } - } - ], - "initialData": [ - { - "collectionName": "test_bulkwrite_update_hint", - "databaseName": "crud-v2", - "documents": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 22 - }, - { - "_id": 3, - "x": 33 - }, - { - "_id": 4, - "x": 44 - } - ] - } - ], - "tests": [ - { - "description": "BulkWrite updateOne with update hints unsupported (client-side error)", - "operations": [ - { - "object": "collection0", - "name": "bulkWrite", - "arguments": { - "requests": [ - { - "updateOne": { - "filter": { - "_id": 1 - }, - "update": { - "$inc": { - "x": 1 - } - }, - "hint": "_id_" - } - }, - { - "updateOne": { - "filter": { - "_id": 1 - }, - "update": { - "$inc": { - "x": 1 - } - }, - "hint": { - "_id": 1 - } - } - } - ], - "ordered": true - }, - "expectError": { - "isError": true - } - } - ], - "expectEvents": [ - { - "client": "client0", - "events": [] - } - ], - "outcome": [ - { - "collectionName": "test_bulkwrite_update_hint", - "databaseName": "crud-v2", - "documents": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 22 - }, - { - "_id": 3, - "x": 33 - }, - { - "_id": 4, - "x": 44 - } - ] - } - ] - }, - { - "description": "BulkWrite updateMany with update hints unsupported (client-side error)", - "operations": [ - { - "object": "collection0", - "name": "bulkWrite", - "arguments": { - "requests": [ - { - "updateMany": { - "filter": { - "_id": { - "$lt": 3 - } - }, - "update": { - "$inc": { - "x": 1 - } - }, - "hint": "_id_" - } - }, - { - "updateMany": { - "filter": { - "_id": { - "$lt": 3 - } - }, - "update": { - "$inc": { - "x": 1 - } - }, - "hint": { - "_id": 1 - } - } - } - ], - "ordered": true - }, - "expectError": { - "isError": true - } - } - ], - "expectEvents": [ - { - "client": "client0", - "events": [] - } - ], - "outcome": [ - { - "collectionName": "test_bulkwrite_update_hint", - "databaseName": "crud-v2", - "documents": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 22 - }, - { - "_id": 3, - "x": 33 - }, - { - "_id": 4, - "x": 44 - } - ] - } - ] - }, - { - "description": "BulkWrite replaceOne with update hints unsupported (client-side error)", - "operations": [ - { - "object": "collection0", - "name": "bulkWrite", - "arguments": { - "requests": [ - { - "replaceOne": { - "filter": { - "_id": 3 - }, - "replacement": { - "x": 333 - }, - "hint": "_id_" - } - }, - { - "replaceOne": { - "filter": { - "_id": 4 - }, - "replacement": { - "x": 444 - }, - "hint": { - "_id": 1 - } - } - } - ], - "ordered": true - }, - "expectError": { - "isError": true - } - } - ], - "expectEvents": [ - { - "client": "client0", - "events": [] - } - ], - "outcome": [ - { - "collectionName": "test_bulkwrite_update_hint", - "databaseName": "crud-v2", - "documents": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 22 - }, - { - "_id": 3, - "x": 33 - }, - { - "_id": 4, - "x": 44 - } - ] - } - ] - } - ] -} diff --git a/data/crud/unified/deleteMany-hint-clientError.json b/data/crud/unified/deleteMany-hint-clientError.json deleted file mode 100644 index 66320122b5..0000000000 --- a/data/crud/unified/deleteMany-hint-clientError.json +++ /dev/null @@ -1,149 +0,0 @@ -{ - "description": "deleteMany-hint-clientError", - "schemaVersion": "1.0", - "runOnRequirements": [ - { - "maxServerVersion": "3.3.99" - } - ], - "createEntities": [ - { - "client": { - "id": "client0", - "observeEvents": [ - "commandStartedEvent" - ] - } - }, - { - "database": { - "id": "database0", - "client": "client0", - "databaseName": "crud-v2" - } - }, - { - "collection": { - "id": "collection0", - "database": "database0", - "collectionName": "DeleteMany_hint" - } - } - ], - "initialData": [ - { - "collectionName": "DeleteMany_hint", - "databaseName": "crud-v2", - "documents": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 22 - }, - { - "_id": 3, - "x": 33 - } - ] - } - ], - "tests": [ - { - "description": "DeleteMany with hint string unsupported (client-side error)", - "operations": [ - { - "object": "collection0", - "name": "deleteMany", - "arguments": { - "filter": { - "_id": { - "$gt": 1 - } - }, - "hint": "_id_" - }, - "expectError": { - "isError": true - } - } - ], - "expectEvents": [ - { - "client": "client0", - "events": [] - } - ], - "outcome": [ - { - "collectionName": "DeleteMany_hint", - "databaseName": "crud-v2", - "documents": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 22 - }, - { - "_id": 3, - "x": 33 - } - ] - } - ] - }, - { - "description": "DeleteMany with hint document unsupported (client-side error)", - "operations": [ - { - "object": "collection0", - "name": "deleteMany", - "arguments": { - "filter": { - "_id": { - "$gt": 1 - } - }, - "hint": { - "_id": 1 - } - }, - "expectError": { - "isError": true - } - } - ], - "expectEvents": [ - { - "client": "client0", - "events": [] - } - ], - "outcome": [ - { - "collectionName": "DeleteMany_hint", - "databaseName": "crud-v2", - "documents": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 22 - }, - { - "_id": 3, - "x": 33 - } - ] - } - ] - } - ] -} diff --git a/data/crud/unified/deleteOne-hint-clientError.json b/data/crud/unified/deleteOne-hint-clientError.json deleted file mode 100644 index cf629f59e0..0000000000 --- a/data/crud/unified/deleteOne-hint-clientError.json +++ /dev/null @@ -1,133 +0,0 @@ -{ - "description": "deleteOne-hint-clientError", - "schemaVersion": "1.0", - "runOnRequirements": [ - { - "maxServerVersion": "3.3.99" - } - ], - "createEntities": [ - { - "client": { - "id": "client0", - "observeEvents": [ - "commandStartedEvent" - ] - } - }, - { - "database": { - "id": "database0", - "client": "client0", - "databaseName": "crud-v2" - } - }, - { - "collection": { - "id": "collection0", - "database": "database0", - "collectionName": "DeleteOne_hint" - } - } - ], - "initialData": [ - { - "collectionName": "DeleteOne_hint", - "databaseName": "crud-v2", - "documents": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 22 - } - ] - } - ], - "tests": [ - { - "description": "DeleteOne with hint string unsupported (client-side error)", - "operations": [ - { - "object": "collection0", - "name": "deleteOne", - "arguments": { - "filter": { - "_id": 1 - }, - "hint": "_id_" - }, - "expectError": { - "isError": true - } - } - ], - "expectEvents": [ - { - "client": "client0", - "events": [] - } - ], - "outcome": [ - { - "collectionName": "DeleteOne_hint", - "databaseName": "crud-v2", - "documents": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 22 - } - ] - } - ] - }, - { - "description": "DeleteOne with hint document unsupported (client-side error)", - "operations": [ - { - "object": "collection0", - "name": "deleteOne", - "arguments": { - "filter": { - "_id": 1 - }, - "hint": { - "_id": 1 - } - }, - "expectError": { - "isError": true - } - } - ], - "expectEvents": [ - { - "client": "client0", - "events": [] - } - ], - "outcome": [ - { - "collectionName": "DeleteOne_hint", - "databaseName": "crud-v2", - "documents": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 22 - } - ] - } - ] - } - ] -} diff --git a/data/crud/unified/find-allowdiskuse-clientError.json b/data/crud/unified/find-allowdiskuse-clientError.json deleted file mode 100644 index 5bd954e79d..0000000000 --- a/data/crud/unified/find-allowdiskuse-clientError.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "description": "find-allowdiskuse-clientError", - "schemaVersion": "1.0", - "runOnRequirements": [ - { - "maxServerVersion": "3.0.99" - } - ], - "createEntities": [ - { - "client": { - "id": "client0", - "observeEvents": [ - "commandStartedEvent" - ] - } - }, - { - "database": { - "id": "database0", - "client": "client0", - "databaseName": "crud-v2" - } - }, - { - "collection": { - "id": "collection0", - "database": "database0", - "collectionName": "test_find_allowdiskuse_clienterror" - } - } - ], - "tests": [ - { - "description": "Find fails when allowDiskUse true is specified against pre 3.2 server", - "operations": [ - { - "object": "collection0", - "name": "find", - "arguments": { - "filter": {}, - "allowDiskUse": true - }, - "expectError": { - "isError": true - } - } - ], - "expectEvents": [ - { - "client": "client0", - "events": [] - } - ] - }, - { - "description": "Find fails when allowDiskUse false is specified against pre 3.2 server", - "operations": [ - { - "object": "collection0", - "name": "find", - "arguments": { - "filter": {}, - "allowDiskUse": false - }, - "expectError": { - "isError": true - } - } - ], - "expectEvents": [ - { - "client": "client0", - "events": [] - } - ] - } - ] -} diff --git a/data/crud/unified/findOneAndReplace-dots_and_dollars.json b/data/crud/unified/findOneAndReplace-dots_and_dollars.json index 19ac447f84..5a0c551e3f 100644 --- a/data/crud/unified/findOneAndReplace-dots_and_dollars.json +++ b/data/crud/unified/findOneAndReplace-dots_and_dollars.json @@ -99,67 +99,6 @@ } ] }, - { - "description": "Replacing document with top-level dotted key on pre-3.6 server yields server-side error", - "runOnRequirements": [ - { - "maxServerVersion": "3.4.99" - } - ], - "operations": [ - { - "name": "findOneAndReplace", - "object": "collection0", - "arguments": { - "filter": { - "_id": 1 - }, - "replacement": { - "_id": 1, - "a.b": 1 - } - }, - "expectError": { - "isClientError": false - } - } - ], - "expectEvents": [ - { - "client": "client0", - "events": [ - { - "commandStartedEvent": { - "command": { - "findAndModify": "coll0", - "query": { - "_id": 1 - }, - "update": { - "_id": 1, - "a.b": 1 - }, - "new": { - "$$unsetOrMatches": false - } - } - } - } - ] - } - ], - "outcome": [ - { - "collectionName": "coll0", - "databaseName": "crud-tests", - "documents": [ - { - "_id": 1 - } - ] - } - ] - }, { "description": "Replacing document with dollar-prefixed key in embedded doc on 5.0+ server", "runOnRequirements": [ @@ -360,71 +299,6 @@ ] } ] - }, - { - "description": "Replacing document with dotted key in embedded doc on pre-3.6 server yields server-side error", - "runOnRequirements": [ - { - "maxServerVersion": "3.4.99" - } - ], - "operations": [ - { - "name": "findOneAndReplace", - "object": "collection0", - "arguments": { - "filter": { - "_id": 1 - }, - "replacement": { - "_id": 1, - "a": { - "b.c": 1 - } - } - }, - "expectError": { - "isClientError": false - } - } - ], - "expectEvents": [ - { - "client": "client0", - "events": [ - { - "commandStartedEvent": { - "command": { - "findAndModify": "coll0", - "query": { - "_id": 1 - }, - "update": { - "_id": 1, - "a": { - "b.c": 1 - } - }, - "new": { - "$$unsetOrMatches": false - } - } - } - } - ] - } - ], - "outcome": [ - { - "collectionName": "coll0", - "databaseName": "crud-tests", - "documents": [ - { - "_id": 1 - } - ] - } - ] } ] } diff --git a/data/crud/unified/updateMany-hint-clientError.json b/data/crud/unified/updateMany-hint-clientError.json deleted file mode 100644 index 5da878e293..0000000000 --- a/data/crud/unified/updateMany-hint-clientError.json +++ /dev/null @@ -1,159 +0,0 @@ -{ - "description": "updateMany-hint-clientError", - "schemaVersion": "1.0", - "runOnRequirements": [ - { - "maxServerVersion": "3.3.99" - } - ], - "createEntities": [ - { - "client": { - "id": "client0", - "observeEvents": [ - "commandStartedEvent" - ] - } - }, - { - "database": { - "id": "database0", - "client": "client0", - "databaseName": "crud-v2" - } - }, - { - "collection": { - "id": "collection0", - "database": "database0", - "collectionName": "test_updatemany_hint" - } - } - ], - "initialData": [ - { - "collectionName": "test_updatemany_hint", - "databaseName": "crud-v2", - "documents": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 22 - }, - { - "_id": 3, - "x": 33 - } - ] - } - ], - "tests": [ - { - "description": "UpdateMany with hint string unsupported (client-side error)", - "operations": [ - { - "object": "collection0", - "name": "updateMany", - "arguments": { - "filter": { - "_id": { - "$gt": 1 - } - }, - "update": { - "$inc": { - "x": 1 - } - }, - "hint": "_id_" - }, - "expectError": { - "isError": true - } - } - ], - "expectEvents": [ - { - "client": "client0", - "events": [] - } - ], - "outcome": [ - { - "collectionName": "test_updatemany_hint", - "databaseName": "crud-v2", - "documents": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 22 - }, - { - "_id": 3, - "x": 33 - } - ] - } - ] - }, - { - "description": "UpdateMany with hint document unsupported (client-side error)", - "operations": [ - { - "object": "collection0", - "name": "updateMany", - "arguments": { - "filter": { - "_id": { - "$gt": 1 - } - }, - "update": { - "$inc": { - "x": 1 - } - }, - "hint": { - "_id": 1 - } - }, - "expectError": { - "isError": true - } - } - ], - "expectEvents": [ - { - "client": "client0", - "events": [] - } - ], - "outcome": [ - { - "collectionName": "test_updatemany_hint", - "databaseName": "crud-v2", - "documents": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 22 - }, - { - "_id": 3, - "x": 33 - } - ] - } - ] - } - ] -} diff --git a/data/crud/unified/updateOne-hint-clientError.json b/data/crud/unified/updateOne-hint-clientError.json deleted file mode 100644 index d4f1a53430..0000000000 --- a/data/crud/unified/updateOne-hint-clientError.json +++ /dev/null @@ -1,147 +0,0 @@ -{ - "description": "updateOne-hint-clientError", - "schemaVersion": "1.0", - "runOnRequirements": [ - { - "maxServerVersion": "3.3.99" - } - ], - "createEntities": [ - { - "client": { - "id": "client0", - "observeEvents": [ - "commandStartedEvent" - ] - } - }, - { - "database": { - "id": "database0", - "client": "client0", - "databaseName": "crud-v2" - } - }, - { - "collection": { - "id": "collection0", - "database": "database0", - "collectionName": "test_updateone_hint" - } - } - ], - "initialData": [ - { - "collectionName": "test_updateone_hint", - "databaseName": "crud-v2", - "documents": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 22 - } - ] - } - ], - "tests": [ - { - "description": "UpdateOne with hint string unsupported (client-side error)", - "operations": [ - { - "object": "collection0", - "name": "updateOne", - "arguments": { - "filter": { - "_id": { - "$gt": 1 - } - }, - "update": { - "$inc": { - "x": 1 - } - }, - "hint": "_id_" - }, - "expectError": { - "isError": true - } - } - ], - "expectEvents": [ - { - "client": "client0", - "events": [] - } - ], - "outcome": [ - { - "collectionName": "test_updateone_hint", - "databaseName": "crud-v2", - "documents": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 22 - } - ] - } - ] - }, - { - "description": "UpdateOne with hint document unsupported (client-side error)", - "operations": [ - { - "object": "collection0", - "name": "updateOne", - "arguments": { - "filter": { - "_id": { - "$gt": 1 - } - }, - "update": { - "$inc": { - "x": 1 - } - }, - "hint": { - "_id": 1 - } - }, - "expectError": { - "isError": true - } - } - ], - "expectEvents": [ - { - "client": "client0", - "events": [] - } - ], - "outcome": [ - { - "collectionName": "test_updateone_hint", - "databaseName": "crud-v2", - "documents": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 22 - } - ] - } - ] - } - ] -} From 174e6e64a0d67b239847b7f4639905f8cdd41477 Mon Sep 17 00:00:00 2001 From: Julia Garland Date: Wed, 24 Jul 2024 14:56:13 +0000 Subject: [PATCH 2/7] Remove deleted tests from test_files --- data/crud/unified/test_files.txt | 6 ------ 1 file changed, 6 deletions(-) diff --git a/data/crud/unified/test_files.txt b/data/crud/unified/test_files.txt index cb5e3a0e5c..fa51e9164e 100644 --- a/data/crud/unified/test_files.txt +++ b/data/crud/unified/test_files.txt @@ -18,7 +18,6 @@ bulkWrite-insertOne-dots_and_dollars.json bulkWrite-replaceOne-dots_and_dollars.json bulkWrite-replaceOne-hint-unacknowledged.json bulkWrite-replaceOne-let.json -bulkWrite-update-hint-clientError.json bulkWrite-update-hint-serverError.json bulkWrite-update-hint.json bulkWrite-update-validation.json @@ -32,13 +31,11 @@ countDocuments-comment.json db-aggregate-write-readPreference.json db-aggregate.json deleteMany-comment.json -deleteMany-hint-clientError.json deleteMany-hint-serverError.json deleteMany-hint-unacknowledged.json deleteMany-hint.json deleteMany-let.json deleteOne-comment.json -deleteOne-hint-clientError.json deleteOne-hint-serverError.json deleteOne-hint-unacknowledged.json deleteOne-hint.json @@ -46,7 +43,6 @@ deleteOne-let.json distinct-comment.json estimatedDocumentCount-comment.json estimatedDocumentCount.json -find-allowdiskuse-clientError.json find-allowdiskuse-serverError.json find-allowdiskuse.json find-comment.json @@ -84,7 +80,6 @@ replaceOne-let.json replaceOne-validation.json updateMany-comment.json updateMany-dots_and_dollars.json -updateMany-hint-clientError.json updateMany-hint-serverError.json updateMany-hint-unacknowledged.json updateMany-hint.json @@ -92,7 +87,6 @@ updateMany-let.json updateMany-validation.json updateOne-comment.json updateOne-dots_and_dollars.json -updateOne-hint-clientError.json updateOne-hint-serverError.json updateOne-hint-unacknowledged.json updateOne-hint.json From d9787d366f7fe5497b8d6fe6560ce133c2bf965d Mon Sep 17 00:00:00 2001 From: Julia Garland Date: Wed, 24 Jul 2024 15:39:33 +0000 Subject: [PATCH 3/7] Revert previous commits --- ...bulkWrite-replaceOne-dots_and_dollars.json | 152 ++++++++++ .../bulkWrite-update-hint-clientError.json | 285 ++++++++++++++++++ .../unified/deleteMany-hint-clientError.json | 149 +++++++++ .../unified/deleteOne-hint-clientError.json | 133 ++++++++ .../find-allowdiskuse-clientError.json | 79 +++++ .../findOneAndReplace-dots_and_dollars.json | 126 ++++++++ data/crud/unified/test_files.txt | 6 + .../unified/updateMany-hint-clientError.json | 159 ++++++++++ .../unified/updateOne-hint-clientError.json | 147 +++++++++ 9 files changed, 1236 insertions(+) create mode 100644 data/crud/unified/bulkWrite-update-hint-clientError.json create mode 100644 data/crud/unified/deleteMany-hint-clientError.json create mode 100644 data/crud/unified/deleteOne-hint-clientError.json create mode 100644 data/crud/unified/find-allowdiskuse-clientError.json create mode 100644 data/crud/unified/updateMany-hint-clientError.json create mode 100644 data/crud/unified/updateOne-hint-clientError.json diff --git a/data/crud/unified/bulkWrite-replaceOne-dots_and_dollars.json b/data/crud/unified/bulkWrite-replaceOne-dots_and_dollars.json index cbbc30c18c..fce647d8f4 100644 --- a/data/crud/unified/bulkWrite-replaceOne-dots_and_dollars.json +++ b/data/crud/unified/bulkWrite-replaceOne-dots_and_dollars.json @@ -120,6 +120,80 @@ } ] }, + { + "description": "Replacing document with top-level dotted key on pre-3.6 server yields server-side error", + "runOnRequirements": [ + { + "maxServerVersion": "3.4.99" + } + ], + "operations": [ + { + "name": "bulkWrite", + "object": "collection0", + "arguments": { + "requests": [ + { + "replaceOne": { + "filter": { + "_id": 1 + }, + "replacement": { + "_id": 1, + "a.b": 1 + } + } + } + ] + }, + "expectError": { + "isClientError": false + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "update": "coll0", + "updates": [ + { + "q": { + "_id": 1 + }, + "u": { + "_id": 1, + "a.b": 1 + }, + "multi": { + "$$unsetOrMatches": false + }, + "upsert": { + "$$unsetOrMatches": false + } + } + ] + } + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "coll0", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 1 + } + ] + } + ] + }, { "description": "Replacing document with dollar-prefixed key in embedded doc on 5.0+ server", "runOnRequirements": [ @@ -375,6 +449,84 @@ ] } ] + }, + { + "description": "Replacing document with dotted key in embedded doc on pre-3.6 server yields server-side error", + "runOnRequirements": [ + { + "maxServerVersion": "3.4.99" + } + ], + "operations": [ + { + "name": "bulkWrite", + "object": "collection0", + "arguments": { + "requests": [ + { + "replaceOne": { + "filter": { + "_id": 1 + }, + "replacement": { + "_id": 1, + "a": { + "b.c": 1 + } + } + } + } + ] + }, + "expectError": { + "isClientError": false + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "update": "coll0", + "updates": [ + { + "q": { + "_id": 1 + }, + "u": { + "_id": 1, + "a": { + "b.c": 1 + } + }, + "multi": { + "$$unsetOrMatches": false + }, + "upsert": { + "$$unsetOrMatches": false + } + } + ] + } + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "coll0", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 1 + } + ] + } + ] } ] } diff --git a/data/crud/unified/bulkWrite-update-hint-clientError.json b/data/crud/unified/bulkWrite-update-hint-clientError.json new file mode 100644 index 0000000000..3fd778c273 --- /dev/null +++ b/data/crud/unified/bulkWrite-update-hint-clientError.json @@ -0,0 +1,285 @@ +{ + "description": "bulkWrite-update-hint-clientError", + "schemaVersion": "1.0", + "runOnRequirements": [ + { + "maxServerVersion": "3.3.99" + } + ], + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-v2" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test_bulkwrite_update_hint" + } + } + ], + "initialData": [ + { + "collectionName": "test_bulkwrite_update_hint", + "databaseName": "crud-v2", + "documents": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + }, + { + "_id": 4, + "x": 44 + } + ] + } + ], + "tests": [ + { + "description": "BulkWrite updateOne with update hints unsupported (client-side error)", + "operations": [ + { + "object": "collection0", + "name": "bulkWrite", + "arguments": { + "requests": [ + { + "updateOne": { + "filter": { + "_id": 1 + }, + "update": { + "$inc": { + "x": 1 + } + }, + "hint": "_id_" + } + }, + { + "updateOne": { + "filter": { + "_id": 1 + }, + "update": { + "$inc": { + "x": 1 + } + }, + "hint": { + "_id": 1 + } + } + } + ], + "ordered": true + }, + "expectError": { + "isError": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [] + } + ], + "outcome": [ + { + "collectionName": "test_bulkwrite_update_hint", + "databaseName": "crud-v2", + "documents": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + }, + { + "_id": 4, + "x": 44 + } + ] + } + ] + }, + { + "description": "BulkWrite updateMany with update hints unsupported (client-side error)", + "operations": [ + { + "object": "collection0", + "name": "bulkWrite", + "arguments": { + "requests": [ + { + "updateMany": { + "filter": { + "_id": { + "$lt": 3 + } + }, + "update": { + "$inc": { + "x": 1 + } + }, + "hint": "_id_" + } + }, + { + "updateMany": { + "filter": { + "_id": { + "$lt": 3 + } + }, + "update": { + "$inc": { + "x": 1 + } + }, + "hint": { + "_id": 1 + } + } + } + ], + "ordered": true + }, + "expectError": { + "isError": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [] + } + ], + "outcome": [ + { + "collectionName": "test_bulkwrite_update_hint", + "databaseName": "crud-v2", + "documents": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + }, + { + "_id": 4, + "x": 44 + } + ] + } + ] + }, + { + "description": "BulkWrite replaceOne with update hints unsupported (client-side error)", + "operations": [ + { + "object": "collection0", + "name": "bulkWrite", + "arguments": { + "requests": [ + { + "replaceOne": { + "filter": { + "_id": 3 + }, + "replacement": { + "x": 333 + }, + "hint": "_id_" + } + }, + { + "replaceOne": { + "filter": { + "_id": 4 + }, + "replacement": { + "x": 444 + }, + "hint": { + "_id": 1 + } + } + } + ], + "ordered": true + }, + "expectError": { + "isError": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [] + } + ], + "outcome": [ + { + "collectionName": "test_bulkwrite_update_hint", + "databaseName": "crud-v2", + "documents": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + }, + { + "_id": 4, + "x": 44 + } + ] + } + ] + } + ] + } + \ No newline at end of file diff --git a/data/crud/unified/deleteMany-hint-clientError.json b/data/crud/unified/deleteMany-hint-clientError.json new file mode 100644 index 0000000000..0ee31a2a23 --- /dev/null +++ b/data/crud/unified/deleteMany-hint-clientError.json @@ -0,0 +1,149 @@ +{ + "description": "deleteMany-hint-clientError", + "schemaVersion": "1.0", + "runOnRequirements": [ + { + "maxServerVersion": "3.3.99" + } + ], + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-v2" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "DeleteMany_hint" + } + } + ], + "initialData": [ + { + "collectionName": "DeleteMany_hint", + "databaseName": "crud-v2", + "documents": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + } + ] + } + ], + "tests": [ + { + "description": "DeleteMany with hint string unsupported (client-side error)", + "operations": [ + { + "object": "collection0", + "name": "deleteMany", + "arguments": { + "filter": { + "_id": { + "$gt": 1 + } + }, + "hint": "_id_" + }, + "expectError": { + "isError": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [] + } + ], + "outcome": [ + { + "collectionName": "DeleteMany_hint", + "databaseName": "crud-v2", + "documents": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + } + ] + } + ] + }, + { + "description": "DeleteMany with hint document unsupported (client-side error)", + "operations": [ + { + "object": "collection0", + "name": "deleteMany", + "arguments": { + "filter": { + "_id": { + "$gt": 1 + } + }, + "hint": { + "_id": 1 + } + }, + "expectError": { + "isError": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [] + } + ], + "outcome": [ + { + "collectionName": "DeleteMany_hint", + "databaseName": "crud-v2", + "documents": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + } + ] + } + ] + } + ] + } \ No newline at end of file diff --git a/data/crud/unified/deleteOne-hint-clientError.json b/data/crud/unified/deleteOne-hint-clientError.json new file mode 100644 index 0000000000..bf3e469a6a --- /dev/null +++ b/data/crud/unified/deleteOne-hint-clientError.json @@ -0,0 +1,133 @@ +{ + "description": "deleteOne-hint-clientError", + "schemaVersion": "1.0", + "runOnRequirements": [ + { + "maxServerVersion": "3.3.99" + } + ], + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-v2" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "DeleteOne_hint" + } + } + ], + "initialData": [ + { + "collectionName": "DeleteOne_hint", + "databaseName": "crud-v2", + "documents": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + } + ] + } + ], + "tests": [ + { + "description": "DeleteOne with hint string unsupported (client-side error)", + "operations": [ + { + "object": "collection0", + "name": "deleteOne", + "arguments": { + "filter": { + "_id": 1 + }, + "hint": "_id_" + }, + "expectError": { + "isError": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [] + } + ], + "outcome": [ + { + "collectionName": "DeleteOne_hint", + "databaseName": "crud-v2", + "documents": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + } + ] + } + ] + }, + { + "description": "DeleteOne with hint document unsupported (client-side error)", + "operations": [ + { + "object": "collection0", + "name": "deleteOne", + "arguments": { + "filter": { + "_id": 1 + }, + "hint": { + "_id": 1 + } + }, + "expectError": { + "isError": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [] + } + ], + "outcome": [ + { + "collectionName": "DeleteOne_hint", + "databaseName": "crud-v2", + "documents": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + } + ] + } + ] + } + ] + } \ No newline at end of file diff --git a/data/crud/unified/find-allowdiskuse-clientError.json b/data/crud/unified/find-allowdiskuse-clientError.json new file mode 100644 index 0000000000..1309d04bc9 --- /dev/null +++ b/data/crud/unified/find-allowdiskuse-clientError.json @@ -0,0 +1,79 @@ +{ + "description": "find-allowdiskuse-clientError", + "schemaVersion": "1.0", + "runOnRequirements": [ + { + "maxServerVersion": "3.0.99" + } + ], + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-v2" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test_find_allowdiskuse_clienterror" + } + } + ], + "tests": [ + { + "description": "Find fails when allowDiskUse true is specified against pre 3.2 server", + "operations": [ + { + "object": "collection0", + "name": "find", + "arguments": { + "filter": {}, + "allowDiskUse": true + }, + "expectError": { + "isError": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [] + } + ] + }, + { + "description": "Find fails when allowDiskUse false is specified against pre 3.2 server", + "operations": [ + { + "object": "collection0", + "name": "find", + "arguments": { + "filter": {}, + "allowDiskUse": false + }, + "expectError": { + "isError": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [] + } + ] + } + ] + } \ No newline at end of file diff --git a/data/crud/unified/findOneAndReplace-dots_and_dollars.json b/data/crud/unified/findOneAndReplace-dots_and_dollars.json index 5a0c551e3f..19ac447f84 100644 --- a/data/crud/unified/findOneAndReplace-dots_and_dollars.json +++ b/data/crud/unified/findOneAndReplace-dots_and_dollars.json @@ -99,6 +99,67 @@ } ] }, + { + "description": "Replacing document with top-level dotted key on pre-3.6 server yields server-side error", + "runOnRequirements": [ + { + "maxServerVersion": "3.4.99" + } + ], + "operations": [ + { + "name": "findOneAndReplace", + "object": "collection0", + "arguments": { + "filter": { + "_id": 1 + }, + "replacement": { + "_id": 1, + "a.b": 1 + } + }, + "expectError": { + "isClientError": false + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "findAndModify": "coll0", + "query": { + "_id": 1 + }, + "update": { + "_id": 1, + "a.b": 1 + }, + "new": { + "$$unsetOrMatches": false + } + } + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "coll0", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 1 + } + ] + } + ] + }, { "description": "Replacing document with dollar-prefixed key in embedded doc on 5.0+ server", "runOnRequirements": [ @@ -299,6 +360,71 @@ ] } ] + }, + { + "description": "Replacing document with dotted key in embedded doc on pre-3.6 server yields server-side error", + "runOnRequirements": [ + { + "maxServerVersion": "3.4.99" + } + ], + "operations": [ + { + "name": "findOneAndReplace", + "object": "collection0", + "arguments": { + "filter": { + "_id": 1 + }, + "replacement": { + "_id": 1, + "a": { + "b.c": 1 + } + } + }, + "expectError": { + "isClientError": false + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "findAndModify": "coll0", + "query": { + "_id": 1 + }, + "update": { + "_id": 1, + "a": { + "b.c": 1 + } + }, + "new": { + "$$unsetOrMatches": false + } + } + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "coll0", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 1 + } + ] + } + ] } ] } diff --git a/data/crud/unified/test_files.txt b/data/crud/unified/test_files.txt index fa51e9164e..cb5e3a0e5c 100644 --- a/data/crud/unified/test_files.txt +++ b/data/crud/unified/test_files.txt @@ -18,6 +18,7 @@ bulkWrite-insertOne-dots_and_dollars.json bulkWrite-replaceOne-dots_and_dollars.json bulkWrite-replaceOne-hint-unacknowledged.json bulkWrite-replaceOne-let.json +bulkWrite-update-hint-clientError.json bulkWrite-update-hint-serverError.json bulkWrite-update-hint.json bulkWrite-update-validation.json @@ -31,11 +32,13 @@ countDocuments-comment.json db-aggregate-write-readPreference.json db-aggregate.json deleteMany-comment.json +deleteMany-hint-clientError.json deleteMany-hint-serverError.json deleteMany-hint-unacknowledged.json deleteMany-hint.json deleteMany-let.json deleteOne-comment.json +deleteOne-hint-clientError.json deleteOne-hint-serverError.json deleteOne-hint-unacknowledged.json deleteOne-hint.json @@ -43,6 +46,7 @@ deleteOne-let.json distinct-comment.json estimatedDocumentCount-comment.json estimatedDocumentCount.json +find-allowdiskuse-clientError.json find-allowdiskuse-serverError.json find-allowdiskuse.json find-comment.json @@ -80,6 +84,7 @@ replaceOne-let.json replaceOne-validation.json updateMany-comment.json updateMany-dots_and_dollars.json +updateMany-hint-clientError.json updateMany-hint-serverError.json updateMany-hint-unacknowledged.json updateMany-hint.json @@ -87,6 +92,7 @@ updateMany-let.json updateMany-validation.json updateOne-comment.json updateOne-dots_and_dollars.json +updateOne-hint-clientError.json updateOne-hint-serverError.json updateOne-hint-unacknowledged.json updateOne-hint.json diff --git a/data/crud/unified/updateMany-hint-clientError.json b/data/crud/unified/updateMany-hint-clientError.json new file mode 100644 index 0000000000..838408faf5 --- /dev/null +++ b/data/crud/unified/updateMany-hint-clientError.json @@ -0,0 +1,159 @@ +{ + "description": "updateMany-hint-clientError", + "schemaVersion": "1.0", + "runOnRequirements": [ + { + "maxServerVersion": "3.3.99" + } + ], + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-v2" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test_updatemany_hint" + } + } + ], + "initialData": [ + { + "collectionName": "test_updatemany_hint", + "databaseName": "crud-v2", + "documents": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + } + ] + } + ], + "tests": [ + { + "description": "UpdateMany with hint string unsupported (client-side error)", + "operations": [ + { + "object": "collection0", + "name": "updateMany", + "arguments": { + "filter": { + "_id": { + "$gt": 1 + } + }, + "update": { + "$inc": { + "x": 1 + } + }, + "hint": "_id_" + }, + "expectError": { + "isError": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [] + } + ], + "outcome": [ + { + "collectionName": "test_updatemany_hint", + "databaseName": "crud-v2", + "documents": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + } + ] + } + ] + }, + { + "description": "UpdateMany with hint document unsupported (client-side error)", + "operations": [ + { + "object": "collection0", + "name": "updateMany", + "arguments": { + "filter": { + "_id": { + "$gt": 1 + } + }, + "update": { + "$inc": { + "x": 1 + } + }, + "hint": { + "_id": 1 + } + }, + "expectError": { + "isError": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [] + } + ], + "outcome": [ + { + "collectionName": "test_updatemany_hint", + "databaseName": "crud-v2", + "documents": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + } + ] + } + ] + } + ] + } \ No newline at end of file diff --git a/data/crud/unified/updateOne-hint-clientError.json b/data/crud/unified/updateOne-hint-clientError.json new file mode 100644 index 0000000000..a8416b06bb --- /dev/null +++ b/data/crud/unified/updateOne-hint-clientError.json @@ -0,0 +1,147 @@ +{ + "description": "updateOne-hint-clientError", + "schemaVersion": "1.0", + "runOnRequirements": [ + { + "maxServerVersion": "3.3.99" + } + ], + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-v2" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test_updateone_hint" + } + } + ], + "initialData": [ + { + "collectionName": "test_updateone_hint", + "databaseName": "crud-v2", + "documents": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + } + ] + } + ], + "tests": [ + { + "description": "UpdateOne with hint string unsupported (client-side error)", + "operations": [ + { + "object": "collection0", + "name": "updateOne", + "arguments": { + "filter": { + "_id": { + "$gt": 1 + } + }, + "update": { + "$inc": { + "x": 1 + } + }, + "hint": "_id_" + }, + "expectError": { + "isError": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [] + } + ], + "outcome": [ + { + "collectionName": "test_updateone_hint", + "databaseName": "crud-v2", + "documents": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + } + ] + } + ] + }, + { + "description": "UpdateOne with hint document unsupported (client-side error)", + "operations": [ + { + "object": "collection0", + "name": "updateOne", + "arguments": { + "filter": { + "_id": { + "$gt": 1 + } + }, + "update": { + "$inc": { + "x": 1 + } + }, + "hint": { + "_id": 1 + } + }, + "expectError": { + "isError": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [] + } + ], + "outcome": [ + { + "collectionName": "test_updateone_hint", + "databaseName": "crud-v2", + "documents": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + } + ] + } + ] + } + ] + } \ No newline at end of file From 986e29d87e81c20211ebbac31457fd0d2288fd9d Mon Sep 17 00:00:00 2001 From: Julia Garland Date: Wed, 24 Jul 2024 16:03:48 +0000 Subject: [PATCH 4/7] Remove non-spec test case with maxWireVersion < 5 --- src/mongocxx/test/collection.cpp | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/src/mongocxx/test/collection.cpp b/src/mongocxx/test/collection.cpp index f4cf3a383b..276007f0e6 100644 --- a/src/mongocxx/test/collection.cpp +++ b/src/mongocxx/test/collection.cpp @@ -2194,27 +2194,6 @@ TEST_CASE("CRUD functionality", "[driver::collection]") { REQUIRE(result->inserted_count() == 1); } - SECTION("fail if server has maxWireVersion < 5 and write has collation") { - if (test_util::get_max_wire_version(mongodb_client) < 5) { - collection coll = db["bulk_write_collation"]; - coll.drop(); - - auto collation = - make_document(kvp("collation", make_document(kvp("locale", "en_US")))); - - model::delete_one first{std::move(doc1)}; - model::delete_one second{std::move(doc2)}; - - second.collation(collation.view()); - - auto bulk = coll.create_bulk_write(bulk_opts); - bulk.append(first); - bulk.append(second); - - REQUIRE_THROWS_AS(bulk.execute(), operation_exception); - } - } - SECTION("bypass_document_validation ignores validation_criteria", "[collection]") { std::string collname = "bulk_write_bypass_document_validation"; db[collname].drop(); From 4094972551dde184c1217d5eb5f60450b7e49570 Mon Sep 17 00:00:00 2001 From: Julia Garland Date: Wed, 24 Jul 2024 16:19:53 +0000 Subject: [PATCH 5/7] Revert JSON file whitespace --- .../bulkWrite-update-hint-clientError.json | 517 +++++++++--------- .../unified/deleteMany-hint-clientError.json | 276 +++++----- .../unified/deleteOne-hint-clientError.json | 244 ++++----- .../find-allowdiskuse-clientError.json | 146 ++--- .../unified/updateMany-hint-clientError.json | 294 +++++----- .../unified/updateOne-hint-clientError.json | 270 ++++----- 6 files changed, 873 insertions(+), 874 deletions(-) diff --git a/data/crud/unified/bulkWrite-update-hint-clientError.json b/data/crud/unified/bulkWrite-update-hint-clientError.json index 3fd778c273..ec381dde80 100644 --- a/data/crud/unified/bulkWrite-update-hint-clientError.json +++ b/data/crud/unified/bulkWrite-update-hint-clientError.json @@ -1,285 +1,284 @@ { - "description": "bulkWrite-update-hint-clientError", - "schemaVersion": "1.0", - "runOnRequirements": [ - { - "maxServerVersion": "3.3.99" + "description": "bulkWrite-update-hint-clientError", + "schemaVersion": "1.0", + "runOnRequirements": [ + { + "maxServerVersion": "3.3.99" + } + ], + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ] } - ], - "createEntities": [ - { - "client": { - "id": "client0", - "observeEvents": [ - "commandStartedEvent" - ] - } - }, - { - "database": { - "id": "database0", - "client": "client0", - "databaseName": "crud-v2" - } - }, - { - "collection": { - "id": "collection0", - "database": "database0", - "collectionName": "test_bulkwrite_update_hint" - } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-v2" } - ], - "initialData": [ - { - "collectionName": "test_bulkwrite_update_hint", - "databaseName": "crud-v2", - "documents": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 22 - }, - { - "_id": 3, - "x": 33 - }, - { - "_id": 4, - "x": 44 - } - ] + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test_bulkwrite_update_hint" } - ], - "tests": [ - { - "description": "BulkWrite updateOne with update hints unsupported (client-side error)", - "operations": [ - { - "object": "collection0", - "name": "bulkWrite", - "arguments": { - "requests": [ - { - "updateOne": { - "filter": { - "_id": 1 - }, - "update": { - "$inc": { - "x": 1 - } - }, - "hint": "_id_" - } - }, - { - "updateOne": { - "filter": { - "_id": 1 - }, - "update": { - "$inc": { - "x": 1 - } - }, - "hint": { - "_id": 1 + } + ], + "initialData": [ + { + "collectionName": "test_bulkwrite_update_hint", + "databaseName": "crud-v2", + "documents": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + }, + { + "_id": 4, + "x": 44 + } + ] + } + ], + "tests": [ + { + "description": "BulkWrite updateOne with update hints unsupported (client-side error)", + "operations": [ + { + "object": "collection0", + "name": "bulkWrite", + "arguments": { + "requests": [ + { + "updateOne": { + "filter": { + "_id": 1 + }, + "update": { + "$inc": { + "x": 1 } - } + }, + "hint": "_id_" } - ], - "ordered": true - }, - "expectError": { - "isError": true - } - } - ], - "expectEvents": [ - { - "client": "client0", - "events": [] - } - ], - "outcome": [ - { - "collectionName": "test_bulkwrite_update_hint", - "databaseName": "crud-v2", - "documents": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 22 - }, - { - "_id": 3, - "x": 33 }, { - "_id": 4, - "x": 44 - } - ] - } - ] - }, - { - "description": "BulkWrite updateMany with update hints unsupported (client-side error)", - "operations": [ - { - "object": "collection0", - "name": "bulkWrite", - "arguments": { - "requests": [ - { - "updateMany": { - "filter": { - "_id": { - "$lt": 3 - } - }, - "update": { - "$inc": { - "x": 1 - } - }, - "hint": "_id_" - } - }, - { - "updateMany": { - "filter": { - "_id": { - "$lt": 3 - } - }, - "update": { - "$inc": { - "x": 1 - } - }, - "hint": { - "_id": 1 + "updateOne": { + "filter": { + "_id": 1 + }, + "update": { + "$inc": { + "x": 1 } + }, + "hint": { + "_id": 1 } } - ], - "ordered": true + } + ], + "ordered": true + }, + "expectError": { + "isError": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [] + } + ], + "outcome": [ + { + "collectionName": "test_bulkwrite_update_hint", + "databaseName": "crud-v2", + "documents": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 }, - "expectError": { - "isError": true + { + "_id": 3, + "x": 33 + }, + { + "_id": 4, + "x": 44 } - } - ], - "expectEvents": [ - { - "client": "client0", - "events": [] - } - ], - "outcome": [ - { - "collectionName": "test_bulkwrite_update_hint", - "databaseName": "crud-v2", - "documents": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 22 - }, + ] + } + ] + }, + { + "description": "BulkWrite updateMany with update hints unsupported (client-side error)", + "operations": [ + { + "object": "collection0", + "name": "bulkWrite", + "arguments": { + "requests": [ { - "_id": 3, - "x": 33 + "updateMany": { + "filter": { + "_id": { + "$lt": 3 + } + }, + "update": { + "$inc": { + "x": 1 + } + }, + "hint": "_id_" + } }, { - "_id": 4, - "x": 44 - } - ] - } - ] - }, - { - "description": "BulkWrite replaceOne with update hints unsupported (client-side error)", - "operations": [ - { - "object": "collection0", - "name": "bulkWrite", - "arguments": { - "requests": [ - { - "replaceOne": { - "filter": { - "_id": 3 - }, - "replacement": { - "x": 333 - }, - "hint": "_id_" - } - }, - { - "replaceOne": { - "filter": { - "_id": 4 - }, - "replacement": { - "x": 444 - }, - "hint": { - "_id": 1 + "updateMany": { + "filter": { + "_id": { + "$lt": 3 } + }, + "update": { + "$inc": { + "x": 1 + } + }, + "hint": { + "_id": 1 } } - ], - "ordered": true + } + ], + "ordered": true + }, + "expectError": { + "isError": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [] + } + ], + "outcome": [ + { + "collectionName": "test_bulkwrite_update_hint", + "databaseName": "crud-v2", + "documents": [ + { + "_id": 1, + "x": 11 }, - "expectError": { - "isError": true + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + }, + { + "_id": 4, + "x": 44 } - } - ], - "expectEvents": [ - { - "client": "client0", - "events": [] - } - ], - "outcome": [ - { - "collectionName": "test_bulkwrite_update_hint", - "databaseName": "crud-v2", - "documents": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 22 - }, + ] + } + ] + }, + { + "description": "BulkWrite replaceOne with update hints unsupported (client-side error)", + "operations": [ + { + "object": "collection0", + "name": "bulkWrite", + "arguments": { + "requests": [ { - "_id": 3, - "x": 33 + "replaceOne": { + "filter": { + "_id": 3 + }, + "replacement": { + "x": 333 + }, + "hint": "_id_" + } }, { - "_id": 4, - "x": 44 + "replaceOne": { + "filter": { + "_id": 4 + }, + "replacement": { + "x": 444 + }, + "hint": { + "_id": 1 + } + } } - ] + ], + "ordered": true + }, + "expectError": { + "isError": true } - ] - } - ] - } - \ No newline at end of file + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [] + } + ], + "outcome": [ + { + "collectionName": "test_bulkwrite_update_hint", + "databaseName": "crud-v2", + "documents": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + }, + { + "_id": 4, + "x": 44 + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/data/crud/unified/deleteMany-hint-clientError.json b/data/crud/unified/deleteMany-hint-clientError.json index 0ee31a2a23..fc0a4d39ae 100644 --- a/data/crud/unified/deleteMany-hint-clientError.json +++ b/data/crud/unified/deleteMany-hint-clientError.json @@ -1,149 +1,149 @@ { - "description": "deleteMany-hint-clientError", - "schemaVersion": "1.0", - "runOnRequirements": [ - { - "maxServerVersion": "3.3.99" + "description": "deleteMany-hint-clientError", + "schemaVersion": "1.0", + "runOnRequirements": [ + { + "maxServerVersion": "3.3.99" + } + ], + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ] } - ], - "createEntities": [ - { - "client": { - "id": "client0", - "observeEvents": [ - "commandStartedEvent" - ] - } - }, - { - "database": { - "id": "database0", - "client": "client0", - "databaseName": "crud-v2" - } - }, - { - "collection": { - "id": "collection0", - "database": "database0", - "collectionName": "DeleteMany_hint" - } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-v2" } - ], - "initialData": [ - { - "collectionName": "DeleteMany_hint", - "databaseName": "crud-v2", - "documents": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 22 + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "DeleteMany_hint" + } + } + ], + "initialData": [ + { + "collectionName": "DeleteMany_hint", + "databaseName": "crud-v2", + "documents": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + } + ] + } + ], + "tests": [ + { + "description": "DeleteMany with hint string unsupported (client-side error)", + "operations": [ + { + "object": "collection0", + "name": "deleteMany", + "arguments": { + "filter": { + "_id": { + "$gt": 1 + } + }, + "hint": "_id_" }, - { - "_id": 3, - "x": 33 + "expectError": { + "isError": true } - ] - } - ], - "tests": [ - { - "description": "DeleteMany with hint string unsupported (client-side error)", - "operations": [ - { - "object": "collection0", - "name": "deleteMany", - "arguments": { - "filter": { - "_id": { - "$gt": 1 - } - }, - "hint": "_id_" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [] + } + ], + "outcome": [ + { + "collectionName": "DeleteMany_hint", + "databaseName": "crud-v2", + "documents": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 }, - "expectError": { - "isError": true + { + "_id": 3, + "x": 33 } - } - ], - "expectEvents": [ - { - "client": "client0", - "events": [] - } - ], - "outcome": [ - { - "collectionName": "DeleteMany_hint", - "databaseName": "crud-v2", - "documents": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 22 - }, - { - "_id": 3, - "x": 33 - } - ] - } - ] - }, - { - "description": "DeleteMany with hint document unsupported (client-side error)", - "operations": [ - { - "object": "collection0", - "name": "deleteMany", - "arguments": { - "filter": { - "_id": { - "$gt": 1 - } - }, - "hint": { - "_id": 1 + ] + } + ] + }, + { + "description": "DeleteMany with hint document unsupported (client-side error)", + "operations": [ + { + "object": "collection0", + "name": "deleteMany", + "arguments": { + "filter": { + "_id": { + "$gt": 1 } }, - "expectError": { - "isError": true + "hint": { + "_id": 1 } + }, + "expectError": { + "isError": true } - ], - "expectEvents": [ - { - "client": "client0", - "events": [] - } - ], - "outcome": [ - { - "collectionName": "DeleteMany_hint", - "databaseName": "crud-v2", - "documents": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 22 - }, - { - "_id": 3, - "x": 33 - } - ] - } - ] - } - ] - } \ No newline at end of file + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [] + } + ], + "outcome": [ + { + "collectionName": "DeleteMany_hint", + "databaseName": "crud-v2", + "documents": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/data/crud/unified/deleteOne-hint-clientError.json b/data/crud/unified/deleteOne-hint-clientError.json index bf3e469a6a..94ca69c3f4 100644 --- a/data/crud/unified/deleteOne-hint-clientError.json +++ b/data/crud/unified/deleteOne-hint-clientError.json @@ -1,133 +1,133 @@ { - "description": "deleteOne-hint-clientError", - "schemaVersion": "1.0", - "runOnRequirements": [ - { - "maxServerVersion": "3.3.99" + "description": "deleteOne-hint-clientError", + "schemaVersion": "1.0", + "runOnRequirements": [ + { + "maxServerVersion": "3.3.99" + } + ], + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ] } - ], - "createEntities": [ - { - "client": { - "id": "client0", - "observeEvents": [ - "commandStartedEvent" - ] + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-v2" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "DeleteOne_hint" + } + } + ], + "initialData": [ + { + "collectionName": "DeleteOne_hint", + "databaseName": "crud-v2", + "documents": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + } + ] + } + ], + "tests": [ + { + "description": "DeleteOne with hint string unsupported (client-side error)", + "operations": [ + { + "object": "collection0", + "name": "deleteOne", + "arguments": { + "filter": { + "_id": 1 + }, + "hint": "_id_" + }, + "expectError": { + "isError": true + } } - }, - { - "database": { - "id": "database0", + ], + "expectEvents": [ + { "client": "client0", - "databaseName": "crud-v2" + "events": [] } - }, - { - "collection": { - "id": "collection0", - "database": "database0", - "collectionName": "DeleteOne_hint" + ], + "outcome": [ + { + "collectionName": "DeleteOne_hint", + "databaseName": "crud-v2", + "documents": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + } + ] } - } - ], - "initialData": [ - { - "collectionName": "DeleteOne_hint", - "databaseName": "crud-v2", - "documents": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 22 - } - ] - } - ], - "tests": [ - { - "description": "DeleteOne with hint string unsupported (client-side error)", - "operations": [ - { - "object": "collection0", - "name": "deleteOne", - "arguments": { - "filter": { - "_id": 1 - }, - "hint": "_id_" + ] + }, + { + "description": "DeleteOne with hint document unsupported (client-side error)", + "operations": [ + { + "object": "collection0", + "name": "deleteOne", + "arguments": { + "filter": { + "_id": 1 }, - "expectError": { - "isError": true + "hint": { + "_id": 1 } + }, + "expectError": { + "isError": true } - ], - "expectEvents": [ - { - "client": "client0", - "events": [] - } - ], - "outcome": [ - { - "collectionName": "DeleteOne_hint", - "databaseName": "crud-v2", - "documents": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 22 - } - ] - } - ] - }, - { - "description": "DeleteOne with hint document unsupported (client-side error)", - "operations": [ - { - "object": "collection0", - "name": "deleteOne", - "arguments": { - "filter": { - "_id": 1 - }, - "hint": { - "_id": 1 - } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [] + } + ], + "outcome": [ + { + "collectionName": "DeleteOne_hint", + "databaseName": "crud-v2", + "documents": [ + { + "_id": 1, + "x": 11 }, - "expectError": { - "isError": true + { + "_id": 2, + "x": 22 } - } - ], - "expectEvents": [ - { - "client": "client0", - "events": [] - } - ], - "outcome": [ - { - "collectionName": "DeleteOne_hint", - "databaseName": "crud-v2", - "documents": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 22 - } - ] - } - ] - } - ] - } \ No newline at end of file + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/data/crud/unified/find-allowdiskuse-clientError.json b/data/crud/unified/find-allowdiskuse-clientError.json index 1309d04bc9..4ce584d324 100644 --- a/data/crud/unified/find-allowdiskuse-clientError.json +++ b/data/crud/unified/find-allowdiskuse-clientError.json @@ -1,79 +1,79 @@ { - "description": "find-allowdiskuse-clientError", - "schemaVersion": "1.0", - "runOnRequirements": [ - { - "maxServerVersion": "3.0.99" + "description": "find-allowdiskuse-clientError", + "schemaVersion": "1.0", + "runOnRequirements": [ + { + "maxServerVersion": "3.0.99" + } + ], + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-v2" } - ], - "createEntities": [ - { - "client": { - "id": "client0", - "observeEvents": [ - "commandStartedEvent" - ] + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test_find_allowdiskuse_clienterror" + } + } + ], + "tests": [ + { + "description": "Find fails when allowDiskUse true is specified against pre 3.2 server", + "operations": [ + { + "object": "collection0", + "name": "find", + "arguments": { + "filter": {}, + "allowDiskUse": true + }, + "expectError": { + "isError": true + } } - }, - { - "database": { - "id": "database0", + ], + "expectEvents": [ + { "client": "client0", - "databaseName": "crud-v2" + "events": [] } - }, - { - "collection": { - "id": "collection0", - "database": "database0", - "collectionName": "test_find_allowdiskuse_clienterror" - } - } - ], - "tests": [ - { - "description": "Find fails when allowDiskUse true is specified against pre 3.2 server", - "operations": [ - { - "object": "collection0", - "name": "find", - "arguments": { - "filter": {}, - "allowDiskUse": true - }, - "expectError": { - "isError": true - } + ] + }, + { + "description": "Find fails when allowDiskUse false is specified against pre 3.2 server", + "operations": [ + { + "object": "collection0", + "name": "find", + "arguments": { + "filter": {}, + "allowDiskUse": false + }, + "expectError": { + "isError": true } - ], - "expectEvents": [ - { - "client": "client0", - "events": [] - } - ] - }, - { - "description": "Find fails when allowDiskUse false is specified against pre 3.2 server", - "operations": [ - { - "object": "collection0", - "name": "find", - "arguments": { - "filter": {}, - "allowDiskUse": false - }, - "expectError": { - "isError": true - } - } - ], - "expectEvents": [ - { - "client": "client0", - "events": [] - } - ] - } - ] - } \ No newline at end of file + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [] + } + ] + } + ] +} \ No newline at end of file diff --git a/data/crud/unified/updateMany-hint-clientError.json b/data/crud/unified/updateMany-hint-clientError.json index 838408faf5..c6e280f63d 100644 --- a/data/crud/unified/updateMany-hint-clientError.json +++ b/data/crud/unified/updateMany-hint-clientError.json @@ -1,159 +1,159 @@ { - "description": "updateMany-hint-clientError", - "schemaVersion": "1.0", - "runOnRequirements": [ - { - "maxServerVersion": "3.3.99" + "description": "updateMany-hint-clientError", + "schemaVersion": "1.0", + "runOnRequirements": [ + { + "maxServerVersion": "3.3.99" + } + ], + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ] } - ], - "createEntities": [ - { - "client": { - "id": "client0", - "observeEvents": [ - "commandStartedEvent" - ] - } - }, - { - "database": { - "id": "database0", - "client": "client0", - "databaseName": "crud-v2" - } - }, - { - "collection": { - "id": "collection0", - "database": "database0", - "collectionName": "test_updatemany_hint" - } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-v2" } - ], - "initialData": [ - { - "collectionName": "test_updatemany_hint", - "databaseName": "crud-v2", - "documents": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 22 + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test_updatemany_hint" + } + } + ], + "initialData": [ + { + "collectionName": "test_updatemany_hint", + "databaseName": "crud-v2", + "documents": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + } + ] + } + ], + "tests": [ + { + "description": "UpdateMany with hint string unsupported (client-side error)", + "operations": [ + { + "object": "collection0", + "name": "updateMany", + "arguments": { + "filter": { + "_id": { + "$gt": 1 + } + }, + "update": { + "$inc": { + "x": 1 + } + }, + "hint": "_id_" }, - { - "_id": 3, - "x": 33 + "expectError": { + "isError": true } - ] - } - ], - "tests": [ - { - "description": "UpdateMany with hint string unsupported (client-side error)", - "operations": [ - { - "object": "collection0", - "name": "updateMany", - "arguments": { - "filter": { - "_id": { - "$gt": 1 - } - }, - "update": { - "$inc": { - "x": 1 - } - }, - "hint": "_id_" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [] + } + ], + "outcome": [ + { + "collectionName": "test_updatemany_hint", + "databaseName": "crud-v2", + "documents": [ + { + "_id": 1, + "x": 11 }, - "expectError": { - "isError": true + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 } - } - ], - "expectEvents": [ - { - "client": "client0", - "events": [] - } - ], - "outcome": [ - { - "collectionName": "test_updatemany_hint", - "databaseName": "crud-v2", - "documents": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 22 - }, - { - "_id": 3, - "x": 33 + ] + } + ] + }, + { + "description": "UpdateMany with hint document unsupported (client-side error)", + "operations": [ + { + "object": "collection0", + "name": "updateMany", + "arguments": { + "filter": { + "_id": { + "$gt": 1 } - ] - } - ] - }, - { - "description": "UpdateMany with hint document unsupported (client-side error)", - "operations": [ - { - "object": "collection0", - "name": "updateMany", - "arguments": { - "filter": { - "_id": { - "$gt": 1 - } - }, - "update": { - "$inc": { - "x": 1 - } - }, - "hint": { - "_id": 1 + }, + "update": { + "$inc": { + "x": 1 } }, - "expectError": { - "isError": true + "hint": { + "_id": 1 } + }, + "expectError": { + "isError": true } - ], - "expectEvents": [ - { - "client": "client0", - "events": [] - } - ], - "outcome": [ - { - "collectionName": "test_updatemany_hint", - "databaseName": "crud-v2", - "documents": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 22 - }, - { - "_id": 3, - "x": 33 - } - ] - } - ] - } - ] - } \ No newline at end of file + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [] + } + ], + "outcome": [ + { + "collectionName": "test_updatemany_hint", + "databaseName": "crud-v2", + "documents": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/data/crud/unified/updateOne-hint-clientError.json b/data/crud/unified/updateOne-hint-clientError.json index a8416b06bb..d1aa73d687 100644 --- a/data/crud/unified/updateOne-hint-clientError.json +++ b/data/crud/unified/updateOne-hint-clientError.json @@ -1,147 +1,147 @@ { - "description": "updateOne-hint-clientError", - "schemaVersion": "1.0", - "runOnRequirements": [ - { - "maxServerVersion": "3.3.99" + "description": "updateOne-hint-clientError", + "schemaVersion": "1.0", + "runOnRequirements": [ + { + "maxServerVersion": "3.3.99" + } + ], + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ] } - ], - "createEntities": [ - { - "client": { - "id": "client0", - "observeEvents": [ - "commandStartedEvent" - ] - } - }, - { - "database": { - "id": "database0", - "client": "client0", - "databaseName": "crud-v2" - } - }, - { - "collection": { - "id": "collection0", - "database": "database0", - "collectionName": "test_updateone_hint" - } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-v2" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test_updateone_hint" } - ], - "initialData": [ - { - "collectionName": "test_updateone_hint", - "databaseName": "crud-v2", - "documents": [ - { - "_id": 1, - "x": 11 + } + ], + "initialData": [ + { + "collectionName": "test_updateone_hint", + "databaseName": "crud-v2", + "documents": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + } + ] + } + ], + "tests": [ + { + "description": "UpdateOne with hint string unsupported (client-side error)", + "operations": [ + { + "object": "collection0", + "name": "updateOne", + "arguments": { + "filter": { + "_id": { + "$gt": 1 + } + }, + "update": { + "$inc": { + "x": 1 + } + }, + "hint": "_id_" }, - { - "_id": 2, - "x": 22 + "expectError": { + "isError": true } - ] - } - ], - "tests": [ - { - "description": "UpdateOne with hint string unsupported (client-side error)", - "operations": [ - { - "object": "collection0", - "name": "updateOne", - "arguments": { - "filter": { - "_id": { - "$gt": 1 - } - }, - "update": { - "$inc": { - "x": 1 - } - }, - "hint": "_id_" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [] + } + ], + "outcome": [ + { + "collectionName": "test_updateone_hint", + "databaseName": "crud-v2", + "documents": [ + { + "_id": 1, + "x": 11 }, - "expectError": { - "isError": true + { + "_id": 2, + "x": 22 } - } - ], - "expectEvents": [ - { - "client": "client0", - "events": [] - } - ], - "outcome": [ - { - "collectionName": "test_updateone_hint", - "databaseName": "crud-v2", - "documents": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 22 + ] + } + ] + }, + { + "description": "UpdateOne with hint document unsupported (client-side error)", + "operations": [ + { + "object": "collection0", + "name": "updateOne", + "arguments": { + "filter": { + "_id": { + "$gt": 1 } - ] - } - ] - }, - { - "description": "UpdateOne with hint document unsupported (client-side error)", - "operations": [ - { - "object": "collection0", - "name": "updateOne", - "arguments": { - "filter": { - "_id": { - "$gt": 1 - } - }, - "update": { - "$inc": { - "x": 1 - } - }, - "hint": { - "_id": 1 + }, + "update": { + "$inc": { + "x": 1 } }, - "expectError": { - "isError": true + "hint": { + "_id": 1 } + }, + "expectError": { + "isError": true } - ], - "expectEvents": [ - { - "client": "client0", - "events": [] - } - ], - "outcome": [ - { - "collectionName": "test_updateone_hint", - "databaseName": "crud-v2", - "documents": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 22 - } - ] - } - ] - } - ] - } \ No newline at end of file + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [] + } + ], + "outcome": [ + { + "collectionName": "test_updateone_hint", + "databaseName": "crud-v2", + "documents": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + } + ] + } + ] + } + ] +} \ No newline at end of file From 8ee21a2a1cf6231f4fc7e139ad933ebd76859969 Mon Sep 17 00:00:00 2001 From: Julia Garland Date: Thu, 25 Jul 2024 17:24:54 +0000 Subject: [PATCH 6/7] Revert whitespace to master --- data/crud/unified/bulkWrite-update-hint-clientError.json | 2 +- data/crud/unified/deleteMany-hint-clientError.json | 2 +- data/crud/unified/deleteOne-hint-clientError.json | 2 +- data/crud/unified/find-allowdiskuse-clientError.json | 2 +- data/crud/unified/updateMany-hint-clientError.json | 2 +- data/crud/unified/updateOne-hint-clientError.json | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/data/crud/unified/bulkWrite-update-hint-clientError.json b/data/crud/unified/bulkWrite-update-hint-clientError.json index ec381dde80..d5eb71c29e 100644 --- a/data/crud/unified/bulkWrite-update-hint-clientError.json +++ b/data/crud/unified/bulkWrite-update-hint-clientError.json @@ -281,4 +281,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/data/crud/unified/deleteMany-hint-clientError.json b/data/crud/unified/deleteMany-hint-clientError.json index fc0a4d39ae..66320122b5 100644 --- a/data/crud/unified/deleteMany-hint-clientError.json +++ b/data/crud/unified/deleteMany-hint-clientError.json @@ -146,4 +146,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/data/crud/unified/deleteOne-hint-clientError.json b/data/crud/unified/deleteOne-hint-clientError.json index 94ca69c3f4..cf629f59e0 100644 --- a/data/crud/unified/deleteOne-hint-clientError.json +++ b/data/crud/unified/deleteOne-hint-clientError.json @@ -130,4 +130,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/data/crud/unified/find-allowdiskuse-clientError.json b/data/crud/unified/find-allowdiskuse-clientError.json index 4ce584d324..5bd954e79d 100644 --- a/data/crud/unified/find-allowdiskuse-clientError.json +++ b/data/crud/unified/find-allowdiskuse-clientError.json @@ -76,4 +76,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/data/crud/unified/updateMany-hint-clientError.json b/data/crud/unified/updateMany-hint-clientError.json index c6e280f63d..5da878e293 100644 --- a/data/crud/unified/updateMany-hint-clientError.json +++ b/data/crud/unified/updateMany-hint-clientError.json @@ -156,4 +156,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/data/crud/unified/updateOne-hint-clientError.json b/data/crud/unified/updateOne-hint-clientError.json index d1aa73d687..d4f1a53430 100644 --- a/data/crud/unified/updateOne-hint-clientError.json +++ b/data/crud/unified/updateOne-hint-clientError.json @@ -144,4 +144,4 @@ ] } ] -} \ No newline at end of file +} From f65c7e056fe37035036c3ca1399b2d684c4d96de Mon Sep 17 00:00:00 2001 From: Julia Garland Date: Thu, 25 Jul 2024 17:52:14 +0000 Subject: [PATCH 7/7] Remove dead code in tests --- src/mongocxx/test/client_helpers.cpp | 4 - src/mongocxx/test/client_helpers.hh | 9 - src/mongocxx/test/collection.cpp | 468 +++++++++------------------ src/mongocxx/test/index_view.cpp | 55 ++-- 4 files changed, 179 insertions(+), 357 deletions(-) diff --git a/src/mongocxx/test/client_helpers.cpp b/src/mongocxx/test/client_helpers.cpp index 2bda85348a..8121898ccd 100644 --- a/src/mongocxx/test/client_helpers.cpp +++ b/src/mongocxx/test/client_helpers.cpp @@ -297,10 +297,6 @@ stdx::optional parse_test_file(std::string path) { return bsoncxx::from_json(stream.str()); } -bool supports_collation(const client& client) { - return get_max_wire_version(client) >= 5; -} - bsoncxx::document::value transform_document(bsoncxx::document::view view, const xformer_t& fcn) { bsoncxx::builder::basic::array context; diff --git a/src/mongocxx/test/client_helpers.hh b/src/mongocxx/test/client_helpers.hh index 9481087ba1..89c594520c 100644 --- a/src/mongocxx/test/client_helpers.hh +++ b/src/mongocxx/test/client_helpers.hh @@ -125,15 +125,6 @@ std::string get_hosts(const client& client = {uri{}, add_test_server_api()}); /// stdx::optional parse_test_file(std::string path); -// -// Determines whether or not the given client supports the collation feature, by running the -// "hello" command. -// -// Throws mongocxx::operation_exception if the operation fails, or the server reply is -// malformed. -// -bool supports_collation(const client& client); - using item_t = std::pair, bsoncxx::types::bson_value::view>; using xformer_t = std::function(item_t, bsoncxx::builder::basic::array*)>; diff --git a/src/mongocxx/test/collection.cpp b/src/mongocxx/test/collection.cpp index 276007f0e6..009faa8729 100644 --- a/src/mongocxx/test/collection.cpp +++ b/src/mongocxx/test/collection.cpp @@ -462,11 +462,7 @@ TEST_CASE("CRUD functionality", "[driver::collection]") { auto predicate = make_document(kvp("x", "FOO")); auto find_opts = options::find{}.collation(case_insensitive_collation.view()); auto cursor = coll.find(predicate.view(), find_opts); - if (test_util::supports_collation(mongodb_client)) { - REQUIRE(std::distance(cursor.begin(), cursor.end()) == 1); - } else { - REQUIRE_THROWS_AS(std::distance(cursor.begin(), cursor.end()), query_exception); - } + REQUIRE(std::distance(cursor.begin(), cursor.end()) == 1); } SECTION("find with return_key", "[collection]") { @@ -519,11 +515,7 @@ TEST_CASE("CRUD functionality", "[driver::collection]") { auto predicate = make_document(kvp("x", "FOO")); auto find_opts = options::find{}.collation(case_insensitive_collation.view()); - if (test_util::supports_collation(mongodb_client)) { - REQUIRE(coll.find_one(predicate.view(), find_opts)); - } else { - REQUIRE_THROWS_AS(coll.find_one(predicate.view(), find_opts), query_exception); - } + REQUIRE(coll.find_one(predicate.view(), find_opts)); } SECTION("insert and update single document", "[collection]") { @@ -674,21 +666,16 @@ TEST_CASE("CRUD functionality", "[driver::collection]") { update_doc.append(kvp("$set", make_document(kvp("changed", true)))); auto update_opts = options::update{}.collation(case_insensitive_collation.view()); - if (test_util::supports_collation(mongodb_client)) { - INFO("unacknowledged write concern fails"); - update_opts.write_concern(noack); - REQUIRE_THROWS_AS(coll.update_one(predicate.view(), update_doc.view(), update_opts), - operation_exception); - - INFO("default write concern succeeds"); - update_opts.write_concern(default_wc); - auto result = coll.update_one(predicate.view(), update_doc.view(), update_opts); - REQUIRE(result); - REQUIRE(result->modified_count() == 1); - } else { - REQUIRE_THROWS_AS(coll.update_one(predicate.view(), update_doc.view(), update_opts), - bulk_write_exception); - } + INFO("unacknowledged write concern fails"); + update_opts.write_concern(noack); + REQUIRE_THROWS_AS(coll.update_one(predicate.view(), update_doc.view(), update_opts), + operation_exception); + + INFO("default write concern succeeds"); + update_opts.write_concern(default_wc); + auto result = coll.update_one(predicate.view(), update_doc.view(), update_opts); + REQUIRE(result); + REQUIRE(result->modified_count() == 1); } SECTION("insert and update multiple documents", "[collection]") { @@ -793,22 +780,16 @@ TEST_CASE("CRUD functionality", "[driver::collection]") { update_doc.append(kvp("$set", make_document(kvp("changed", true)))); auto update_opts = options::update{}.collation(case_insensitive_collation.view()); - if (test_util::supports_collation(mongodb_client)) { - INFO("unacknowledged write concern fails"); - update_opts.write_concern(noack); - REQUIRE_THROWS_AS(coll.update_many(predicate.view(), update_doc.view(), update_opts), - operation_exception); - - INFO("default write concern succeeds"); - update_opts.write_concern(default_wc); - auto result = coll.update_many(predicate.view(), update_doc.view(), update_opts); - REQUIRE(result); - REQUIRE(result->modified_count() == 1); - - } else { - REQUIRE_THROWS_AS(coll.update_many(predicate.view(), update_doc.view(), update_opts), - bulk_write_exception); - } + INFO("unacknowledged write concern fails"); + update_opts.write_concern(noack); + REQUIRE_THROWS_AS(coll.update_many(predicate.view(), update_doc.view(), update_opts), + operation_exception); + + INFO("default write concern succeeds"); + update_opts.write_concern(default_wc); + auto result = coll.update_many(predicate.view(), update_doc.view(), update_opts); + REQUIRE(result); + REQUIRE(result->modified_count() == 1); } SECTION("replace document replaces only one document", "[collection]") { @@ -895,11 +876,7 @@ TEST_CASE("CRUD functionality", "[driver::collection]") { auto predicate = make_document(kvp("x", "FOO")); auto count_opts = options::count{}.collation(case_insensitive_collation.view()); - if (test_util::supports_collation(mongodb_client)) { - REQUIRE(coll.count_documents(predicate.view(), count_opts) == 1); - } else { - REQUIRE_THROWS_AS(coll.count_documents(predicate.view(), count_opts), query_exception); - } + REQUIRE(coll.count_documents(predicate.view(), count_opts) == 1); } SECTION("replace_one returns correct result object", "[collection]") { @@ -972,24 +949,16 @@ TEST_CASE("CRUD functionality", "[driver::collection]") { replacement_doc.append(kvp("x", "bar")); auto replace_opts = options::replace{}.collation(case_insensitive_collation.view()); - if (test_util::supports_collation(mongodb_client)) { - INFO("unacknowledged write concern fails"); - replace_opts.write_concern(noack); - REQUIRE_THROWS_AS( - coll.replace_one(predicate.view(), replacement_doc.view(), replace_opts), - operation_exception); - - INFO("default write concern succeeds"); - replace_opts.write_concern(default_wc); - auto result = coll.replace_one(predicate.view(), replacement_doc.view(), replace_opts); - REQUIRE(result); - REQUIRE(result->modified_count() == 1); - - } else { - REQUIRE_THROWS_AS( - coll.replace_one(predicate.view(), replacement_doc.view(), replace_opts), - bulk_write_exception); - } + INFO("unacknowledged write concern fails"); + replace_opts.write_concern(noack); + REQUIRE_THROWS_AS(coll.replace_one(predicate.view(), replacement_doc.view(), replace_opts), + operation_exception); + + INFO("default write concern succeeds"); + replace_opts.write_concern(default_wc); + auto result = coll.replace_one(predicate.view(), replacement_doc.view(), replace_opts); + REQUIRE(result); + REQUIRE(result->modified_count() == 1); } SECTION("filtered document delete one works", "[collection]") { @@ -1093,19 +1062,15 @@ TEST_CASE("CRUD functionality", "[driver::collection]") { auto predicate = make_document(kvp("x", "FOO")); auto delete_opts = options::delete_options{}.collation(case_insensitive_collation.view()); - if (test_util::supports_collation(mongodb_client)) { - INFO("unacknowledged write concern fails"); - delete_opts.write_concern(noack); - REQUIRE_THROWS_AS(coll.delete_one(predicate.view(), delete_opts), operation_exception); + INFO("unacknowledged write concern fails"); + delete_opts.write_concern(noack); + REQUIRE_THROWS_AS(coll.delete_one(predicate.view(), delete_opts), operation_exception); - INFO("default write concern succeeds"); - delete_opts.write_concern(default_wc); - auto result = coll.delete_one(predicate.view(), delete_opts); - REQUIRE(result); - REQUIRE(result->deleted_count() == 1); - } else { - REQUIRE_THROWS_AS(coll.delete_one(predicate.view(), delete_opts), bulk_write_exception); - } + INFO("default write concern succeeds"); + delete_opts.write_concern(default_wc); + auto result = coll.delete_one(predicate.view(), delete_opts); + REQUIRE(result); + REQUIRE(result->deleted_count() == 1); } SECTION("delete many works", "[collection]") { @@ -1200,20 +1165,15 @@ TEST_CASE("CRUD functionality", "[driver::collection]") { auto predicate = make_document(kvp("x", "FOO")); auto delete_opts = options::delete_options{}.collation(case_insensitive_collation.view()); - if (test_util::supports_collation(mongodb_client)) { - INFO("unacknowledged write concern fails"); - delete_opts.write_concern(noack); - REQUIRE_THROWS_AS(coll.delete_many(predicate.view(), delete_opts), operation_exception); + INFO("unacknowledged write concern fails"); + delete_opts.write_concern(noack); + REQUIRE_THROWS_AS(coll.delete_many(predicate.view(), delete_opts), operation_exception); - INFO("default write concern succeeds"); - delete_opts.write_concern(default_wc); - auto result = coll.delete_many(predicate.view(), delete_opts); - REQUIRE(result); - REQUIRE(result->deleted_count() == 1); - } else { - REQUIRE_THROWS_AS(coll.delete_many(predicate.view(), delete_opts), - bulk_write_exception); - } + INFO("default write concern succeeds"); + delete_opts.write_concern(default_wc); + auto result = coll.delete_many(predicate.view(), delete_opts); + REQUIRE(result); + REQUIRE(result->deleted_count() == 1); } SECTION("find works with sort", "[collection]") { @@ -1307,24 +1267,18 @@ TEST_CASE("CRUD functionality", "[driver::collection]") { auto collation_criteria = make_document(kvp("x", "FOO")); - if (test_util::supports_collation(mongodb_client)) { - INFO("unacknowledged write concern fails"); - options.write_concern(noack); - REQUIRE_THROWS_AS(coll.find_one_and_replace( - collation_criteria.view(), replacement.view(), options), - logic_error); - - INFO("default write concern succeeds"); - options.write_concern(default_wc); - auto doc = coll.find_one_and_replace( - collation_criteria.view(), replacement.view(), options); - REQUIRE(doc); - REQUIRE(doc->view()["x"].get_string().value == stdx::string_view{"foo"}); - } else { - REQUIRE_THROWS_AS(coll.find_one_and_replace( - collation_criteria.view(), replacement.view(), options), - write_exception); - } + INFO("unacknowledged write concern fails"); + options.write_concern(noack); + REQUIRE_THROWS_AS( + coll.find_one_and_replace(collation_criteria.view(), replacement.view(), options), + logic_error); + + INFO("default write concern succeeds"); + options.write_concern(default_wc); + auto doc = + coll.find_one_and_replace(collation_criteria.view(), replacement.view(), options); + REQUIRE(doc); + REQUIRE(doc->view()["x"].get_string().value == stdx::string_view{"foo"}); } SECTION("bad criteria returns negative optional") { @@ -1416,25 +1370,17 @@ TEST_CASE("CRUD functionality", "[driver::collection]") { auto collation_criteria = make_document(kvp("x", "FOO")); - if (test_util::supports_collation(mongodb_client)) { - INFO("unacknowledged write concern fails"); - options.write_concern(noack); - REQUIRE_THROWS_AS( - coll.find_one_and_update(collation_criteria.view(), update.view(), options), - logic_error); - - INFO("default write concern succeeds"); - options.write_concern(default_wc); - auto doc = - coll.find_one_and_update(collation_criteria.view(), update.view(), options); - REQUIRE(doc); - REQUIRE(doc->view()["x"].get_string().value == stdx::string_view{"foo"}); - - } else { - REQUIRE_THROWS_AS( - coll.find_one_and_update(collation_criteria.view(), update.view(), options), - write_exception); - } + INFO("unacknowledged write concern fails"); + options.write_concern(noack); + REQUIRE_THROWS_AS( + coll.find_one_and_update(collation_criteria.view(), update.view(), options), + logic_error); + + INFO("default write concern succeeds"); + options.write_concern(default_wc); + auto doc = coll.find_one_and_update(collation_criteria.view(), update.view(), options); + REQUIRE(doc); + REQUIRE(doc->view()["x"].get_string().value == stdx::string_view{"foo"}); } SECTION("bad criteria returns negative optional") { @@ -1510,22 +1456,16 @@ TEST_CASE("CRUD functionality", "[driver::collection]") { auto collation_criteria = make_document(kvp("x", "FOO")); - if (test_util::supports_collation(mongodb_client)) { - INFO("unacknowledged write concern fails"); - options.write_concern(noack); - REQUIRE_THROWS_AS(coll.find_one_and_delete(collation_criteria.view(), options), - logic_error); - - INFO("default write concern succeeds"); - options.write_concern(default_wc); - auto doc = coll.find_one_and_delete(collation_criteria.view(), options); - REQUIRE(doc); - REQUIRE(doc->view()["x"].get_string().value == stdx::string_view{"foo"}); - - } else { - REQUIRE_THROWS_AS(coll.find_one_and_delete(collation_criteria.view(), options), - write_exception); - } + INFO("unacknowledged write concern fails"); + options.write_concern(noack); + REQUIRE_THROWS_AS(coll.find_one_and_delete(collation_criteria.view(), options), + logic_error); + + INFO("default write concern succeeds"); + options.write_concern(default_wc); + auto doc = coll.find_one_and_delete(collation_criteria.view(), options); + REQUIRE(doc); + REQUIRE(doc->view()["x"].get_string().value == stdx::string_view{"foo"}); } } @@ -1550,15 +1490,9 @@ TEST_CASE("CRUD functionality", "[driver::collection]") { pipeline.add_fields(make_document(kvp("x", 1))); auto cursor = coll.aggregate(pipeline); - if (test_util::get_max_wire_version(mongodb_client) >= 5) { - // The server supports add_fields(). - auto results = get_results(std::move(cursor)); - REQUIRE(results.size() == 1); - REQUIRE(results[0].view()["x"].get_int32() == 1); - } else { - // The server does not support add_fields(). - REQUIRE_THROWS_AS(get_results(std::move(cursor)), operation_exception); - } + auto results = get_results(std::move(cursor)); + REQUIRE(results.size() == 1); + REQUIRE(results[0].view()["x"].get_int32() == 1); } SECTION("bucket") { @@ -1573,20 +1507,14 @@ TEST_CASE("CRUD functionality", "[driver::collection]") { make_document(kvp("groupBy", "$x"), kvp("boundaries", make_array(0, 2, 6)))); auto cursor = coll.aggregate(pipeline); - if (test_util::get_max_wire_version(mongodb_client) >= 5) { - // The server supports bucket(). - auto results = get_results(std::move(cursor)); - REQUIRE(results.size() == 2); + auto results = get_results(std::move(cursor)); + REQUIRE(results.size() == 2); - REQUIRE(results[0].view()["_id"].get_int32() == 0); - REQUIRE(results[0].view()["count"].get_int32() == 1); + REQUIRE(results[0].view()["_id"].get_int32() == 0); + REQUIRE(results[0].view()["count"].get_int32() == 1); - REQUIRE(results[1].view()["_id"].get_int32() == 2); - REQUIRE(results[1].view()["count"].get_int32() == 2); - } else { - // The server does not support bucket(). - REQUIRE_THROWS_AS(get_results(std::move(cursor)), operation_exception); - } + REQUIRE(results[1].view()["_id"].get_int32() == 2); + REQUIRE(results[1].view()["count"].get_int32() == 2); } SECTION("bucket_auto") { @@ -1600,20 +1528,13 @@ TEST_CASE("CRUD functionality", "[driver::collection]") { pipeline.bucket_auto(make_document(kvp("groupBy", "$x"), kvp("buckets", 2))); auto cursor = coll.aggregate(pipeline); - if (test_util::get_max_wire_version(mongodb_client) >= 5) { - // The server supports bucket_auto(). - - auto results = get_results(std::move(cursor)); - REQUIRE(results.size() == 2); - // We check that the "count" field exists here, but we don't assert the exact count, - // since the server doesn't guarantee what the exact boundaries (and thus the exact - // counts) will be. - REQUIRE(results[0].view()["count"]); - REQUIRE(results[1].view()["count"]); - } else { - // The server does not support bucket_auto(). - REQUIRE_THROWS_AS(get_results(std::move(cursor)), operation_exception); - } + auto results = get_results(std::move(cursor)); + REQUIRE(results.size() == 2); + // We check that the "count" field exists here, but we don't assert the exact count, + // since the server doesn't guarantee what the exact boundaries (and thus the exact + // counts) will be. + REQUIRE(results[0].view()["count"]); + REQUIRE(results[1].view()["count"]); } SECTION("coll_stats") { @@ -1625,16 +1546,10 @@ TEST_CASE("CRUD functionality", "[driver::collection]") { pipeline.coll_stats(make_document(kvp("latencyStats", make_document()))); auto cursor = coll.aggregate(pipeline); - if (test_util::get_max_wire_version(mongodb_client) >= 5) { - // The server supports coll_stats(). - auto results = get_results(std::move(cursor)); - REQUIRE(results.size() == 1); - REQUIRE(results[0].view()["ns"]); - REQUIRE(results[0].view()["latencyStats"]); - } else { - // The server does not support coll_stats(). - REQUIRE_THROWS_AS(get_results(std::move(cursor)), operation_exception); - } + auto results = get_results(std::move(cursor)); + REQUIRE(results.size() == 1); + REQUIRE(results[0].view()["ns"]); + REQUIRE(results[0].view()["latencyStats"]); } SECTION("count") { @@ -1648,15 +1563,9 @@ TEST_CASE("CRUD functionality", "[driver::collection]") { pipeline.count("foo"); auto cursor = coll.aggregate(pipeline); - if (test_util::get_max_wire_version(mongodb_client) >= 5) { - // The server supports count(). - auto results = get_results(std::move(cursor)); - REQUIRE(results.size() == 1); - REQUIRE(results[0].view()["foo"].get_int32() == 3); - } else { - // The server does not support count(). - REQUIRE_THROWS_AS(get_results(std::move(cursor)), operation_exception); - } + auto results = get_results(std::move(cursor)); + REQUIRE(results.size() == 1); + REQUIRE(results[0].view()["foo"].get_int32() == 3); } SECTION("facet") { @@ -1670,16 +1579,10 @@ TEST_CASE("CRUD functionality", "[driver::collection]") { pipeline.facet(make_document(kvp("foo", make_array(make_document(kvp("$limit", 2)))))); auto cursor = coll.aggregate(pipeline); - if (test_util::get_max_wire_version(mongodb_client) >= 5) { - // The server supports facet(). - auto results = get_results(std::move(cursor)); - REQUIRE(results.size() == 1); - auto foo_array = results[0].view()["foo"].get_array().value; - REQUIRE(std::distance(foo_array.begin(), foo_array.end()) == 2); - } else { - // The server does not support facet(). - REQUIRE_THROWS_AS(get_results(std::move(cursor)), operation_exception); - } + auto results = get_results(std::move(cursor)); + REQUIRE(results.size() == 1); + auto foo_array = results[0].view()["foo"].get_array().value; + REQUIRE(std::distance(foo_array.begin(), foo_array.end()) == 2); } SECTION("geo_near") { @@ -1718,16 +1621,10 @@ TEST_CASE("CRUD functionality", "[driver::collection]") { pipeline.sort(make_document(kvp("x", 1))); auto cursor = coll.aggregate(pipeline); - if (test_util::get_max_wire_version(mongodb_client) >= 5) { - // The server supports graph_lookup(). - auto results = get_results(std::move(cursor)); - REQUIRE(results.size() == 2); - REQUIRE(results[0].view()["z"].get_array().value.empty()); - REQUIRE(!results[1].view()["z"].get_array().value.empty()); - } else { - // The server does not support graph_lookup(). - REQUIRE_THROWS_AS(get_results(std::move(cursor)), operation_exception); - } + auto results = get_results(std::move(cursor)); + REQUIRE(results.size() == 2); + REQUIRE(results[0].view()["z"].get_array().value.empty()); + REQUIRE(!results[1].view()["z"].get_array().value.empty()); } SECTION("group") { @@ -1760,14 +1657,8 @@ TEST_CASE("CRUD functionality", "[driver::collection]") { pipeline.index_stats(); auto cursor = coll.aggregate(pipeline); - if (test_util::get_max_wire_version(mongodb_client) >= 4) { - // The server supports index_stats(). - auto results = get_results(std::move(cursor)); - REQUIRE(results.size() == 4); - } else { - // The server does not support index_stats(). - REQUIRE_THROWS_AS(get_results(std::move(cursor)), operation_exception); - } + auto results = get_results(std::move(cursor)); + REQUIRE(results.size() == 4); } SECTION("limit") { @@ -1804,16 +1695,10 @@ TEST_CASE("CRUD functionality", "[driver::collection]") { pipeline.sort(make_document(kvp("x", 1))); auto cursor = coll.aggregate(pipeline); - if (test_util::get_max_wire_version(mongodb_client) >= 4) { - // The server supports lookup(). - auto results = get_results(std::move(cursor)); - REQUIRE(results.size() == 2); - REQUIRE(!results[0].view()["z"].get_array().value.empty()); - REQUIRE(results[1].view()["z"].get_array().value.empty()); - } else { - // The server does not support lookup(). - REQUIRE_THROWS_AS(get_results(std::move(cursor)), operation_exception); - } + auto results = get_results(std::move(cursor)); + REQUIRE(results.size() == 2); + REQUIRE(!results[0].view()["z"].get_array().value.empty()); + REQUIRE(results[1].view()["z"].get_array().value.empty()); } SECTION("match") { @@ -1898,19 +1783,13 @@ TEST_CASE("CRUD functionality", "[driver::collection]") { stdx::optional cursor; REQUIRE_NOTHROW(cursor = coll_in.aggregate(pipeline, options)); - if (test_util::get_max_wire_version(mongodb_client) >= 1) { - // The server supports out(). - auto results = get_results(std::move(*cursor)); - REQUIRE(results.empty()); - - auto collection_contents = get_results(coll_out.find({})); - REQUIRE(collection_contents.size() == 1); - REQUIRE(collection_contents[0].view()["x"].get_int32() == 1); - REQUIRE(!collection_contents[0].view()["y"]); - } else { - // The server does not support out(). - REQUIRE_THROWS_AS(get_results(std::move(*cursor)), operation_exception); - } + auto results = get_results(std::move(*cursor)); + REQUIRE(results.empty()); + + auto collection_contents = get_results(coll_out.find({})); + REQUIRE(collection_contents.size() == 1); + REQUIRE(collection_contents[0].view()["x"].get_int32() == 1); + REQUIRE(!collection_contents[0].view()["y"]); } SECTION("out fails when not last") { @@ -1969,15 +1848,9 @@ TEST_CASE("CRUD functionality", "[driver::collection]") { pipeline.replace_root(make_document(kvp("newRoot", "$x"))); auto cursor = coll.aggregate(pipeline); - if (test_util::get_max_wire_version(mongodb_client) >= 5) { - // The server supports replace_root(). - auto results = get_results(std::move(cursor)); - REQUIRE(results.size() == 1); - REQUIRE(results[0].view()["y"]); - } else { - // The server does not support replace_root(). - REQUIRE_THROWS_AS(get_results(std::move(cursor)), operation_exception); - } + auto results = get_results(std::move(cursor)); + REQUIRE(results.size() == 1); + REQUIRE(results[0].view()["y"]); } SECTION("sample") { @@ -1992,14 +1865,8 @@ TEST_CASE("CRUD functionality", "[driver::collection]") { pipeline.sample(3); auto cursor = coll.aggregate(pipeline); - if (test_util::get_max_wire_version(mongodb_client) >= 4) { - // The server supports sample(). - auto results = get_results(std::move(cursor)); - REQUIRE(results.size() == 3); - } else { - // The server does not support sample(). - REQUIRE_THROWS_AS(get_results(std::move(cursor)), operation_exception); - } + auto results = get_results(std::move(cursor)); + REQUIRE(results.size() == 3); } SECTION("skip") { @@ -2052,16 +1919,10 @@ TEST_CASE("CRUD functionality", "[driver::collection]") { pipeline.sort_by_count("$x"); auto cursor = coll.aggregate(pipeline); - if (test_util::get_max_wire_version(mongodb_client) >= 5) { - // The server supports sort_by_count(). - auto results = get_results(std::move(cursor)); - REQUIRE(results.size() == 2); - REQUIRE(results[0].view()["_id"].get_int32() == 2); - REQUIRE(results[1].view()["_id"].get_int32() == 1); - } else { - // The server does not support sort_by_count(). - REQUIRE_THROWS_AS(get_results(std::move(cursor)), operation_exception); - } + auto results = get_results(std::move(cursor)); + REQUIRE(results.size() == 2); + REQUIRE(results[0].view()["_id"].get_int32() == 2); + REQUIRE(results[1].view()["_id"].get_int32() == 1); } SECTION("with document") { @@ -2073,16 +1934,10 @@ TEST_CASE("CRUD functionality", "[driver::collection]") { pipeline.sort_by_count(make_document(kvp("$mod", make_array("$x", 2)))); auto cursor = coll.aggregate(pipeline); - if (test_util::get_max_wire_version(mongodb_client) >= 5) { - // The server supports sort_by_count(). - auto results = get_results(std::move(cursor)); - REQUIRE(results.size() == 2); - REQUIRE(results[0].view()["_id"].get_int32() == 0); - REQUIRE(results[1].view()["_id"].get_int32() == 1); - } else { - // The server does not support sort_by_count(). - REQUIRE_THROWS_AS(get_results(std::move(cursor)), operation_exception); - } + auto results = get_results(std::move(cursor)); + REQUIRE(results.size() == 2); + REQUIRE(results[0].view()["_id"].get_int32() == 0); + REQUIRE(results[1].view()["_id"].get_int32() == 1); } } @@ -2107,14 +1962,8 @@ TEST_CASE("CRUD functionality", "[driver::collection]") { pipeline.unwind(make_document(kvp("path", "$x"))); auto cursor = coll.aggregate(pipeline); - if (test_util::get_max_wire_version(mongodb_client) >= 4) { - // The server supports unwind() with a document. - auto results = get_results(std::move(cursor)); - REQUIRE(results.size() == 5); - } else { - // The server does not support unwind() with a document. - REQUIRE_THROWS_AS(get_results(std::move(cursor)), operation_exception); - } + auto results = get_results(std::move(cursor)); + REQUIRE(results.size() == 5); } } @@ -2134,12 +1983,7 @@ TEST_CASE("CRUD functionality", "[driver::collection]") { auto agg_opts = options::aggregate{}.collation(case_insensitive_collation.view()); auto results = coll.aggregate(p, agg_opts); - if (test_util::supports_collation(mongodb_client)) { - REQUIRE(std::distance(results.begin(), results.end()) == 1); - } else { - // The server does not support collation. - REQUIRE_THROWS_AS(std::distance(results.begin(), results.end()), operation_exception); - } + REQUIRE(std::distance(results.begin(), results.end()) == 1); } SECTION("bulk_write returns correct result object") { @@ -2274,19 +2118,13 @@ TEST_CASE("CRUD functionality", "[driver::collection]") { auto distinct_opts = options::distinct{}.collation(case_insensitive_collation.view()); - if (test_util::supports_collation(mongodb_client)) { - auto distinct_results = coll.distinct("x", predicate.view(), distinct_opts); - auto iter = distinct_results.begin(); - REQUIRE(iter != distinct_results.end()); - auto result = *iter; - auto values = result["values"].get_array().value; - REQUIRE(std::distance(values.begin(), values.end()) == 1); - REQUIRE(values[0].get_string().value == stdx::string_view{"foo"}); - } else { - // The server does not support collation. - REQUIRE_THROWS_AS(coll.distinct("x", predicate.view(), distinct_opts), - operation_exception); - } + auto distinct_results = coll.distinct("x", predicate.view(), distinct_opts); + auto iter = distinct_results.begin(); + REQUIRE(iter != distinct_results.end()); + auto result = *iter; + auto values = result["values"].get_array().value; + REQUIRE(std::distance(values.begin(), values.end()) == 1); + REQUIRE(values[0].get_string().value == stdx::string_view{"foo"}); } } @@ -2316,10 +2154,10 @@ TEST_CASE("read_concern is inherited from parent", "[collection]") { } } -void find_index_and_validate(collection& coll, - stdx::string_view index_name, - const std::function& validate = - [](bsoncxx::document::view) {}) { +void find_index_and_validate( + collection& coll, + stdx::string_view index_name, + const std::function& validate = [](bsoncxx::document::view) {}) { auto cursor = coll.list_indexes(); for (auto&& index : cursor) { diff --git a/src/mongocxx/test/index_view.cpp b/src/mongocxx/test/index_view.cpp index 3b3de7c18e..03de7c827d 100644 --- a/src/mongocxx/test/index_view.cpp +++ b/src/mongocxx/test/index_view.cpp @@ -449,45 +449,42 @@ TEST_CASE("index creation and deletion with different collation") { client mongodb_client{uri{}, test_util::add_test_server_api()}; - if (test_util::get_max_wire_version(mongodb_client) >= 5) { - database db = mongodb_client["index_view_collation"]; - collection coll = db["index_view_collation"]; - coll.drop(); - coll.insert_one({}); // Ensure that the collection exists. + database db = mongodb_client["index_view_collation"]; + collection coll = db["index_view_collation"]; + coll.drop(); + coll.insert_one({}); // Ensure that the collection exists. - bsoncxx::document::value keys = make_document(kvp("a", 1), kvp("bcd", -1), kvp("d", 1)); - bsoncxx::document::value us_collation = - make_document(kvp("collation", make_document(kvp("locale", "en_US")))); - bsoncxx::document::value ko_collation = make_document( - kvp("name", "custom_index_name"), kvp("collation", make_document(kvp("locale", "ko")))); + bsoncxx::document::value keys = make_document(kvp("a", 1), kvp("bcd", -1), kvp("d", 1)); + bsoncxx::document::value us_collation = + make_document(kvp("collation", make_document(kvp("locale", "en_US")))); + bsoncxx::document::value ko_collation = make_document( + kvp("name", "custom_index_name"), kvp("collation", make_document(kvp("locale", "ko")))); - index_model index_us{keys.view(), us_collation.view()}; - index_model index_ko{keys.view(), ko_collation.view()}; + index_model index_us{keys.view(), us_collation.view()}; + index_model index_ko{keys.view(), ko_collation.view()}; - index_view view = coll.indexes(); + index_view view = coll.indexes(); - view.create_one(index_us); - view.create_one(index_ko); + view.create_one(index_us); + view.create_one(index_ko); - auto cursor = view.list(); - REQUIRE(std::distance(cursor.begin(), cursor.end()) == 3); + auto cursor = view.list(); + REQUIRE(std::distance(cursor.begin(), cursor.end()) == 3); - view.drop_one("a_1_bcd_-1_d_1"); + view.drop_one("a_1_bcd_-1_d_1"); - auto cursor_after_drop = view.list(); + auto cursor_after_drop = view.list(); - REQUIRE(std::distance(cursor_after_drop.begin(), cursor_after_drop.end()) == 2); + REQUIRE(std::distance(cursor_after_drop.begin(), cursor_after_drop.end()) == 2); - auto cursor_after_drop1 = view.list(); - auto index_it = cursor_after_drop1.begin(); - ++index_it; - bsoncxx::document::view index = *index_it; + auto cursor_after_drop1 = view.list(); + auto index_it = cursor_after_drop1.begin(); + ++index_it; + bsoncxx::document::view index = *index_it; - REQUIRE(bsoncxx::string::to_string(index["name"].get_string().value) == - "custom_index_name"); + REQUIRE(bsoncxx::string::to_string(index["name"].get_string().value) == "custom_index_name"); - coll.drop(); - db.drop(); - } + coll.drop(); + db.drop(); } } // namespace