Skip to content

Add $commitTransaction command tests and enable replica set in CI#560

Open
alinaliBQ wants to merge 19 commits into
documentdb:mainfrom
alinaliBQ:commitTransaction
Open

Add $commitTransaction command tests and enable replica set in CI#560
alinaliBQ wants to merge 19 commits into
documentdb:mainfrom
alinaliBQ:commitTransaction

Conversation

@alinaliBQ

@alinaliBQ alinaliBQ commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

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_set tests against an instance with replica set enabled.

@alinaliBQ alinaliBQ force-pushed the commitTransaction branch from f6a6ebf to fa76a9b Compare June 3, 2026 22:28
@alinaliBQ alinaliBQ changed the title Add $commitTransaction command tests Add $commitTransaction command tests and enable replica set in CI Jun 3, 2026
@documentdb-triage-tool documentdb-triage-tool Bot added compatibility test Compatibility test related enhancement New feature or request labels Jun 3, 2026
@documentdb-triage-tool

Copy link
Copy Markdown

🤖 Auto-triaged by documentdb-triage-tool.

Applied: compatibility test, enhancement
Project fields suggested: Component test-coverage · Priority P2 · Effort L · Status In Progress
Confidence: 0.72 (mixed)

Reasoning

component 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 @patty-chow so the rules can be tuned. The bot will not re-label items that already have component labels.

@alinaliBQ alinaliBQ force-pushed the commitTransaction branch 2 times, most recently from 2703424 to fe969bf Compare June 8, 2026 19:16
@alinaliBQ alinaliBQ marked this pull request as ready for review June 8, 2026 20:11
@alinaliBQ alinaliBQ requested a review from a team as a code owner June 8, 2026 20:11
OPERATION_FAILED_ERROR = 96
DOCUMENT_VALIDATION_FAILURE_ERROR = 121
NOT_A_REPLICA_SET_ERROR = 123
NO_SUCH_TRANSACTION_ERROR = 125

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this value is wrong. MongoDB's NoSuchTransaction is error code 251, not 125.

https://www.mongodb.com/docs/manual/reference/error-codes/

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added check len(docs) > 0 to verify doc returned persisted

@alinaliBQ alinaliBQ force-pushed the commitTransaction branch from 53f28e4 to 82aa441 Compare June 11, 2026 18:02

@alinaliBQ alinaliBQ left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added check len(docs) > 0 to verify doc returned persisted

alinaliBQ added 16 commits June 12, 2026 14:28
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>
@alinaliBQ alinaliBQ force-pushed the commitTransaction branch from e499b0c to 95cdce2 Compare June 12, 2026 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

compatibility test Compatibility test related enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants