Skip to content
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

test(promtail): Fix flaky test with promtail bind port. #6859

Merged
merged 2 commits into from
Aug 10, 2022

Commits on Aug 9, 2022

  1. 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>
    kavirajk committed Aug 9, 2022
    Configuration menu
    Copy the full SHA
    4a031c8 View commit details
    Browse the repository at this point in the history
  2. go mod tidy

    Signed-off-by: Kaviraj <kavirajkanagaraj@gmail.com>
    kavirajk committed Aug 9, 2022
    Configuration menu
    Copy the full SHA
    286a31d View commit details
    Browse the repository at this point in the history