Skip to content

test: keep smart routing reset fixture within one hour - #77

Merged
yetone merged 1 commit into
yetone:mainfrom
charan-rathore:fix/smart-routing-hour-boundary-test
Sep 25, 2026
Merged

yetone merged 1 commit into
yetone:mainfrom
charan-rathore:fix/smart-routing-hour-boundary-test

Conversation

@charan-rathore

Copy link
Copy Markdown
Contributor

Root cause

The Ubuntu test job in #76 failed in TestSmartRouting at routing_test.go:119: it got s#b s#c s#a rather than s#c s#b s#a in the "week, then five hours" case (failed job). The test uses time.Now() to create weekly resets for b and c one minute apart. Routing compares their reset times after truncating them to an hour. If the test starts in the final minute of an hour, b and c land in different hour buckets, so b correctly goes before c and the test's expected five-hour tie-breaker does not apply.

This fixture predates #76 and is unrelated to its disabled-key change. The provider tests passed in that run.

Fix

Anchor only this routing fixture at 20 minutes into the current hour. Both weekly resets are then in the same hour, so the test consistently checks the five-hour tie-breaker it names. The other timing and rest assertions keep their real-time anchor.

Tests

  • Reproduced the original failure on current main by forcing the test's now to time.Now().Truncate(time.Hour).Add(59*time.Minute + 30*time.Second): the exact s#b s#c s#a failure.
  • With this fix, TZ=UTC go test ./internal/gateway -run '^TestSmartRouting$' -count=1 passed; TZ=UTC go test ./internal/gateway ./internal/provider -count=1 passed.
  • Forcing only routingNow to the synthetic 59:30 boundary after the fix reproduces the same failure. Restoring the 20-minute anchor returns the test to green.
  • Full go test ./... could not compile the GUI in my Linux container: GTK4/WebKitGTK 6 development libraries are absent. The CI workflow installs GTK3/WebKitGTK 4.1 and uses -tags gtk3; the relevant gateway/provider tests above ran locally without GUI dependencies.

@yetone
yetone merged commit f298bb4 into yetone:main Sep 25, 2026
4 checks passed
@yetone

yetone commented Sep 25, 2026

Copy link
Copy Markdown
Owner

Thanks — the diagnosis is right: with now in an hour's last minute, b's and c's weekly resets (2d and 2d+1m out) truncate to different hours, so the week decides and the five-hour tie-break never runs. I ran it locally with the anchor, and the order holds at any minute; merged. (A separate thing I noticed while checking: -count>1 fails at the rests assertions because restingUntil keeps state between runs — I'll reset it in the test.)

@yetone

yetone commented Sep 25, 2026

Copy link
Copy Markdown
Owner

Correction to my aside: the whole gateway test package keeps package-level state (turn counters, rests, subscription runs), so -count>1 isn't something it supports; a one-line reset in this test doesn't change that, so I'm leaving it. -count=1 and CI are what count.

@charan-rathore

Copy link
Copy Markdown
Contributor Author

Thanks for confirming and merging!

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.

2 participants