Tests: Attempt to fix flaky test in reloader on directories changes #4765
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Signed-off-by: Matej Gera matejgera@gmail.com
Changes
We've been seeing some increase in failures for
TestReloader_DirectoriesApply
recently (see e.g. this CI run). Although there were other fixes for the test (#3798), it looks like this is not directly related to the previously discovered issues.According to the output, the test seems to skip step
1
from among the steps required to be run to manipulate rule files, leading to incorrect number of watch events:After more investigation, I have established that this is due to a 'race' between the reloader and the goroutine executing the steps. On an occasion, the reloader can invoke the reload handler two times while the step executing goroutine did not have time to catch up with the reloader. This causes the step execution loop to skip ahead to get on the same number of reloads as the reloader and thus not executing the step in between. The suggestion in this PR is to have mechanism to check these skips and 'catch up' with the reloader if that happens.
Verification
Run a modified test locally with extra output confirming the skipped steps are executed, if such a skip occurs in the test run.