-
Notifications
You must be signed in to change notification settings - Fork 535
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test(client-presence): old collateral connection and stale connection tests #23351
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (3)
packages/framework/presence/src/internalTypes.ts:54
- The event names 'connected' and 'disconnected' should be consistent with the rest of the codebase.
export interface EphemeralRuntimeEvents extends IEvent {
packages/framework/presence/src/test/mockEphemeralRuntime.ts:121
- The removal of the 'on' and 'off' methods from 'MockEphemeralRuntime' might break existing code that relies on these methods. Confirm if this change was intentional and if it might cause any issues.
public clientId: string | undefined;
packages/framework/presence/src/test/mockEphemeralRuntime.ts:71
- [nitpick] Ensure that the new event handling mechanism is consistent with the rest of the codebase and aligns with existing conventions.
extends TypedEventEmitter<EphemeralRuntimeEvents>
Updated the tests a bit from our last discussion, looking for some guidance around better ways to simulate reconnect since I now know we want to move away from TypedEventEmitter @jason-ha |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like a lot - still have notes :)
}); | ||
|
||
it.skip("updates stale attendees status to 'Disconnected' afer multiple reconnects", () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
between these cases I am curious what happens after local connect is disconnected again. Do the stale connections ever become disconnected?
And what about the case where local disconnects, connects, and we hear from one of the stale connections?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a few other test cases to the existing ones:
- stale attendee status is not updated to 'Disconnected' if local client does not reconnect
- stale attendee status is not updated to 'Disconnected' if local client reconnection lasts less than 30s
- attendee status is not updated to 'Disconnected' if stale attendee becomes active
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
few more suggestions
}); | ||
it("is announced via `attendeeDisconnected`", () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Should have a blank line in here
assert.strictEqual( | ||
disconnectedAttendees.length, | ||
1, | ||
"Exactly one attendee should be announced as disconnected", | ||
); | ||
assert( | ||
disconnectedAttendee !== undefined, | ||
disconnectedAttendees[0] !== undefined, | ||
"No attendee was disconnected during `removeMember`", | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Second assert is not useful.
// Verify - stale attendee should still be 'Connected' after 30 seconds | ||
clock.tick(30_001); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the tick is part of the action
you can use a larger number (a much larger number)
in the other cases the time past is 31,002.
clock.tick(15_001); // Wait another 15 seconds (30s total since reconnection) | ||
|
||
// Verify - stale attendee should still be 'Connected' after 30s post-reconnection | ||
assert.strictEqual( | ||
knownAttendee.getConnectionStatus(), | ||
SessionClientStatus.Connected, | ||
"Stale attendee should still be 'Connected' after 30s", | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can use a larger number here as well. There is no time that is too large as should never disconnect.
// Verify | ||
assert.strictEqual( | ||
knownAttendee.getConnectionStatus(), | ||
SessionClientStatus.Connected, | ||
"Active attendee should still be 'Connected' 30s after reconnection", | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And also doesn't raise an attendeeJoined event
describe("and has their connection removed", () => { | ||
it("is announced via `attendeeDisconnected`", () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just realized the grammar of what these cases are saying after rereading the PR description. Thank for putting the test list in there. If you read the "sentence" down you get:
PresenceManager , when connected, attendee that is already known and has their connection removed...
In that situation "their" refers to "attendee". But you mean to refer to this local client.
it.skip("does not update attendee status to 'Disconnected' if stale attendee becomes active", () => { | ||
assert(knownAttendee !== undefined, "No attendee was set in beforeEach"); | ||
|
||
// Act - disconnect, reconnect, then process rejoin signal from known attendee after 15s | ||
runtime.disconnect(); | ||
clock.tick(1000); | ||
runtime.connect("client6"); | ||
clock.tick(15_001); | ||
processJoinSignals([rejoinAttendeeSignal]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How else might a stale attendee become active. This sounds like situation where the other was also disconnected but has rejoined. What about if the other had always stayed connected?
Description
There are 6 tests that are added (and disabled) in this PR.
The first test is to verify that old collateral connections do not effect the connection status of remote attendees. This scenario was written as an edge case to old solution where old connection information sent in a join response would result in the attendee connection status being set to 'Disconnected'.
The next five have to do with stale remote attendee's connection status upon local client reconnect scenarios:
I added connect() and disconnect() function to MockEphemeralRuntime that manipulates the connection state of the local client.