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 test flakiness by warming up molecule tests #1226

Merged
merged 1 commit into from
Sep 6, 2023

Conversation

jonnyandrew
Copy link
Contributor

@jonnyandrew jonnyandrew commented Sep 5, 2023

Type of change

  • Feature
  • Bugfix
  • Technical
  • Other :

Content

Reduce test flakiness by warming up molecule tests. Add a test rule that pre-runs a no-op molecule test and apply it to any presenter tests that use molecule.

Motivation and context

Through profiling, I found that the first test of every test class takes a significant time to run. It turns out that molecule takes a significant amount of time to initialise when running in the first test of any given test class. This can create flakiness as tests will randomly exceed the default timeout of runTest (10 seconds).

To remove this source of flakiness, this solution ensures that the first call to initialise moleculeFlow occurs in a way that isn't impacted by the short default timeout.

image

Related issues:

Screenshots / GIFs

N/A

Tests

N/A

Tested devices

  • Physical
  • Emulator
  • OS version(s):

Checklist

@github-actions
Copy link
Contributor

github-actions bot commented Sep 5, 2023

📱 Scan the QR code below to install the build (arm64 only) for this PR.
QR code
If you can't scan the QR code you can install the build via this link: https://i.diawi.com/yhhYkL

@codecov
Copy link

codecov bot commented Sep 5, 2023

Codecov Report

Patch and project coverage have no change.

Comparison is base (7f8e546) 57.59% compared to head (07a2fd0) 57.59%.
Report is 1 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #1226   +/-   ##
========================================
  Coverage    57.59%   57.59%           
========================================
  Files         1067     1067           
  Lines        27700    27700           
  Branches      5716     5716           
========================================
  Hits         15955    15955           
  Misses        9259     9259           
  Partials      2486     2486           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jonnyandrew jonnyandrew marked this pull request as ready for review September 6, 2023 09:10
@jonnyandrew jonnyandrew requested a review from a team as a code owner September 6, 2023 09:10
@jonnyandrew jonnyandrew requested review from bmarty and removed request for a team September 6, 2023 09:10
@sonarcloud
Copy link

sonarcloud bot commented Sep 6, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

Copy link
Contributor

@jmartinesp jmartinesp left a comment

Choose a reason for hiding this comment

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

LGTM, it's great that it doesn't affect CI times either!

Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

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

@jonnyandrew jonnyandrew merged commit 9e5b462 into develop Sep 6, 2023
15 of 18 checks passed
@jonnyandrew jonnyandrew deleted the jonny/warmup-tests branch September 6, 2023 10:08
@julioromano
Copy link
Contributor

Isn't this actually running the warm up before every test of the test class?
It seems from the wording of the PR that it'd be enough to run the warmup once for all the tests of a given test class, did I get it right?
If this is the case then would it be worth using @ClassRule instead of @Rule ?

@julioromano
Copy link
Contributor

julioromano commented Sep 12, 2023

On a side note, sine it's been repeated lots of times:

    @Rule
    @JvmField
    val warmUpRule = WarmUpRule()

Could be shortened as:

    @get:Rule
    val warmUpRule = WarmUpRule()

@jonnyandrew
Copy link
Contributor Author

Yes it should work as a class rule although I haven't tested this. Once warmed up the rule adds negligible overhead but perhaps we could still incrementally update these?

@julioromano
Copy link
Contributor

Yes it should work as a class rule although I haven't tested this. Once warmed up the rule adds negligible overhead but perhaps we could still incrementally update these?

Followed up with: #1310

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.

None yet

4 participants