]>
Commit | Line | Data |
---|---|---|
68e70a74 C |
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | ||
86347717 | 3 | import { expect } from 'chai' |
68e70a74 | 4 | import { FfmpegCommand } from 'fluent-ffmpeg' |
4ec52d04 | 5 | import { checkLiveCleanup } from '@server/tests/shared' |
c55e3d72 | 6 | import { wait } from '@shared/core-utils' |
26e3e98f | 7 | import { HttpStatusCode, LiveVideoCreate, LiveVideoError, VideoPrivacy, VideoState } from '@shared/models' |
68e70a74 | 8 | import { |
68e70a74 | 9 | cleanupTests, |
65e6e260 | 10 | ConfigCommand, |
254d3579 | 11 | createMultipleServers, |
4c7e60bc | 12 | doubleFollow, |
4ec52d04 | 13 | findExternalSavedVideo, |
254d3579 | 14 | PeerTubeServer, |
68e70a74 C |
15 | setAccessTokensToServers, |
16 | setDefaultVideoChannel, | |
17 | stopFfmpeg, | |
18 | testFfmpegStreamError, | |
0305db28 JB |
19 | waitJobs, |
20 | waitUntilLivePublishedOnAllServers, | |
4ec52d04 C |
21 | waitUntilLiveReplacedByReplayOnAllServers, |
22 | waitUntilLiveWaitingOnAllServers | |
bf54587a | 23 | } from '@shared/server-commands' |
68e70a74 | 24 | |
68e70a74 | 25 | describe('Save replay setting', function () { |
254d3579 | 26 | let servers: PeerTubeServer[] = [] |
68e70a74 C |
27 | let liveVideoUUID: string |
28 | let ffmpegCommand: FfmpegCommand | |
29 | ||
05a60d85 | 30 | async function createLiveWrapper (options: { permanent: boolean, replay: boolean, replaySettings?: { privacy: VideoPrivacy } }) { |
68e70a74 C |
31 | if (liveVideoUUID) { |
32 | try { | |
89d241a7 | 33 | await servers[0].videos.remove({ id: liveVideoUUID }) |
68e70a74 C |
34 | await waitJobs(servers) |
35 | } catch {} | |
36 | } | |
37 | ||
38 | const attributes: LiveVideoCreate = { | |
89d241a7 | 39 | channelId: servers[0].store.channel.id, |
68e70a74 C |
40 | privacy: VideoPrivacy.PUBLIC, |
41 | name: 'my super live', | |
4ec52d04 | 42 | saveReplay: options.replay, |
05a60d85 | 43 | replaySettings: options.replaySettings, |
4ec52d04 | 44 | permanentLive: options.permanent |
68e70a74 C |
45 | } |
46 | ||
89d241a7 | 47 | const { uuid } = await servers[0].live.create({ fields: attributes }) |
4f219914 | 48 | return uuid |
68e70a74 C |
49 | } |
50 | ||
05a60d85 | 51 | async function publishLive (options: { permanent: boolean, replay: boolean, replaySettings?: { privacy: VideoPrivacy } }) { |
98ebfa39 C |
52 | liveVideoUUID = await createLiveWrapper(options) |
53 | ||
54 | const ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) | |
55 | await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID) | |
56 | ||
57 | const liveDetails = await servers[0].videos.get({ id: liveVideoUUID }) | |
58 | ||
59 | await waitJobs(servers) | |
60 | await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200) | |
61 | ||
62 | return { ffmpegCommand, liveDetails } | |
63 | } | |
64 | ||
05a60d85 | 65 | async function publishLiveAndDelete (options: { permanent: boolean, replay: boolean, replaySettings?: { privacy: VideoPrivacy } }) { |
98ebfa39 C |
66 | const { ffmpegCommand, liveDetails } = await publishLive(options) |
67 | ||
68 | await Promise.all([ | |
69 | servers[0].videos.remove({ id: liveVideoUUID }), | |
70 | testFfmpegStreamError(ffmpegCommand, true) | |
71 | ]) | |
72 | ||
73 | await waitJobs(servers) | |
74 | await wait(5000) | |
75 | await waitJobs(servers) | |
76 | ||
77 | return { liveDetails } | |
78 | } | |
79 | ||
05a60d85 | 80 | async function publishLiveAndBlacklist (options: { permanent: boolean, replay: boolean, replaySettings?: { privacy: VideoPrivacy } }) { |
98ebfa39 C |
81 | const { ffmpegCommand, liveDetails } = await publishLive(options) |
82 | ||
83 | await Promise.all([ | |
84 | servers[0].blacklist.add({ videoId: liveVideoUUID, reason: 'bad live', unfederate: true }), | |
85 | testFfmpegStreamError(ffmpegCommand, true) | |
86 | ]) | |
87 | ||
88 | await waitJobs(servers) | |
89 | await wait(5000) | |
90 | await waitJobs(servers) | |
91 | ||
92 | return { liveDetails } | |
93 | } | |
94 | ||
d23dd9fb | 95 | async function checkVideosExist (videoId: string, existsInList: boolean, expectedStatus?: number) { |
68e70a74 C |
96 | for (const server of servers) { |
97 | const length = existsInList ? 1 : 0 | |
98 | ||
89d241a7 | 99 | const { data, total } = await server.videos.list() |
d23dd9fb C |
100 | expect(data).to.have.lengthOf(length) |
101 | expect(total).to.equal(length) | |
68e70a74 | 102 | |
d23dd9fb | 103 | if (expectedStatus) { |
89d241a7 | 104 | await server.videos.get({ id: videoId, expectedStatus }) |
68e70a74 C |
105 | } |
106 | } | |
107 | } | |
108 | ||
109 | async function checkVideoState (videoId: string, state: VideoState) { | |
110 | for (const server of servers) { | |
89d241a7 | 111 | const video = await server.videos.get({ id: videoId }) |
d23dd9fb | 112 | expect(video.state.id).to.equal(state) |
68e70a74 C |
113 | } |
114 | } | |
115 | ||
05a60d85 W |
116 | async function checkVideoPrivacy (videoId: string, privacy: VideoPrivacy) { |
117 | for (const server of servers) { | |
118 | const video = await server.videos.get({ id: videoId }) | |
119 | expect(video.privacy.id).to.equal(privacy) | |
120 | } | |
121 | } | |
122 | ||
68e70a74 C |
123 | before(async function () { |
124 | this.timeout(120000) | |
125 | ||
254d3579 | 126 | servers = await createMultipleServers(2) |
68e70a74 C |
127 | |
128 | // Get the access tokens | |
129 | await setAccessTokensToServers(servers) | |
130 | await setDefaultVideoChannel(servers) | |
131 | ||
132 | // Server 1 and server 2 follow each other | |
133 | await doubleFollow(servers[0], servers[1]) | |
134 | ||
89d241a7 | 135 | await servers[0].config.updateCustomSubConfig({ |
65e6e260 C |
136 | newConfig: { |
137 | live: { | |
138 | enabled: true, | |
139 | allowReplay: true, | |
140 | maxDuration: -1, | |
141 | transcoding: { | |
142 | enabled: false, | |
143 | resolutions: ConfigCommand.getCustomConfigResolutions(true) | |
144 | } | |
68e70a74 C |
145 | } |
146 | } | |
147 | }) | |
148 | }) | |
149 | ||
150 | describe('With save replay disabled', function () { | |
26e3e98f C |
151 | let sessionStartDateMin: Date |
152 | let sessionStartDateMax: Date | |
153 | let sessionEndDateMin: Date | |
68e70a74 | 154 | |
68e70a74 C |
155 | it('Should correctly create and federate the "waiting for stream" live', async function () { |
156 | this.timeout(20000) | |
157 | ||
4ec52d04 | 158 | liveVideoUUID = await createLiveWrapper({ permanent: false, replay: false }) |
68e70a74 C |
159 | |
160 | await waitJobs(servers) | |
161 | ||
f2eb23cd | 162 | await checkVideosExist(liveVideoUUID, false, HttpStatusCode.OK_200) |
68e70a74 C |
163 | await checkVideoState(liveVideoUUID, VideoState.WAITING_FOR_LIVE) |
164 | }) | |
165 | ||
166 | it('Should correctly have updated the live and federated it when streaming in the live', async function () { | |
fae6e4da | 167 | this.timeout(30000) |
68e70a74 | 168 | |
89d241a7 | 169 | ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) |
fae6e4da | 170 | |
26e3e98f | 171 | sessionStartDateMin = new Date() |
0305db28 | 172 | await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID) |
26e3e98f | 173 | sessionStartDateMax = new Date() |
68e70a74 C |
174 | |
175 | await waitJobs(servers) | |
176 | ||
f2eb23cd | 177 | await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200) |
68e70a74 C |
178 | await checkVideoState(liveVideoUUID, VideoState.PUBLISHED) |
179 | }) | |
180 | ||
181 | it('Should correctly delete the video files after the stream ended', async function () { | |
59fd824c | 182 | this.timeout(40000) |
68e70a74 | 183 | |
26e3e98f | 184 | sessionEndDateMin = new Date() |
68e70a74 C |
185 | await stopFfmpeg(ffmpegCommand) |
186 | ||
fae6e4da | 187 | for (const server of servers) { |
89d241a7 | 188 | await server.live.waitUntilEnded({ videoId: liveVideoUUID }) |
fae6e4da | 189 | } |
68e70a74 C |
190 | await waitJobs(servers) |
191 | ||
192 | // Live still exist, but cannot be played anymore | |
f2eb23cd | 193 | await checkVideosExist(liveVideoUUID, false, HttpStatusCode.OK_200) |
68e70a74 C |
194 | await checkVideoState(liveVideoUUID, VideoState.LIVE_ENDED) |
195 | ||
196 | // No resolutions saved since we did not save replay | |
aa887096 | 197 | await checkLiveCleanup({ server: servers[0], videoUUID: liveVideoUUID, permanent: false }) |
68e70a74 C |
198 | }) |
199 | ||
26e3e98f C |
200 | it('Should have appropriate ended session', async function () { |
201 | const { data, total } = await servers[0].live.listSessions({ videoId: liveVideoUUID }) | |
202 | expect(total).to.equal(1) | |
203 | expect(data).to.have.lengthOf(1) | |
204 | ||
205 | const session = data[0] | |
206 | ||
207 | const startDate = new Date(session.startDate) | |
208 | expect(startDate).to.be.above(sessionStartDateMin) | |
209 | expect(startDate).to.be.below(sessionStartDateMax) | |
210 | ||
211 | expect(session.endDate).to.exist | |
212 | expect(new Date(session.endDate)).to.be.above(sessionEndDateMin) | |
213 | ||
c8fa571f | 214 | expect(session.saveReplay).to.be.false |
26e3e98f C |
215 | expect(session.error).to.not.exist |
216 | expect(session.replayVideo).to.not.exist | |
217 | }) | |
218 | ||
68e70a74 C |
219 | it('Should correctly terminate the stream on blacklist and delete the live', async function () { |
220 | this.timeout(40000) | |
221 | ||
98ebfa39 | 222 | await publishLiveAndBlacklist({ permanent: false, replay: false }) |
68e70a74 C |
223 | |
224 | await checkVideosExist(liveVideoUUID, false) | |
225 | ||
89d241a7 C |
226 | await servers[0].videos.get({ id: liveVideoUUID, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) |
227 | await servers[1].videos.get({ id: liveVideoUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) | |
68e70a74 | 228 | |
94d721ef C |
229 | await wait(5000) |
230 | await waitJobs(servers) | |
aa887096 | 231 | await checkLiveCleanup({ server: servers[0], videoUUID: liveVideoUUID, permanent: false }) |
68e70a74 C |
232 | }) |
233 | ||
26e3e98f C |
234 | it('Should have blacklisted session error', async function () { |
235 | const session = await servers[0].live.findLatestSession({ videoId: liveVideoUUID }) | |
236 | expect(session.startDate).to.exist | |
237 | expect(session.endDate).to.exist | |
238 | ||
239 | expect(session.error).to.equal(LiveVideoError.BLACKLISTED) | |
240 | expect(session.replayVideo).to.not.exist | |
241 | }) | |
242 | ||
68e70a74 C |
243 | it('Should correctly terminate the stream on delete and delete the video', async function () { |
244 | this.timeout(40000) | |
245 | ||
98ebfa39 | 246 | await publishLiveAndDelete({ permanent: false, replay: false }) |
68e70a74 | 247 | |
f2eb23cd | 248 | await checkVideosExist(liveVideoUUID, false, HttpStatusCode.NOT_FOUND_404) |
aa887096 | 249 | await checkLiveCleanup({ server: servers[0], videoUUID: liveVideoUUID, permanent: false }) |
68e70a74 C |
250 | }) |
251 | }) | |
252 | ||
4ec52d04 | 253 | describe('With save replay enabled on non permanent live', function () { |
68e70a74 C |
254 | |
255 | it('Should correctly create and federate the "waiting for stream" live', async function () { | |
256 | this.timeout(20000) | |
257 | ||
05a60d85 | 258 | liveVideoUUID = await createLiveWrapper({ permanent: false, replay: true, replaySettings: { privacy: VideoPrivacy.UNLISTED } }) |
68e70a74 C |
259 | |
260 | await waitJobs(servers) | |
261 | ||
f2eb23cd | 262 | await checkVideosExist(liveVideoUUID, false, HttpStatusCode.OK_200) |
68e70a74 | 263 | await checkVideoState(liveVideoUUID, VideoState.WAITING_FOR_LIVE) |
05a60d85 | 264 | await checkVideoPrivacy(liveVideoUUID, VideoPrivacy.PUBLIC) |
68e70a74 C |
265 | }) |
266 | ||
267 | it('Should correctly have updated the live and federated it when streaming in the live', async function () { | |
268 | this.timeout(20000) | |
269 | ||
89d241a7 | 270 | ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) |
0305db28 | 271 | await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID) |
68e70a74 C |
272 | |
273 | await waitJobs(servers) | |
274 | ||
f2eb23cd | 275 | await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200) |
68e70a74 | 276 | await checkVideoState(liveVideoUUID, VideoState.PUBLISHED) |
05a60d85 | 277 | await checkVideoPrivacy(liveVideoUUID, VideoPrivacy.PUBLIC) |
68e70a74 C |
278 | }) |
279 | ||
280 | it('Should correctly have saved the live and federated it after the streaming', async function () { | |
281 | this.timeout(30000) | |
282 | ||
c8fa571f C |
283 | const session = await servers[0].live.findLatestSession({ videoId: liveVideoUUID }) |
284 | expect(session.endDate).to.not.exist | |
285 | expect(session.endingProcessed).to.be.false | |
286 | expect(session.saveReplay).to.be.true | |
05a60d85 W |
287 | expect(session.replaySettings).to.exist |
288 | expect(session.replaySettings.privacy).to.equal(VideoPrivacy.UNLISTED) | |
c8fa571f | 289 | |
68e70a74 C |
290 | await stopFfmpeg(ffmpegCommand) |
291 | ||
4ec52d04 | 292 | await waitUntilLiveReplacedByReplayOnAllServers(servers, liveVideoUUID) |
68e70a74 C |
293 | await waitJobs(servers) |
294 | ||
295 | // Live has been transcoded | |
05a60d85 | 296 | await checkVideosExist(liveVideoUUID, false, HttpStatusCode.OK_200) |
68e70a74 | 297 | await checkVideoState(liveVideoUUID, VideoState.PUBLISHED) |
05a60d85 | 298 | await checkVideoPrivacy(liveVideoUUID, VideoPrivacy.UNLISTED) |
68e70a74 C |
299 | }) |
300 | ||
26e3e98f C |
301 | it('Should find the replay live session', async function () { |
302 | const session = await servers[0].live.getReplaySession({ videoId: liveVideoUUID }) | |
303 | ||
304 | expect(session).to.exist | |
305 | ||
306 | expect(session.startDate).to.exist | |
307 | expect(session.endDate).to.exist | |
308 | ||
309 | expect(session.error).to.not.exist | |
c8fa571f C |
310 | expect(session.saveReplay).to.be.true |
311 | expect(session.endingProcessed).to.be.true | |
05a60d85 W |
312 | expect(session.replaySettings).to.exist |
313 | expect(session.replaySettings.privacy).to.equal(VideoPrivacy.UNLISTED) | |
26e3e98f C |
314 | |
315 | expect(session.replayVideo).to.exist | |
316 | expect(session.replayVideo.id).to.exist | |
317 | expect(session.replayVideo.shortUUID).to.exist | |
318 | expect(session.replayVideo.uuid).to.equal(liveVideoUUID) | |
319 | }) | |
320 | ||
68e70a74 C |
321 | it('Should update the saved live and correctly federate the updated attributes', async function () { |
322 | this.timeout(30000) | |
323 | ||
05a60d85 | 324 | await servers[0].videos.update({ id: liveVideoUUID, attributes: { name: 'video updated', privacy: VideoPrivacy.PUBLIC } }) |
68e70a74 C |
325 | await waitJobs(servers) |
326 | ||
327 | for (const server of servers) { | |
89d241a7 | 328 | const video = await server.videos.get({ id: liveVideoUUID }) |
d23dd9fb C |
329 | expect(video.name).to.equal('video updated') |
330 | expect(video.isLive).to.be.false | |
05a60d85 | 331 | expect(video.privacy.id).to.equal(VideoPrivacy.PUBLIC) |
68e70a74 C |
332 | } |
333 | }) | |
334 | ||
335 | it('Should have cleaned up the live files', async function () { | |
aa887096 | 336 | await checkLiveCleanup({ server: servers[0], videoUUID: liveVideoUUID, permanent: false, savedResolutions: [ 720 ] }) |
68e70a74 C |
337 | }) |
338 | ||
339 | it('Should correctly terminate the stream on blacklist and blacklist the saved replay video', async function () { | |
6504b3bf | 340 | this.timeout(120000) |
68e70a74 | 341 | |
05a60d85 | 342 | await publishLiveAndBlacklist({ permanent: false, replay: true, replaySettings: { privacy: VideoPrivacy.PUBLIC } }) |
68e70a74 C |
343 | |
344 | await checkVideosExist(liveVideoUUID, false) | |
345 | ||
89d241a7 C |
346 | await servers[0].videos.get({ id: liveVideoUUID, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) |
347 | await servers[1].videos.get({ id: liveVideoUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) | |
68e70a74 | 348 | |
94d721ef C |
349 | await wait(5000) |
350 | await waitJobs(servers) | |
aa887096 | 351 | await checkLiveCleanup({ server: servers[0], videoUUID: liveVideoUUID, permanent: false, savedResolutions: [ 720 ] }) |
68e70a74 C |
352 | }) |
353 | ||
354 | it('Should correctly terminate the stream on delete and delete the video', async function () { | |
355 | this.timeout(40000) | |
356 | ||
05a60d85 | 357 | await publishLiveAndDelete({ permanent: false, replay: true, replaySettings: { privacy: VideoPrivacy.PUBLIC } }) |
68e70a74 | 358 | |
f2eb23cd | 359 | await checkVideosExist(liveVideoUUID, false, HttpStatusCode.NOT_FOUND_404) |
aa887096 | 360 | await checkLiveCleanup({ server: servers[0], videoUUID: liveVideoUUID, permanent: false }) |
4ec52d04 C |
361 | }) |
362 | }) | |
363 | ||
364 | describe('With save replay enabled on permanent live', function () { | |
365 | let lastReplayUUID: string | |
366 | ||
05a60d85 | 367 | describe('With a first live and its replay', function () { |
4ec52d04 | 368 | |
05a60d85 W |
369 | it('Should correctly create and federate the "waiting for stream" live', async function () { |
370 | this.timeout(20000) | |
4ec52d04 | 371 | |
05a60d85 | 372 | liveVideoUUID = await createLiveWrapper({ permanent: true, replay: true, replaySettings: { privacy: VideoPrivacy.UNLISTED } }) |
4ec52d04 | 373 | |
05a60d85 | 374 | await waitJobs(servers) |
4ec52d04 | 375 | |
05a60d85 W |
376 | await checkVideosExist(liveVideoUUID, false, HttpStatusCode.OK_200) |
377 | await checkVideoState(liveVideoUUID, VideoState.WAITING_FOR_LIVE) | |
378 | await checkVideoPrivacy(liveVideoUUID, VideoPrivacy.PUBLIC) | |
379 | }) | |
4ec52d04 | 380 | |
05a60d85 W |
381 | it('Should correctly have updated the live and federated it when streaming in the live', async function () { |
382 | this.timeout(20000) | |
4ec52d04 | 383 | |
05a60d85 W |
384 | ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) |
385 | await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID) | |
4ec52d04 | 386 | |
05a60d85 | 387 | await waitJobs(servers) |
4ec52d04 | 388 | |
05a60d85 W |
389 | await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200) |
390 | await checkVideoState(liveVideoUUID, VideoState.PUBLISHED) | |
391 | await checkVideoPrivacy(liveVideoUUID, VideoPrivacy.PUBLIC) | |
392 | }) | |
4ec52d04 | 393 | |
05a60d85 W |
394 | it('Should correctly have saved the live and federated it after the streaming', async function () { |
395 | this.timeout(30000) | |
4ec52d04 | 396 | |
05a60d85 | 397 | const liveDetails = await servers[0].videos.get({ id: liveVideoUUID }) |
4ec52d04 | 398 | |
05a60d85 | 399 | await stopFfmpeg(ffmpegCommand) |
4ec52d04 | 400 | |
05a60d85 W |
401 | await waitUntilLiveWaitingOnAllServers(servers, liveVideoUUID) |
402 | await waitJobs(servers) | |
4ec52d04 | 403 | |
05a60d85 W |
404 | const video = await findExternalSavedVideo(servers[0], liveDetails) |
405 | expect(video).to.exist | |
4ec52d04 | 406 | |
05a60d85 W |
407 | for (const server of servers) { |
408 | await server.videos.get({ id: video.uuid }) | |
409 | } | |
4ec52d04 | 410 | |
05a60d85 W |
411 | lastReplayUUID = video.uuid |
412 | }) | |
26e3e98f | 413 | |
05a60d85 W |
414 | it('Should have appropriate ended session and replay live session', async function () { |
415 | const { data, total } = await servers[0].live.listSessions({ videoId: liveVideoUUID }) | |
416 | expect(total).to.equal(1) | |
417 | expect(data).to.have.lengthOf(1) | |
26e3e98f | 418 | |
05a60d85 W |
419 | const sessionFromLive = data[0] |
420 | const sessionFromReplay = await servers[0].live.getReplaySession({ videoId: lastReplayUUID }) | |
26e3e98f | 421 | |
05a60d85 W |
422 | for (const session of [ sessionFromLive, sessionFromReplay ]) { |
423 | expect(session.startDate).to.exist | |
424 | expect(session.endDate).to.exist | |
26e3e98f | 425 | |
05a60d85 W |
426 | expect(session.replaySettings).to.exist |
427 | expect(session.replaySettings.privacy).to.equal(VideoPrivacy.UNLISTED) | |
26e3e98f | 428 | |
05a60d85 W |
429 | expect(session.error).to.not.exist |
430 | ||
431 | expect(session.replayVideo).to.exist | |
432 | expect(session.replayVideo.id).to.exist | |
433 | expect(session.replayVideo.shortUUID).to.exist | |
434 | expect(session.replayVideo.uuid).to.equal(lastReplayUUID) | |
435 | } | |
436 | }) | |
437 | ||
438 | it('Should have the first live replay with correct settings', async function () { | |
439 | await checkVideosExist(lastReplayUUID, false, HttpStatusCode.OK_200) | |
440 | await checkVideoState(lastReplayUUID, VideoState.PUBLISHED) | |
441 | await checkVideoPrivacy(lastReplayUUID, VideoPrivacy.UNLISTED) | |
442 | }) | |
4ec52d04 C |
443 | }) |
444 | ||
05a60d85 W |
445 | describe('With a second live and its replay', function () { |
446 | it('Should update the replay settings', async function () { | |
447 | await servers[0].live.update( | |
448 | { videoId: liveVideoUUID, fields: { replaySettings: { privacy: VideoPrivacy.PUBLIC } } }) | |
449 | await waitJobs(servers) | |
450 | const live = await servers[0].live.get({ videoId: liveVideoUUID }) | |
4ec52d04 | 451 | |
05a60d85 W |
452 | expect(live.saveReplay).to.be.true |
453 | expect(live.replaySettings).to.exist | |
454 | expect(live.replaySettings.privacy).to.equal(VideoPrivacy.PUBLIC) | |
4ec52d04 | 455 | |
05a60d85 | 456 | }) |
4ec52d04 | 457 | |
05a60d85 W |
458 | it('Should correctly have updated the live and federated it when streaming in the live', async function () { |
459 | this.timeout(20000) | |
4ec52d04 | 460 | |
05a60d85 W |
461 | ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) |
462 | await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID) | |
4ec52d04 | 463 | |
05a60d85 | 464 | await waitJobs(servers) |
4ec52d04 | 465 | |
05a60d85 W |
466 | await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200) |
467 | await checkVideoState(liveVideoUUID, VideoState.PUBLISHED) | |
468 | await checkVideoPrivacy(liveVideoUUID, VideoPrivacy.PUBLIC) | |
469 | }) | |
4ec52d04 | 470 | |
05a60d85 W |
471 | it('Should correctly have saved the live and federated it after the streaming', async function () { |
472 | this.timeout(30000) | |
473 | const liveDetails = await servers[0].videos.get({ id: liveVideoUUID }) | |
4ec52d04 | 474 | |
05a60d85 | 475 | await stopFfmpeg(ffmpegCommand) |
4ec52d04 | 476 | |
05a60d85 W |
477 | await waitUntilLiveWaitingOnAllServers(servers, liveVideoUUID) |
478 | await waitJobs(servers) | |
479 | ||
480 | const video = await findExternalSavedVideo(servers[0], liveDetails) | |
481 | expect(video).to.exist | |
482 | ||
483 | for (const server of servers) { | |
484 | await server.videos.get({ id: video.uuid }) | |
485 | } | |
486 | ||
487 | lastReplayUUID = video.uuid | |
488 | }) | |
489 | ||
490 | it('Should have appropriate ended session and replay live session', async function () { | |
491 | const { data, total } = await servers[0].live.listSessions({ videoId: liveVideoUUID }) | |
492 | expect(total).to.equal(2) | |
493 | expect(data).to.have.lengthOf(2) | |
494 | ||
495 | const sessionFromLive = data[1] | |
496 | const sessionFromReplay = await servers[0].live.getReplaySession({ videoId: lastReplayUUID }) | |
497 | ||
498 | for (const session of [ sessionFromLive, sessionFromReplay ]) { | |
499 | expect(session.startDate).to.exist | |
500 | expect(session.endDate).to.exist | |
501 | ||
502 | expect(session.replaySettings).to.exist | |
503 | expect(session.replaySettings.privacy).to.equal(VideoPrivacy.PUBLIC) | |
504 | ||
505 | expect(session.error).to.not.exist | |
506 | ||
507 | expect(session.replayVideo).to.exist | |
508 | expect(session.replayVideo.id).to.exist | |
509 | expect(session.replayVideo.shortUUID).to.exist | |
510 | expect(session.replayVideo.uuid).to.equal(lastReplayUUID) | |
511 | } | |
512 | }) | |
513 | ||
514 | it('Should have the first live replay with correct settings', async function () { | |
515 | await checkVideosExist(lastReplayUUID, true, HttpStatusCode.OK_200) | |
516 | await checkVideoState(lastReplayUUID, VideoState.PUBLISHED) | |
517 | await checkVideoPrivacy(lastReplayUUID, VideoPrivacy.PUBLIC) | |
518 | }) | |
519 | ||
520 | it('Should have cleaned up the live files', async function () { | |
521 | await checkLiveCleanup({ server: servers[0], videoUUID: liveVideoUUID, permanent: false }) | |
522 | }) | |
523 | ||
524 | it('Should correctly terminate the stream on blacklist and blacklist the saved replay video', async function () { | |
525 | this.timeout(120000) | |
526 | ||
527 | await servers[0].videos.remove({ id: lastReplayUUID }) | |
528 | const { liveDetails } = await publishLiveAndBlacklist({ | |
529 | permanent: true, | |
530 | replay: true, | |
531 | replaySettings: { privacy: VideoPrivacy.PUBLIC } | |
532 | }) | |
533 | ||
534 | const replay = await findExternalSavedVideo(servers[0], liveDetails) | |
535 | expect(replay).to.exist | |
536 | ||
537 | for (const videoId of [ liveVideoUUID, replay.uuid ]) { | |
538 | await checkVideosExist(videoId, false) | |
539 | ||
540 | await servers[0].videos.get({ id: videoId, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) | |
541 | await servers[1].videos.get({ id: videoId, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) | |
542 | } | |
543 | ||
544 | await checkLiveCleanup({ server: servers[0], videoUUID: liveVideoUUID, permanent: false }) | |
545 | }) | |
546 | ||
547 | it('Should correctly terminate the stream on delete and not save the video', async function () { | |
548 | this.timeout(40000) | |
549 | ||
550 | const { liveDetails } = await publishLiveAndDelete({ | |
551 | permanent: true, | |
552 | replay: true, | |
553 | replaySettings: { privacy: VideoPrivacy.PUBLIC } | |
554 | }) | |
555 | ||
556 | const replay = await findExternalSavedVideo(servers[0], liveDetails) | |
557 | expect(replay).to.not.exist | |
558 | ||
559 | await checkVideosExist(liveVideoUUID, false, HttpStatusCode.NOT_FOUND_404) | |
560 | await checkLiveCleanup({ server: servers[0], videoUUID: liveVideoUUID, permanent: false }) | |
561 | }) | |
68e70a74 C |
562 | }) |
563 | }) | |
564 | ||
565 | after(async function () { | |
566 | await cleanupTests(servers) | |
567 | }) | |
568 | }) |