Repository navigation
UTS: repair realtime/unit fixtures that cannot reach their condition - #590
Open
owenpearson wants to merge 6 commits into
Open
owenpearson wants to merge 6 commits into
owenpearson wants to merge 6 commits into
Conversation
…connect RTN25 error-reason-suspended-2, RTN14e disconnected-to-suspended-0, RTL6c4 fails-conn-suspended-0 and RTL4b fails-connection-suspended-2 refuse every connection attempt and then wait for a SUSPENDED connection. No CONNECTED message reaches the client, so the TTL in force is the DF1a default of 120 s, which RTN14e names. The tests tried to shorten it with a local variable (RTN25, RTN14e), a ClientOptions field that does not exist (RTL6c4), or channelRetryTimeout, which governs channels (RTL4b). None of these reaches the SDK. Each test now advances fake time past 120 s in a loop. RTL4b also enables fake timers and installs its mock before building the client. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nect first RTN7e pending-fail-suspended-0, RTP5f suspended-maintains-presence-map-0 and RTL11 queued-presence-fail-suspended-1 connect, drop the transport, and wait for a SUSPENDED connection or channel. None of them could get there: - RTN7e passed connectionStateTtl as a ClientOptions field, which does not exist. It also re-bound mock_ws to a new mock that had never accepted a connection, so simulate_disconnect() targeted a mock with no active connection, and the second install_mock was not guaranteed to reach a client that was already connected. - RTP5f and RTL11 dropped the transport and awaited a SUSPENDED channel straight away. A transport drop leaves the connection DISCONNECTED (RTN15a); RTL3c suspends channels only from a SUSPENDED connection. Their mocks also accepted every reconnection attempt, and neither test used fake timers. Each now uses one mock that accepts the first attempt with a CONNECTED whose connectionDetails carry connectionStateTtl: 5000, and refuses the rest, then advances fake time until the connection is SUSPENDED. This is the recipe already documented at RTP11d in realtime_presence_get.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RTP11d get-suspended-errors-default-0 and get-suspended-no-wait-returns-1 have the defect RTP5f had: they drop the transport and await a SUSPENDED channel at once, with a mock that accepts every reconnection attempt and no fake timers. The client reconnects, so the channel never becomes SUSPENDED. Both already send connectionStateTtl: 5000 in CONNECTED, as the note above them describes, but do not carry out the rest of that note. Each now refuses every attempt after the first and advances fake time until the connection is SUSPENDED, following the note. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RTN24 connection-details-override-2 sent a second CONNECTED whose connectionDetails changed clientId from "client-original" to "client-updated", then asserted the connection was still CONNECTED. The test's own requirement line lists the details RTN24 overrides as operational parameters (maxIdleInterval, connectionStateTtl, maxMessageSize, serverId). Re-identifying an already-identified connection is not one of them, and whether an SDK should accept it is a separate question under RSA7b3 that the fixture should not settle. The second CONNECTED now repeats the original clientId. The other changed details still exercise RTN24. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RTP5a detached-clears-presence-maps-0 detaches the channel and then reads the presence map with presence.get(waitForSync: false), expecting no members. On a DETACHED channel get runs ensure-active-channel (RTP11e), which re-attaches it (RTL33b); waitForSync: false only skips waiting for the SYNC. The mock answered every ATTACH with a SYNC carrying alice, so a conforming SDK returned one member. The mock now sends the SYNC only for the first ATTACH, and answers the re-attach with ATTACHED alone, so get returns the map DETACHED left. The read-back is also awaited, since it attaches. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RTS3c1 error-reattach-params-0 and RTL16a triggers-reattach-0 build a client with autoConnect: false, install no mock, never connect, and then await channel.attach() and assert ATTACHED. Per RTL4i the attach leaves the channel ATTACHING until the connection is CONNECTED, so the await never returns, and with no mock nothing would answer the ATTACH. RTS3c1 error-reattach-modes-1 needs an ATTACHING channel and only says "Put channel in attaching state (implementation detail)". Each setup now installs a mock and connects. The two attached tests answer every ATTACH; error-reattach-modes-1 leaves its ATTACH unanswered and waits for ATTACHING. The file gains the Mock WebSocket Infrastructure section its siblings have. RTL16a's assertion that the channel passes through ATTACHING is left as it is; that is #579. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the
uts/realtime/unitfixtures reported in #544, which set up a condition they can't reach, and the second-mock problem in RTN7e reported in #571.connectionStateTtlisn't aClientOptionsfield. DF1a gives it a 120 s default, and CD2f/RTN21 let the CONNECTED message'sconnectionDetailsoverride it. So a test can shorten it only by sending it in CONNECTED. That recipe is already documented at RTP11d inrealtime_presence_get.md, so no mock change is needed. The fixes follow one rule:connectionStateTtl.connectionStateTtl: 5000and refuses every later attempt. The test drops the transport and advances fake time until the connection is SUSPENDED.Corrections to #544
release-after-detach-1. This PR doesn't touchchannels_collection.md.connectionStateTtl, butrespond_with_success(ProtocolMessage(..., connectionDetails: ConnectionDetails(connectionStateTtl: 5000)))already does this.clientId. §2 proposes dropping theclientIdfrom the second CONNECTED. This PR sends the original value again instead, so an absentclientIdcan't be read as clearing it.Per-fixture changes
Never connect: advance past the 120 s default
realtime/unit/RTN25/error-reason-suspended-2(connection/error_reason_test.md). Removed the localDEFAULT_CONNECTION_STATE_TTL = 5000, which nothing passed to the SDK. It now loopsADVANCE_TIME(10000)until SUSPENDED, up to 150 s.realtime/unit/RTN14e/disconnected-to-suspended-0(connection/connection_open_failures_test.md). Same change. The requirement line now says "default connectionStateTtl".realtime/unit/RTL6c4/fails-conn-suspended-0(channels/channel_publish.md). Removed the non-existentClientOptions(connectionStateTtl: 5000). The loop now advances 10 s per step instead of 2 s, so it gets past 120 s.realtime/unit/RTL4b/fails-connection-suspended-2(channels/channel_attach.md). RemovedchannelRetryTimeout: 100, which governs channels (RTL13b). Addedenable_fake_timers(), which the test lacked, and the 120 s advance loop. Also movedinstall_mockbefore the client is built, as everywhere else in the suite.Connect first: short TTL from CONNECTED
realtime/unit/RTN7e/pending-fail-suspended-0(channels/channel_publish.md). RemovedClientOptions(connectionStateTtl: 5000). The test used to bindmock_wsto a second mock and callinstall_mockagain mid-test, sosimulate_disconnect()targeted a mock with no connection (channel_publish.md: RTN7e pending-fail-suspended-0 replacesmock_wsmid-test, sosimulate_disconnect()targets a mock with no connection #571). It now uses one mock that accepts the first attempt withconnectionStateTtl: 5000and refuses the rest, aschannel_publish.md: RTN7e pending-fail-suspended-0 replacesmock_wsmid-test, sosimulate_disconnect()targets a mock with no connection #571 proposes.realtime/unit/RTP5f/suspended-maintains-presence-map-0(presence/realtime_presence_channel_state.md). The test dropped the transport and awaited a SUSPENDED channel straight away. A transport drop leaves the connection DISCONNECTED (RTN15a), and RTL3c suspends channels only from a SUSPENDED connection. The mock also accepted every reconnect. It now uses the counting mock withconnectionStateTtl: 5000, fake timers and the advance loop.realtime/unit/RTL11/queued-presence-fail-suspended-1(same file). Same change as RTP5f.Other fixtures from #544
realtime/unit/RTN24/connection-details-override-2(connection/update_events_test.md). The second CONNECTED now sendsclientId: "client-original"again instead of changing it to"client-updated". RTN24 overrides operational parameters; it doesn't change the connection's identity. The changedserverId,maxIdleInterval,connectionStateTtlandmaxMessageSizestill exercise RTN24.realtime/unit/RTP5a/detached-clears-presence-maps-0(presence/realtime_presence_channel_state.md). On a DETACHED channel,presence.get(waitForSync: false)re-attaches it (RTP11e → RTL33b), and the mock answered every ATTACH with a SYNC carrying alice, so a conforming SDK returned one member. The mock now sends the SYNC only for the first ATTACH. It answers the re-attach with ATTACHED (withHAS_PRESENCE) and no SYNC, so the read-back is the map DETACHED left. If an SDK didn't clear the map, it still holds alice and the test fails. The read-back is nowAWAITed, since it attaches.realtime/unit/RTS3c1/error-reattach-params-0(channels/channel_options.md). Installs a mock that answers ATTACH and connects before attaching. Without a connection, RTL4i parks the attach in ATTACHING.realtime/unit/RTS3c1/error-reattach-modes-1(same file). The test only had the comment# Put channel in attaching state (implementation detail). It now installs a mock that leaves ATTACH unanswered, connects, callsattach(), and waits for ATTACHING.realtime/unit/RTL16a/triggers-reattach-0(same file). Same mock and connection as RTS3c1-0. Its assertion that the channel passes through ATTACHING is unchanged;realtime/unit/channels: seven tests expect behaviour the features spec doesn't define, or rely on the client not reconnecting #579 §2 covers it.channel_options.mdalso gets the## Mock WebSocket Infrastructuresection that the otherchannels/files have.Same defect, not listed in #544
realtime/unit/RTP11d/get-suspended-errors-default-0andrealtime/unit/RTP11d/get-suspended-no-wait-returns-1(presence/realtime_presence_get.md). These are the tests under the note that documents the CONNECTED-TTL recipe, and they have RTP5f's defect. They already sendconnectionStateTtl: 5000, but their mock accepts every reconnect and they await SUSPENDED with no fake time. They now follow the rest of their own note: the counting mock,disconnectedRetryTimeout: 500, fake timers and the advance loop. This is in a separate commit, so it can be dropped if it's out of scope here.Not changed
connection_open_failures_test.md: RTN14f awaits SUSPENDED without advancing fake time, and its third attempt connects before SUSPENDED is reached #570) and the otherchannels/tests inrealtime/unit/channels: seven tests expect behaviour the features spec doesn't define, or rely on the client not reconnecting #579 are separate.active_connectionand the other undeclared mock members (helpers/mock_websocket.mddoes not declareactive_connection, which the suite uses 193 times across 28 files — plus eight tests calling five members that do not exist #545) are used as the rest of the suite uses them.specifications/change.npm run lintpasses.Closes #544
Closes #571
🤖 Generated with Claude Code