aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/live/live-socket-messages.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-08 10:18:40 +0200
committerChocobozzz <me@florianbigard.com>2021-07-20 15:27:17 +0200
commit4f2199144e428c16460750305f737b890c1ac322 (patch)
treea19c5c0f254ab0b32d6c8838af33a1ba260e4877 /server/tests/api/live/live-socket-messages.ts
parent2c27e70471120c92e0bc8c8114141fbb31ff98ac (diff)
downloadPeerTube-4f2199144e428c16460750305f737b890c1ac322.tar.gz
PeerTube-4f2199144e428c16460750305f737b890c1ac322.tar.zst
PeerTube-4f2199144e428c16460750305f737b890c1ac322.zip
Introduce live command
Diffstat (limited to 'server/tests/api/live/live-socket-messages.ts')
-rw-r--r--server/tests/api/live/live-socket-messages.ts19
1 files changed, 8 insertions, 11 deletions
diff --git a/server/tests/api/live/live-socket-messages.ts b/server/tests/api/live/live-socket-messages.ts
index 20fec16a9..73a300384 100644
--- a/server/tests/api/live/live-socket-messages.ts
+++ b/server/tests/api/live/live-socket-messages.ts
@@ -5,11 +5,9 @@ import * as chai from 'chai'
5import { VideoPrivacy, VideoState } from '@shared/models' 5import { VideoPrivacy, VideoState } from '@shared/models'
6import { 6import {
7 cleanupTests, 7 cleanupTests,
8 createLive,
9 doubleFollow, 8 doubleFollow,
10 flushAndRunMultipleServers, 9 flushAndRunMultipleServers,
11 getVideoIdFromUUID, 10 getVideoIdFromUUID,
12 sendRTMPStreamInVideo,
13 ServerInfo, 11 ServerInfo,
14 setAccessTokensToServers, 12 setAccessTokensToServers,
15 setDefaultVideoChannel, 13 setDefaultVideoChannel,
@@ -17,7 +15,6 @@ import {
17 viewVideo, 15 viewVideo,
18 wait, 16 wait,
19 waitJobs, 17 waitJobs,
20 waitUntilLiveEnded,
21 waitUntilLivePublishedOnAllServers 18 waitUntilLivePublishedOnAllServers
22} from '../../../../shared/extra-utils' 19} from '../../../../shared/extra-utils'
23 20
@@ -60,8 +57,8 @@ describe('Test live', function () {
60 privacy: VideoPrivacy.PUBLIC 57 privacy: VideoPrivacy.PUBLIC
61 } 58 }
62 59
63 const res = await createLive(servers[0].url, servers[0].accessToken, liveAttributes) 60 const { uuid } = await servers[0].liveCommand.createLive({ fields: liveAttributes })
64 return res.body.video.uuid 61 return uuid
65 } 62 }
66 63
67 it('Should correctly send a message when the live starts and ends', async function () { 64 it('Should correctly send a message when the live starts and ends', async function () {
@@ -89,7 +86,7 @@ describe('Test live', function () {
89 remoteSocket.emit('subscribe', { videoId }) 86 remoteSocket.emit('subscribe', { videoId })
90 } 87 }
91 88
92 const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID) 89 const ffmpegCommand = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
93 90
94 await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID) 91 await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID)
95 await waitJobs(servers) 92 await waitJobs(servers)
@@ -99,10 +96,10 @@ describe('Test live', function () {
99 expect(stateChanges[stateChanges.length - 1]).to.equal(VideoState.PUBLISHED) 96 expect(stateChanges[stateChanges.length - 1]).to.equal(VideoState.PUBLISHED)
100 } 97 }
101 98
102 await stopFfmpeg(command) 99 await stopFfmpeg(ffmpegCommand)
103 100
104 for (const server of servers) { 101 for (const server of servers) {
105 await waitUntilLiveEnded(server.url, server.accessToken, liveVideoUUID) 102 await server.liveCommand.waitUntilLiveEnded({ videoId: liveVideoUUID })
106 } 103 }
107 await waitJobs(servers) 104 await waitJobs(servers)
108 105
@@ -137,7 +134,7 @@ describe('Test live', function () {
137 remoteSocket.emit('subscribe', { videoId }) 134 remoteSocket.emit('subscribe', { videoId })
138 } 135 }
139 136
140 const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID) 137 const ffmpegCommand = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
141 138
142 await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID) 139 await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID)
143 await waitJobs(servers) 140 await waitJobs(servers)
@@ -155,7 +152,7 @@ describe('Test live', function () {
155 expect(localLastVideoViews).to.equal(2) 152 expect(localLastVideoViews).to.equal(2)
156 expect(remoteLastVideoViews).to.equal(2) 153 expect(remoteLastVideoViews).to.equal(2)
157 154
158 await stopFfmpeg(command) 155 await stopFfmpeg(ffmpegCommand)
159 }) 156 })
160 157
161 it('Should not receive a notification after unsubscribe', async function () { 158 it('Should not receive a notification after unsubscribe', async function () {
@@ -172,7 +169,7 @@ describe('Test live', function () {
172 socket.on('state-change', data => stateChanges.push(data.state)) 169 socket.on('state-change', data => stateChanges.push(data.state))
173 socket.emit('subscribe', { videoId }) 170 socket.emit('subscribe', { videoId })
174 171
175 const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID) 172 const command = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
176 173
177 await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID) 174 await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID)
178 await waitJobs(servers) 175 await waitJobs(servers)