mirror of
https://github.com/livekit/livekit.git
synced 2026-10-22 15:22:30 +00:00
integration test around receive before publish
This commit is contained in:
1 parent
88e247d95a
commit
d117cce37b
6 files changed
+102
-11
No files matched your search
@@ -104,6 +104,7 @@ func waitForServerToStart(s *service.LivekitServer) {
|
||||
}
|
||||
|
||||
func withTimeout(t *testing.T, description string, f func() bool) bool {
|
||||
logger.Infow(description)
|
||||
ctx, _ := context.WithTimeout(context.Background(), connectTimeout)
|
||||
for {
|
||||
select {
|
||||
|
||||
+21
-6
@@ -94,19 +94,34 @@ func TestConnectWithoutCreation(t *testing.T) {
|
||||
}
|
||||
|
||||
// testing multiple scenarios rooms
|
||||
func TestMultinodeScenarios(t *testing.T) {
|
||||
func TestMultinodePublishingUponJoining(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.SkipNow()
|
||||
return
|
||||
}
|
||||
|
||||
logger.Infow("---Starting TestScenarios---")
|
||||
defer logger.Infow("---Finishing TestScenarios---")
|
||||
logger.Infow("---Starting TestMultinodePublishingUponJoining---")
|
||||
defer logger.Infow("---Finishing TestMultinodePublishingUponJoining---")
|
||||
|
||||
s1, s2 := setupMultiNodeTest()
|
||||
|
||||
scenarioPublishingUponJoining(t, defaultServerPort, secondServerPort)
|
||||
|
||||
defer s1.Stop()
|
||||
defer s2.Stop()
|
||||
|
||||
scenarioPublishingUponJoining(t, defaultServerPort, secondServerPort)
|
||||
}
|
||||
|
||||
func TestMultinodeReceiveBeforePublish(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.SkipNow()
|
||||
return
|
||||
}
|
||||
|
||||
logger.Infow("---Starting TestMultinodeReceiveBeforePublish---")
|
||||
defer logger.Infow("---Finishing TestMultinodeReceiveBeforePublish---")
|
||||
|
||||
s1, s2 := setupMultiNodeTest()
|
||||
defer s1.Stop()
|
||||
defer s2.Stop()
|
||||
|
||||
scenarioReceiveBeforePublish(t)
|
||||
}
|
||||
+28
-1
@@ -69,7 +69,6 @@ func scenarioPublishingUponJoining(t *testing.T, ports ...int) {
|
||||
writers = publishTracksForClients(t, c2)
|
||||
defer stopWriters(writers...)
|
||||
|
||||
logger.Infow("waiting for reconnected c2 tracks to publish")
|
||||
success = withTimeout(t, "new c2 tracks should be published again", func() bool {
|
||||
tracks := c3.SubscribedTracks()
|
||||
if len(tracks[c2.ID()]) != 2 {
|
||||
@@ -85,6 +84,34 @@ func scenarioPublishingUponJoining(t *testing.T, ports ...int) {
|
||||
}
|
||||
}
|
||||
|
||||
func scenarioReceiveBeforePublish(t *testing.T) {
|
||||
c1 := createRTCClient("rbp_1", defaultServerPort)
|
||||
c2 := createRTCClient("rbp_2", defaultServerPort)
|
||||
|
||||
waitUntilConnected(t, c1, c2)
|
||||
defer stopClients(c1, c2)
|
||||
|
||||
// c1 publishes
|
||||
writers := publishTracksForClients(t, c1)
|
||||
defer stopWriters(writers...)
|
||||
|
||||
// c2 should see some bytes flowing through
|
||||
success := withTimeout(t, "waiting to receive bytes on c2", func() bool {
|
||||
return c2.BytesReceived() > 20
|
||||
})
|
||||
if !success {
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
// now publish on C2
|
||||
writers = publishTracksForClients(t, c2)
|
||||
defer stopWriters(writers...)
|
||||
|
||||
success = withTimeout(t, "waiting to receive c2 tracks on c1", func() bool {
|
||||
return len(c1.SubscribedTracks()[c2.ID()]) == 2
|
||||
})
|
||||
}
|
||||
|
||||
// websocket reconnects
|
||||
func scenarioWSReconnect(t *testing.T) {
|
||||
c1 := createRTCClient("wsr_1", defaultServerPort)
|
||||
|
||||
Reference in new issue
Block a user