test(dashmate): make ZeroSSL provider-change test deterministic - #4482
Conversation
The provider-change test ticked a blanket 64 days after the handoff. That is free when the handoff cleared every timer, but whenever a 60-second config-refresh timer survives into the tick, tickAsync must replay ~92k firings — each one a real event-loop hop plus sinon call bookkeeping — which blows the 10s mocha timeout on a slow shared runner instead of failing on an assertion (e.g. run 32935417801: 10.00s of silence between the scheduling log line and the timeout, while the structurally identical sibling test passed in 6ms right after). Replace the 64-day tick with clock.runAllAsync(), which proves a stronger statement: the handoff leaves nothing armed at all, so the old renewal can never fire. Verified against seeded regressions: a cron job surviving the handoff now fails on the calledOnce assertion in ~50ms, and a surviving refresh interval fails with fake-timers' infinite-loop guard in ~170ms — both instead of a 10-second timeout. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
🕓 Ready for review — next in queue (commit c32e3b5) |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe provider-change test now drains pending timers with ChangesZeroSSL renewal timer validation
Estimated code review effort: 1 (Trivial) | ~2 minutes Merge Risk: ⚪ Minimal · up to This localized test-only change makes the ZeroSSL provider-change test deterministic without changing production behavior; no actionable merge-blocking risk remains beyond normal checks and review. Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Full details: Docstring CoverageExplanation No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1 files. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Reviewed |
Issue being fixed or feature implemented
The dashmate unit test "should detect a provider change before the old certificate renewal date" intermittently fails with
Timeout of 10000ms exceededon GitHub-hosted runners (example failure, on a PR with zero JS changes).The test ends with a blanket
clock.tickAsync(64 days). That tick is free when the provider handoff cleared every timer, but whenever the 60-second config-refresh timer survives into it, sinon must replay ~92k firings — each one a real event-loop hop plus stub call bookkeeping — which blows the 10s mocha timeout on a slow shared runner instead of failing on an assertion. The CI log shows exactly this shape: 10.00s of silence between the test's scheduling log line and the timeout, while the structurally identical sibling test passed in 6ms right after.What was done?
await clock.tickAsync(64 * 24 * 60 * 60 * 1000)inpackages/dashmate/test/unit/helper/scheduleRenewZeroSslCertificateFactory.spec.jswithawait clock.runAllAsync(), with a comment explaining why.runAllAsyncand trips thecalledOnce/not.calledassertions (~50ms); a surviving refresh interval trips fake-timers' 1000-timer infinite-loop guard (~170ms). Both verified by temporarily seeding those regressions intoscheduleRenewalJob.js/watchCertificateConfig.js.How Has This Been Tested?
yarn workspace dashmate mocha test/unit/helper/scheduleRenewZeroSslCertificateFactory.spec.jsrun 18× (mixedTZ=UTCand local timezone to match CI): 16 passing every run, 42–61ms per run.job.stop()removed from the config-change handoff the test fails on the assertion in ~50ms; withclearIntervalremoved from the watcher it fails with sinon's infinite-loop guard in ~170ms — instead of a 10s timeout in both cases.Breaking Changes
None.
Checklist:
For repository code-owners and collaborators only
🤖 Generated with Claude Code
Summary by CodeRabbit