close rooms after delay instead of immediately after participant departure, to allow reconnects

This commit is contained in:
David Zhao
2021-01-31 14:19:16 -08:00
parent 084ec378f0
commit 76b0dc62a7
6 changed files with 149 additions and 39 deletions
+15 -16
View File
@@ -1,14 +1,10 @@
package test
import (
"context"
"testing"
"github.com/go-redis/redis/v8"
"github.com/stretchr/testify/assert"
"github.com/livekit/livekit-server/pkg/routing"
"github.com/livekit/livekit-server/pkg/service"
"github.com/livekit/livekit-server/proto/livekit"
)
@@ -58,18 +54,21 @@ func TestMultiNodeRouting(t *testing.T) {
c1.Stop()
c2.Stop()
// ensure that room is closed
rc := redisClient()
ctx := context.Background()
withTimeout(t, "room should be closed", func() bool {
if rc.HGet(ctx, service.RoomsKey, testRoom).Err() == nil {
return false
}
return true
})
assert.Equal(t, redis.Nil, rc.HGet(ctx, routing.NodeRoomKey, testRoom).Err())
assert.Equal(t, redis.Nil, rc.HGet(ctx, service.RoomIdMap, testRoom).Err())
// TODO: delete room explicitly and ensure it's closed
//
//// ensure that room is closed
//
//rc := redisClient()
//ctx := context.Background()
//withTimeout(t, "room should be closed", func() bool {
// if rc.HGet(ctx, service.RoomsKey, testRoom).Err() == nil {
// return false
// }
// return true
//})
//
//assert.Equal(t, redis.Nil, rc.HGet(ctx, routing.NodeRoomKey, testRoom).Err())
//assert.Equal(t, redis.Nil, rc.HGet(ctx, service.RoomIdMap, testRoom).Err())
}
func TestConnectWithoutCreation(t *testing.T) {