grafana / mimir

Grafana Mimir provides horizontally scalable, highly available, multi-tenant, long-term storage for Prometheus.
https://grafana.com/oss/mimir/
GNU Affero General Public License v3.0
4.17k stars 535 forks source link

ingest: add long polling to TestConcurrentFetchers #9971

Closed dimitarvdimitrov closed 4 days ago

dimitarvdimitrov commented 4 days ago

What this PR does

Some of the tests assume that we'd fetch all produced records in one go. The Kafka protocol doesn't guarantee that and sometimes kfake also returns less than that. This means that sometimes the tests would finish early before we've fetched all records.

This PR introduced logPollFetches which loops over fetchers.PollFetches multiple times until a timeout or until we fetch the expected number of records.

I also changed all places which had this assumption and all places which already did some form of log polling.

2s timeout

I set the timeout to 2s because of the MinBytesMaxWait of 1s in tests (code):

Another solution to waiting for 2s is to make the merging of results in start() for example.

Which issue(s) this PR fixes or relates to

Fixes https://github.com/grafana/mimir/issues/9970

Checklist