test: add test for specifying custom pidfile via -pid #30724

pull theStack wants to merge 2 commits into bitcoin:master from theStack:202408-test-add_custom_pidfile_test changing 3 files +39 −7
  1. theStack commented at 12:44 pm on August 27, 2024: contributor
    This small PR adds test coverage for the -pid command line option, which allows to overrule the pid filename (bitcoind.pid by default). One can specify either a relative path (within the datadir) or an absolute one; the latter is tested using self.options.tmpdir. Note that the functional test file feature_init.py so far only contained a stress test; with this new sub-test added, both the description and the test name are adapted to be more generic.
  2. DrahtBot commented at 12:45 pm on August 27, 2024: contributor

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

    Code Coverage

    For detailed information about the code coverage, see the test coverage report.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK tdb3, ryanofsky, naiyoma, achow101

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

  3. DrahtBot added the label Tests on Aug 27, 2024
  4. in test/functional/feature_init.py:16 in db3edefce4 outdated
    11@@ -12,7 +12,11 @@
    12 from test_framework.util import assert_equal
    13 
    14 
    15-class InitStressTest(BitcoinTestFramework):
    16+BITCOIN_PID_FILENAME_DEFAULT = "bitcoind.pid"
    17+BITCOIN_PID_FILENAME_CUSTOM = "my_fancy_bitcoin_pid_file.foobar"
    


    furszy commented at 1:35 pm on August 27, 2024:
    nit: why not declaring this custom param within the test function?

    theStack commented at 10:43 am on September 23, 2024:
    Good point, done.
  5. tdb3 commented at 12:07 pm on August 28, 2024: contributor

    Concept ACK Good addition. CR and ran tests locally.

    "bitcoind.pid" is also mentioned in feature_filelock.py. Could add a commit that deduplicates this.

    Created an example commit here: https://github.com/tdb3/bitcoin/commit/b622390b33cf3813b4f80d13377b248d6e898a4f

    Thought about maybe making something like a

    0[@property](/bitcoin-bitcoin/contributor/property/)
    1def pid_file_path(self) -> Path:
    2    return self.chain_path / "bitcoind.pid"
    

    but with bitcoind -pid=someotherfile being an option, might be confusing/unexpected to have pid_file_path mismatch the pid file actually used by the node.

  6. naiyoma commented at 7:08 pm on September 7, 2024: contributor

    Concept ACK +1 on the suggestion above to move BITCOIN_PID_FILENAME_DEFAULT and import it in both files.

    This is out of scope for this PR, so feel free to ignore. it would be good to add an edge case to test starting a node when there’s already a pre-existing PID file.

  7. refactor: introduce default pid file name constant in tests b832ffe044
  8. test: add test for specifying custom pidfile via `-pid` 04e4d52420
  9. theStack force-pushed on Sep 23, 2024
  10. theStack commented at 10:47 am on September 23, 2024: contributor

    @tdb3:

    "bitcoind.pid" is also mentioned in feature_filelock.py. Could add a commit that deduplicates this.

    Created an example commit here: tdb3@b622390

    Thanks! I’ve cherry-picked your commit, but reordered it to appear before the test introduction commit and changed the commit subject accordingly (introduce constant, instead of deduplicating). Let me know if that’s okay for you. @naiyoma:

    This is out of scope for this PR, so feel free to ignore. it would be good to add an edge case to test starting a node when there’s already a pre-existing PID file.

    Good idea. I decided to leave that for a follow-up, happy to review if someone opens a PR.

  11. tdb3 commented at 4:14 pm on September 23, 2024: contributor

    Thanks! I’ve cherry-picked your commit, but reordered it to appear before the test introduction commit and changed the commit subject accordingly (introduce constant, instead of deduplicating). Let me know if that’s okay for you.

    Looks great, thanks.

  12. tdb3 approved
  13. tdb3 commented at 4:15 pm on September 23, 2024: contributor
    ACK 04e4d52420a0e6bf40d4bd6fe1f31f66db9eab0a
  14. ryanofsky approved
  15. ryanofsky commented at 8:01 pm on September 25, 2024: contributor
    Code review ACK 04e4d52420a0e6bf40d4bd6fe1f31f66db9eab0a
  16. achow101 commented at 9:09 pm on October 23, 2024: member
    ACK 04e4d52420a0e6bf40d4bd6fe1f31f66db9eab0a
  17. achow101 merged this on Oct 23, 2024
  18. achow101 closed this on Oct 23, 2024

  19. theStack deleted the branch on Oct 23, 2024

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: 2025-01-15 03:12 UTC

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