fix(outputs/graylog): fix failing test due to port already in use #10074
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.
Direct link: https://app.circleci.com/pipelines/github/influxdata/telegraf/7370/workflows/dd5cc7c4-9b38-4f91-9f6d-86040c4fca5a/jobs/127224/tests
The error message from the CI:
Description:
The output plugin graylog tests are failing due to trying to bind to a port already in use, because the previous test didn't fully unbind yet. I found this package: https://github.com/libp2p/go-reuseport that makes it easy to call a syscall
SO_REUSEPORT
so that the bind can be reused even if something else was already bound to it. Originally I was hoping to just usebytes.Buffer
instead to avoid having to start a UDP and TCP server in a test, but it doesn't cover the connection logic. This approach introduces the fewest changes, so decided this would be better.