-
Notifications
You must be signed in to change notification settings - Fork 37.8k
Add configuration file/argument testing #11883
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
test/functional/conf_args.py
Outdated
def run_test(self): | ||
self.stop_node(0) | ||
# Remove the -datadir argument so it doesn't override the config file | ||
self.nodes[0].args = [arg for arg in self.nodes[0].args if arg.startswith("-datadir")] |
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.
Did you mean if **not** arg.startswith("-datadir")
?
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.
Doh, yes, oops :)
test/functional/conf_args.py
Outdated
# Ensure command line argument overrides datadir in conf | ||
os.mkdir(new_data_dir_2) | ||
self.start_node(0, ['-datadir='+new_data_dir_2, '-wallet=w2']) | ||
assert(os.path.isfile(os.path.join(new_data_dir_2, 'wallets', 'w2'))) |
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.
femto-nit: missing space after assert, redundant round braces.
def run_test(self): | ||
self.stop_node(0) | ||
# Remove the -datadir argument so it doesn't override the config file | ||
self.nodes[0].args = [arg for arg in self.nodes[0].args if not arg.startswith("-datadir")] |
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.
Note that the configuration is written to the bitcoin.conf
in the datadir that you are removing from the args. I suspect this will cause issues.
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.
Hint: git grep 'def initialize_datadir'
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.
Yeah I've been trying to figure a way around this, if -datadir is specified on the command line it will override the conf file, but if it isn't then it can't find the conf file anyway. Still trying to think if this is possible or not. EDIT: Fixed
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.
utACK 7dc6a4253ea1c101b6b0591e4c9a84b9015d5891
test/functional/conf_args.py
Outdated
new_data_dir = os.path.join(default_data_dir, 'newdatadir') | ||
new_data_dir_2 = os.path.join(default_data_dir, 'newdatadir2') | ||
|
||
# Check that using -datadir argument on non-existant directory fails |
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.
spelling existent
test/functional/conf_args.py
Outdated
# Remove the -datadir argument so it doesn't override the config file | ||
self.nodes[0].args = [arg for arg in self.nodes[0].args if not arg.startswith("-datadir")] | ||
|
||
default_data_dir = os.path.join(self.options.tmpdir, 'node0') |
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.
Maybe call get_datadir_path(self.options.tmpdir, 0) to avoid hardcoding this.
Addressed @ryanofsky comments and squashed fixup commit, thanks :) |
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.
utACK be9a13c.
new_data_dir_2 = os.path.join(default_data_dir, 'newdatadir2') | ||
|
||
# Check that using -datadir argument on non-existent directory fails | ||
self.nodes[0].datadir = new_data_dir |
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.
Remove?
|
||
# Ensure command line argument overrides datadir in conf | ||
os.mkdir(new_data_dir_2) | ||
self.nodes[0].datadir = new_data_dir_2 |
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.
Remove?
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.
Can't remove either of those, they are used by the test runner to connect to the RPC and monitor the output of debug.log and stuff I believe, otherwise it can't find it. It's set separately from any command line arguments to bitcoind
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.
Maybe check if datadir is specified in extra_args in TestNode.start?
Thank you so much for adding tests for this! |
be9a13c Add configuration/argument testing (MeshCollider) Pull request description: Adds a new functional test for testing various command line and configuration file argument interactions, that aren't specific enough to other functionality to be placed in other tests. Currently this tests the error messages for non-existent datadir, which would have caught the bug fixed in #11829. It also tests that command line arguments override the ones in the config file. I plan on working on a fix for #11819 / #1044 and then expanding this test with cases for that. Tree-SHA512: 97aea18c67d331db3ca3d0c99c79267cf012df67fddafc9fac63d392f5c3a6469aa14d93b5865c3bbe561461648d2485367978a77446483b8df53d1916f1c8e8
Post-merge:
|
new_data_dir_2 = os.path.join(default_data_dir, 'newdatadir2') | ||
|
||
# Check that using -datadir argument on non-existent directory fails | ||
self.nodes[0].datadir = new_data_dir |
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.
This is a shame. I don't think individual tests should be reaching into a TestNode object to change the datadir, since that's used by the test framework in various places.
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.
@jnewbery You propose to discard the "old" TestNode and create a fresh one whenever the datadir is changed?
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.
No. The problem here is that it's useful to have a static datadir that files like debug.log and stderr are written to, since that helps with debugging failing scripts.
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.
I agree that it's not a clean solution but it's the only thing I could come up with to make it work, how do you propose otherwise to test the datadir argument?
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.
I think you're right. It's not ideal, but it's as good a way as any to do this.
It might be nice to have a log message at the start of the test warning that not all the node logs will be in the standard location:
self.log.warning("This test uses non-default data directories. Not all node logs will be in the default location.")
but probably not worth a separate PR to add that at this point.
be9a13c Add configuration/argument testing (MeshCollider) Pull request description: Adds a new functional test for testing various command line and configuration file argument interactions, that aren't specific enough to other functionality to be placed in other tests. Currently this tests the error messages for non-existent datadir, which would have caught the bug fixed in bitcoin#11829. It also tests that command line arguments override the ones in the config file. I plan on working on a fix for bitcoin#11819 / bitcoin#1044 and then expanding this test with cases for that. Tree-SHA512: 97aea18c67d331db3ca3d0c99c79267cf012df67fddafc9fac63d392f5c3a6469aa14d93b5865c3bbe561461648d2485367978a77446483b8df53d1916f1c8e8
be9a13c Add configuration/argument testing (MeshCollider) Pull request description: Adds a new functional test for testing various command line and configuration file argument interactions, that aren't specific enough to other functionality to be placed in other tests. Currently this tests the error messages for non-existent datadir, which would have caught the bug fixed in bitcoin#11829. It also tests that command line arguments override the ones in the config file. I plan on working on a fix for bitcoin#11819 / bitcoin#1044 and then expanding this test with cases for that. Tree-SHA512: 97aea18c67d331db3ca3d0c99c79267cf012df67fddafc9fac63d392f5c3a6469aa14d93b5865c3bbe561461648d2485367978a77446483b8df53d1916f1c8e8
be9a13c Add configuration/argument testing (MeshCollider) Pull request description: Adds a new functional test for testing various command line and configuration file argument interactions, that aren't specific enough to other functionality to be placed in other tests. Currently this tests the error messages for non-existent datadir, which would have caught the bug fixed in bitcoin#11829. It also tests that command line arguments override the ones in the config file. I plan on working on a fix for bitcoin#11819 / bitcoin#1044 and then expanding this test with cases for that. Tree-SHA512: 97aea18c67d331db3ca3d0c99c79267cf012df67fddafc9fac63d392f5c3a6469aa14d93b5865c3bbe561461648d2485367978a77446483b8df53d1916f1c8e8
be9a13c Add configuration/argument testing (MeshCollider) Pull request description: Adds a new functional test for testing various command line and configuration file argument interactions, that aren't specific enough to other functionality to be placed in other tests. Currently this tests the error messages for non-existent datadir, which would have caught the bug fixed in bitcoin#11829. It also tests that command line arguments override the ones in the config file. I plan on working on a fix for bitcoin#11819 / bitcoin#1044 and then expanding this test with cases for that. Tree-SHA512: 97aea18c67d331db3ca3d0c99c79267cf012df67fddafc9fac63d392f5c3a6469aa14d93b5865c3bbe561461648d2485367978a77446483b8df53d1916f1c8e8
be9a13c Add configuration/argument testing (MeshCollider) Pull request description: Adds a new functional test for testing various command line and configuration file argument interactions, that aren't specific enough to other functionality to be placed in other tests. Currently this tests the error messages for non-existent datadir, which would have caught the bug fixed in bitcoin#11829. It also tests that command line arguments override the ones in the config file. I plan on working on a fix for bitcoin#11819 / bitcoin#1044 and then expanding this test with cases for that. Tree-SHA512: 97aea18c67d331db3ca3d0c99c79267cf012df67fddafc9fac63d392f5c3a6469aa14d93b5865c3bbe561461648d2485367978a77446483b8df53d1916f1c8e8
Adds a new functional test for testing various command line and configuration file argument interactions, that aren't specific enough to other functionality to be placed in other tests.
Currently this tests the error messages for non-existent datadir, which would have caught the bug fixed in #11829. It also tests that command line arguments override the ones in the config file.
I plan on working on a fix for #11819 / #1044 and then expanding this test with cases for that.