(t *testing.T)
| 126 | } |
| 127 | |
| 128 | func TestAgentNamespaces(t *testing.T) { |
| 129 | for _, testRTCServicePath := range testRTCServicePaths { |
| 130 | t.Run(fmt.Sprintf("testRTCServicePath=%s", testRTCServicePath.String()), func(t *testing.T) { |
| 131 | _, finish := setupSingleNodeTest("TestAgentNamespaces") |
| 132 | defer finish() |
| 133 | |
| 134 | ac1, err := newAgentClient(agentToken(), defaultServerPort) |
| 135 | require.NoError(t, err) |
| 136 | ac2, err := newAgentClient(agentToken(), defaultServerPort) |
| 137 | require.NoError(t, err) |
| 138 | defer ac1.close() |
| 139 | defer ac2.close() |
| 140 | ac1.Run(livekit.JobType_JT_ROOM, "namespace1") |
| 141 | ac2.Run(livekit.JobType_JT_ROOM, "namespace2") |
| 142 | |
| 143 | _, err = roomClient.CreateRoom(contextWithToken(createRoomToken()), &livekit.CreateRoomRequest{ |
| 144 | Name: testRoom, |
| 145 | Agents: []*livekit.RoomAgentDispatch{ |
| 146 | {}, |
| 147 | { |
| 148 | AgentName: "ag", |
| 149 | }, |
| 150 | }, |
| 151 | }) |
| 152 | require.NoError(t, err) |
| 153 | |
| 154 | testutils.WithTimeout(t, func() string { |
| 155 | if ac1.registered.Load() != 1 || ac2.registered.Load() != 1 { |
| 156 | return "worker not registered" |
| 157 | } |
| 158 | return "" |
| 159 | }, RegisterTimeout) |
| 160 | |
| 161 | c1 := createRTCClient("c1", defaultServerPort, testRTCServicePath, nil) |
| 162 | waitUntilConnected(t, c1) |
| 163 | |
| 164 | testutils.WithTimeout(t, func() string { |
| 165 | if ac1.roomJobs.Load() != 1 || ac2.roomJobs.Load() != 1 { |
| 166 | return "room job not assigned" |
| 167 | } |
| 168 | |
| 169 | job1 := <-ac1.requestedJobs |
| 170 | job2 := <-ac2.requestedJobs |
| 171 | |
| 172 | if job1.Namespace != "namespace1" { |
| 173 | return "namespace is not 'namespace'" |
| 174 | } |
| 175 | |
| 176 | if job2.Namespace != "namespace2" { |
| 177 | return "namespace is not 'namespace2'" |
| 178 | } |
| 179 | |
| 180 | if job1.Id == job2.Id { |
| 181 | return "job ids are the same" |
| 182 | } |
| 183 | |
| 184 | return "" |
| 185 | }, AssignJobTimeout) |
nothing calls this directly
no test coverage detected