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

Do not Errorf during file watcher verification test loop. #3938

Merged

Conversation

timoreimann
Copy link
Contributor

@timoreimann timoreimann commented Sep 27, 2018

What does this PR do?

Change the logic in file_test.go's TestProvideWithWatch verification loop to t.Error / t.Fail only if the timeout hits (that is, we fail to collect the desired configuration updates in time).

Motivation

The loop in TestProvideWithWatch is meant to be executed multiple times until either all configuration elements are found or the timeout expires. By calling assert.* (such as assert.Len), however, an assertion failure in a non-terminal loop run will cause t.Error to be invoked, thereby marking the whole test as failed even though subsequent loop runs could still yield a positive test result overall.

Additional Notes

This test has failed repeatedly (albeit not consistently) in our (HolidayCheck's) local CI. I couldn't exactly pinpoint the reason, but I suspect different concurrency behavior and/or CI machine specs. Still, the logic as it is implemented now seems incorrect for the reasons I outlined above (t.Error should only be called on terminal test errors), and thus the implementation change should be an improvement IMHO.

@dtomcej
Copy link
Contributor

dtomcej commented Sep 27, 2018

@timoreimann Can you rebase on 1.7? Better tests in stable is a good thing ;)

@timoreimann timoreimann force-pushed the dont-t-error-in-file-test-watcher-loop branch from 946ec7e to 485aeed Compare September 27, 2018 22:00
@timoreimann timoreimann changed the base branch from master to v1.7 September 27, 2018 22:00
@timoreimann
Copy link
Contributor Author

@dtomcej done!

@ldez ldez added kind/bug/fix a bug fix and removed bot/no-merge labels Sep 27, 2018
Copy link
Member

@ldez ldez left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@dtomcej dtomcej left a comment

Choose a reason for hiding this comment

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

LGTM
:shipit:

Copy link
Contributor

@nmengin nmengin left a comment

Choose a reason for hiding this comment

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

LGTM

The loop in TestProvideWithWatch is meant to be executed multiple times
until either all configuration elements are found or the timeout
expires. By calling assert.*, however, an assertion failure in a
non-terminal loop run will cause t.Error to be invoked, thereby
marking the whole test as failed even though subsequent loop runs could
still yield a positive test result overall.

We change the logic to t.Error only if the timeout hits (that is, we
fail to collect the desired configuration updates in time).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants