-
Notifications
You must be signed in to change notification settings - Fork 521
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
[BUG]: Flaky Test: testLoggingInterceptor_makeNetworkCall_succeeds #5430
Comments
I could be wrong, but is there actually a way to mark this test as flaky in code? Bazel does technically support a way by auto-rerunning flaky tests, but I think it'd be better just to fix the test, instead, since we don't want to encourage checking in flaky code (where we can avoid it). Currently running 100x runs to see how flaky the test is. |
With 100x runs, I saw 19 failures:
Edit: Also, here's the command run: bazel test --runs_per_test=100 //data:src/test/java/org/oppia/android/data/backends/gae/NetworkLoggingInterceptorTest Unfortunately, running the tests above in isolation doesn't seem to actually catch any flakes, so these flakes are seemingly caused by state interaction between the tests of the suite. Specific failures that we're seeing for each: testLoggingInterceptor_makeNetworkCall_succeeds:
testLoggingInterceptor_makeNetworkCallWithInvalidUrl_failsAndCompletes:
|
So the ultimate problem for both tests seems to be this line: val firstRequest = firstRequestsDeferred.getCompleted().single() This was caused indirectly by #5402 since it fixed the tests to properly verify what they're trying to verify. Note that #5402 also made similar changes to bazel test --runs_per_test=100 //utility/src/test/java/org/oppia/android/util/logging:ConsoleLoggerTest However, this is probably a false result since, per the previous comment, it seems that multiple tests need to cooperate in order to trigger the failure. |
I've added a bunch of See https://gist.github.com/BenHenning/473e76df316acdfc99c609c363db155f for the instrumentation used for these results. Here's the debug output when testLoggingInterceptor_makeNetworkCall_succeeds fails:
Here's the debug output when testLoggingInterceptor_makeNetworkCall_succeeds passes:
The diff is interesting: Specific takeaways:
I'm not certain the order difference matters here, and we're otherwise not getting interesting information on why the flow isn't completing. |
Ah, I think I figured it out. Per https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-mutable-shared-flow.html Adding another additional synchronization barrier seems to fix the problem by ensuring flow consumption happens before |
Describe the bug
Test fails frequently on Gradle:
Steps To Reproduce
Open a PR against develop to trigger a CI run
Expected Behavior
The test should always pass.
Screenshots/Videos
No response
What device/emulator are you using?
CI
Which Android version is your device/emulator running?
No response
Which version of the Oppia Android app are you using?
No response
Additional Context
Because of the frequency of this failure, we should consider annotating it with @flaky, should a fix not be straightforward.
The text was updated successfully, but these errors were encountered: