Add tests to data publishing with protocol 3
This commit is contained in:
+24
-6
@@ -5,6 +5,8 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/livekit/protocol/logger"
|
||||
livekit "github.com/livekit/protocol/proto"
|
||||
"github.com/livekit/protocol/utils"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/livekit/livekit-server/pkg/testutils"
|
||||
@@ -13,11 +15,9 @@ import (
|
||||
|
||||
// a scenario with lots of clients connecting, publishing, and leaving at random periods
|
||||
func scenarioPublishingUponJoining(t *testing.T, ports ...int) {
|
||||
firstPort := ports[0]
|
||||
lastPort := ports[len(ports)-1]
|
||||
c1 := createRTCClient("puj_1", firstPort, nil)
|
||||
c2 := createRTCClient("puj_2", lastPort, &testclient.Options{AutoSubscribe: true})
|
||||
c3 := createRTCClient("puj_3", firstPort, &testclient.Options{AutoSubscribe: true})
|
||||
c1 := createRTCClient("puj_1", defaultServerPort, nil)
|
||||
c2 := createRTCClient("puj_2", secondServerPort, &testclient.Options{AutoSubscribe: true})
|
||||
c3 := createRTCClient("puj_3", defaultServerPort, &testclient.Options{AutoSubscribe: true})
|
||||
defer stopClients(c1, c2, c3)
|
||||
|
||||
waitUntilConnected(t, c1, c2, c3)
|
||||
@@ -66,7 +66,7 @@ func scenarioPublishingUponJoining(t *testing.T, ports ...int) {
|
||||
|
||||
logger.Infow("c2 reconnecting")
|
||||
// connect to a diff port
|
||||
c2 = createRTCClient("puj_2", firstPort, nil)
|
||||
c2 = createRTCClient("puj_2", defaultServerPort, nil)
|
||||
defer c2.Stop()
|
||||
waitUntilConnected(t, c2)
|
||||
writers = publishTracksForClients(t, c2)
|
||||
@@ -119,6 +119,24 @@ func scenarioReceiveBeforePublish(t *testing.T) {
|
||||
require.Empty(t, c1.RemoteParticipants())
|
||||
}
|
||||
|
||||
func scenarioDataPublish(t *testing.T) {
|
||||
c1 := createRTCClient("dp1", defaultServerPort, nil)
|
||||
c2 := createRTCClient("dp2", secondServerPort, nil)
|
||||
waitUntilConnected(t, c1, c2)
|
||||
defer stopClients(c1, c2)
|
||||
|
||||
payload := "test bytes"
|
||||
|
||||
received := utils.AtomicFlag{}
|
||||
c2.OnDataReceived = func(data []byte, sid string) {
|
||||
if string(data) == payload && sid == c2.ID() {
|
||||
received.TrySet(true)
|
||||
}
|
||||
}
|
||||
|
||||
require.NoError(t, c1.PublishData([]byte(payload), livekit.DataPacket_LOSSY))
|
||||
}
|
||||
|
||||
// websocket reconnects
|
||||
func scenarioWSReconnect(t *testing.T) {
|
||||
c1 := createRTCClient("wsr_1", defaultServerPort, nil)
|
||||
|
||||
Reference in New Issue
Block a user