-
Notifications
You must be signed in to change notification settings - Fork 132
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
[common] Introduce testlogger as a workaround of poor lifecycle #1398
[common] Introduce testlogger as a workaround of poor lifecycle #1398
Conversation
55eb3d6
to
9ec9816
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files
Continue to review full report in Codecov by Sentry.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM though I don't see the reason for the added mutex.
If something seemed to be flaky without it, I can pretty much guarantee that it didn't fix it, so there's something else that needs fixing instead.
From some more reading and thinking and IRL chat: I'm pretty sure the mutex doesn't change anything, but it's not risky or anything. So yeah, still approved, merge any time. Now that there's a counter-example showing this logger isn't reliable, I think it's pretty clear it's just that the atomics aren't ensuring "fallback logger is used after test completes". it currently allows: pausing after checking the atomic is not-completed -> test completes -> resuming and using the T logger. But I can make a PR for that if you want. The mutex here shouldn't make anything worse, and a mutex will be needed to fix the "atomics are not enough" issue anyway. |
What changed?
I've copied over the workaround racy logs in tests from the backend.
We have the same issues with the client who cannot establish a clear stop for internal processes at the first stop. This is not an issue for real workflow usage but can lead to test failures due to racy log messages after the test ends.
Sidenote:
Changed the approach from using atomic to RWMutex, since this situation requires semantic:
Why?
Improving test stability
How did you test it?
Run unit tests a few hundred times.
This is a bit tricky, since the TestLoggerShouldNotFailIfLoggedLate requires rerun, but I've done
for i in {1..100}; do go test . --count 1; done
with race and without.Potential risks
Some tests could be flaky, though they were failing before the fix.