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 <noreply@anthropic.com>

* 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 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Raja Subramanian
2026-10-04 23:54:14 +05:30
committed by GitHub
co-authored by Claude Opus 5.5
parent c2339b2b85
commit 44b791ad50
2 changed files with 7 additions and 0 deletions
+1
View File
@@ -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())
+6
View File
@@ -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)