Skip to content

Add abortTransaction command tests#600

Merged
eerxuan merged 1 commit into
documentdb:mainfrom
alinaliBQ:abortTransaction
Jul 6, 2026
Merged

Add abortTransaction command tests#600
eerxuan merged 1 commit into
documentdb:mainfrom
alinaliBQ:abortTransaction

Conversation

@alinaliBQ

@alinaliBQ alinaliBQ commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

This change adds tests for the $abortTransaction command operator.

Add command operator tests for $abortTransaction. Tests database $abortTransaction behavior, output collection, syntax, and expected errors.

@alinaliBQ

alinaliBQ commented Jun 12, 2026

Copy link
Copy Markdown
Contributor Author

Once #560 is merged, I can rebase this PR if there are conflicts.

@documentdb-triage-tool documentdb-triage-tool Bot added compatibility test Compatibility test related enhancement New feature or request labels Jun 12, 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.85 (mixed)

Reasoning

component from path globs (test-coverage, test-framework, ci); effort from diff stats (1817+0 LOC, 17 files); LLM: Adds new test coverage for the $abortTransaction command operator, covering behavior, output collection, syntax, and error cases — a meaningful functional addition to the test suite.

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 abortTransaction branch 2 times, most recently from 8780e5b to 8ecb689 Compare June 15, 2026 19:39
@alinaliBQ

Copy link
Copy Markdown
Contributor Author

Rebased PR to get fix from #606

@alinaliBQ alinaliBQ marked this pull request as ready for review June 16, 2026 19:51
@alinaliBQ alinaliBQ requested a review from a team as a code owner June 16, 2026 19:51
@alinaliBQ alinaliBQ force-pushed the abortTransaction branch 4 times, most recently from ff242bf to 91bd213 Compare June 24, 2026 21:10
Comment thread documentdb_tests/framework/executor.py Outdated
Comment thread documentdb_tests/framework/executor.py Outdated

@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.

addressed comments

Comment thread documentdb_tests/framework/executor.py Outdated
Comment thread documentdb_tests/framework/executor.py Outdated
@alinaliBQ

Copy link
Copy Markdown
Contributor Author

@eerxuan Addressed comments. I also applied the commitTransaction PR comments in this PR.

Refactor (mirrors the commitTransaction restructure)

Removed the shared helper indirection so each test's setup → act → assert is visible top to bottom.

  • Deleted utils/session_test_case.py — removed SessionTestCase, SessionOp, SessionOperation, and the execute_session_command runner (which bundledlifecycle, branching, and raw asserts).
  • Deleted utils/session_command_test_case.py (SessionCommandTestCase) — dead code, unused. This left utils/ with only an empty __init__.py, so the whole utils/ directory was removed.
  • test_abortTransaction_core.py — restructured to plain one-def-per-spec(no parametrize, one assertion, insert-only), inline lifecycle:
    • test_abortTransaction_rolls_back_insert
    • test_pre_existing_data_survives_abort
    • test_abortTransaction_empty
    • test_abortTransaction_response_ok
    • Dropped the parametrized op-type rollback variants (update/delete/multi/insert+delete/multiple-inserts/update+insert) — insert proves rollback.
  • test_abortTransaction_field_types.py / _comment.py / _writeconcern.py — converted from SessionTestCase to CommandTestCase (command + msg), inline lifecycle (insert → raw abortTransaction command → assertSuccessPartial(result, {"ok": 1.0})).

New behavioral specs (one file per spec, insert-only)

  • test_abortTransaction_atomicity.py — cross-collection: aborting rolls back writes to a second collection (neither persists).
  • test_abortTransaction_failed_op_blocks_txn.py — after a dup-key (11000 ) write in a txn, a later op in the same txn fails with 251 NoSuchTransaction .
  • test_abortTransaction_recovers_session.py — after a failed op + abort, the same session runs and commits a fresh transaction successfully.
  • test_abortTransaction_cannot_commit_after_abort.py — committing an already-aborted transaction (same lsid/txnNumber) fails with 251. Driven with explicit session fields on a dedicated throwaway client so the hand-managed session does not disturb the shared client's server-session pool (avoids parallel-run conflicts / CI flake).

@alinaliBQ alinaliBQ changed the title Add $abortTransaction command tests Add abortTransaction command tests Jul 3, 2026
Signed-off-by: Alina (Xi) Li <Alina.Li@improving.com>
@eerxuan eerxuan merged commit 02775e8 into documentdb:main Jul 6, 2026
20 checks passed
krishnasai453 pushed a commit to krishnasai453/functional-tests that referenced this pull request Jul 8, 2026
Signed-off-by: Alina (Xi) Li <Alina.Li@improving.com>
SarthakDalmia1 pushed a commit to SarthakDalmia1/functional-tests that referenced this pull request Jul 10, 2026
Signed-off-by: Alina (Xi) Li <Alina.Li@improving.com>
Signed-off-by: Sarthak Dalmia <sadalmia@microsoft.com>
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.

3 participants