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

test, init: perturb file to ensure failure instead of only deleting them #26653

Merged
merged 1 commit into from May 5, 2023

Conversation

brunoerg
Copy link
Contributor

@brunoerg brunoerg commented Dec 7, 2022

In feature_init.py there is a TODO about perturbing the files instead of only testing by deleting them.

            # TODO: at some point, we should test perturbing the files instead of removing
            # them, e.g.
            #
            # contents = target_file.read_bytes()
            # tweaked_contents = bytearray(contents)
            # tweaked_contents[50:250] = b'1' * 200
            # target_file.write_bytes(bytes(tweaked_contents))
            #
            # At the moment I can't get this to work (bitcoind loads successfully?) so
            # investigate doing this later.

This PR adds it by writing into the file random bytes and checking whether it throws an error when starting.

@DrahtBot
Copy link
Contributor

DrahtBot commented Dec 7, 2022

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK MarcoFalke

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

@fanquake fanquake requested a review from jamesob December 7, 2022 17:15
@fanquake fanquake added the Tests label Dec 7, 2022
@brunoerg brunoerg changed the title test, init: perturb file to ensure failure instead of only deleting them [WIP] test, init: perturb file to ensure failure instead of only deleting them Dec 7, 2022
@brunoerg brunoerg force-pushed the 2022-12-stress-test-perturbing branch from e5d3d80 to c371cae Compare December 7, 2022 18:01
@brunoerg brunoerg changed the title [WIP] test, init: perturb file to ensure failure instead of only deleting them test, init: perturb file to ensure failure instead of only deleting them Dec 7, 2022
@brunoerg brunoerg marked this pull request as ready for review December 7, 2022 20:36
@achow101 achow101 requested a review from maflcko April 25, 2023 15:39
@maflcko
Copy link
Member

maflcko commented May 5, 2023

lgtm ACK c371cae

@DrahtBot DrahtBot removed the request for review from maflcko May 5, 2023 12:44
@fanquake fanquake merged commit b11bd04 into bitcoin:master May 5, 2023
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request May 5, 2023

for target_file in target_files:
self.log.info(f"Perturbing file to ensure failure {target_file}")
with open(target_file, "rb") as tf_read, open(target_file, "wb") as tf_write:
Copy link
Member

Choose a reason for hiding this comment

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

Note that it looks like this didn't work, and is being fixed in #27823.

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

Successfully merging this pull request may close these issues.

None yet

4 participants