Address flaky tests by updating episode manager coroutine handling for archiveAllFilesInList #1334
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.
Description
This is fixing some recent test flakiness we've seen in the
AutoArchiveTest
class due to the recent change that started launching a coroutine from theEpisodeManagerImpl::archiveAllInList
method (#1327).I've been wanting to convert more of our manager classes to use properly suspending functions instead of having regular functions that launch coroutines (which then call other regular functions that launch new coroutines, etc.). Making this kind of change will make help us avoid hard to reproduce/fix race conditions due to the order the coroutines run.
The recent test flakiness we had due to the
archiveAllInList
method change seemed like another example of how this is hurting us, so I'm taking this opportunity to do this as a bit of a small POC/first-step toward the changes I would like to make. In particular, this PR focuses on making thearchiveAllInList
method a proper suspended function and, conveniently enough, the tests don't seem to be flaky anymore (I'm scared that me saying that is basically guaranteeing that they will fail the next time CI runs 🤞 ).I intentionally limited the changes to the minimum ones necessary to make
archiveAllInList
a proper suspended function, which is why everywhere else I just changed the new suspend function calls to be called in arunBlocking {...}
block. If I were doing this as a broader refactor, I would remove those as well, but since we might want to merge this change to a release branch I didn't want to do that in this PR.I've got this currently targetng the
release/7.46
branch since that is where we have the test flakiness, but I think I'm probably leaning toward just merging this tomain
instead to minimize the risk of breakages on the release branch. In fact, I'm kind of thinking we should perhaps reverthttps://github.com/Automattic/pocket-casts-android/pull/1327
on therelease/7.46
branch, and merge that, along with these changes, tomain
. That way, if everything goes according to plan, neither branch will be flaky.Anyway, take a look, and let me know what you think both about this general approach (since I'm currently planning to do more of this next week), and about how we should approach the flakiness on
release/7.46
.Testing Instructions
Checklist
./gradlew spotlessApply
to automatically apply formatting/linting)modules/services/localization/src/main/res/values/strings.xml