Add configuration file/argument testing #11883

pull meshcollider wants to merge 1 commits into bitcoin:master from meshcollider:201712_datadir_tests changing 2 files +50 −0
  1. meshcollider commented at 11:59 PM on December 12, 2017: contributor

    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.

  2. in test/functional/conf_args.py:20 in 49bfddddeb outdated
      15 | +        self.num_nodes = 1
      16 | +
      17 | +    def run_test(self):
      18 | +        self.stop_node(0)
      19 | +        # Remove the -datadir argument so it doesn't override the config file
      20 | +        self.nodes[0].args = [arg for arg in self.nodes[0].args if arg.startswith("-datadir")]
    


    MarcoFalke commented at 12:48 AM on December 13, 2017:

    Did you mean if **not** arg.startswith("-datadir")?


    meshcollider commented at 1:22 AM on December 13, 2017:

    Doh, yes, oops :)

  3. in test/functional/conf_args.py:43 in 49bfddddeb outdated
      38 | +        self.stop_node(0)
      39 | +
      40 | +        # Ensure command line argument overrides datadir in conf
      41 | +        os.mkdir(new_data_dir_2)
      42 | +        self.start_node(0, ['-datadir='+new_data_dir_2, '-wallet=w2'])
      43 | +        assert(os.path.isfile(os.path.join(new_data_dir_2, 'wallets', 'w2')))
    


    MarcoFalke commented at 12:49 AM on December 13, 2017:

    femto-nit: missing space after assert, redundant round braces.

  4. fanquake added the label Tests on Dec 13, 2017
  5. in test/functional/conf_args.py:20 in 640d5c0d8f outdated
      14 | +        self.num_nodes = 1
      15 | +
      16 | +    def run_test(self):
      17 | +        self.stop_node(0)
      18 | +        # Remove the -datadir argument so it doesn't override the config file
      19 | +        self.nodes[0].args = [arg for arg in self.nodes[0].args if not arg.startswith("-datadir")]
    


    MarcoFalke commented at 7:19 PM on December 13, 2017:

    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.


    MarcoFalke commented at 7:42 PM on December 13, 2017:

    Hint: git grep 'def initialize_datadir'


    meshcollider commented at 11:11 PM on December 13, 2017:

    ~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

  6. meshcollider renamed this:
    Add configuration file/argument testing
    [WiP] Add configuration file/argument testing
    on Dec 14, 2017
  7. meshcollider renamed this:
    [WiP] Add configuration file/argument testing
    Add configuration file/argument testing
    on Dec 15, 2017
  8. in test/functional/conf_args.py:25 in 7dc6a4253e outdated
      20 | +
      21 | +        default_data_dir = os.path.join(self.options.tmpdir, 'node0')
      22 | +        new_data_dir = os.path.join(default_data_dir, 'newdatadir')
      23 | +        new_data_dir_2 = os.path.join(default_data_dir, 'newdatadir2')
      24 | +
      25 | +        # Check that using -datadir argument on non-existant directory fails
    


    ryanofsky commented at 1:50 PM on December 18, 2017:

    spelling existent

  9. in test/functional/conf_args.py:21 in 7dc6a4253e outdated
      16 | +    def run_test(self):
      17 | +        self.stop_node(0)
      18 | +        # Remove the -datadir argument so it doesn't override the config file
      19 | +        self.nodes[0].args = [arg for arg in self.nodes[0].args if not arg.startswith("-datadir")]
      20 | +
      21 | +        default_data_dir = os.path.join(self.options.tmpdir, 'node0')
    


    ryanofsky commented at 1:56 PM on December 18, 2017:

    Maybe call get_datadir_path(self.options.tmpdir, 0) to avoid hardcoding this.

  10. ryanofsky commented at 1:59 PM on December 18, 2017: member

    utACK 7dc6a4253ea1c101b6b0591e4c9a84b9015d5891

  11. Add configuration/argument testing be9a13c8a0
  12. meshcollider commented at 11:26 PM on December 19, 2017: contributor

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

  13. in test/functional/conf_args.py:27 in be9a13c8a0
      22 | +        default_data_dir = get_datadir_path(self.options.tmpdir, 0)
      23 | +        new_data_dir = os.path.join(default_data_dir, 'newdatadir')
      24 | +        new_data_dir_2 = os.path.join(default_data_dir, 'newdatadir2')
      25 | +
      26 | +        # Check that using -datadir argument on non-existent directory fails
      27 | +        self.nodes[0].datadir = new_data_dir
    


    promag commented at 2:48 AM on December 20, 2017:

    Remove?


    jnewbery commented at 9:30 PM on February 6, 2018:

    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.


    MarcoFalke commented at 9:37 PM on February 6, 2018:

    @jnewbery You propose to discard the "old" TestNode and create a fresh one whenever the datadir is changed?


    jnewbery commented at 6:22 PM on February 7, 2018:

    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.


    meshcollider commented at 9:15 PM on February 7, 2018:

    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?


    jnewbery commented at 6:40 PM on March 21, 2018:

    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.

  14. in test/functional/conf_args.py:44 in be9a13c8a0
      39 | +        self.stop_node(0)
      40 | +        assert os.path.isfile(os.path.join(new_data_dir, 'regtest', 'wallets', 'w1'))
      41 | +
      42 | +        # Ensure command line argument overrides datadir in conf
      43 | +        os.mkdir(new_data_dir_2)
      44 | +        self.nodes[0].datadir = new_data_dir_2
    


    promag commented at 2:48 AM on December 20, 2017:

    Remove?


    meshcollider commented at 3:01 AM on December 20, 2017:

    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


    promag commented at 7:46 AM on December 20, 2017:

    Maybe check if datadir is specified in extra_args in TestNode.start?

  15. promag commented at 2:52 AM on December 20, 2017: member

    utACK be9a13c.

  16. laanwj commented at 8:37 AM on December 20, 2017: member

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

  17. laanwj merged this on Dec 20, 2017
  18. laanwj closed this on Dec 20, 2017

  19. laanwj referenced this in commit cfd99ddc3c on Dec 20, 2017
  20. meshcollider deleted the branch on Dec 20, 2017
  21. MarcoFalke commented at 11:18 PM on December 20, 2017: member

    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-----
    
  22. PastaPastaPasta referenced this in commit bdf1e71125 on Feb 13, 2020
  23. PastaPastaPasta referenced this in commit d7dec0fbfb on Feb 27, 2020
  24. PastaPastaPasta referenced this in commit 262bac5213 on Feb 27, 2020
  25. PastaPastaPasta referenced this in commit df30971371 on Feb 27, 2020
  26. ckti referenced this in commit 36fc29566d on Mar 28, 2021
  27. gades referenced this in commit 98834cbae2 on Jun 30, 2021
  28. MarcoFalke locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-13 15:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me