Skip to content
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

test(NODE-6492): add integration tests for transaction write concern behavior #4490

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

nbbeeken
Copy link
Contributor

@nbbeeken nbbeeken commented Mar 26, 2025

Description

What is changing?

Add prose test - NODE-6492

Is there new documentation needed for these changes?

No

What is the motivation for this change?

Spec compliance

Double check the following

  • Ran npm run check:lint script
  • Self-review completed using the steps outlined here
  • PR title follows the correct format: type(NODE-xxxx)[!]: description
    • Example: feat(NODE-1234)!: rewriting everything in coffeescript
  • Changes are covered by tests
  • New TODOs have a related JIRA ticket

@nbbeeken nbbeeken requested a review from a team as a code owner March 26, 2025 15:34
@baileympearson baileympearson self-assigned this Mar 26, 2025
@baileympearson baileympearson added the Primary Review In Review with primary reviewer, not yet ready for team's eyes label Mar 26, 2025

describe('Transactions Spec Prose', function () {
let client: MongoClient;
const started = [];
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think it is worth updating the spec with the additional requirements you found here? Looks like Python's implementation has found the same things (they're the only other driver that has implemented the test so far).

  1. requires transactions (4.0+, non-sharded. 4.2+, sharded)
  2. you must create the collection / ensure it exists beforehand

Copy link
Contributor Author

Choose a reason for hiding this comment

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


const insertStarted = started.find(ev => ev.commandName === 'insert');
expect(insertStarted).to.not.have.nested.property('command.writeConcern');

Copy link
Contributor

Choose a reason for hiding this comment

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

Are we missing the following check?

Ensure the document was inserted and no error was thrown from the transaction.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, its just by nature of the insert / commitTransaction not throwing. Checking the command started is sort of unreachable, if the WC is set the commitTxn throws, but its a reasonable double-check

Copy link
Contributor

Choose a reason for hiding this comment

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

Python checks that the result of the insert is an inserted id. We could also query the collection after the transaction for our doc - either would satisfy the "confirm the document was inserted".

This is important because w: 0 doesn't throw but might not insert.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Gotcha, will do

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added

@nbbeeken nbbeeken requested a review from baileympearson March 27, 2025 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Primary Review In Review with primary reviewer, not yet ready for team's eyes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants