-
Notifications
You must be signed in to change notification settings - Fork 38.7k
test: use higher value and per-platform assert in cnetaddr link-local test #21690
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The intermittently failing bitcoin/src/test/net_tests.cpp Lines 310 to 312 in 9712f75
I don't understand why we test if |
|
My understanding when working on this was that Apple might be going in its own direction with this starting with macOS 10.14 but it still seemed worthwhile to test our code on platforms like Linux and Windows where we can. |
|
(Without the fallback, only the macOS 10.14 CI was failing. So coverage on the other CIs seemed good to have.) |
But the test is not conditional on platform, so AFAICT we're testing that bitcoin/src/test/net_tests.cpp Lines 310 to 312 in 9712f75
In other words: we're effectively not testing anything meaningful in a test that is intermittently failing, no? :) If so, why not simply remove it? :) |
|
If you test only the fallback, I found that the change fails on all CIs except the macOS 10.14 one: - BOOST_CHECK(addr_str == scoped_addr || addr_str == "fe80:0:0:0:0:0:0:1");
+ BOOST_CHECK(addr_str == "fe80:0:0:0:0:0:0:1");$ src/test/test_bitcoin -t net_tests *** 1 failure is detected in the test module "Bitcoin Core Test Suite" |
|
Does this actually fix the issue or make it only less likely? |
|
As far as I know, the issue began appearing in the CI only this week, so it may be from some recent change in the CI setup, as the tested value of 32 wasn't very high. The CI is green here, so re-pushing now with a very high value (4096). If that causes a failure down the line, I guess we could drop the coverage as suggested above. |
03c7b16 to
edb6ac7
Compare
|
I didn't get if you agree with my statement that the intermittently failing And if so, is there any point in keeping it around? :) FWIW, patch against current diff --git a/src/test/net_tests.cpp b/src/test/net_tests.cpp
index 8eab26f3d..e7c3475ef 100644
--- a/src/test/net_tests.cpp
+++ b/src/test/net_tests.cpp
@@ -308,8 +308,9 @@ BOOST_AUTO_TEST_CASE(cnetaddr_basic)
BOOST_REQUIRE(addr.IsIPv6());
BOOST_CHECK(!addr.IsBindAny());
const std::string addr_str{addr.ToString()};
- BOOST_CHECK(addr_str == scoped_addr || addr_str == "fe80:0:0:0:0:0:0:1");
- // The fallback case "fe80:0:0:0:0:0:0:1" is needed for macOS 10.14/10.15 and (probably) later.
+ const bool to_string_does_contain_zone_id = addr_str == scoped_addr;
+ const bool to_string_does_not_contain_zone_id = addr_str == "fe80:0:0:0:0:0:0:1";
+ BOOST_CHECK(to_string_does_contain_zone_id || to_string_does_not_contain_zone_id);
// Test that the delimiter "%" and default zone id of 0 can be omitted for the default scope.
BOOST_REQUIRE(LookupHost(link_local + "%0", addr, false));
BOOST_REQUIRE(addr.IsValid()); |
|
@practicalswift It looks like I should document the test better to communicate the context and information. |
Why can't that be done as part of this change? |
|
Ok. The CI has been green, and #21696 showed that macOS remains the only CI that fails the Let's try (a) improving the documentation and (b) testing Edit: will update to |
34b5790 to
0be8e8c
Compare
|
Great--the per-platform scoped address test is green along with the previous two CI runs. Pushing an updated version with |
0be8e8c to
9005fb5
Compare
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsNo conflicts as of last run. |
|
Needs rebase after #21689 (comment) |
I think it is better to improve the test and contextual information it provides and I spent time in a way that I thought was constructive and helpful re-verifying and working to do that. Unfortunately, it's an order of magnitude more work to refute statements like "not very meaningful" in the #21689 PR title and the comment above, than it is to say them and just erase coverage and (I think) valuable context. |
9005fb5 to
6ab76c0
Compare
|
Rebased, added 6b0e879 for context since this change is not adding a test but hopefully improving it. |
src/test/net_tests.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reference that 4096 is guaranteed to be unused or is this something that depends on the operating system and the programs currently running?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question. From what I understand, the scope ids / zone indices depend on the number of local network interfaces when there are multiple on a single link-local address. Whereas many machines may have the first 8 or 16 decimal integer scope ids in use, the previous test value of 32 seems to be on the high end of the range. I'm not aware of one that is guaranteed to be free, but a value in the thousands (or tens of thousands) might be reasonably worth trying.
Resources:
|
@practicalswift does this now address your feedback? |
The I think the issue @MarcoFalke raised about the test outcome being dependent on the user's local configuration remains unfortunately. |
| const std::string addr_str{addr.ToString()}; | ||
| #ifdef MAC_OSX | ||
| // Expect macOS to return the address in this format, without zone ids. | ||
| BOOST_CHECK_EQUAL(addr_str, "fe80:0:0:0:0:0:0:1"); | ||
| #else | ||
| // Expect normal scoped address functionality on the other platforms. | ||
| BOOST_CHECK_EQUAL(addr_str, scoped_addr); | ||
| #endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| const std::string addr_str{addr.ToString()}; | |
| #ifdef MAC_OSX | |
| // Expect macOS to return the address in this format, without zone ids. | |
| BOOST_CHECK_EQUAL(addr_str, "fe80:0:0:0:0:0:0:1"); | |
| #else | |
| // Expect normal scoped address functionality on the other platforms. | |
| BOOST_CHECK_EQUAL(addr_str, scoped_addr); | |
| #endif | |
| BOOST_CHECK(addr.ToString().starts_with("fe80:0:0:0:0:0:0:1")); |
Maybe just check the prefix if the suffix is unstable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The suffix is stable but if the first few scope ids are in use locally then they will be another string and not share the same prefix.
|
This test and informational context involved some trial and error and time to obtain, and I think it's a shame to throw out the coverage and information, particularly as it seems to be not well-known info and I tried to provide context about that. However, it seems like I'm swimming upstream to provide this coverage and information. |
|
The scoped id/zone indices functionality appears to have been dropped entirely by #21756. |
|
The |
This patch improves the cnetaddr link-local test in
net_testsby making it platform-specific and by using a higher scoped id value to alleviate recent CI issues.Closes #21682.