-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(promtail): Fix flaky test with promtail bind port. (#6859)
* test(promtail): Fix flaky test with promtail bind port. You cannot run promtail tests if there is already running promtail in your local. e.g: ``` $ go test -run TestPromtail ./clients/pkg/promtail/ ``` It gives you error ``` --- FAIL: TestPromtail (0.02s) promtail_test.go:112: error creating promtail listen tcp 127.0.0.1:9080: bind: address already in use FAIL FAIL github.com/grafana/loki/clients/pkg/promtail 0.043s ``` Cause for the error is, test uses static default port (the same we use for promtail normally) in tests. This is not **too** annonying if seen in isolation. But mainly annoying in two cases particularly 1. Hard to run tests parallely in general with these kind of static ports 2. These are causing some real problems in some integeration tests on GEL which starts docker-compose to run some test suites and even stopping containers won't release ports soon enough making CI fail randomly. This PR takes advantage of Go idiom of passing `port=0` to http (and also grpc) servers enforce Go's `net` package to bind some unused random ports. Making each test run choose random ports enabling easy running theses tests in parallel. NOTE: This PR also contains upgrade in `common/server` package that made this fix possible. weaveworks/common#249 Signed-off-by: Kaviraj <kavirajkanagaraj@gmail.com> * go mod tidy Signed-off-by: Kaviraj <kavirajkanagaraj@gmail.com>
- Loading branch information
Showing
7 changed files
with
36 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters