Skip to content

Conversation

meshcollider
Copy link
Contributor

@meshcollider meshcollider commented Dec 12, 2017

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.

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")]
Copy link
Member

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")?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Doh, yes, oops :)

# 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')))
Copy link
Member

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.

@fanquake fanquake added the Tests label Dec 13, 2017
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")]
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 the configuration is written to the bitcoin.conf in the datadir that you are removing from the args. I suspect this will cause issues.

Copy link
Member

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'

Copy link
Contributor Author

@meshcollider meshcollider Dec 13, 2017

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

@meshcollider meshcollider changed the title Add configuration file/argument testing [WiP] Add configuration file/argument testing Dec 14, 2017
@meshcollider meshcollider changed the title [WiP] Add configuration file/argument testing Add configuration file/argument testing Dec 15, 2017
Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

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

utACK 7dc6a4253ea1c101b6b0591e4c9a84b9015d5891

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
Copy link
Contributor

Choose a reason for hiding this comment

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

spelling existent

# 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')
Copy link
Contributor

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.

@meshcollider
Copy link
Contributor Author

Addressed @ryanofsky comments and squashed fixup commit, thanks :)

Copy link
Contributor

@promag promag left a 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
Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove?

Copy link
Contributor Author

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

Copy link
Contributor

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?

@laanwj
Copy link
Member

laanwj commented Dec 20, 2017

Thank you so much for adding tests for this!
utACK be9a13c

@laanwj laanwj merged commit be9a13c into bitcoin:master Dec 20, 2017
laanwj added a commit that referenced this pull request Dec 20, 2017
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
@meshcollider meshcollider deleted the 201712_datadir_tests branch December 20, 2017 11:31
@maflcko
Copy link
Member

maflcko commented Dec 20, 2017

Post-merge:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

utACK be9a13c8a0f149ac219934b515399cca60bf2123
-----BEGIN PGP SIGNATURE-----

iQIcBAEBCgAGBQJaOu+pAAoJENLqSFDnUoslsOcQAIiaYN2oS9TNACNr4wnYBcXW
CY6i4q5Eyfr8CaENaeZNvDoYm92DH+dysVvVXjJoQetxTL+kiEU6xj1MdV24RCcd
IWgqAroaLIGDFbe5DL7J9YOGwUWsO56NtSLKB5vZsaX8HocP/kNh2jvXTaq6Hq8E
tvUev82IWTQQfit15yiO6ETsSiJadN7WPst0tfrj+gqIs67Acrg8hyP2VQ5Q594v
8O7nt0IFUr8TWmYPf/8JrCN3odiEAwva+KSGuYYayQT4bEIBVUxy49D0vfRQMdad
paTVdw7u53lFbcZKyIDzHFPKnU6FDV+wIqtCgtGPWNhFq3p6s4GCxlKHo37WbVdi
cjsm4tC4v7UN0Mor9WACc79gkkooWD32ZqN9iOtkshG6aTJt0kIwLrzOVm60uR6D
HkGj3yLREBYUZsvF4wSngCrdWAreHU9RePRTo8vKfPVTf7sr5LLoe+iBiSlvaviI
5gUUNMxD+UG5nfotBQSNBV7I1WQ48t+wO5WjIW7SKUfVnlGk0FT6C1eNI6JDpW9i
Ln2Mq82pwO16aZKAn+NxXxyQe9huqs1xNNC/TtBqMLbM2Wf96MjhPjTQJTujJBrH
90LAJ35nHawrrxC4RZL5ipkJUIu8ruDITchZomQmYujsO8jvBsQvdrkHmgOPZDOS
RZW+i/hZ8oG1oze/BjYh
=N62V
-----END PGP SIGNATURE-----

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
Copy link
Contributor

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.

Copy link
Member

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor

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.

PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Feb 13, 2020
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
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Feb 27, 2020
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
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Feb 27, 2020
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
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Feb 27, 2020
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
gades pushed a commit to cosanta/cosanta-core that referenced this pull request Jun 30, 2021
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
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants