Run feature_bind_port_(discover|externalip).py in CI#33362
Run feature_bind_port_(discover|externalip).py in CI#33362vasild wants to merge 4 commits intobitcoin:masterfrom
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code Coverage & BenchmarksFor details see: https://corecheck.dev/bitcoin/bitcoin/pulls/33362. ReviewsSee the guideline for information on the review process. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
6917740 to
f047fce
Compare
|
|
f047fce to
9b30b0b
Compare
|
|
9b30b0b to
e245da3
Compare
|
|
| ).stdout.strip() | ||
| os.environ["CI_CONTAINER_ID"] = container_id | ||
|
|
||
| run(["docker", "network", "connect", "--ip=1.1.1.5", "ci-ip4net", container_id]) |
There was a problem hiding this comment.
The container has been attached to both the default bridge network and ci-ip4net, hence two
IPv4 addresses. Do you think getifaddrs() may return the bridge IP first, and cause Discover() to find the wrong address?
If thats the case then I think it might be worth it to disconnect from bridge after connecting to ci-ip4net.
There was a problem hiding this comment.
Discover() finds all addresses, not just the first one?
| CI_CCACHE_MOUNT = f"type=bind,src={os.environ['CCACHE_DIR']},dst={os.environ['CCACHE_DIR']}" | ||
|
|
||
| run(["docker", "network", "create", "--ipv6", "--subnet", "1111:1111::/112", "ci-ip6net"], check=False) | ||
| run(["docker", "network", "create", "--subnet", "1.1.1.0/24", "ci-ip4net"], check=False) |
There was a problem hiding this comment.
Would it make sense to use RFC-5737 here? (I think they are reserved for documentation and testing)
| try: | ||
| self.start_nodes() | ||
| except FailedToStartError as e: | ||
| for node in self.nodes: |
There was a problem hiding this comment.
This error/cleanup code is duplicated in both files (with the exception of printing 1 or 2 addresses), would it be worth extracting this into a helper in test_node.py or somewhere?
There was a problem hiding this comment.
Maybe, do you want me to take a short at that?
There was a problem hiding this comment.
Using rg -C 2 "self.start_nodes()" . it does not seem like any other tests do this (surround with try/except) so I am wondering is this cleanup even necessary?
In case it is, is it only for this test or for all tests? In case you can't argue why it is necessary this should be removed in both files, in case it is only for these tests adding a helper is not worth it imo. in case its relevant for all tests this should be a separate PR (but you can leave the duplicated logic in this PR)
…dd comprehensive test coverage test: use tor_port to prevent bind conflicts test: Update feature_bind_port_discover.py instructions Replace deprecated ifconfig with modern ip commands and updated instructions for non-loopback interfaces.
… skip condition Instead of requiring a run with an explicit `--ihave1111and2222`, detect whether the routable addresses are set up and if not, then skip the test. To detect whether the addresses are set use `bitcoind` - start it and ask it to bind on them and see if it will error with "Unable to bind". Since this is what the tests do anyway, just start the nodes and see if an exception will be raised like `FailedToStartError` / "Unable to bind". This makes it possible for the CI to run `feature_bind_port_discover.py` and `feature_bind_port_externalip.py` by just setting up the addresses, without having to explicitly provide `--ihave1111and2222`.
Also explicitly specify which addresses from the docker network to assign to the VM. With `1.1.1.5` and `1111:1111::5` set on the machine, the tests `feature_bind_port_discover.py` and `feature_bind_port_externalip.py` will run.
e245da3 to
70558c6
Compare
|
|
| for node in self.nodes: | ||
| node.has_explicit_bind = True |
There was a problem hiding this comment.
In case this PR is intended to build on top of #32757 you can add a commit that removes this as this is a workaround that is required before that PR.
See: #31293 (comment)
So, if that is fixed, then the above fix to the test will not be necessary.
There was a problem hiding this comment.
Removing it also indirectly tests that the discover fix works and makes this test better.
|
Moved to draft, given this builds on #32757, and review should go there. |
This PR includes #32757 (first two commits here).
Then, on top of that:
feature_bind_port_discover.pyandfeature_bind_port_externalip.pyrequire a routable address on the machine to run. Since that was not predictably available on CI, those tests required a manual setting up of IP addresses (e.g. usingifconfig) and then running the tests with a command line option telling them that the addresses are set up. The tests were not run in CI and got rot.Change that to auto-detect, from the tests, whether the needed IP addresses are present and if yes, run the test, otherwise skip it. Also change the CI to configure the needed addresses when running the functional tests. This way the tests will be run regularly on CI.
Fixes: #31293
Fixes: #31336