Skip to content

Fix flaky tests: port in for loki source api tests and logs integration test#4875

Merged
kgeckhart merged 2 commits intomainfrom
kgeckhart/flaky-port-tests
Nov 18, 2025
Merged

Fix flaky tests: port in for loki source api tests and logs integration test#4875
kgeckhart merged 2 commits intomainfrom
kgeckhart/flaky-port-tests

Conversation

@kgeckhart
Copy link
Contributor

@kgeckhart kgeckhart commented Nov 18, 2025

PR Description

Fix issues from port's being in used when testing loki source api by using random ports assigned by the server unless absolutely necessary. Since there's only 1 place we absolutely need a non-random port the likelihood we hit port in use is significantly reduced. The free port function is a race condition, we ask for a free port and release it before the server can claim it making it an option for another test to find as a free port.

Before this change all it took was 5 iterations to get it to fail locally through,

go test ./internal/component/loki/source/api/... -run 'TestComponent_detectsWhenUpdateRequiresARestart' -count 5

and with the change count 500 caused no issues.

Pins the version we use for the Loki container in integration-tests so CI won't be testing with version of Loki we will not be using locally. We currently pin our other database dependencies as well.

PR Checklist

  • Tests updated

@kgeckhart kgeckhart requested a review from a team as a code owner November 18, 2025 18:20
@kgeckhart kgeckhart changed the title Fix port in use flakyness for loki source api tests Fix port in use flakyness for loki source api tests and logs integration test Nov 18, 2025
@kgeckhart kgeckhart changed the title Fix port in use flakyness for loki source api tests and logs integration test Fix flaky tests: port in for loki source api tests and logs integration test Nov 18, 2025
@kgeckhart kgeckhart merged commit 9ff4e6d into main Nov 18, 2025
41 of 42 checks passed
@kgeckhart kgeckhart deleted the kgeckhart/flaky-port-tests branch November 18, 2025 20:16
jharvey10 pushed a commit that referenced this pull request Nov 18, 2025
…on test (#4875)

* Fix port in use flakyness for loki source api tests

* Pin loki container version for integration tests
@jharvey10 jharvey10 mentioned this pull request Nov 18, 2025
jharvey10 added a commit that referenced this pull request Nov 19, 2025
* fix: no longer drop request if stream is dropped in loki.source.api (#4834)

* fix: add ForceShutdown that will cancel in-flight requests before
stopping server

* Split into multiple files and add LogsBatchReceiver

* don't drop request when relabel rules drops a specific stream

* fix: use loki.LogsBatchReceiver to ensure all entries in a request is sent down the
pipeline

* add changelog

* add checks for entries and use sync once to close channel

* update changelog for next rc

* Fix flaky tests: port in for loki source api tests and logs integration test (#4875)

* Fix port in use flakyness for loki source api tests

* Pin loki container version for integration tests

* Add a new mimir.alerts.kubernetes component (#3448)

* Add a new mimir.alerts.kubernetes component

* Sync Mimir periodically, test the case of a CRD deletion

* Add TODOs

* Longer test timeout

* Check if pods are running

* Apply suggestions from code review

Co-authored-by: Clayton Cornell <131809008+clayton-cornell@users.noreply.github.com>

* Fix metric doc

* Fix changelog

---------

Co-authored-by: Clayton Cornell <131809008+clayton-cornell@users.noreply.github.com>

* Remove experimental flag from stage.windowsevent (#4879)

---------

Co-authored-by: Karl Persson <23356117+kalleep@users.noreply.github.com>
Co-authored-by: Kyle Eckhart <kgeckhart@users.noreply.github.com>
Co-authored-by: Paulin Todev <paulin.todev@gmail.com>
Co-authored-by: Clayton Cornell <131809008+clayton-cornell@users.noreply.github.com>
dehaansa pushed a commit to madhub/alloy that referenced this pull request Dec 10, 2025
…on test (grafana#4875)

* Fix port in use flakyness for loki source api tests

* Pin loki container version for integration tests
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 18, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants