Skip to content

Add fsync command tests#657

Open
danielfrankcom wants to merge 4 commits into
documentdb:mainfrom
danielfrankcom:pr/fsync
Open

Add fsync command tests#657
danielfrankcom wants to merge 4 commits into
documentdb:mainfrom
danielfrankcom:pr/fsync

Conversation

@danielfrankcom

Copy link
Copy Markdown
Collaborator

This change adds tests for the fsync command.

There is some machinery overlap with #641 but they have the same content so they should merge cleanly.

Closes #420

Signed-off-by: Daniel Frankcom <frankcom@amazon.com>
@danielfrankcom danielfrankcom requested a review from a team as a code owner June 29, 2026 21:48
@documentdb-triage-tool documentdb-triage-tool Bot added compatibility test Compatibility test related enhancement New feature or request labels Jun 29, 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 Needs Review
Confidence: 0.30 (deterministic)

Reasoning

component from path globs (test-coverage, test-framework); effort from diff stats (1081+1 LOC, 11 files); LLM failed: Invalid response body while trying to fetch https://api.anthropic.com/v1/messages: Premature close

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.

@ramgokul-14

Copy link
Copy Markdown

Required - Doc update needed for conftest.py validator allowance — the change to test_structure_validator.py is a project-wide convention change. Per REVIEW.md §9, update TEST_FORMAT.md or FOLDER_STRUCTURE.md to document that conftest.py is a valid non-test Python file.

Suggestions

  • Add a max-iteration guard to drain_fsync_lock's while True to prevent CI hangs
  • Assert the first lock acquisition succeeded in test_fsync_lock_persists_after_connection_close before closing the client
  • Consider an inline comment in test_fsync_rejects_non_admin_database explaining why execute_command (non-admin) is used

Questions

  • Is afterClusterTime in readConcern in-scope, or is the current level-focused testing sufficient for an admin command that mostly rejects these options?
  • Was placing the fixture at administration/conftest.py (parent level) considered vs. the re-export pattern?

Complete the readConcern sub-field coverage for fsync. afterClusterTime and
atClusterTime must both be Timestamps: a non-Timestamp value (including null) is
a TypeMismatch. A null-timestamp afterClusterTime and any atClusterTime timestamp
are InvalidOptions (atClusterTime requires the unsupported snapshot level). A
non-zero afterClusterTime is accepted only where replication-dependent read
concern is available (gated with requires(cluster_read_concern)), rejected with
IllegalOperation elsewhere.

The provenance and afterOpTime sub-fields are intentionally omitted as internal
fields outside the compatibility surface.

Signed-off-by: Daniel Frankcom <frankcom@amazon.com>
FOLDER_STRUCTURE.md did not mention conftest.py, yet the structure validator
now exempts it (alongside __init__.py) from the test-file naming rules. Document
which non-test Python files a test folder may contain and the convention that
shared fixtures live in utils/ and are re-exported from a thin conftest.py.

Signed-off-by: Daniel Frankcom <frankcom@amazon.com>
@danielfrankcom

Copy link
Copy Markdown
Collaborator Author

Required - Doc update needed for conftest.py validator allowance — the change to test_structure_validator.py is a project-wide convention change. Per REVIEW.md §9, update TEST_FORMAT.md or FOLDER_STRUCTURE.md to document that conftest.py is a valid non-test Python file.

Added a note about this.

  • Add a max-iteration guard to drain_fsync_lock's while True to prevent CI hangs

I don't think this is needed. If the loop does not progress and reach a guard condition then there is a critical bug in the engine itself, which could apply to any command we execute hanging forever in the engine. The CI will eventually time out and fail the test run regardless of the problem with the engine so I don't think this is a concern we need to worry about.

  • Assert the first lock acquisition succeeded in test_fsync_lock_persists_after_connection_close before closing the client

The final lockCount 2 assertion already proves the first acquire succeeded, since a failed one would leave the count at 1. The test framework also encourages only 1 assertion per method so it is easier this way.

  • Consider an inline comment in test_fsync_rejects_non_admin_database explaining why execute_command (non-admin) is used

I think the property comment and test method naming already make this clear enough.

  • Is afterClusterTime in readConcern in-scope, or is the current level-focused testing sufficient for an admin command that mostly rejects these options?

Added tests for both missing readConcern sub-fields. afterClusterTime and atClusterTime are now covered.

  • Was placing the fixture at administration/conftest.py (parent level) considered vs. the re-export pattern?

The re-export keeps the autouse lock-drain scoped to just the fsync and fsyncUnlock directories. A parent conftest.py under administration/ would run the drain around every admin test, most of which have nothing to do with the fsync lock.

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.

Add compatibility test for fsync

2 participants