-
Notifications
You must be signed in to change notification settings - Fork 1.6k
test: Add unit test for append_challenged_posix_file #3055
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
base: master
Are you sure you want to change the base?
test: Add unit test for append_challenged_posix_file #3055
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a comprehensive unit test for the append_challenged_posix_file
implementation to validate append concurrency limits, write behavior, and exclusive fsync functionality. The test ensures that the file implementation correctly handles write operations that extend beyond the current file size while respecting concurrency constraints.
- Adds a test framework class
append_challenged_posix_file_test
that simulates file operations without actual I/O - Implements validation for append concurrency limits and exclusive fsync behavior
- Creates helper functions to construct test instances of the append-challenged file implementation
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
tests/unit/file_io_test.cc | Adds the main test class and test cases for append-challenged file behavior |
src/core/file.cc | Implements factory function for creating test instances of append-challenged files |
src/core/file-impl.hh | Adds forward declarations and friend class access for testing |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
||
SEASTAR_TEST_CASE(test_append_challenged_posix_file_impl) { | ||
return tmp_dir::do_with_thread([] (tmp_dir& t) { | ||
test_append_challenged_posix_file_concurrency(t, 0); |
Copilot
AI
Oct 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Testing with concurrency 0 may not be meaningful since it suggests no concurrent operations are allowed, which could lead to undefined behavior or deadlocks in the append-challenged file implementation.
test_append_challenged_posix_file_concurrency(t, 0); |
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0 concurrency means something else here -- it tells that no size-changing operations are allowed, so the appenc challenged file truncates it ahead of any write.
140b6c5
to
d86d69f
Compare
The test validates several things: - the maximum number of writes-above-file-size doesn't exceed the limit - the number of writes-above-file-size actually reaches it - no parallel fsyncs are run if disabled In fact, the 2nd test fails for concurrency above 1, but for XFS it's not currently configured, so OK for now. To work, the test creates an "real" temporary file, but doesn't do real IO, instead, it runs counting-only operations. Truncations, however, happen for real, because this file impl uses raw ftruncate systemcall for it. Signed-off-by: Pavel Emelyanov <[email protected]>
d86d69f
to
1783f7c
Compare
upd:
|
The test validates several things:
In fact, the 2nd test fails for concurrency above 1, but for XFS it's not currently configured, so OK for now.
To work, the test creates an "real" temporary file, but doesn't do real IO, instead, it runs counting-only operations. Truncations, however, happen for real, because this file impl uses raw ftruncate systemcall for it.