test: expect that files may disappear from /proc/PID/fd/ #31614

pull vasild wants to merge 1 commits into bitcoin:master from vasild:expect_file_not_found_in_get_socket_inodes changing 1 files +6 −3
  1. vasild commented at 10:45 am on January 7, 2025: contributor

    get_socket_inodes() calls os.listdir() and then iterates on the results using os.readlink(). However a file may disappear from the directory after os.listdir() and before os.readlink() resulting in a FileNotFoundError exception.

    It is expected that this may happen for bitcoind which is running and could open or close files or sockets at any time. Thus ignore the FileNotFoundError exception.

  2. test: expect that files may disappear from /proc/PID/fd/
    `get_socket_inodes()` calls `os.listdir()` and then iterates on the
    results using `os.readlink()`. However a file may disappear from the
    directory after `os.listdir()` and before `os.readlink()` resulting in a
    `FileNotFoundError` exception.
    
    It is expected that this may happen for `bitcoind` which is running and
    could open or close files or sockets at any time. Thus ignore the
    `FileNotFoundError` exception.
    b2e9fdc00f
  3. DrahtBot commented at 10:45 am on January 7, 2025: contributor

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

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/31614.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK theuni
    Concept ACK luke-jr

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

  4. DrahtBot added the label Tests on Jan 7, 2025
  5. vasild commented at 10:47 am on January 7, 2025: contributor

    A failure like this observed in #31349 in CI job https://github.com/bitcoin/bitcoin/actions/runs/12633511389/job/35241370470?pr=31349:

     02025-01-07T09:20:07.629000Z TestFramework (INFO): Bind test for ['[::1]']
     12025-01-07T09:20:08.155000Z TestFramework (ERROR): Unexpected exception caught during testing
     2Traceback (most recent call last):
     3  File "/home/runner/work/_temp/test/functional/test_framework/test_framework.py", line 135, in main
     4    self.run_test()
     5  File "/home/runner/work/_temp/ci/scratch/build-x86_64-pc-linux-gnu/test/functional/rpc_bind.py", line 99, in run_test
     6    self._run_loopback_tests()
     7  File "/home/runner/work/_temp/ci/scratch/build-x86_64-pc-linux-gnu/test/functional/rpc_bind.py", line 126, in _run_loopback_tests
     8    self.run_bind_test(['[::1]'], '[::1]', ['[::1]'],
     9  File "/home/runner/work/_temp/ci/scratch/build-x86_64-pc-linux-gnu/test/functional/rpc_bind.py", line 45, in run_bind_test
    10    assert_equal(set(get_bind_addrs(pid)), set(expected))
    11                     ^^^^^^^^^^^^^^^^^^^
    12  File "/home/runner/work/_temp/test/functional/test_framework/netutil.py", line 84, in get_bind_addrs
    13    inodes = get_socket_inodes(pid)
    14             ^^^^^^^^^^^^^^^^^^^^^^
    15  File "/home/runner/work/_temp/test/functional/test_framework/netutil.py", line 40, in get_socket_inodes
    16    target = os.readlink(os.path.join(base, item))
    17             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    18FileNotFoundError: [Errno 2] No such file or directory: '/proc/18148/fd/19'
    
  6. luke-jr approved
  7. luke-jr commented at 4:20 am on January 8, 2025: member
    crACK
  8. theuni approved
  9. theuni commented at 4:40 pm on January 8, 2025: member

    utACK b2e9fdc00f5c40c241a37739f7b73b74c2181e39

    I looked around for a way to iterate on a cached list using os.scandir, but one doesn’t seems to exist. So this makes sense to me.

  10. DrahtBot requested review from luke-jr on Jan 8, 2025

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-21 03:12 UTC

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