Use RequestResponse to report protocol handling errors (#3895)
* Send errors as necessary * WIP * WIP * WIP * WIP * deps * static check * fix test * test * test * logs
This commit is contained in:
@@ -132,7 +132,8 @@ func TestTrackPublishing(t *testing.T) {
|
||||
Type: livekit.TrackType_AUDIO,
|
||||
})
|
||||
|
||||
require.Equal(t, 1, sink.WriteMessageCallCount())
|
||||
// error response on duplicate adds a message
|
||||
require.Equal(t, 2, sink.WriteMessageCallCount())
|
||||
})
|
||||
|
||||
t.Run("should queue adding of duplicate tracks if already published by client id in signalling", func(t *testing.T) {
|
||||
@@ -150,7 +151,8 @@ func TestTrackPublishing(t *testing.T) {
|
||||
Name: "webcam",
|
||||
Type: livekit.TrackType_VIDEO,
|
||||
})
|
||||
require.Equal(t, 0, sink.WriteMessageCallCount())
|
||||
// `queued` `RequestResponse` should add a message
|
||||
require.Equal(t, 1, sink.WriteMessageCallCount())
|
||||
require.Equal(t, 1, len(p.pendingTracks["cid"].trackInfos))
|
||||
|
||||
// add again - it should be added to the queue
|
||||
@@ -159,7 +161,8 @@ func TestTrackPublishing(t *testing.T) {
|
||||
Name: "webcam",
|
||||
Type: livekit.TrackType_VIDEO,
|
||||
})
|
||||
require.Equal(t, 0, sink.WriteMessageCallCount())
|
||||
// `queued` `RequestResponse`s should have been sent for duplicate additions
|
||||
require.Equal(t, 2, sink.WriteMessageCallCount())
|
||||
require.Equal(t, 2, len(p.pendingTracks["cid"].trackInfos))
|
||||
|
||||
// check SID is the same
|
||||
@@ -181,7 +184,8 @@ func TestTrackPublishing(t *testing.T) {
|
||||
Name: "webcam",
|
||||
Type: livekit.TrackType_VIDEO,
|
||||
})
|
||||
require.Equal(t, 0, sink.WriteMessageCallCount())
|
||||
// `queued` `RequestResponse` should add a message
|
||||
require.Equal(t, 1, sink.WriteMessageCallCount())
|
||||
require.Equal(t, 1, len(p.pendingTracks["cid"].trackInfos))
|
||||
|
||||
// add again - it should be added to the queue
|
||||
@@ -190,7 +194,8 @@ func TestTrackPublishing(t *testing.T) {
|
||||
Name: "webcam",
|
||||
Type: livekit.TrackType_VIDEO,
|
||||
})
|
||||
require.Equal(t, 0, sink.WriteMessageCallCount())
|
||||
// `queued` `RequestResponse`s should have been sent for duplicate additions
|
||||
require.Equal(t, 2, sink.WriteMessageCallCount())
|
||||
require.Equal(t, 2, len(p.pendingTracks["cid"].trackInfos))
|
||||
|
||||
// check SID is the same
|
||||
@@ -220,7 +225,8 @@ func TestTrackPublishing(t *testing.T) {
|
||||
Type: livekit.TrackType_AUDIO,
|
||||
Source: livekit.TrackSource_MICROPHONE,
|
||||
})
|
||||
require.Equal(t, 1, sink.WriteMessageCallCount())
|
||||
// an error response for disallowed source should send a `RequestResponse`.
|
||||
require.Equal(t, 2, sink.WriteMessageCallCount())
|
||||
})
|
||||
}
|
||||
|
||||
@@ -278,7 +284,10 @@ func TestMuteSetting(t *testing.T) {
|
||||
ti := &livekit.TrackInfo{Sid: "testTrack"}
|
||||
p.pendingTracks["cid"] = &pendingTrackInfo{trackInfos: []*livekit.TrackInfo{ti}}
|
||||
|
||||
p.SetTrackMuted(livekit.TrackID(ti.Sid), true, false)
|
||||
p.SetTrackMuted(&livekit.MuteTrackRequest{
|
||||
Sid: ti.Sid,
|
||||
Muted: true,
|
||||
}, false)
|
||||
require.True(t, p.pendingTracks["cid"].trackInfos[0].Muted)
|
||||
})
|
||||
|
||||
@@ -384,7 +393,11 @@ func TestDisableCodecs(t *testing.T) {
|
||||
}
|
||||
return nil
|
||||
})
|
||||
participant.HandleOffer(sdp, offerId)
|
||||
participant.HandleOffer(&livekit.SessionDescription{
|
||||
Type: webrtc.SDPTypeOffer.String(),
|
||||
Sdp: sdp.SDP,
|
||||
Id: offerId,
|
||||
})
|
||||
|
||||
testutils.WithTimeout(t, func() string {
|
||||
if answerReceived.Load() && answerIdReceived.Load() == offerId {
|
||||
@@ -573,7 +586,11 @@ func TestPreferMediaCodecForPublisher(t *testing.T) {
|
||||
}
|
||||
return nil
|
||||
})
|
||||
participant.HandleOffer(sdp, offerId)
|
||||
participant.HandleOffer(&livekit.SessionDescription{
|
||||
Type: webrtc.SDPTypeOffer.String(),
|
||||
Sdp: sdp.SDP,
|
||||
Id: offerId,
|
||||
})
|
||||
|
||||
require.Eventually(t, func() bool { return answerReceived.Load() && answerIdReceived.Load() == offerId }, 5*time.Second, 10*time.Millisecond)
|
||||
|
||||
@@ -660,7 +677,11 @@ func TestPreferAudioCodecForRed(t *testing.T) {
|
||||
}
|
||||
return nil
|
||||
})
|
||||
participant.HandleOffer(sdp, offerId)
|
||||
participant.HandleOffer(&livekit.SessionDescription{
|
||||
Type: webrtc.SDPTypeOffer.String(),
|
||||
Sdp: sdp.SDP,
|
||||
Id: offerId,
|
||||
})
|
||||
|
||||
require.Eventually(t, func() bool { return answerReceived.Load() && answerIdReceived.Load() == offerId }, 5*time.Second, 10*time.Millisecond)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user