test: Add unit & functional test coverage for blockstore#27850
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
b58d3fa to
4daeaa5
Compare
ba8547f to
38bc463
Compare
|
Concept ACK |
6f7499a to
e01ac84
Compare
e01ac84 to
f88b87b
Compare
f37e904 to
da1f187
Compare
|
I fixed the CI failures by skipping tasks that are run as root. Root privileges override the read-only file permissions and the test fails because we expect an error that doesn't throw (can not open read-only file in write mode). There are 6 tasks that skip this test for this reason: [ASan + LSan + UBSan + integer, no depends, USDT] [lunar] |
689448d to
ae4d5f5
Compare
|
Ready for review now, CI is passing modulo #27879 |
|
Just curious, did you try using Seems a shame to miss linux out. |
ae4d5f5 to
5bc5150
Compare
Bold strategy, Cotton let's see if it pays off: cd394b637f |
cd394b6 to
1dd0dfd
Compare
|
You can find the error in the logs: |
Right but that error is caught in a I guess the difference is on windows |
|
Ah right. It is not allowed to print anything to stderr during the test. You'll have to catch that as well. See if proc.returncode == TEST_EXIT_PASSED and stderr == "":
status = "Passed"
elif proc.returncode == TEST_EXIT_SKIPPED:
status = "Skipped"
skip_reason = re.search(r"Test Skipped: (.*)", stdout).group(1)
else:
status = "Failed" |
bee4e3f to
0ff660f
Compare
Maybe need to install it? |
Added |
There was a problem hiding this comment.
nit: May be better to put this into CI_BASE_PACKAGES, both for centos, and ubuntu/debian to avoid failures when it is removed from the vanilla ubuntu/debian container image.
maflcko
left a comment
There was a problem hiding this comment.
lgtm, thanks for taking the feedback so far
thanks for your stamina on this one as well! >100 comments 👍 |
|
Only changes since last review:
|
maflcko
left a comment
There was a problem hiding this comment.
left two nits/questions.
re-ACK 6cda1acdea2b908345406389baaef593ac5cce76 🤼
Show signature
Signature:
untrusted comment: signature from minisign secret key on empty file; verify via: minisign -Vm "${path_to_any_empty_file}" -P RWTRmVTMeKV5noAMqVlsMugDDCyyTSbA3Re5AkUrhvLVln0tSaFWglOw -x "${path_to_this_whole_four_line_signature_blob}"
RUTRmVTMeKV5npGrKx1nqXCw5zeVHdtdYURB/KlyA/LMFgpNCs+SkW9a8N95d+U4AP1RJMi+krxU1A3Yux4bpwZNLvVBKy0wLgM=
trusted comment: re-ACK 6cda1acdea2b908345406389baaef593ac5cce76 🤼
dakRHCgn0dA/yjlDWocN/nVHFZ2qhu24JHr3Kf+ETosirJP1raLsjYzRUHm5kFp04VPWj0OXABmzLNxYXMymCA==
There was a problem hiding this comment.
style nit in 6cda1acdea: Can remove this?
There was a problem hiding this comment.
| self.log.warning(f"Can not make file immutable with chattr, trying chmod instead") | |
| self.log.info("Cannot make file immutable with chattr, trying chmod instead") |
Would suggest logging this as info or debug rather than warning, as it is platform-specific and not an actionable warning for the user.
Drop unneeded f-string.
s/Can not/Cannot/ or s/Can not/Unable to/
Not a blocker, but I need the same logic for #28116, if you feel like making a test framework utility method as you did previously here.
There was a problem hiding this comment.
Thanks Jon I'll change the log level but leave the utility method for a follow up to keep revisions minimal
|
force-pushed because I accidentally squashed two commits together. Diff is null 278e675 to 9791b31 |
jonatack
left a comment
There was a problem hiding this comment.
ACK 9791b3182514a2571a7c1cdb38b59338c24d974d
There was a problem hiding this comment.
259889d Maybe assert the value here before the read, to ensure that it changed with the BOOST_CHECK_EQUAL(read_block.nVersion, 1); check that follows.
CBlock read_block;
+ BOOST_CHECK_EQUAL(read_block.nVersion, 0);
{There was a problem hiding this comment.
9791b31
- suggest making the other added logs
info, or this logdebug s/Can not/Cannot/and mention that chattr is platform-specific to linux (see suggestion)- missing line breaks
@@ -11,6 +11,7 @@ import stat
from test_framework.test_framework import BitcoinTestFramework
+
class BlockstoreReindexTest(BitcoinTestFramework):
@@ -41,7 +42,7 @@ class BlockstoreReindexTest(BitcoinTestFramework):
if not used_chattr:
- self.log.info("Can not make file immutable with chattr, trying chmod instead")
+ self.log.debug("Cannot make file read-only with chattr (which is linux-only), using chmod instead")
@@ -57,5 +58,6 @@ class BlockstoreReindexTest(BitcoinTestFramework):
self.reindex_readonly()
+
if __name__ == '__main__':
BlockstoreReindexTest().main()$ pycodestyle test/functional/feature_reindex_readonly.py
test/functional/feature_reindex_readonly.py:14:1: E302 expected 2 blank lines, found 1
test/functional/feature_reindex_readonly.py:60:1: E305 expected 2 blank lines after class or function definition, found 1There was a problem hiding this comment.
I generally prefer chatty tests, which makes it easier to see progress and see what the test is currently doing, as long as the output is not high-frequent. So I think the log level can be left as-is.
maflcko
left a comment
There was a problem hiding this comment.
re-ACK 9791b3182514a2571a7c1cdb38b59338c24d974d 🕕
Show signature
Signature:
untrusted comment: signature from minisign secret key on empty file; verify via: minisign -Vm "${path_to_any_empty_file}" -P RWTRmVTMeKV5noAMqVlsMugDDCyyTSbA3Re5AkUrhvLVln0tSaFWglOw -x "${path_to_this_whole_four_line_signature_blob}"
RUTRmVTMeKV5npGrKx1nqXCw5zeVHdtdYURB/KlyA/LMFgpNCs+SkW9a8N95d+U4AP1RJMi+krxU1A3Yux4bpwZNLvVBKy0wLgM=
trusted comment: re-ACK 9791b3182514a2571a7c1cdb38b59338c24d974d 🕕
Yj2uRwzpT1GD2q/ibV1KkO+mrHtJd2SSWN8t4DWILeAQrpp52zK2SWHQFhk/iD04RqlyGEtI32q3lRbj3NNvBg==
There was a problem hiding this comment.
nit: I think this wasn't addressed?
There was a problem hiding this comment.
Any reason to add an alias, but not use it consistently?
There was a problem hiding this comment.
Why is this needed, when the same call was already done unconditionally, which seems preferable than a conditional call?
There was a problem hiding this comment.
Any reason for the else? Seems better to also do this unconditionally, because setting it was done unconditionally.
Otherwise it may cause edge cause test failures on some machines/configs only.
There was a problem hiding this comment.
| # Copyright (c) 2023 The Bitcoin Core developers | |
| # Copyright (c) 2023-present The Bitcoin Core developers |
nit: For new code could use -present (or omit the year) to avoid having to ever touch it again.
|
Thanks again @MarcoFalke and @jonatack I addressed all your feedback |
maflcko
left a comment
There was a problem hiding this comment.
re-ACK f1264f9baca4207c4c530f01d90fcdc841368126 🍦
Show signature
Signature:
untrusted comment: signature from minisign secret key on empty file; verify via: minisign -Vm "${path_to_any_empty_file}" -P RWTRmVTMeKV5noAMqVlsMugDDCyyTSbA3Re5AkUrhvLVln0tSaFWglOw -x "${path_to_this_whole_four_line_signature_blob}"
RUTRmVTMeKV5npGrKx1nqXCw5zeVHdtdYURB/KlyA/LMFgpNCs+SkW9a8N95d+U4AP1RJMi+krxU1A3Yux4bpwZNLvVBKy0wLgM=
trusted comment: re-ACK f1264f9baca4207c4c530f01d90fcdc841368126 🍦
G5HM6LhMQyxLvXfOSzHbPsljWaZ9XpmswhOHqpwakw2n06WWG+7NyED+63/6l0Lcy6tPvu6axWBFhHvMZKAMAA==
|
ACK f1264f9baca4207c4c530f01d90fcdc841368126 |
There was a problem hiding this comment.
When this test is run as non-root, this results in something being written to stderr which will cause the test runner to always fail. That's really annoying for testing locally.
| try: | |
| subprocess.check_call(['chattr', '+i', filename]) | |
| used_chattr = True | |
| self.log.info("Made file immutable with chattr") | |
| except Exception: | |
| pass | |
| try: | |
| subprocess.run(['chattr', '+i', filename], capture_output=True, check=True) | |
| used_chattr = True | |
| self.log.info("Made file immutable with chattr") | |
| except subprocess.CalledProcessError as e: | |
| self.log.warning(str(e)) | |
| if e.stdout: | |
| self.log.warning(f"stdout: {e.stdout}") | |
| if e.stderr: | |
| self.log.warning(f"stderr: {e.stderr}") |
There was a problem hiding this comment.
Added! thanks for the patch
Co-authored-by: Andrew Chow <github@achow101.com>
|
ACK de8f912 tested on macOS, but not on Linux for the Linux-related change in the last push |
maflcko
left a comment
There was a problem hiding this comment.
lgtm ACK de8f912 📶
Show signature
Signature:
untrusted comment: signature from minisign secret key on empty file; verify via: minisign -Vm "${path_to_any_empty_file}" -P RWTRmVTMeKV5noAMqVlsMugDDCyyTSbA3Re5AkUrhvLVln0tSaFWglOw -x "${path_to_this_whole_four_line_signature_blob}"
RUTRmVTMeKV5npGrKx1nqXCw5zeVHdtdYURB/KlyA/LMFgpNCs+SkW9a8N95d+U4AP1RJMi+krxU1A3Yux4bpwZNLvVBKy0wLgM=
trusted comment: lgtm ACK de8f9123afbecc3b4f59fa80af8148bc865d0588 📶
aCT7KL7/lymQNqrfkzsZyKFtz7sH6ZgYVwranWjN6pDe/m5Cd47wdd2X8+yokXAAQkqj7TMxrlrauXR514LfBw==
|
ACK de8f912 |
| filename.chmod(stat.S_IREAD) | ||
|
|
||
| used_chattr = False | ||
| if platform.system() == "Linux": |
There was a problem hiding this comment.
I guess this test will also fail on freebsd when running as root
There was a problem hiding this comment.
A solution may be to check for freebsd and chflags?
There was a problem hiding this comment.
I have an OpenBSD server I can run the test on, will follow up with a PR this week
This PR adds unit and functional tests to cover the behavior described in #2039. In particular, that bitcoind will crash on startup if a reindex is requested but the
blkfiles are read-only. Eventually this behavior can be updated with #27039. This PR just commits the test coverage from #27039 as suggested in #27039 (comment)