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

Fix #4775: SpotlightFragmentTest is very flaky #4780

Merged
merged 2 commits into from
Dec 9, 2022

Conversation

JishnuGoyal
Copy link
Contributor

@JishnuGoyal JishnuGoyal commented Dec 5, 2022

Explanation

fixes #4775

This PR was created to investigate why 2 tests mentioned here were so flaky and fix these issues. From what I found, it seems that the problem occurs in sequencing while adding spotlight targets:

checkNotNull(activity.getSpotlightFragment()).requestSpotlight(firstSpotlightTarget)
checkNotNull(activity.getSpotlightFragment()).requestSpotlight(secondSpotlightTarget)

The addition of targets probably lead to a race condition? I haven't really gotten as deep as to debug it though, but I assumed my speculation was correct, and an easy fix was to add testCoroutineDispatchers.runCurrent() between these two lines.

Essential Checklist

  • The PR title and explanation each start with "Fix #bugnum: " (If this PR fixes part of an issue, prefix the title with "Fix part of #bugnum: ...".)
  • Any changes to scripts/assets files have their rationale included in the PR explanation.
  • The PR follows the style guide.
  • The PR does not contain any unnecessary code changes from Android Studio (reference).
  • The PR is made from a branch that's not called "develop" and is up-to-date with "develop".
  • The PR is assigned to the appropriate reviewers (reference).

@BenHenning
Copy link
Member

Thanks @JishnuGoyal. This seems reasonable. Have you run the tests ~100 times to verify they are no longer flaky? This is usually really straightforward with Bazel by running the whole test suite with the runs_per_test flag set.

@BenHenning BenHenning assigned JishnuGoyal and unassigned BenHenning Dec 7, 2022
@JishnuGoyal
Copy link
Contributor Author

Hi @BenHenning, I ran the tests for a 100 times and it seems like they all passed (PTAL at the result):

image

@JishnuGoyal JishnuGoyal assigned BenHenning and unassigned JishnuGoyal Dec 7, 2022
Copy link
Member

@BenHenning BenHenning left a comment

Choose a reason for hiding this comment

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

Thanks @JishnuGoyal! This LGTM.

@BenHenning BenHenning merged commit 3928c18 into oppia:develop Dec 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SpotlightFragmentTest is very flaky
3 participants