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

DRIVERS-943 Convert retryable writes command construction tests to unified format #1697

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

isabelatkinson
Copy link
Contributor

@isabelatkinson isabelatkinson commented Oct 29, 2024

DRIVERS-943

This PR removes the retryable writes command construction tests that assert on the presence/absence of txnNumber and adds equivalent assertions to the unified tests. Most of the existing retryable writes unified tests don't currently use command monitoring, and I only added what was necessary to match the coverage of the removed construction tests. DRIVERS-2849 tracks adding more comprehensive command monitoring assertions to the retryable writes tests.

Draft PR for Rust: mongodb/mongo-rust-driver#1234

The unacknowledged writes and collection bulk write tests are not run in the Rust driver, so another driver will need to verify that these tests work.

Please complete the following before merging:

  • Update changelog.
  • Test changes in at least one language driver.
  • Test these changes against all server versions and topologies (including standalone, replica set, sharded
    clusters, and serverless).

@isabelatkinson isabelatkinson marked this pull request as ready for review October 30, 2024 22:47
@isabelatkinson isabelatkinson requested a review from a team as a code owner October 30, 2024 22:47
@isabelatkinson isabelatkinson requested review from aditi-khare-mongoDB and kevinAlbs and removed request for a team October 30, 2024 22:47
- `insertMany()` with `ordered=false`
- `bulkWrite()` with `ordered=true` (no `UpdateMany` or `DeleteMany`)
- `bulkWrite()` with `ordered=false` (no `UpdateMany` or `DeleteMany`)
Command construction tests asserting on the absence or presence of the `txnNumber` field have been replaced by command
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel this wording is a little confusing - originally it made me think we are no longer asserting on txnNumber.

I think it'd be better to remove this section, and if we want to include this information somewhere, we can expand in the changelog instead. Something like the following:

Convert command construction tests to unified format. In the retryable writes unified tests, the unified spec runner now asserts on the absence or presence of the txnNumber field using 'Command Monitoring'.

What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The specs README states:

Outdated tests must not be removed completely, but may be marked as such (e.g. by striking through or replacing the entire test with a note (e.g. Removed).

I think it's useful to maintain this section as a reference for drivers that have not yet removed these tests. WDYT about adding a strikethrough to the section title and rephrasing this as:

These prose tests have been removed in favor of unified format tests.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure, we can also rephrase it to something like.

In the retryable writes unified tests, the unified spec runner now asserts on the absence or presence of the txnNumber field using 'Command Monitoring'.

This or the strikethrough works!

Copy link
Contributor

@kevinAlbs kevinAlbs left a comment

Choose a reason for hiding this comment

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

LGTM with suggestions applied. Tests pass in C driver.


DRIVERS-943 includes:

also move the Split Batch Tests section to a numbered prose test.

Though I prefer leaving that change out of this PR (as is done now). I expect that can be done in a separate PR if that is still desired, and may not require a DRIVERS ticket.

source/retryable-writes/tests/unified/bulkWrite.yml Outdated Show resolved Hide resolved
@@ -493,3 +493,25 @@ tests:
documents:
- { _id: 1, x: 12 }
- { _id: 2, x: 22 }
- description: "collection bulkWrite with updateMany and deleteMany does not set txnNumber"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggest splitting to test updateMany and deleteMany in isolation:

  - description: "collection bulkWrite with updateMany does not set txnNumber"
    operations:
      - object: *collection0
        name: bulkWrite
        arguments:
          requests:
            - 
              updateMany:
                filter: {}
                update: { $set: { x: 1 } }
    expectEvents:
      - client: client0
        events:
          - commandStartedEvent:
              commandName: update
              command:
                txnNumber: { $$exists: false }
  - description: "collection bulkWrite with deleteMany does not set txnNumber"
    operations:
      - object: *collection0
        name: bulkWrite
        arguments:
          requests:
            - 
              deleteMany:
                filter: {}
    expectEvents:
      - client: client0
        events:
          - commandStartedEvent:
              commandName: delete
              command:
                txnNumber: { $$exists: false }

isabelatkinson and others added 3 commits November 7, 2024 11:06
Co-authored-by: Kevin Albertson <kevin.albertson@10gen.com>
Copy link
Contributor Author

@isabelatkinson isabelatkinson left a comment

Choose a reason for hiding this comment

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

@aditi-khare-mongoDB do these tests pass in the Node driver?

- `insertMany()` with `ordered=false`
- `bulkWrite()` with `ordered=true` (no `UpdateMany` or `DeleteMany`)
- `bulkWrite()` with `ordered=false` (no `UpdateMany` or `DeleteMany`)
Command construction tests asserting on the absence or presence of the `txnNumber` field have been replaced by command
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The specs README states:

Outdated tests must not be removed completely, but may be marked as such (e.g. by striking through or replacing the entire test with a note (e.g. Removed).

I think it's useful to maintain this section as a reference for drivers that have not yet removed these tests. WDYT about adding a strikethrough to the section title and rephrasing this as:

These prose tests have been removed in favor of unified format tests.

Copy link
Contributor

@aditi-khare-mongoDB aditi-khare-mongoDB left a comment

Choose a reason for hiding this comment

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

See comment! LGTM with changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants