gh-124213: Skip tests failing with --suppress-sync=true when inside systemd-nspawn container#124215
Merged
vstinner merged 8 commits intopython:mainfrom Sep 20, 2024
Merged
gh-124213: Skip tests failing with --suppress-sync=true when inside systemd-nspawn container#124215vstinner merged 8 commits intopython:mainfrom
--suppress-sync=true when inside systemd-nspawn container#124215vstinner merged 8 commits intopython:mainfrom
Conversation
…n inside systemd-nspawn container Add a helper functon that checks whether the test suite is running inside a systemd-nspawn container, and skip the few tests failing with `--suppress-sync=true` in that case. The tests are failing because `--suppress-sync=true` stubs out `fsync()`, `fdatasync()` and `msync()` calls, and therefore they always return success without checking for invalid arguments. Technically, this means that the tests are also skipped when running inside systemd-nspawn container without `--suppress-sync=true`. However, to the best of my knowledge the only way to detect this option is to actually reproduce one of the unexpectedly-succeeding syscalls, and since this is precisely what we're testing for, the skip-test and the actual test would be doing the same thing.
vstinner
reviewed
Sep 20, 2024
Misc/NEWS.d/next/Tests/2024-09-18-18-39-21.gh-issue-124213.AQq_xg.rst
Outdated
Show resolved
Hide resolved
Add a docstring explaining the function in detail. Switch from pathlib to plain `open().read()`. Update the news entry.
Contributor
Author
|
Thanks. Updated per your comments. Thinking about it, I think I could make the skips a bit more specific — that is, detect |
Call `os.open("", os.O_RDONLY | os.O_SYNC)` and check the errno to
detect whether `--suppress-sync=true` is actually used, and skip
the tests only in that scenario.
vstinner
reviewed
Sep 20, 2024
Co-authored-by: Victor Stinner <vstinner@python.org>
vstinner
reviewed
Sep 20, 2024
vstinner
reviewed
Sep 20, 2024
mgorny
commented
Sep 20, 2024
| self.assertIsNone(result) | ||
| if sys.platform.startswith(('linux', 'android')): | ||
| if (sys.platform.startswith(('linux', 'android')) | ||
| and not in_systemd_nspawn_sync_suppressed()): |
Contributor
Author
There was a problem hiding this comment.
To be honest, I wanted to avoid this because it's very confusing when the condition has the same indent as the code below.
Member
There was a problem hiding this comment.
Yeah but the line was too long. That's the problem of long function names.
mgorny
commented
Sep 20, 2024
Comment on lines
+843
to
+844
| if (sys.platform.startswith(('linux', 'android')) | ||
| and not in_systemd_nspawn_sync_suppressed()): |
Contributor
Author
There was a problem hiding this comment.
Perhaps we could follow black here:
Suggested change
| if (sys.platform.startswith(('linux', 'android')) | |
| and not in_systemd_nspawn_sync_suppressed()): | |
| if ( | |
| sys.platform.startswith(("linux", "android")) | |
| and not in_systemd_nspawn_sync_suppressed() | |
| ): |
Member
|
Merged, thanks. |
Contributor
Author
|
Thanks! |
savannahostrowski
pushed a commit
to savannahostrowski/cpython
that referenced
this pull request
Sep 22, 2024
…sync=true (python#124215) Add a helper function that checks whether the test suite is running inside a systemd-nspawn container, and skip the few tests failing with `--suppress-sync=true` in that case. The tests are failing because `--suppress-sync=true` stubs out `fsync()`, `fdatasync()` and `msync()` calls, and therefore they always return success without checking for invalid arguments. Call `os.open(__file__, os.O_RDONLY | os.O_SYNC)` and check the errno to detect whether `--suppress-sync=true` is actually used, and skip the tests only in that scenario.
savannahostrowski
pushed a commit
to savannahostrowski/cpython
that referenced
this pull request
Sep 22, 2024
…sync=true (python#124215) Add a helper function that checks whether the test suite is running inside a systemd-nspawn container, and skip the few tests failing with `--suppress-sync=true` in that case. The tests are failing because `--suppress-sync=true` stubs out `fsync()`, `fdatasync()` and `msync()` calls, and therefore they always return success without checking for invalid arguments. Call `os.open(__file__, os.O_RDONLY | os.O_SYNC)` and check the errno to detect whether `--suppress-sync=true` is actually used, and skip the tests only in that scenario.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a helper functon that checks whether the test suite is running inside a systemd-nspawn container, and skip the few tests failing with
--suppress-sync=truein that case. The tests are failing because--suppress-sync=truestubs outfsync(),fdatasync()andmsync()calls, and therefore they always return success without checking for invalid arguments.Technically, this means that the tests are also skipped when running inside systemd-nspawn container without
--suppress-sync=true. However, to the best of my knowledge the only way to detect this option is to actually reproduce one of the unexpectedly-succeeding syscalls, and since this is precisely what we're testing for, the skip-test and the actual test would be doing the same thing.systemd-nspawn --suppress-sync=truecontainer #124213