Add $commitTransaction command tests and enable replica set in CI#560
Add $commitTransaction command tests and enable replica set in CI#560alinaliBQ wants to merge 19 commits into
Conversation
f6a6ebf to
fa76a9b
Compare
|
🤖 Auto-triaged by documentdb-triage-tool. Applied: Reasoningcomponent from path globs (test-coverage, test-framework, ci); effort from diff stats (1591+13 LOC, 15 files); LLM: Adds new $commitTransaction command test coverage and enables replica set in CI, touching both test files and CI workflow configuration. If a label is wrong, remove it manually and ping |
2703424 to
fe969bf
Compare
| OPERATION_FAILED_ERROR = 96 | ||
| DOCUMENT_VALIDATION_FAILURE_ERROR = 121 | ||
| NOT_A_REPLICA_SET_ERROR = 123 | ||
| NO_SUCH_TRANSACTION_ERROR = 125 |
There was a problem hiding this comment.
I think this value is wrong. MongoDB's NoSuchTransaction is error code 251, not 125.
There was a problem hiding this comment.
Yes you are right and I have fixed the naming. The 125 value should actually be named COMMAND_FAILED_ERROR, not NO_SUCH_TRANSACTION_ERROR.
| session.start_transaction() | ||
| for op in test_case.ops: | ||
| op.execute(collection, session) | ||
| if test_case.commit_command is not None: |
There was a problem hiding this comment.
When a test supplies its own commit_command, we commit via the raw admin command but pymongo's session doesn't know we did, so on with block exit it and auto-abort the "still open" transaction.
So for commit_response_ok: insert {_id: 1} → {commitTransaction: 1} returns ok:1 → block exits → pymongo aborts the already-committed txn. The test only checks ok:1, so it'd stay green even if the data got rolled back. Since all the writeConcern / comment / field_types success cases use this path, can you confirm the data actually lands? Reading the doc back after commit (e.g. find_one({"_id": 1})) and asserting it exists would prove it.
There was a problem hiding this comment.
added check len(docs) > 0 to verify doc returned persisted
53f28e4 to
82aa441
Compare
alinaliBQ
left a comment
There was a problem hiding this comment.
@Rishabh998 Addressed the comments, please have a look
| OPERATION_FAILED_ERROR = 96 | ||
| DOCUMENT_VALIDATION_FAILURE_ERROR = 121 | ||
| NOT_A_REPLICA_SET_ERROR = 123 | ||
| NO_SUCH_TRANSACTION_ERROR = 125 |
There was a problem hiding this comment.
Yes you are right and I have fixed the naming. The 125 value should actually be named COMMAND_FAILED_ERROR, not NO_SUCH_TRANSACTION_ERROR.
| session.start_transaction() | ||
| for op in test_case.ops: | ||
| op.execute(collection, session) | ||
| if test_case.commit_command is not None: |
There was a problem hiding this comment.
added check len(docs) > 0 to verify doc returned persisted
Signed-off-by: Alina (Xi) Li <Alina.Li@improving.com>
Signed-off-by: Alina (Xi) Li <Alina.Li@improving.com>
Signed-off-by: Alina (Xi) Li <Alina.Li@improving.com>
Signed-off-by: Alina (Xi) Li <Alina.Li@improving.com>
Signed-off-by: Alina (Xi) Li <Alina.Li@improving.com>
Signed-off-by: Alina (Xi) Li <Alina.Li@improving.com>
Signed-off-by: Alina (Xi) Li <Alina.Li@improving.com>
Signed-off-by: Alina (Xi) Li <Alina.Li@improving.com>
Signed-off-by: Alina (Xi) Li <Alina.Li@improving.com>
Signed-off-by: Alina (Xi) Li <Alina.Li@improving.com>
Signed-off-by: Alina (Xi) Li <Alina.Li@improving.com>
Daniel's PR is merged, so I can remove the workaround Signed-off-by: Alina (Xi) Li <Alina.Li@improving.com>
Signed-off-by: Alina (Xi) Li <Alina.Li@improving.com>
Signed-off-by: Alina (Xi) Li <Alina.Li@improving.com>
Signed-off-by: Alina (Xi) Li <Alina.Li@improving.com>
Signed-off-by: Alina (Xi) Li <Alina.Li@improving.com>
Signed-off-by: Alina (Xi) Li <Alina.Li@improving.com>
Signed-off-by: Alina (Xi) Li <Alina.Li@improving.com>
Signed-off-by: Alina (Xi) Li <Alina.Li@improving.com>
e499b0c to
95cdce2
Compare
This change adds tests for the $commitTransaction command operator.
Add command operator tests for $commitTransaction. Tests database $commitTransaction behavior, output collection, syntax, and expected errors.
This PR adds workflow to run
replica_settests against an instance with replica set enabled.