-
Notifications
You must be signed in to change notification settings - Fork 38.8k
test: add functional test for -startupnotify #23532
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
Conversation
|
Concept ACK. Perhaps the test with valid command can create a file in test or |
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. 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. |
c31930c to
a25e636
Compare
a25e636 to
36b9623
Compare
|
I've tried different valid commands with -startupnotify like: |
|
You can find the error in the log: |
Sorry, I read that but didn't notice this part of the log. Thanks. |
5f7d252 to
b9908fa
Compare
|
Concept ACK |
|
Force-pushed with a update on |
7818542 to
9e94a23
Compare
510919d to
e9ebe3b
Compare
|
Force-pushed adding |
7f462b1 to
b0fc9f9
Compare
luke-jr
left a comment
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.
Ideally, a test for -startupnotify should ensure that the command is executed exactly once, and when it is executed, the node is fully started (which may involve races which make it difficult to deterministically fail).
b0fc9f9 to
31931a5
Compare
|
Force-pushed addressing the reviews, thanks everyone for them. I just changed the approach for this test (updated the description). |
jonatack
left a comment
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.
ACK 31931a5ab009256bf583025939e6e3ca2f875d9a
A couple of ideas, feel free to ignore/pick/choose:
- Begin by testing the absence of
tmpdirwithout-startupnotifybefore asserting on its presence with the option - Maybe abstract the magic strings to constants
from test_framework.test_framework import BitcoinTestFramework
+NODE_DIR = "node0"
+FILE_NAME = "test_123_xyz"
class StartupNotifyTest(BitcoinTestFramework):
def set_test_params(self):
self.num_nodes = 1
self.disable_syscall_sandbox = True
- self.extra_args = [["-startupnotify=echo 'test' >> node0/test.txt"]]
def run_test(self):
- tmpdir = os.path.join(self.options.tmpdir, "node0", "test.txt")
+ tmpdir = os.path.join(self.options.tmpdir, NODE_DIR, FILE_NAME)
+ assert not os.path.exists(tmpdir)
self.log.info("When node starts, check if test.txt exists")
+ self.restart_node(0, extra_args=[f"-startupnotify=echo '{FILE_NAME}' >> {NODE_DIR}/{FILE_NAME}"])
assert os.path.exists(tmpdir)
Maybe checking the expected result of an RPC (like getblockcount) could verify the node is fully up. |
506c9ce to
3e2be6f
Compare
|
ACK, modulo unrelated code that appears to have crept into the last push? |
omg, didn't understand why it happened, going to check it. |
3e2be6f to
98014c5
Compare
|
fixed commits! @jonatack |
98014c5 to
dbdcc78
Compare
|
force-pushed addressing @luke-jr and @kristapsk reviews (check if the command is executed once). |
kristapsk
left a comment
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.
ACK dbdcc783e39794d54c2f17040d248539b1ca46b0
lsilva01
left a comment
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.
reACK dbdcc78
Nice addition to test coverage.
|
dbdcc78 to
1268532
Compare
Fixed! |
theStack
left a comment
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.
Tested ACK 1268532
(run on OpenBSD 7.0)
kristapsk
left a comment
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.
re-ACK 1268532
1268532 test: add functional test for -startupnotify (Bruno Garcia) Pull request description: This PR adds a functional test for -startupnotify. It basically starts the node passing a command on -startupnotify to create a file on tmp and then, we check if the file has been successfully created. ACKs for top commit: theStack: Tested ACK 1268532 kristapsk: re-ACK 1268532 Tree-SHA512: 5bf3e46124ee5c9d609c9993e6465d5a71a8d2275dcf07c8ce0549f013f7f8863d483b46b7164152f566468a689371ccb87f01cf118c3c9cac5b2be673b61a5c
|
Concept and approach ACK. Tested and working fine :) |



This PR adds a functional test for -startupnotify. It basically starts the node passing a command on -startupnotify to create a file on tmp and then, we check if the file has been successfully created.