Make TestIdleCleanupKeepsActiveUser independent of timing (closes #181) #182

Merged
clawbot merged 1 commits from issue-181-idle-cleanup-test into next 2026-10-21 13:06:02 +02:00
Collaborator

Cause: the test counted active as stale whenever its PONG took more than 500 ms to arrive, which happens on a loaded build host. The code was right.

The test used to sleep 500 ms, have active send PING, and then ask GetStaleOrphanSessions for sessions last seen before the current time minus 500 ms. It now reads the clock once after both users have registered and before active sends its PING, and passes that time as the cutoff. idle was last seen when it registered, before the cutoff, and active's PING is recorded after it, so the result follows from the order of events. If handleMessage stopped recording a user's activity, active would still be last seen at registration and the test would fail.

Both readings in #181 were checked against the code: the IRC listener records the activity in handleMessage before the command's handler replies, and the SQLite driver stores the last-seen time as text that keeps the nanoseconds. A temporary diagnostic (not committed) caught a failing run in which the server had recorded the PING at once but the PONG reached the test more than 500 ms later.

Judgement call: the test relies on the wall clock not stepping backwards between the cutoff and the PING, since the stored time and the cutoff both come from it.

Model: opus-5-5

Cause: the test counted `active` as stale whenever its `PONG` took more than 500 ms to arrive, which happens on a loaded build host. The code was right. The test used to sleep 500 ms, have `active` send `PING`, and then ask `GetStaleOrphanSessions` for sessions last seen before the current time minus 500 ms. It now reads the clock once after both users have registered and before `active` sends its `PING`, and passes that time as the cutoff. `idle` was last seen when it registered, before the cutoff, and `active`'s `PING` is recorded after it, so the result follows from the order of events. If `handleMessage` stopped recording a user's activity, `active` would still be last seen at registration and the test would fail. Both readings in https://git.eeqj.de/sneak/neoirc/issues/181 were checked against the code: the IRC listener records the activity in `handleMessage` before the command's handler replies, and the SQLite driver stores the last-seen time as text that keeps the nanoseconds. A temporary diagnostic (not committed) caught a failing run in which the server had recorded the `PING` at once but the `PONG` reached the test more than 500 ms later. Judgement call: the test relies on the wall clock not stepping backwards between the cutoff and the `PING`, since the stored time and the cutoff both come from it. Model: opus-5-5
clawbot added the needs-review label 2026-10-21 07:08:44 +02:00
clawbot self-assigned this 2026-10-21 07:08:45 +02:00
clawbot added 1 commit 2026-10-21 07:08:45 +02:00
The test slept 500 ms, had active send PING, then asked for sessions
last seen before now minus 500 ms. On a loaded host the PONG can take
more than 500 ms to arrive, which puts active's last-seen time before
that cutoff. The code is right: it records the time before it replies,
to the nanosecond.

The test now takes the cutoff after both users register and before
active's PING, so the result follows from the order of events alone.

Model: opus-5-5
Author
Collaborator

Review passed: the stated cause matches the code, and the test change makes the result follow from the order of events.

Model: opus-5-5

Review passed: the stated cause matches the code, and the test change makes the result follow from the order of events. Model: opus-5-5
clawbot merged commit d539b4c558 into next 2026-10-21 13:06:02 +02:00
clawbot deleted branch issue-181-idle-cleanup-test 2026-10-21 13:06:04 +02:00
Sign in to join this conversation.