diff options
Diffstat (limited to 'server/tests/api/live')
-rw-r--r-- | server/tests/api/live/live-constraints.ts | 4 | ||||
-rw-r--r-- | server/tests/api/live/live-permanent.ts | 5 | ||||
-rw-r--r-- | server/tests/api/live/live-save-replay.ts | 155 | ||||
-rw-r--r-- | server/tests/api/live/live.ts | 4 |
4 files changed, 144 insertions, 24 deletions
diff --git a/server/tests/api/live/live-constraints.ts b/server/tests/api/live/live-constraints.ts index 909399836..b92dc7b89 100644 --- a/server/tests/api/live/live-constraints.ts +++ b/server/tests/api/live/live-constraints.ts | |||
@@ -14,7 +14,7 @@ import { | |||
14 | setDefaultVideoChannel, | 14 | setDefaultVideoChannel, |
15 | waitJobs | 15 | waitJobs |
16 | } from '@shared/server-commands' | 16 | } from '@shared/server-commands' |
17 | import { checkLiveCleanupAfterSave } from '../../shared' | 17 | import { checkLiveCleanup } from '../../shared' |
18 | 18 | ||
19 | const expect = chai.expect | 19 | const expect = chai.expect |
20 | 20 | ||
@@ -43,7 +43,7 @@ describe('Test live constraints', function () { | |||
43 | expect(video.duration).to.be.greaterThan(0) | 43 | expect(video.duration).to.be.greaterThan(0) |
44 | } | 44 | } |
45 | 45 | ||
46 | await checkLiveCleanupAfterSave(servers[0], videoId, resolutions) | 46 | await checkLiveCleanup(servers[0], videoId, resolutions) |
47 | } | 47 | } |
48 | 48 | ||
49 | async function waitUntilLivePublishedOnAllServers (videoId: string) { | 49 | async function waitUntilLivePublishedOnAllServers (videoId: string) { |
diff --git a/server/tests/api/live/live-permanent.ts b/server/tests/api/live/live-permanent.ts index 3e6fec453..a88d71dd9 100644 --- a/server/tests/api/live/live-permanent.ts +++ b/server/tests/api/live/live-permanent.ts | |||
@@ -121,7 +121,7 @@ describe('Permanent live', function () { | |||
121 | await waitJobs(servers) | 121 | await waitJobs(servers) |
122 | }) | 122 | }) |
123 | 123 | ||
124 | it('Should not have cleaned up this live', async function () { | 124 | it('Should have cleaned up this live', async function () { |
125 | this.timeout(40000) | 125 | this.timeout(40000) |
126 | 126 | ||
127 | await wait(5000) | 127 | await wait(5000) |
@@ -129,7 +129,8 @@ describe('Permanent live', function () { | |||
129 | 129 | ||
130 | for (const server of servers) { | 130 | for (const server of servers) { |
131 | const videoDetails = await server.videos.get({ id: videoUUID }) | 131 | const videoDetails = await server.videos.get({ id: videoUUID }) |
132 | expect(videoDetails.streamingPlaylists).to.have.lengthOf(1) | 132 | |
133 | expect(videoDetails.streamingPlaylists).to.have.lengthOf(0) | ||
133 | } | 134 | } |
134 | }) | 135 | }) |
135 | 136 | ||
diff --git a/server/tests/api/live/live-save-replay.ts b/server/tests/api/live/live-save-replay.ts index 95a342b01..ba68a4287 100644 --- a/server/tests/api/live/live-save-replay.ts +++ b/server/tests/api/live/live-save-replay.ts | |||
@@ -3,7 +3,7 @@ | |||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { FfmpegCommand } from 'fluent-ffmpeg' | 5 | import { FfmpegCommand } from 'fluent-ffmpeg' |
6 | import { checkLiveCleanupAfterSave } from '@server/tests/shared' | 6 | import { checkLiveCleanup } from '@server/tests/shared' |
7 | import { wait } from '@shared/core-utils' | 7 | import { wait } from '@shared/core-utils' |
8 | import { HttpStatusCode, LiveVideoCreate, VideoPrivacy, VideoState } from '@shared/models' | 8 | import { HttpStatusCode, LiveVideoCreate, VideoPrivacy, VideoState } from '@shared/models' |
9 | import { | 9 | import { |
@@ -11,6 +11,7 @@ import { | |||
11 | ConfigCommand, | 11 | ConfigCommand, |
12 | createMultipleServers, | 12 | createMultipleServers, |
13 | doubleFollow, | 13 | doubleFollow, |
14 | findExternalSavedVideo, | ||
14 | PeerTubeServer, | 15 | PeerTubeServer, |
15 | setAccessTokensToServers, | 16 | setAccessTokensToServers, |
16 | setDefaultVideoChannel, | 17 | setDefaultVideoChannel, |
@@ -18,7 +19,8 @@ import { | |||
18 | testFfmpegStreamError, | 19 | testFfmpegStreamError, |
19 | waitJobs, | 20 | waitJobs, |
20 | waitUntilLivePublishedOnAllServers, | 21 | waitUntilLivePublishedOnAllServers, |
21 | waitUntilLiveSavedOnAllServers | 22 | waitUntilLiveReplacedByReplayOnAllServers, |
23 | waitUntilLiveWaitingOnAllServers | ||
22 | } from '@shared/server-commands' | 24 | } from '@shared/server-commands' |
23 | 25 | ||
24 | const expect = chai.expect | 26 | const expect = chai.expect |
@@ -28,7 +30,7 @@ describe('Save replay setting', function () { | |||
28 | let liveVideoUUID: string | 30 | let liveVideoUUID: string |
29 | let ffmpegCommand: FfmpegCommand | 31 | let ffmpegCommand: FfmpegCommand |
30 | 32 | ||
31 | async function createLiveWrapper (saveReplay: boolean) { | 33 | async function createLiveWrapper (options: { permanent: boolean, replay: boolean }) { |
32 | if (liveVideoUUID) { | 34 | if (liveVideoUUID) { |
33 | try { | 35 | try { |
34 | await servers[0].videos.remove({ id: liveVideoUUID }) | 36 | await servers[0].videos.remove({ id: liveVideoUUID }) |
@@ -40,7 +42,8 @@ describe('Save replay setting', function () { | |||
40 | channelId: servers[0].store.channel.id, | 42 | channelId: servers[0].store.channel.id, |
41 | privacy: VideoPrivacy.PUBLIC, | 43 | privacy: VideoPrivacy.PUBLIC, |
42 | name: 'my super live', | 44 | name: 'my super live', |
43 | saveReplay | 45 | saveReplay: options.replay, |
46 | permanentLive: options.permanent | ||
44 | } | 47 | } |
45 | 48 | ||
46 | const { uuid } = await servers[0].live.create({ fields: attributes }) | 49 | const { uuid } = await servers[0].live.create({ fields: attributes }) |
@@ -104,7 +107,7 @@ describe('Save replay setting', function () { | |||
104 | it('Should correctly create and federate the "waiting for stream" live', async function () { | 107 | it('Should correctly create and federate the "waiting for stream" live', async function () { |
105 | this.timeout(20000) | 108 | this.timeout(20000) |
106 | 109 | ||
107 | liveVideoUUID = await createLiveWrapper(false) | 110 | liveVideoUUID = await createLiveWrapper({ permanent: false, replay: false }) |
108 | 111 | ||
109 | await waitJobs(servers) | 112 | await waitJobs(servers) |
110 | 113 | ||
@@ -140,13 +143,13 @@ describe('Save replay setting', function () { | |||
140 | await checkVideoState(liveVideoUUID, VideoState.LIVE_ENDED) | 143 | await checkVideoState(liveVideoUUID, VideoState.LIVE_ENDED) |
141 | 144 | ||
142 | // No resolutions saved since we did not save replay | 145 | // No resolutions saved since we did not save replay |
143 | await checkLiveCleanupAfterSave(servers[0], liveVideoUUID, []) | 146 | await checkLiveCleanup(servers[0], liveVideoUUID, []) |
144 | }) | 147 | }) |
145 | 148 | ||
146 | it('Should correctly terminate the stream on blacklist and delete the live', async function () { | 149 | it('Should correctly terminate the stream on blacklist and delete the live', async function () { |
147 | this.timeout(40000) | 150 | this.timeout(40000) |
148 | 151 | ||
149 | liveVideoUUID = await createLiveWrapper(false) | 152 | liveVideoUUID = await createLiveWrapper({ permanent: false, replay: false }) |
150 | 153 | ||
151 | ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) | 154 | ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) |
152 | 155 | ||
@@ -169,13 +172,13 @@ describe('Save replay setting', function () { | |||
169 | 172 | ||
170 | await wait(5000) | 173 | await wait(5000) |
171 | await waitJobs(servers) | 174 | await waitJobs(servers) |
172 | await checkLiveCleanupAfterSave(servers[0], liveVideoUUID, []) | 175 | await checkLiveCleanup(servers[0], liveVideoUUID, []) |
173 | }) | 176 | }) |
174 | 177 | ||
175 | it('Should correctly terminate the stream on delete and delete the video', async function () { | 178 | it('Should correctly terminate the stream on delete and delete the video', async function () { |
176 | this.timeout(40000) | 179 | this.timeout(40000) |
177 | 180 | ||
178 | liveVideoUUID = await createLiveWrapper(false) | 181 | liveVideoUUID = await createLiveWrapper({ permanent: false, replay: false }) |
179 | 182 | ||
180 | ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) | 183 | ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) |
181 | 184 | ||
@@ -193,16 +196,16 @@ describe('Save replay setting', function () { | |||
193 | await waitJobs(servers) | 196 | await waitJobs(servers) |
194 | 197 | ||
195 | await checkVideosExist(liveVideoUUID, false, HttpStatusCode.NOT_FOUND_404) | 198 | await checkVideosExist(liveVideoUUID, false, HttpStatusCode.NOT_FOUND_404) |
196 | await checkLiveCleanupAfterSave(servers[0], liveVideoUUID, []) | 199 | await checkLiveCleanup(servers[0], liveVideoUUID, []) |
197 | }) | 200 | }) |
198 | }) | 201 | }) |
199 | 202 | ||
200 | describe('With save replay enabled', function () { | 203 | describe('With save replay enabled on non permanent live', function () { |
201 | 204 | ||
202 | it('Should correctly create and federate the "waiting for stream" live', async function () { | 205 | it('Should correctly create and federate the "waiting for stream" live', async function () { |
203 | this.timeout(20000) | 206 | this.timeout(20000) |
204 | 207 | ||
205 | liveVideoUUID = await createLiveWrapper(true) | 208 | liveVideoUUID = await createLiveWrapper({ permanent: false, replay: true }) |
206 | 209 | ||
207 | await waitJobs(servers) | 210 | await waitJobs(servers) |
208 | 211 | ||
@@ -227,7 +230,7 @@ describe('Save replay setting', function () { | |||
227 | 230 | ||
228 | await stopFfmpeg(ffmpegCommand) | 231 | await stopFfmpeg(ffmpegCommand) |
229 | 232 | ||
230 | await waitUntilLiveSavedOnAllServers(servers, liveVideoUUID) | 233 | await waitUntilLiveReplacedByReplayOnAllServers(servers, liveVideoUUID) |
231 | await waitJobs(servers) | 234 | await waitJobs(servers) |
232 | 235 | ||
233 | // Live has been transcoded | 236 | // Live has been transcoded |
@@ -249,13 +252,13 @@ describe('Save replay setting', function () { | |||
249 | }) | 252 | }) |
250 | 253 | ||
251 | it('Should have cleaned up the live files', async function () { | 254 | it('Should have cleaned up the live files', async function () { |
252 | await checkLiveCleanupAfterSave(servers[0], liveVideoUUID, [ 720 ]) | 255 | await checkLiveCleanup(servers[0], liveVideoUUID, [ 720 ]) |
253 | }) | 256 | }) |
254 | 257 | ||
255 | it('Should correctly terminate the stream on blacklist and blacklist the saved replay video', async function () { | 258 | it('Should correctly terminate the stream on blacklist and blacklist the saved replay video', async function () { |
256 | this.timeout(40000) | 259 | this.timeout(40000) |
257 | 260 | ||
258 | liveVideoUUID = await createLiveWrapper(true) | 261 | liveVideoUUID = await createLiveWrapper({ permanent: false, replay: true }) |
259 | 262 | ||
260 | ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) | 263 | ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) |
261 | await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID) | 264 | await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID) |
@@ -277,13 +280,13 @@ describe('Save replay setting', function () { | |||
277 | 280 | ||
278 | await wait(5000) | 281 | await wait(5000) |
279 | await waitJobs(servers) | 282 | await waitJobs(servers) |
280 | await checkLiveCleanupAfterSave(servers[0], liveVideoUUID, [ 720 ]) | 283 | await checkLiveCleanup(servers[0], liveVideoUUID, [ 720 ]) |
281 | }) | 284 | }) |
282 | 285 | ||
283 | it('Should correctly terminate the stream on delete and delete the video', async function () { | 286 | it('Should correctly terminate the stream on delete and delete the video', async function () { |
284 | this.timeout(40000) | 287 | this.timeout(40000) |
285 | 288 | ||
286 | liveVideoUUID = await createLiveWrapper(true) | 289 | liveVideoUUID = await createLiveWrapper({ permanent: false, replay: true }) |
287 | 290 | ||
288 | ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) | 291 | ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) |
289 | await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID) | 292 | await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID) |
@@ -300,7 +303,123 @@ describe('Save replay setting', function () { | |||
300 | await waitJobs(servers) | 303 | await waitJobs(servers) |
301 | 304 | ||
302 | await checkVideosExist(liveVideoUUID, false, HttpStatusCode.NOT_FOUND_404) | 305 | await checkVideosExist(liveVideoUUID, false, HttpStatusCode.NOT_FOUND_404) |
303 | await checkLiveCleanupAfterSave(servers[0], liveVideoUUID, []) | 306 | await checkLiveCleanup(servers[0], liveVideoUUID, []) |
307 | }) | ||
308 | }) | ||
309 | |||
310 | describe('With save replay enabled on permanent live', function () { | ||
311 | let lastReplayUUID: string | ||
312 | |||
313 | it('Should correctly create and federate the "waiting for stream" live', async function () { | ||
314 | this.timeout(20000) | ||
315 | |||
316 | liveVideoUUID = await createLiveWrapper({ permanent: true, replay: true }) | ||
317 | |||
318 | await waitJobs(servers) | ||
319 | |||
320 | await checkVideosExist(liveVideoUUID, false, HttpStatusCode.OK_200) | ||
321 | await checkVideoState(liveVideoUUID, VideoState.WAITING_FOR_LIVE) | ||
322 | }) | ||
323 | |||
324 | it('Should correctly have updated the live and federated it when streaming in the live', async function () { | ||
325 | this.timeout(20000) | ||
326 | |||
327 | ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) | ||
328 | await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID) | ||
329 | |||
330 | await waitJobs(servers) | ||
331 | |||
332 | await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200) | ||
333 | await checkVideoState(liveVideoUUID, VideoState.PUBLISHED) | ||
334 | }) | ||
335 | |||
336 | it('Should correctly have saved the live and federated it after the streaming', async function () { | ||
337 | this.timeout(30000) | ||
338 | |||
339 | const liveDetails = await servers[0].videos.get({ id: liveVideoUUID }) | ||
340 | |||
341 | await stopFfmpeg(ffmpegCommand) | ||
342 | |||
343 | await waitUntilLiveWaitingOnAllServers(servers, liveVideoUUID) | ||
344 | await waitJobs(servers) | ||
345 | |||
346 | const video = await findExternalSavedVideo(servers[0], liveDetails) | ||
347 | expect(video).to.exist | ||
348 | |||
349 | for (const server of servers) { | ||
350 | await server.videos.get({ id: video.uuid }) | ||
351 | } | ||
352 | |||
353 | lastReplayUUID = video.uuid | ||
354 | }) | ||
355 | |||
356 | it('Should have cleaned up the live files', async function () { | ||
357 | await checkLiveCleanup(servers[0], liveVideoUUID, []) | ||
358 | }) | ||
359 | |||
360 | it('Should correctly terminate the stream on blacklist and blacklist the saved replay video', async function () { | ||
361 | this.timeout(60000) | ||
362 | |||
363 | await servers[0].videos.remove({ id: lastReplayUUID }) | ||
364 | |||
365 | liveVideoUUID = await createLiveWrapper({ permanent: true, replay: true }) | ||
366 | |||
367 | ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) | ||
368 | await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID) | ||
369 | |||
370 | const liveDetails = await servers[0].videos.get({ id: liveVideoUUID }) | ||
371 | |||
372 | await waitJobs(servers) | ||
373 | await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200) | ||
374 | |||
375 | await Promise.all([ | ||
376 | servers[0].blacklist.add({ videoId: liveVideoUUID, reason: 'bad live', unfederate: true }), | ||
377 | testFfmpegStreamError(ffmpegCommand, true) | ||
378 | ]) | ||
379 | |||
380 | await waitJobs(servers) | ||
381 | await wait(5000) | ||
382 | await waitJobs(servers) | ||
383 | |||
384 | const replay = await findExternalSavedVideo(servers[0], liveDetails) | ||
385 | expect(replay).to.exist | ||
386 | |||
387 | for (const videoId of [ liveVideoUUID, replay.uuid ]) { | ||
388 | await checkVideosExist(videoId, false) | ||
389 | |||
390 | await servers[0].videos.get({ id: videoId, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) | ||
391 | await servers[1].videos.get({ id: videoId, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) | ||
392 | } | ||
393 | |||
394 | await checkLiveCleanup(servers[0], liveVideoUUID, []) | ||
395 | }) | ||
396 | |||
397 | it('Should correctly terminate the stream on delete and not save the video', async function () { | ||
398 | this.timeout(40000) | ||
399 | |||
400 | liveVideoUUID = await createLiveWrapper({ permanent: true, replay: true }) | ||
401 | |||
402 | ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) | ||
403 | await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID) | ||
404 | |||
405 | const liveDetails = await servers[0].videos.get({ id: liveVideoUUID }) | ||
406 | |||
407 | await waitJobs(servers) | ||
408 | await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200) | ||
409 | |||
410 | await Promise.all([ | ||
411 | servers[0].videos.remove({ id: liveVideoUUID }), | ||
412 | testFfmpegStreamError(ffmpegCommand, true) | ||
413 | ]) | ||
414 | |||
415 | await wait(5000) | ||
416 | await waitJobs(servers) | ||
417 | |||
418 | const replay = await findExternalSavedVideo(servers[0], liveDetails) | ||
419 | expect(replay).to.not.exist | ||
420 | |||
421 | await checkVideosExist(liveVideoUUID, false, HttpStatusCode.NOT_FOUND_404) | ||
422 | await checkLiveCleanup(servers[0], liveVideoUUID, []) | ||
304 | }) | 423 | }) |
305 | }) | 424 | }) |
306 | 425 | ||
diff --git a/server/tests/api/live/live.ts b/server/tests/api/live/live.ts index aeb039696..6e7b77bce 100644 --- a/server/tests/api/live/live.ts +++ b/server/tests/api/live/live.ts | |||
@@ -4,7 +4,7 @@ import 'mocha' | |||
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { basename, join } from 'path' | 5 | import { basename, join } from 'path' |
6 | import { ffprobePromise, getVideoStream } from '@server/helpers/ffmpeg' | 6 | import { ffprobePromise, getVideoStream } from '@server/helpers/ffmpeg' |
7 | import { checkLiveCleanupAfterSave, checkLiveSegmentHash, checkResolutionsInMasterPlaylist, testImage } from '@server/tests/shared' | 7 | import { checkLiveCleanup, checkLiveSegmentHash, checkResolutionsInMasterPlaylist, testImage } from '@server/tests/shared' |
8 | import { wait } from '@shared/core-utils' | 8 | import { wait } from '@shared/core-utils' |
9 | import { | 9 | import { |
10 | HttpStatusCode, | 10 | HttpStatusCode, |
@@ -583,7 +583,7 @@ describe('Test live', function () { | |||
583 | it('Should correctly have cleaned up the live files', async function () { | 583 | it('Should correctly have cleaned up the live files', async function () { |
584 | this.timeout(30000) | 584 | this.timeout(30000) |
585 | 585 | ||
586 | await checkLiveCleanupAfterSave(servers[0], liveVideoId, [ 240, 360, 720 ]) | 586 | await checkLiveCleanup(servers[0], liveVideoId, [ 240, 360, 720 ]) |
587 | }) | 587 | }) |
588 | }) | 588 | }) |
589 | 589 | ||