Repository navigation
Conversation
TestRealtimePresence_Presence_Enter_Update_Leave occasionally fails on CI because client1's subscriber receives PRESENT where the test expects ENTER or UPDATE. The SDK emits each presence message to subscribers with the action the server sent (RTP2d1), so a PRESENT can only come from the server, typically in a SYNC. Ably may start a sync at any time (RTP18). If one carries client2's current state before the matching ENTER or UPDATE arrives, the member is emitted as PRESENT, and the later ENTER or UPDATE has the same msgSerial and index, so it isn't newer and is dropped (RTP2a, RTP2b2). Both CI failures fit this, one at the ENTER step and one at the UPDATE step. We could not reproduce it against the sandbox, so the trigger is inferred rather than observed. Accept PRESENT alongside ENTER and UPDATE at those two steps. The test still checks the client ID and data of each message, and LEAVE stays strict, since a sync never delivers a leave as PRESENT. Skipping PRESENT instead would hang the test, because the real event is dropped as a duplicate.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
WalkthroughTwo presence integration test assertions now accept ChangesPresence integration tests
Priority: ⬇️ Low Estimated code review effort: 1 (Trivial) | ~4 minutes Change: Other Merge Risk: ⚪ Minimal · up to
|
|
closing in favor of https://github.com/ably/ably-go/pull/720 |
Summary
Fixes an occasional CI failure in
TestRealtimePresence_Presence_Enter_Update_Leave. Client1's presence subscriber sometimes receives PRESENT where the test expects ENTER or UPDATE. The fix is 2 lines, test-only: accept PRESENT at those two steps. No SDK code changes.The failures
Both on CI, in the
integration-test (1.25, json)job, and both passed on re-run.integration/v22(ENTER)1(PRESENT)4(UPDATE)1(PRESENT)Why a PRESENT can arrive
processProtoPresenceMessage(ably/realtime_presence.go) emits each message to subscribers with the action the server sent. It rewrites the action to PRESENT only for the internal presence map, as spec RTP2d1/RTP2d2 require. So a subscriber sees PRESENT only when the server sent PRESENT, which is what a presence SYNC delivers.IsNewerThan, RTP2b2) says it isn't newer and it's discarded (RTP2a). The test therefore never sees ENTER or UPDATE for that step; it sees PRESENT.This fits both failures: a sync carrying client2's entered state at the ENTER step, and its updated state at the UPDATE step.
The fix
What still holds:
ClientID == "client2"and the exactData("enter client2","update client2"), so the content is still verified.Why not just skip PRESENT messages? Because the real ENTER or UPDATE is dropped as a duplicate (step 3), a test that waited for it would hang until timeout.
Evidence
ably/realtime_presence.go(Emit(msg.Action, …)), matching spec RTP2d1/RTP2d2ably/proto_presence_message.go(IsNewerThan), matching RTP2b2-race, plus 6 parallel × 60 with per-message logging): always ENTER → UPDATE → LEAVEmainintroducing itValidation on this branch
go build ./...,go vetwith default,unitandintegrationtags,gofmt -lgo test -tags=unit ./...application/jsonapplication/x-msgpackrealtime_presence_integration_test.go, once (json)Compatibility with open work
Checked with in-memory trial merges; no branches were changed:
mainintegration/v2(#712), where the file moved tointernal/ably/Reviewer notes
ably/realtime_presence_integration_test.go. No SDK changes.msg.Presenceactions, IDs andchannelSerialat the top ofprocessProtoPresenceMessagein a CI run would capture the actual sequence.TimeFuncsfake clock. The two can merge in either order.Summary by CodeRabbit