p2p: fix flaky test TestServerPortMapping #2108
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The test specifies
ListenAddr: ":0"
, which means a random ephemeral port will be chosen for the TCP listener by the OS. Additionally, since noDiscAddr
was specified, the same port that is chosen automatically by the OS will also be used for the UDP listener in the discovery UDP setup. This sometimes leads to test failures if the TCP listener picks a free TCP port that is already taken for UDP. By specifyingDiscAddr: ":0"
, the UDP port will be chosen independently from the TCP port, fixing the random failure.Verified using
The issue described above can technically lead to sporadic failures on systems that specify a listen address via the
--port
flag of 0 while not setting--discovery.port
. Since the default is using port30303
and using a random ephemeral port is likely not used much to begin with, not addressing the root cause might be acceptable.