aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-12-09 15:00:02 +0100
committerChocobozzz <me@florianbigard.com>2020-12-09 16:31:42 +0100
commita800dbf345e856ab790e7b3ab9a97e8c5dfa0a32 (patch)
treeb7f814ee0dae543a6f2937b9ab5154cfeff3e986 /server/tests
parent5cac83a78d6ba5212755fafce2ed25f7c74b04e5 (diff)
downloadPeerTube-a800dbf345e856ab790e7b3ab9a97e8c5dfa0a32.tar.gz
PeerTube-a800dbf345e856ab790e7b3ab9a97e8c5dfa0a32.tar.zst
PeerTube-a800dbf345e856ab790e7b3ab9a97e8c5dfa0a32.zip
Live views update
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/api/live/live.ts51
1 files changed, 50 insertions, 1 deletions
diff --git a/server/tests/api/live/live.ts b/server/tests/api/live/live.ts
index e728fcce0..6d504f742 100644
--- a/server/tests/api/live/live.ts
+++ b/server/tests/api/live/live.ts
@@ -328,7 +328,7 @@ describe('Test live', function () {
328 await checkResolutionsInMasterPlaylist(hlsPlaylist.playlistUrl, resolutions) 328 await checkResolutionsInMasterPlaylist(hlsPlaylist.playlistUrl, resolutions)
329 329
330 for (let i = 0; i < resolutions.length; i++) { 330 for (let i = 0; i < resolutions.length; i++) {
331 const segmentNum = 2 331 const segmentNum = 3
332 const segmentName = `${i}-00000${segmentNum}.ts` 332 const segmentName = `${i}-00000${segmentNum}.ts`
333 await waitUntilLiveSegmentGeneration(servers[0], video.uuid, i, segmentNum) 333 await waitUntilLiveSegmentGeneration(servers[0], video.uuid, i, segmentNum)
334 334
@@ -608,6 +608,55 @@ describe('Test live', function () {
608 } 608 }
609 }) 609 })
610 610
611 it('Should correctly send views change notification', async function () {
612 this.timeout(60000)
613
614 let localLastVideoViews = 0
615 let remoteLastVideoViews = 0
616
617 const liveVideoUUID = await createLiveWrapper()
618 await waitJobs(servers)
619
620 {
621 const videoId = await getVideoIdFromUUID(servers[0].url, liveVideoUUID)
622
623 const localSocket = getLiveNotificationSocket(servers[0].url)
624 localSocket.on('views-change', data => { localLastVideoViews = data.views })
625 localSocket.emit('subscribe', { videoId })
626 }
627
628 {
629 const videoId = await getVideoIdFromUUID(servers[1].url, liveVideoUUID)
630
631 const remoteSocket = getLiveNotificationSocket(servers[1].url)
632 remoteSocket.on('views-change', data => { remoteLastVideoViews = data.views })
633 remoteSocket.emit('subscribe', { videoId })
634 }
635
636 const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID)
637
638 for (const server of servers) {
639 await waitUntilLivePublished(server.url, server.accessToken, liveVideoUUID)
640 }
641
642 await waitJobs(servers)
643
644 expect(localLastVideoViews).to.equal(0)
645 expect(remoteLastVideoViews).to.equal(0)
646
647 await viewVideo(servers[0].url, liveVideoUUID)
648 await viewVideo(servers[1].url, liveVideoUUID)
649
650 await waitJobs(servers)
651 await wait(5000)
652 await waitJobs(servers)
653
654 expect(localLastVideoViews).to.equal(2)
655 expect(remoteLastVideoViews).to.equal(2)
656
657 await stopFfmpeg(command)
658 })
659
611 it('Should not receive a notification after unsubscribe', async function () { 660 it('Should not receive a notification after unsubscribe', async function () {
612 this.timeout(60000) 661 this.timeout(60000)
613 662