Ensure RoomService operation is complete prior to returning (#362)

* Ensure service doesn't return before operation is complete

* added integration tests for RoomService
This commit is contained in:
David Zhao
2022-01-21 11:00:33 -08:00
committed by GitHub
parent 126bb8867b
commit f9a1dd97c2
7 changed files with 261 additions and 21 deletions
+15 -1
View File
@@ -101,7 +101,11 @@ func waitForServerToStart(s *service.LivekitServer) {
panic("could not start server after timeout")
case <-time.After(10 * time.Millisecond):
if s.IsRunning() {
return
// ensure we can connect to it
res, err := http.Get(fmt.Sprintf("http://localhost:%d", s.HTTPPort()))
if err == nil && res.StatusCode == http.StatusOK {
return
}
}
}
}
@@ -258,6 +262,16 @@ func createRoomToken() string {
return t
}
func adminRoomToken(name string) string {
at := auth.NewAccessToken(testApiKey, testApiSecret).
AddGrant(&auth.VideoGrant{RoomAdmin: true, Room: name})
t, err := at.ToJWT()
if err != nil {
panic(err)
}
return t
}
func listRoomToken() string {
at := auth.NewAccessToken(testApiKey, testApiSecret).
AddGrant(&auth.VideoGrant{RoomList: true})