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

Nit: Fix timing jitter in AddonConditionWatcherTriggerTimeSecs #9711

Merged
merged 1 commit into from
Jul 3, 2024

Conversation

oskirby
Copy link
Collaborator

@oskirby oskirby commented Jul 3, 2024

Description

Have you been experiencing unstable unit tests in the TestAddon::conditionWatcher_group() test case? Well we have an exciting, limited time offer for you! A fix to the addon condition time calculation now available for the low LOW price of one r+ to this simple PR!

The gist of the issue is that addon condition times are specified in seconds relative to the installation time, but the installation time is stored in milliseconds. The truncation in handling the expiration calculation can result in a second of jitter around the actual emission of the conditionChanged() signal. Sometimes, when the jitter overlaps we can wind up with the conditions going true in reverse order, which is what causes this test to fail.

To fix this, I felt the best approach was to do all the math in milliseconds, which is kind of the native unit of the QDateTime class which eliminates the need to do our own timestamp math.

To reproduce the issue, build the unit tests and then torture them in the following loop. Without this change it dies after a handful of iterations.

while ./tests/unit_tests/app_unit_tests TestAddon; do rm ~/.config/mozilla_testing/vpn_unit.moz; done

Reference

Example test failures: seen here

Checklist

  • My code follows the style guidelines for this project
  • I have not added any packages that contain high risk or unknown licenses (GPL, LGPL, MPL, etc. consult with DevOps if in question)
  • I have performed a self review of my own code
  • I have commented my code PARTICULARLY in hard to understand areas
  • I have added thorough tests where needed
@oskirby oskirby changed the title Nit: Fix fuzzy timing in AddonConditionWatcherTriggerTimeSecs Jul 3, 2024
@oskirby oskirby marked this pull request as ready for review July 3, 2024 02:46
Copy link
Collaborator

@strseb strseb left a comment

Choose a reason for hiding this comment

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

SOLD!

@oskirby oskirby merged commit bd5837b into main Jul 3, 2024
116 checks passed
@oskirby oskirby deleted the nit-addon-unit-test-flakiness branch July 3, 2024 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants