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

fix a flaky test in boltdb shipper #2550

Merged

Conversation

sandeepsukhani
Copy link
Contributor

What this PR does / why we need it:
The test TestTable_ImmutableUploads was flaky and was failing based on when tests are running.
This PR fixes the tests by making the time calculation for oldest active shard time uniform between the actual code and the test by moving it to a function.

Checklist

  • Tests updated

@codecov-commenter
Copy link

Codecov Report

Merging #2550 into master will decrease coverage by 0.09%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2550      +/-   ##
==========================================
- Coverage   63.46%   63.37%   -0.10%     
==========================================
  Files         166      166              
  Lines       14582    14584       +2     
==========================================
- Hits         9254     9242      -12     
- Misses       4586     4601      +15     
+ Partials      742      741       -1     
Impacted Files Coverage Δ
pkg/storage/stores/shipper/uploads/table.go 71.09% <100.00%> (+0.33%) ⬆️
pkg/promtail/positions/positions.go 46.49% <0.00%> (-13.16%) ⬇️
pkg/promtail/targets/file/filetarget.go 66.85% <0.00%> (+0.57%) ⬆️

@@ -379,3 +377,10 @@ func loadBoltDBsFromDir(dir string) (map[string]*bbolt.DB, error) {

return dbs, nil
}

// getOldestActiveShardTime returns the time of oldest active shard with a buffer of 1 minute.
func getOldestActiveShardTime() time.Time {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Admittedly I'm not that familiar with this code, but I'm having a bit of difficulty following. Wouldn't it make more sense as func getOldestActiveShardTime(from time.Time) time.Time, which could then be passed time.Now() as an argument?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We actually always have 1 active shard at a time but we consider last active shard as still active if it was active a minute back. This is to avoid any race conditions. I don't mind changing the function to accept a time.Time as a parameter but it would always be getting time.Now as input. Do you want me to change it?

Copy link
Member

@owen-d owen-d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries. I think I get this now.

@sandeepsukhani sandeepsukhani merged commit dab393a into grafana:master Aug 25, 2020
cyriltovena pushed a commit to cyriltovena/loki that referenced this pull request Jun 11, 2021
* add Redis cache flags used by redigo: idle-timeout, wait, max-conn-lifetime

Signed-off-by: Kyeongwon Seo <ruddnjs1230@gmail.com>

* update CHANGELOG.md

Signed-off-by: Kyeongwon Seo <ruddnjs1230@gmail.com>

* apply check-doc comments

Signed-off-by: Kyeongwon Seo <ruddnjs1230@gmail.com>

* remove white-noise

Signed-off-by: Kyeongwon Seo <ruddnjs1230@gmail.com>

* rename the Redis flag: wait -> wait-on-pool-exhaustion

Signed-off-by: Kyeongwon Seo <ruddnjs1230@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants