[internal/common/testutil] Add support for testing listening udp ports #12888
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.
Description:
Refactored the internal testutil functions for available port discovery used in component service mocking to be able to support
udp
ports similarly to existingtcp
port functionality. Once this is merged, this should provide a path forward to fixing racy tests for all UDP listening components (ex: statsd and carbon receivers), where the tests are currently marked to be skipped.Summary of changes:
Extended the internal testutil functions to make it possible to mock listening UDP ports for components that make use of udp listening servers (ex: statsd receiver).
The existing
findAvailableAddress
function was refactored to support bothnet.Listen
andnet.ListenPacket
supported network types.net.ListenPacket
is needed forudp
available port discovery.A new testutil function
GetAvailableLocalNetworkAddress
was added that exposes the network string argument needed fornet.Listen
andnet.ListenPacket
used infindAvailableAddress
.The existing
GetAvailableLocalAddress
function is refactored as a wrapper aroundGetAvailableLocalNetworkAddress
to provide backwards compatible behavior for all existing functional mock tcp listening test.Ref Issue:
#10916
Link to tracking Issue:
Testing:
Added new test for finding free UDP listening port.
Documentation:
No additional documentation added.