From 44b791ad507d9814ee816f550df407b348d38b4b Mon Sep 17 00:00:00 2001 From: Raja Subramanian Date: Sun, 4 Oct 2026 23:54:14 +0530 Subject: [PATCH] test: give mock participants a connection quality, close test rooms (#4933) * test: give mock participants a connection quality A real participant never returns a nil connection quality. The mock did, which can crash code that does not expect nil. Co-Authored-By: Claude Opus 5.5 * test: close test rooms when each test ends Most room tests left their rooms open, so each room's workers kept running for the rest of the package. Co-Authored-By: Claude Opus 5.5 --------- Co-authored-by: Claude Opus 5.5 --- pkg/rtc/room_test.go | 1 + pkg/rtc/testutils.go | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/pkg/rtc/room_test.go b/pkg/rtc/room_test.go index 7a565aba5..3c828ed6b 100644 --- a/pkg/rtc/room_test.go +++ b/pkg/rtc/room_test.go @@ -906,6 +906,7 @@ func newRoomWithParticipants(t *testing.T, opts testRoomOpts) *Room { telemetry.NewTelemetryService(n, &telemetryfakes.FakeAnalyticsService{}), nil, nil, nil, ) + t.Cleanup(func() { rm.Close(types.RoomCloseReasonUnknown) }) for i := 0; i < opts.num+opts.numHidden; i++ { identity := livekit.ParticipantIdentity(fmt.Sprintf("p%d", i)) participant := NewMockParticipant(identity, opts.protocol, i >= opts.num, true, rm.LocalParticipantListener()) diff --git a/pkg/rtc/testutils.go b/pkg/rtc/testutils.go index 085582113..253707c9c 100644 --- a/pkg/rtc/testutils.go +++ b/pkg/rtc/testutils.go @@ -23,6 +23,7 @@ import ( "github.com/livekit/livekit-server/pkg/rtc/types" "github.com/livekit/livekit-server/pkg/rtc/types/typesfakes" + "github.com/livekit/livekit-server/pkg/sfu/connectionquality" ) func NewMockParticipant( @@ -54,6 +55,11 @@ func NewMockParticipant( State: livekit.ParticipantInfo_JOINED, IsPublisher: publisher, }, utils.TimedVersion(0)) + p.GetConnectionQualityReturns(&livekit.ConnectionQualityInfo{ + ParticipantSid: sid, + Quality: livekit.ConnectionQuality_EXCELLENT, + Score: connectionquality.MaxMOS, + }) p.SetMetadataCalls(func(m string) { participantListener.OnParticipantUpdate(p)