MCPcopy
hub / github.com/livekit/livekit / TestMultiNodeRouting

Function TestMultiNodeRouting

test/multinode_test.go:33–81  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

31)
32
33func TestMultiNodeRouting(t *testing.T) {
34 if testing.Short() {
35 t.SkipNow()
36 return
37 }
38
39 _, _, finish := setupMultiNodeTest("TestMultiNodeRouting")
40 defer finish()
41
42 // creating room on node 1
43 _, err := roomClient.CreateRoom(contextWithToken(createRoomToken()), &livekit.CreateRoomRequest{
44 Name: testRoom,
45 })
46 require.NoError(t, err)
47
48 for _, testRTCServicePath := range testRTCServicePaths {
49 t.Run(fmt.Sprintf("testRTCServicePath=%s", testRTCServicePath.String()), func(t *testing.T) {
50 // one node connecting to node 1, and another connecting to node 2
51 c1 := createRTCClient("c1", defaultServerPort, testRTCServicePath, nil)
52 c2 := createRTCClient("c2", secondServerPort, testRTCServicePath, nil)
53 waitUntilConnected(t, c1, c2)
54 defer stopClients(c1, c2)
55
56 // c1 publishing, and c2 receiving
57 t1, err := c1.AddStaticTrack("audio/opus", "audio", "webcam")
58 require.NoError(t, err)
59 if t1 != nil {
60 defer t1.Stop()
61 }
62
63 testutils.WithTimeout(t, func() string {
64 if len(c2.SubscribedTracks()) == 0 {
65 return "c2 received no tracks"
66 }
67 if len(c2.SubscribedTracks()[c1.ID()]) != 1 {
68 return "c2 didn't receive track published by c1"
69 }
70 tr1 := c2.SubscribedTracks()[c1.ID()][0]
71 streamID, _ := rtc.UnpackStreamID(tr1.StreamID())
72 require.Equal(t, c1.ID(), streamID)
73 return ""
74 })
75
76 remoteC1 := c2.GetRemoteParticipant(c1.ID())
77 require.Equal(t, "c1", remoteC1.Name)
78 require.Equal(t, "metadatac1", remoteC1.Metadata)
79 })
80 }
81}
82
83func TestConnectWithoutCreation(t *testing.T) {
84 if testing.Short() {

Callers

nothing calls this directly

Calls 15

WithTimeoutFunction · 0.92
UnpackStreamIDFunction · 0.92
setupMultiNodeTestFunction · 0.85
contextWithTokenFunction · 0.85
createRoomTokenFunction · 0.85
createRTCClientFunction · 0.85
waitUntilConnectedFunction · 0.85
stopClientsFunction · 0.85
AddStaticTrackMethod · 0.80
SubscribedTracksMethod · 0.80
GetRemoteParticipantMethod · 0.80
CreateRoomMethod · 0.65

Tested by

no test coverage detected