Fix flaky testWeeklyIsSessionTimePeriodically in SessionScheduleTest - #1317
Conversation
Co-authored-by: chrjohn <6644028+chrjohn@users.noreply.github.com>
testWeeklyIsSessionTimePeriodically in SessionScheduleTest
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1317 +/- ##
============================================
+ Coverage 70.40% 70.42% +0.02%
Complexity 2248 2248
============================================
Files 159 159
Lines 9065 9065
Branches 1192 1192
============================================
+ Hits 6382 6384 +2
+ Misses 2218 2216 -2
Partials 465 465 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@copilot codecov is failing. Can you improve test coverage for your added code? |
Co-authored-by: chrjohn <6644028+chrjohn@users.noreply.github.com>
The |
SessionScheduleTest.testWeeklyIsSessionTimePeriodicallyintermittently failed CI withwrong end time expected, most notably onwindows-latestrunners.Root cause
DefaultSessionSchedulecomputes session interval boundaries withMILLISECONDalways zeroed, and treats the interval end as inclusive (t.compareTo(end) <= 0).Calendarfrom the real wall clock but never resetsMILLISECOND, so it retains whatever fractional millisecond happened to be present at test start.0, "now" equals the inclusive end boundary instead of exceeding it, delaying detection of the session-end transition by one full polling increment (5s) and failing the assertion.0far more likely than on higher-resolution Linux/macOS clocks, explaining the platform-specific flakiness.Fix
Calendarto a fixed non-zeroMILLISECONDvalue instead of leaving it dependent on the real clock, removing the dependency on wall-clock luck while preserving the test's original intent.No production code changes were needed — this is a test-only fix.