-
Notifications
You must be signed in to change notification settings - Fork 455
CDRIVER-4425 Provide access to raw result if server error occurs #1144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
95ba2c7
CDRIVER-4425 new test files and parse option
galon1 077af67
CDRIVER-4425 remove changes to bson_error_t
galon1 8208cad
CDRIVER-4425 add errorResponse handling in test runner
galon1 9781c97
CDRIVER-4425 removing unintended changes
galon1 ff8bf0e
CDRIVER-4425 insertOne test passes
galon1 36a695a
CDRIVER-4425 add unique field and optional name to createIndex
galon1 faaf72b
CDRIVER-4425 remove unintended changes and add comment
galon1 2a4e901
CDRIVER-4425 add check for result->error is server
galon1 76514d8
CRIVER-4425 fix comment
galon1 693bcbb
CDRIVER-4425 add linebreak back
galon1 19068c1
CDRIVER-4425 fix comment
galon1 cfe57cb
CDRIVER-4425 wrap write operation return in serverResponse
galon1 13601c5
CDRIVER-4425 destroy before copying to avoid leak
galon1 44f0450
CDRIVER-4425 add destroy to avoid memory leak
galon1 c52b2b1
CDRIVER-4425 do not include unique in createIndex if not set
galon1 3435887
CDRIVER-4425 make parameter constant
galon1 1de331c
CDRIVER-4425 store error replies as an array
galon1 78629b1
CDRIVER-4425 fix comment and delete unintended file
galon1 8d4b644
Merge branch 'master' of github.com:galon1/mongo-c-driver into CDRIVE…
galon1 faf48b1
CDRIVER-4425 change check to errorReplies, check null doc in test, an…
galon1 abc4c7e
CDRIVER-4425 change how createIndex command is built
galon1 f9ece40
CDRIVER-4425 test with multiple errorReplies
galon1 69e6773
CDRIVER-4425 change assert_error_count name for clarity
galon1 8314294
CDRIVER-4425 move destroy statements to avoid memory leak
galon1 b74b2da
CDRIVER-4425 skip test if no failpoint, remove leak
galon1 ba4068f
CDRIVER-4425 remove unintended comment
galon1 76fa9e5
CDRIVER-4425 typecheck result from write responses
galon1 73f10aa
CDRIVER-4425 fix comment
galon1 54abd64
CDRIVER-4425 move child inside if statement
galon1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
119 changes: 119 additions & 0 deletions
119
src/libmongoc/tests/json/collection-management/modifyCollection-errorResponse.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
{ | ||
"description": "modifyCollection-errorResponse", | ||
"schemaVersion": "1.12", | ||
"createEntities": [ | ||
{ | ||
"client": { | ||
"id": "client0", | ||
"observeEvents": [ | ||
"commandStartedEvent" | ||
] | ||
} | ||
}, | ||
{ | ||
"database": { | ||
"id": "database0", | ||
"client": "client0", | ||
"databaseName": "collMod-tests" | ||
} | ||
}, | ||
{ | ||
"collection": { | ||
"id": "collection0", | ||
"database": "database0", | ||
"collectionName": "test" | ||
} | ||
} | ||
], | ||
"initialData": [ | ||
{ | ||
"collectionName": "test", | ||
"databaseName": "collMod-tests", | ||
"documents": [ | ||
{ | ||
"_id": 1, | ||
"x": 1 | ||
}, | ||
{ | ||
"_id": 2, | ||
"x": 1 | ||
} | ||
] | ||
} | ||
], | ||
"tests": [ | ||
{ | ||
"description": "modifyCollection prepareUnique violations are accessible", | ||
"runOnRequirements": [ | ||
{ | ||
"minServerVersion": "5.2" | ||
} | ||
], | ||
"operations": [ | ||
{ | ||
"name": "createIndex", | ||
"object": "collection0", | ||
"arguments": { | ||
"keys": { | ||
"x": 1 | ||
} | ||
} | ||
}, | ||
{ | ||
"name": "modifyCollection", | ||
"object": "database0", | ||
"arguments": { | ||
"collection": "test", | ||
"index": { | ||
"keyPattern": { | ||
"x": 1 | ||
}, | ||
"prepareUnique": true | ||
} | ||
} | ||
}, | ||
{ | ||
"name": "insertOne", | ||
"object": "collection0", | ||
"arguments": { | ||
"document": { | ||
"_id": 3, | ||
"x": 1 | ||
} | ||
}, | ||
"expectError": { | ||
"errorCode": 11000 | ||
} | ||
}, | ||
{ | ||
"name": "modifyCollection", | ||
"object": "database0", | ||
"arguments": { | ||
"collection": "test", | ||
"index": { | ||
"keyPattern": { | ||
"x": 1 | ||
}, | ||
"unique": true | ||
} | ||
}, | ||
"expectError": { | ||
"isClientError": false, | ||
"errorCode": 359, | ||
"errorResponse": { | ||
"violations": [ | ||
{ | ||
"ids": [ | ||
1, | ||
2 | ||
] | ||
} | ||
] | ||
} | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} | ||
|
90 changes: 90 additions & 0 deletions
90
src/libmongoc/tests/json/crud/unified/aggregate-merge-errorResponse.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
{ | ||
"description": "aggregate-merge-errorResponse", | ||
"schemaVersion": "1.12", | ||
"createEntities": [ | ||
{ | ||
"client": { | ||
"id": "client0" | ||
} | ||
}, | ||
{ | ||
"database": { | ||
"id": "database0", | ||
"client": "client0", | ||
"databaseName": "crud-tests" | ||
} | ||
}, | ||
{ | ||
"collection": { | ||
"id": "collection0", | ||
"database": "database0", | ||
"collectionName": "test" | ||
} | ||
} | ||
], | ||
"initialData": [ | ||
{ | ||
"collectionName": "test", | ||
"databaseName": "crud-tests", | ||
"documents": [ | ||
{ | ||
"_id": 1, | ||
"x": 1 | ||
}, | ||
{ | ||
"_id": 2, | ||
"x": 1 | ||
} | ||
] | ||
} | ||
], | ||
"tests": [ | ||
{ | ||
"description": "aggregate $merge DuplicateKey error is accessible", | ||
"runOnRequirements": [ | ||
{ | ||
"minServerVersion": "5.1", | ||
"topologies": [ | ||
"single", | ||
"replicaset" | ||
] | ||
} | ||
], | ||
"operations": [ | ||
{ | ||
"name": "aggregate", | ||
"object": "database0", | ||
"arguments": { | ||
"pipeline": [ | ||
{ | ||
"$documents": [ | ||
{ | ||
"_id": 2, | ||
"x": 1 | ||
} | ||
] | ||
}, | ||
{ | ||
"$merge": { | ||
"into": "test", | ||
"whenMatched": "fail" | ||
} | ||
} | ||
] | ||
}, | ||
"expectError": { | ||
"errorCode": 11000, | ||
"errorResponse": { | ||
"keyPattern": { | ||
"_id": 1 | ||
}, | ||
"keyValue": { | ||
"_id": 2 | ||
} | ||
} | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} |
89 changes: 89 additions & 0 deletions
89
src/libmongoc/tests/json/crud/unified/bulkWrite-errorResponse.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
{ | ||
"description": "bulkWrite-errorResponse", | ||
"schemaVersion": "1.12", | ||
"createEntities": [ | ||
{ | ||
"client": { | ||
"id": "client0", | ||
"useMultipleMongoses": false | ||
} | ||
}, | ||
{ | ||
"database": { | ||
"id": "database0", | ||
"client": "client0", | ||
"databaseName": "crud-tests" | ||
} | ||
}, | ||
{ | ||
"collection": { | ||
"id": "collection0", | ||
"database": "database0", | ||
"collectionName": "test" | ||
} | ||
} | ||
], | ||
"tests": [ | ||
{ | ||
"description": "bulkWrite operations support errorResponse assertions", | ||
"runOnRequirements": [ | ||
{ | ||
"minServerVersion": "4.0.0", | ||
"topologies": [ | ||
"single", | ||
"replicaset" | ||
] | ||
}, | ||
{ | ||
"minServerVersion": "4.2.0", | ||
"topologies": [ | ||
"sharded" | ||
] | ||
} | ||
], | ||
"operations": [ | ||
{ | ||
"name": "failPoint", | ||
"object": "testRunner", | ||
"arguments": { | ||
"client": "client0", | ||
"failPoint": { | ||
"configureFailPoint": "failCommand", | ||
"mode": { | ||
"times": 1 | ||
}, | ||
"data": { | ||
"failCommands": [ | ||
"insert" | ||
], | ||
"errorCode": 8 | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"name": "bulkWrite", | ||
"object": "collection0", | ||
"arguments": { | ||
"requests": [ | ||
{ | ||
"insertOne": { | ||
"document": { | ||
"_id": 1 | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
"expectError": { | ||
"errorCode": 8, | ||
"errorResponse": { | ||
"code": 8 | ||
} | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Offhand, would the first
{ ok: 0 }
command response (post-retry) completely interrupt a bulk write operation regardless of theordered
option (note:ordered: false
is essentially continue-on-error).Our specs are ambiguous about this (see: DRIVERS-2090, DRIVERS-2159).
I noted in the unified test runner code below, the assertion is only done on
errorReplies.0
, which assumes that three will only ever be on error reply. That's fine, as I intentionally wrote the tests with the above ambiguity in mind (see: mongodb/specifications@33a03f2.But here, I'm more curious about whether multiple
errorReplies
are even possible in libmongoc. If not, are we just using anerrorReplies
array on the result for flexibility?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is possible for libmongoc to return multiple
errorReplies
. Here is a test displaying this behavior. Sinceordered: false
continues on error when thefailPoint
is hit twice, twoerrorReplies
are returned by libmongoc, as well as other errors that occurred if they did (in the test awriteError
also was raised).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for indulging my question. Looks like an oversight in the test runner syntax I introduced in DRIVERS-2385. I've made a note about this in DRIVERS-1547 as that's the most likely ticket we'd use to add spec test for multiple command failures in a bulk write.