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: slow down CandidateFinder test to avoid clock race #304

Merged
merged 1 commit into from
Jun 22, 2023

Conversation

rvagg
Copy link
Member

@rvagg rvagg commented Jun 8, 2023

I'm attempting to deal with the flaky CandidateFinder test, which I can't replicate locally. I think the main problem here is that we tick the clock inside the test 1 minute per candidate, but the mock sleeps for 1 second per candidate.

The reasons this works most of the time is that the goroutine startup is fast enough to get started and get to the clock.Sleep before the timer gets through its ticks. The mock clock will do an actual 1ms sleep for each Add to let the goroutine scheduler catch up, so for most cases we get enough breathing room to get at least one clock.Add in after the clock.Sleep.

So there's two things going on in this PR:

  1. Change test's clock tick to 1s
  2. Add a channel into the mock that lets the test observe the incoming requests; for the async request it can wait until the request has come in before moving on to ticking the clock

@codecov-commenter
Copy link

codecov-commenter commented Jun 8, 2023

Codecov Report

Merging #304 (02fc686) into main (6fe2efe) will increase coverage by 0.49%.
The diff coverage is 60.86%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #304      +/-   ##
==========================================
+ Coverage   72.47%   72.96%   +0.49%     
==========================================
  Files          68       68              
  Lines        6242     6248       +6     
==========================================
+ Hits         4524     4559      +35     
+ Misses       1465     1447      -18     
+ Partials      253      242      -11     
Impacted Files Coverage Δ
pkg/internal/mockindexer/mockindexer.go 72.91% <60.86%> (-5.98%) ⬇️

... and 6 files with indirect coverage changes

@rvagg
Copy link
Member Author

rvagg commented Jun 8, 2023

:shakesfist: https://github.com/filecoin-project/lassie/actions/runs/5208640304/jobs/9397456670?pr=304

The second time I've attempted to fix this test but had the test fail when I've put up a PR

@rvagg rvagg force-pushed the rvagg/indexerlookup-slow-down-findertest branch from 4bc05c0 to 02fc686 Compare June 8, 2023 07:47
@rvagg
Copy link
Member Author

rvagg commented Jun 9, 2023

Combined with the timeout extension in #294 and I've rerun CI a bunch of times and have not seen the failure again.

Copy link
Collaborator

@hannahhoward hannahhoward left a comment

Choose a reason for hiding this comment

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

LGTMing for now

@hannahhoward hannahhoward merged commit 9329871 into main Jun 22, 2023
@hannahhoward hannahhoward deleted the rvagg/indexerlookup-slow-down-findertest branch June 22, 2023 02:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants