Repository navigation
[HOLD for payment 2024-08-05] [$125] Fix flakey SubscriptionUtils test #45801
Copy link
Copy link
Closed
Labels
Awaiting PaymentAuto-added when associated PR is deployed to productionAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.Something is broken. Auto assigns a BugZero manager.DailyKSv2KSv2ExternalAdded to denote the issue can be worked on by a contributorAdded to denote the issue can be worked on by a contributor
Description
Problem
It seems like the SubscriptionUtils tests are flaky:
Summary of all failing tests
FAIL tests/unit/SubscriptionUtilsTest.ts (32.87 s)
● SubscriptionUtils › getSubscriptionStatus › should return POLICY_OWNER_WITH_AMOUNT_OWED status
expect(received).toEqual(expected) // deep equality
- Expected - 2
+ Received + 1
Object {
- "isError": true,
- "status": "policy_owner_with_amount_owed",
+ "status": "policy_owner_with_amount_owed_overdue",
}
337 | });
338 |
> 339 | expect(SubscriptionUtils.getSubscriptionStatus()).toEqual({
| ^
340 | status: PAYMENT_STATUS.POLICY_OWNER_WITH_AMOUNT_OWED,
341 | isError: true,
342 | });
at Object.toEqual (tests/unit/SubscriptionUtilsTest.ts:339:63)
at asyncGeneratorStep (node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
at asyncGeneratorStep (node_modules/@babel/runtime/helpers/asyncToGenerator.js:22:9)
● SubscriptionUtils › getSubscriptionStatus › should return OWNER_OF_POLICY_UNDER_INVOICING status
expect(received).toEqual(expected) // deep equality
- Expected - 1
+ Received + 1
Object {
- "status": "owner_of_policy_under_invoicing",
+ "status": "owner_of_policy_under_invoicing_overdue",
}
370 | });
371 |
> 372 | expect(SubscriptionUtils.getSubscriptionStatus()).toEqual({
| ^
373 | status: PAYMENT_STATUS.OWNER_OF_POLICY_UNDER_INVOICING,
374 | });
375 | });
at Object.toEqual (tests/unit/SubscriptionUtilsTest.ts:372:63)
at asyncGeneratorStep (node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
at asyncGeneratorStep (node_modules/@babel/runtime/helpers/asyncToGenerator.js:22:9)
Here is a run
Solution
Fix the flakiness cc @JKobrynski @blimpich @mananjadhav coming from #44072
Issue Owner
Current Issue Owner: @Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~01fc7c3dad62f3576b
- Upwork Job ID: 1816873686533642172
- Last Price Increase: 2024-07-26
Issue Owner
Current Issue Owner: @twisterdotcomReactions are currently unavailable
Metadata
Metadata
Labels
Awaiting PaymentAuto-added when associated PR is deployed to productionAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.Something is broken. Auto assigns a BugZero manager.DailyKSv2KSv2ExternalAdded to denote the issue can be worked on by a contributorAdded to denote the issue can be worked on by a contributor
Activity
melvin-bot commentedon Jul 19, 2024
Triggered auto assignment to Contributor-plus team member for initial proposal review - @rojiphil (
External)melvin-bot commentedon Jul 19, 2024
Triggered auto assignment to @twisterdotcom (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.[-]Fix flakey SubscriptionUtils test[/-][+][$125] Fix flakey SubscriptionUtils test[/+]melvin-bot commentedon Jul 19, 2024
mountiny commentedon Jul 19, 2024
Or maybe this is fixed in main
jaydamani commentedon Jul 20, 2024
Proposal
Please re-state the problem that we are trying to solve in this issue.
tests for SubscriptionUtils.getSubscriptionStatus are flakey
What is the root cause of that problem?
The GRACE_PERIOD_DATE is declared at the beginning and is 1 second + current time so if the other tests take more than 1 second time in total, SubscriptionUtils.getSubscriptionStatus will return overdue status instead of non-overdue.
What changes do you think we should make in order to solve the problem?
Update the 1 second added in GRACE_PERIOD_DATE to be a larger value like 1 hour.
What alternative solutions did you explore? (Optional)
Instead of using just a constant at the beginning, we could update the GRACE_PERIOD_DATE to be now + 1 second before each test or we could also just use a function that returns now + 1 second
Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.
mountiny commentedon Jul 22, 2024
@rojiphil can you please review the proposal?
rojiphil commentedon Jul 22, 2024
RCA of @jaydamani proposal makes sense as 1 second is too tight to check. The current time can become greater than the set time when the tests are executed to cause this flaky behavior.
I think we can safely increase to 1 hour as proposed.
🎀👀🎀 C+ reviewed
26 remaining items
[-][$125] Fix flakey SubscriptionUtils test[/-][+][HOLD for payment 2024-08-05] [$125] Fix flakey SubscriptionUtils test[/+]melvin-bot commentedon Jul 29, 2024
Reviewinglabel has been removed, please complete the "BugZero Checklist".melvin-bot commentedon Jul 29, 2024
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.13-4 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:
If no regressions arise, payment will be issued on 2024-08-05. 🎊
For reference, here are some details about the assignees on this issue:
melvin-bot commentedon Jul 29, 2024
BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:
melvin-bot commentedon Aug 5, 2024
Payment Summary
Upwork Job
BugZero Checklist (@twisterdotcom)
twisterdotcom commentedon Aug 6, 2024
Updated summary above. Closing as we don't need regression for this.