Skip to content

test(e2e): the poll spacing check tolerates the fake Canvas's arrival delay instead of flaking - #173

Merged
SebasB76 merged 1 commit into
mainfrom
fix/e2e-canvas-poll-spacing
Nov 14, 2026
Merged

SebasB76 merged 1 commit into
mainfrom
fix/e2e-canvas-poll-spacing

Conversation

@SebasB76

Copy link
Copy Markdown
Owner

What

test_canvas failed on most PRs at the poll spacing check (min(gaps) >= 0.08; 0.064 s on #171 while every other gap was ~0.100 s). The poller was right. The measurement was wrong.

  • The poller (CanvasClient._pace) paces sends on time.monotonic(): it sleeps until _last + interval, then stamps _last right before the request, so two sends are never closer than 100 ms.
  • FakeCanvas stamps time.time() when the request's handler thread wakes. That adds a variable delay: thread scheduling in the busy pytest process (five E2E tests and their fakes), or a new connection after a streamed download. When request N is stamped late and N+1 is not, the measured gap shrinks to 0.1 - delay.

That delay is bounded and does not add up over several requests, so the check now asserts that no stretch of k gaps ran faster than k intervals, minus one 50 ms arrival delay. The #171 run passes (worst -0.036 s). A poll with no throttle still fails: any two back-to-back requests arrive about 0.1 s too early.

E2E: test_canvas passes. test_academico failed on this run at step 5 (no «Conectar Académico» url button within 120 s after "actualiza mi Académico"). This change doesn't touch that test, and it may be a separate flake.

Docs: none needed, test-only change.

… delay instead of flaking

The poller paces sends 100 ms apart on time.monotonic(), but the fake stamps each
request when its handler thread wakes, so one late stamp shortened the next gap
(0.064 s on PR #171). The check now asserts that no stretch of requests ran faster
than the interval allows, minus one 50 ms arrival delay, which does not add up.
@SebasB76
SebasB76 merged commit 5991dfb into main Nov 14, 2026
1 check passed
@SebasB76
SebasB76 deleted the fix/e2e-canvas-poll-spacing branch November 14, 2026 22:50
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.

1 participant