MCPcopy
hub / github.com/livekit/livekit / TestAgentMultiNode

Function TestAgentMultiNode

test/agent_test.go:190–234  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

188}
189
190func TestAgentMultiNode(t *testing.T) {
191 for _, testRTCServicePath := range testRTCServicePaths {
192 t.Run(fmt.Sprintf("testRTCServicePath=%s", testRTCServicePath.String()), func(t *testing.T) {
193 _, _, finish := setupMultiNodeTest("TestAgentMultiNode")
194 defer finish()
195
196 ac1, err := newAgentClient(agentToken(), defaultServerPort)
197 require.NoError(t, err)
198 ac2, err := newAgentClient(agentToken(), defaultServerPort)
199 require.NoError(t, err)
200 defer ac1.close()
201 defer ac2.close()
202 ac1.Run(livekit.JobType_JT_ROOM, "default")
203 ac2.Run(livekit.JobType_JT_PUBLISHER, "default")
204
205 testutils.WithTimeout(t, func() string {
206 if ac1.registered.Load() != 1 || ac2.registered.Load() != 1 {
207 return "worker not registered"
208 }
209 return ""
210 }, RegisterTimeout)
211
212 c1 := createRTCClient("c1", secondServerPort, testRTCServicePath, nil) // Create a room on the second node
213 waitUntilConnected(t, c1)
214
215 t1, err := c1.AddStaticTrack("audio/opus", "audio", "micro")
216 require.NoError(t, err)
217 defer t1.Stop()
218
219 time.Sleep(time.Second * 10)
220
221 testutils.WithTimeout(t, func() string {
222 if ac1.roomJobs.Load() != 1 {
223 return "room job not assigned"
224 }
225
226 if ac2.publisherJobs.Load() != 1 {
227 return "participant job not assigned"
228 }
229
230 return ""
231 }, AssignJobTimeout)
232 })
233 }
234}
235
236func agentToken() string {
237 at := auth.NewAccessToken(testApiKey, testApiSecret).

Callers

nothing calls this directly

Calls 12

WithTimeoutFunction · 0.92
setupMultiNodeTestFunction · 0.85
newAgentClientFunction · 0.85
agentTokenFunction · 0.85
createRTCClientFunction · 0.85
waitUntilConnectedFunction · 0.85
AddStaticTrackMethod · 0.80
LoadMethod · 0.65
StopMethod · 0.65
RunMethod · 0.45
StringMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected