aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-12-09 14:42:42 +0100
committerChocobozzz <me@florianbigard.com>2020-12-09 14:45:47 +0100
commit0d8de2756fdc43be61a82a96c17d12ee52ba0143 (patch)
tree85b02e683f0dc475e044356dc5adb6246181959d
parente0fea785bf28966da09cdc16a274c9e750b488f4 (diff)
downloadPeerTube-0d8de2756fdc43be61a82a96c17d12ee52ba0143.tar.gz
PeerTube-0d8de2756fdc43be61a82a96c17d12ee52ba0143.tar.zst
PeerTube-0d8de2756fdc43be61a82a96c17d12ee52ba0143.zip
Fix live tests
-rw-r--r--server/lib/activitypub/process/process-delete.ts11
-rw-r--r--server/lib/live-manager.ts7
-rw-r--r--server/tests/api/check-params/live.ts6
-rw-r--r--server/tests/api/live/live-permanent.ts6
-rw-r--r--server/tests/api/live/live-save-replay.ts14
-rw-r--r--server/tests/api/live/live.ts37
-rw-r--r--shared/extra-utils/videos/live.ts23
7 files changed, 55 insertions, 49 deletions
diff --git a/server/lib/activitypub/process/process-delete.ts b/server/lib/activitypub/process/process-delete.ts
index b9fc5e792..a86def936 100644
--- a/server/lib/activitypub/process/process-delete.ts
+++ b/server/lib/activitypub/process/process-delete.ts
@@ -5,11 +5,11 @@ import { sequelizeTypescript } from '../../../initializers/database'
5import { ActorModel } from '../../../models/activitypub/actor' 5import { ActorModel } from '../../../models/activitypub/actor'
6import { VideoModel } from '../../../models/video/video' 6import { VideoModel } from '../../../models/video/video'
7import { VideoCommentModel } from '../../../models/video/video-comment' 7import { VideoCommentModel } from '../../../models/video/video-comment'
8import { markCommentAsDeleted } from '../../video-comment'
9import { forwardVideoRelatedActivity } from '../send/utils'
10import { VideoPlaylistModel } from '../../../models/video/video-playlist' 8import { VideoPlaylistModel } from '../../../models/video/video-playlist'
11import { APProcessorOptions } from '../../../types/activitypub-processor.model' 9import { APProcessorOptions } from '../../../types/activitypub-processor.model'
12import { MAccountActor, MActor, MActorSignature, MChannelActor, MChannelActorAccountActor } from '../../../types/models' 10import { MAccountActor, MActor, MActorSignature, MChannelActor, MChannelActorAccountActor, MCommentOwnerVideo } from '../../../types/models'
11import { markCommentAsDeleted } from '../../video-comment'
12import { forwardVideoRelatedActivity } from '../send/utils'
13 13
14async function processDeleteActivity (options: APProcessorOptions<ActivityDelete>) { 14async function processDeleteActivity (options: APProcessorOptions<ActivityDelete>) {
15 const { activity, byActor } = options 15 const { activity, byActor } = options
@@ -121,7 +121,10 @@ async function processDeleteVideoChannel (videoChannelToRemove: MChannelActor) {
121 logger.info('Remote video channel %s removed.', videoChannelToRemove.Actor.url) 121 logger.info('Remote video channel %s removed.', videoChannelToRemove.Actor.url)
122} 122}
123 123
124function processDeleteVideoComment (byActor: MActorSignature, videoComment: VideoCommentModel, activity: ActivityDelete) { 124function processDeleteVideoComment (byActor: MActorSignature, videoComment: MCommentOwnerVideo, activity: ActivityDelete) {
125 // Already deleted
126 if (videoComment.isDeleted()) return
127
125 logger.debug('Removing remote video comment "%s".', videoComment.url) 128 logger.debug('Removing remote video comment "%s".', videoComment.url)
126 129
127 return sequelizeTypescript.transaction(async t => { 130 return sequelizeTypescript.transaction(async t => {
diff --git a/server/lib/live-manager.ts b/server/lib/live-manager.ts
index ef50e3cdb..5d9b68756 100644
--- a/server/lib/live-manager.ts
+++ b/server/lib/live-manager.ts
@@ -287,16 +287,17 @@ class LiveManager {
287 for (let i = 0; i < allResolutions.length; i++) { 287 for (let i = 0; i < allResolutions.length; i++) {
288 const resolution = allResolutions[i] 288 const resolution = allResolutions[i]
289 289
290 VideoFileModel.upsert({ 290 const file = new VideoFileModel({
291 resolution, 291 resolution,
292 size: -1, 292 size: -1,
293 extname: '.ts', 293 extname: '.ts',
294 infoHash: null, 294 infoHash: null,
295 fps, 295 fps,
296 videoStreamingPlaylistId: playlist.id 296 videoStreamingPlaylistId: playlist.id
297 }).catch(err => {
298 logger.error('Cannot create file for live streaming.', { err })
299 }) 297 })
298
299 VideoFileModel.customUpsert(file, 'streaming-playlist', null)
300 .catch(err => logger.error('Cannot create file for live streaming.', { err }))
300 } 301 }
301 302
302 const outPath = getHLSDirectory(videoLive.Video) 303 const outPath = getHLSDirectory(videoLive.Video)
diff --git a/server/tests/api/check-params/live.ts b/server/tests/api/check-params/live.ts
index 40dca908b..7e76caf6e 100644
--- a/server/tests/api/check-params/live.ts
+++ b/server/tests/api/check-params/live.ts
@@ -22,7 +22,7 @@ import {
22 updateLive, 22 updateLive,
23 uploadVideoAndGetId, 23 uploadVideoAndGetId,
24 userLogin, 24 userLogin,
25 waitUntilLiveStarts 25 waitUntilLivePublished
26} from '../../../../shared/extra-utils' 26} from '../../../../shared/extra-utils'
27import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' 27import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
28 28
@@ -409,7 +409,7 @@ describe('Test video lives API validator', function () {
409 409
410 const command = sendRTMPStream(live.rtmpUrl, live.streamKey) 410 const command = sendRTMPStream(live.rtmpUrl, live.streamKey)
411 411
412 await waitUntilLiveStarts(server.url, server.accessToken, videoId) 412 await waitUntilLivePublished(server.url, server.accessToken, videoId)
413 await updateLive(server.url, server.accessToken, videoId, {}, HttpStatusCode.BAD_REQUEST_400) 413 await updateLive(server.url, server.accessToken, videoId, {}, HttpStatusCode.BAD_REQUEST_400)
414 414
415 await stopFfmpeg(command) 415 await stopFfmpeg(command)
@@ -423,7 +423,7 @@ describe('Test video lives API validator', function () {
423 423
424 const command = sendRTMPStream(live.rtmpUrl, live.streamKey) 424 const command = sendRTMPStream(live.rtmpUrl, live.streamKey)
425 425
426 await waitUntilLiveStarts(server.url, server.accessToken, videoId) 426 await waitUntilLivePublished(server.url, server.accessToken, videoId)
427 427
428 await runAndTestFfmpegStreamError(server.url, server.accessToken, videoId, true) 428 await runAndTestFfmpegStreamError(server.url, server.accessToken, videoId, true)
429 429
diff --git a/server/tests/api/live/live-permanent.ts b/server/tests/api/live/live-permanent.ts
index 54e4010e9..2701c65e3 100644
--- a/server/tests/api/live/live-permanent.ts
+++ b/server/tests/api/live/live-permanent.ts
@@ -20,7 +20,7 @@ import {
20 updateLive, 20 updateLive,
21 wait, 21 wait,
22 waitJobs, 22 waitJobs,
23 waitUntilLiveStarts 23 waitUntilLivePublished
24} from '../../../../shared/extra-utils' 24} from '../../../../shared/extra-utils'
25 25
26const expect = chai.expect 26const expect = chai.expect
@@ -116,7 +116,7 @@ describe('Permenant live', function () {
116 const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, videoUUID) 116 const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, videoUUID)
117 117
118 for (const server of servers) { 118 for (const server of servers) {
119 await waitUntilLiveStarts(server.url, server.accessToken, videoUUID) 119 await waitUntilLivePublished(server.url, server.accessToken, videoUUID)
120 } 120 }
121 121
122 await checkVideoState(videoUUID, VideoState.PUBLISHED) 122 await checkVideoState(videoUUID, VideoState.PUBLISHED)
@@ -171,7 +171,7 @@ describe('Permenant live', function () {
171 const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, videoUUID) 171 const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, videoUUID)
172 172
173 for (const server of servers) { 173 for (const server of servers) {
174 await waitUntilLiveStarts(server.url, server.accessToken, videoUUID) 174 await waitUntilLivePublished(server.url, server.accessToken, videoUUID)
175 } 175 }
176 176
177 await checkVideoState(videoUUID, VideoState.PUBLISHED) 177 await checkVideoState(videoUUID, VideoState.PUBLISHED)
diff --git a/server/tests/api/live/live-save-replay.ts b/server/tests/api/live/live-save-replay.ts
index e300ec345..bd683b2bf 100644
--- a/server/tests/api/live/live-save-replay.ts
+++ b/server/tests/api/live/live-save-replay.ts
@@ -23,7 +23,7 @@ import {
23 updateCustomSubConfig, 23 updateCustomSubConfig,
24 updateVideo, 24 updateVideo,
25 waitJobs, 25 waitJobs,
26 waitUntilLiveStarts 26 waitUntilLivePublished
27} from '../../../../shared/extra-utils' 27} from '../../../../shared/extra-utils'
28import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' 28import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
29 29
@@ -127,7 +127,7 @@ describe('Save replay setting', function () {
127 this.timeout(20000) 127 this.timeout(20000)
128 128
129 ffmpegCommand = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID) 129 ffmpegCommand = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID)
130 await waitUntilLiveStarts(servers[0].url, servers[0].accessToken, liveVideoUUID) 130 await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoUUID)
131 131
132 await waitJobs(servers) 132 await waitJobs(servers)
133 133
@@ -156,7 +156,7 @@ describe('Save replay setting', function () {
156 liveVideoUUID = await createLiveWrapper(false) 156 liveVideoUUID = await createLiveWrapper(false)
157 157
158 ffmpegCommand = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID) 158 ffmpegCommand = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID)
159 await waitUntilLiveStarts(servers[0].url, servers[0].accessToken, liveVideoUUID) 159 await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoUUID)
160 160
161 await waitJobs(servers) 161 await waitJobs(servers)
162 await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200) 162 await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
@@ -182,7 +182,7 @@ describe('Save replay setting', function () {
182 liveVideoUUID = await createLiveWrapper(false) 182 liveVideoUUID = await createLiveWrapper(false)
183 183
184 ffmpegCommand = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID) 184 ffmpegCommand = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID)
185 await waitUntilLiveStarts(servers[0].url, servers[0].accessToken, liveVideoUUID) 185 await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoUUID)
186 186
187 await waitJobs(servers) 187 await waitJobs(servers)
188 await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200) 188 await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
@@ -216,7 +216,7 @@ describe('Save replay setting', function () {
216 this.timeout(20000) 216 this.timeout(20000)
217 217
218 ffmpegCommand = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID) 218 ffmpegCommand = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID)
219 await waitUntilLiveStarts(servers[0].url, servers[0].accessToken, liveVideoUUID) 219 await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoUUID)
220 220
221 await waitJobs(servers) 221 await waitJobs(servers)
222 222
@@ -259,7 +259,7 @@ describe('Save replay setting', function () {
259 liveVideoUUID = await createLiveWrapper(true) 259 liveVideoUUID = await createLiveWrapper(true)
260 260
261 ffmpegCommand = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID) 261 ffmpegCommand = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID)
262 await waitUntilLiveStarts(servers[0].url, servers[0].accessToken, liveVideoUUID) 262 await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoUUID)
263 263
264 await waitJobs(servers) 264 await waitJobs(servers)
265 await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200) 265 await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
@@ -285,7 +285,7 @@ describe('Save replay setting', function () {
285 liveVideoUUID = await createLiveWrapper(true) 285 liveVideoUUID = await createLiveWrapper(true)
286 286
287 ffmpegCommand = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID) 287 ffmpegCommand = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID)
288 await waitUntilLiveStarts(servers[0].url, servers[0].accessToken, liveVideoUUID) 288 await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoUUID)
289 289
290 await waitJobs(servers) 290 await waitJobs(servers)
291 await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200) 291 await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
diff --git a/server/tests/api/live/live.ts b/server/tests/api/live/live.ts
index a74988aba..7ea0ec198 100644
--- a/server/tests/api/live/live.ts
+++ b/server/tests/api/live/live.ts
@@ -7,6 +7,7 @@ import { join } from 'path'
7import { ffprobePromise, getVideoStreamFromFile } from '@server/helpers/ffprobe-utils' 7import { ffprobePromise, getVideoStreamFromFile } from '@server/helpers/ffprobe-utils'
8import { getLiveNotificationSocket } from '@shared/extra-utils/socket/socket-io' 8import { getLiveNotificationSocket } from '@shared/extra-utils/socket/socket-io'
9import { LiveVideo, LiveVideoCreate, Video, VideoDetails, VideoPrivacy, VideoState, VideoStreamingPlaylistType } from '@shared/models' 9import { LiveVideo, LiveVideoCreate, Video, VideoDetails, VideoPrivacy, VideoState, VideoStreamingPlaylistType } from '@shared/models'
10import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
10import { 11import {
11 addVideoToBlacklist, 12 addVideoToBlacklist,
12 buildServerDirectory, 13 buildServerDirectory,
@@ -41,10 +42,9 @@ import {
41 waitJobs, 42 waitJobs,
42 waitUntilLiveEnded, 43 waitUntilLiveEnded,
43 waitUntilLivePublished, 44 waitUntilLivePublished,
44 waitUntilLiveStarts, 45 waitUntilLiveSegmentGeneration,
45 waitUntilLog 46 waitUntilLog
46} from '../../../../shared/extra-utils' 47} from '../../../../shared/extra-utils'
47import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
48 48
49const expect = chai.expect 49const expect = chai.expect
50 50
@@ -329,8 +329,9 @@ describe('Test live', function () {
329 await checkResolutionsInMasterPlaylist(hlsPlaylist.playlistUrl, resolutions) 329 await checkResolutionsInMasterPlaylist(hlsPlaylist.playlistUrl, resolutions)
330 330
331 for (let i = 0; i < resolutions.length; i++) { 331 for (let i = 0; i < resolutions.length; i++) {
332 const segmentName = `${i}-000001.ts` 332 const segmentNum = 1
333 await waitUntilLog(servers[0], `${video.uuid}/${segmentName}`, 2, false) 333 const segmentName = `${i}-00000${segmentNum}.ts`
334 await waitUntilLiveSegmentGeneration(servers[0], video.uuid, i, segmentNum)
334 335
335 const res = await getPlaylist(`${servers[0].url}/static/streaming-playlists/hls/${video.uuid}/${i}.m3u8`) 336 const res = await getPlaylist(`${servers[0].url}/static/streaming-playlists/hls/${video.uuid}/${i}.m3u8`)
336 const subPlaylist = res.text 337 const subPlaylist = res.text
@@ -374,7 +375,7 @@ describe('Test live', function () {
374 liveVideoId = await createLiveWrapper(false) 375 liveVideoId = await createLiveWrapper(false)
375 376
376 const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoId) 377 const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoId)
377 await waitUntilLiveStarts(servers[0].url, servers[0].accessToken, liveVideoId) 378 await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoId)
378 await waitJobs(servers) 379 await waitJobs(servers)
379 380
380 await testVideoResolutions(liveVideoId, [ 720 ]) 381 await testVideoResolutions(liveVideoId, [ 720 ])
@@ -390,7 +391,7 @@ describe('Test live', function () {
390 liveVideoId = await createLiveWrapper(false) 391 liveVideoId = await createLiveWrapper(false)
391 392
392 const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoId) 393 const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoId)
393 await waitUntilLiveStarts(servers[0].url, servers[0].accessToken, liveVideoId) 394 await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoId)
394 await waitJobs(servers) 395 await waitJobs(servers)
395 396
396 await testVideoResolutions(liveVideoId, resolutions) 397 await testVideoResolutions(liveVideoId, resolutions)
@@ -407,7 +408,7 @@ describe('Test live', function () {
407 liveVideoId = await createLiveWrapper(true) 408 liveVideoId = await createLiveWrapper(true)
408 409
409 const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoId, 'video_short2.webm') 410 const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoId, 'video_short2.webm')
410 await waitUntilLiveStarts(servers[0].url, servers[0].accessToken, liveVideoId) 411 await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoId)
411 await waitJobs(servers) 412 await waitJobs(servers)
412 413
413 await testVideoResolutions(liveVideoId, resolutions) 414 await testVideoResolutions(liveVideoId, resolutions)
@@ -495,7 +496,7 @@ describe('Test live', function () {
495 liveVideoId = res.body.video.uuid 496 liveVideoId = res.body.video.uuid
496 497
497 command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoId) 498 command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoId)
498 await waitUntilLiveStarts(servers[0].url, servers[0].accessToken, liveVideoId) 499 await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoId)
499 await waitJobs(servers) 500 await waitJobs(servers)
500 }) 501 })
501 502
@@ -584,7 +585,7 @@ describe('Test live', function () {
584 const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID) 585 const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID)
585 586
586 for (const server of servers) { 587 for (const server of servers) {
587 await waitUntilLiveStarts(server.url, server.accessToken, liveVideoUUID) 588 await waitUntilLivePublished(server.url, server.accessToken, liveVideoUUID)
588 } 589 }
589 590
590 await waitJobs(servers) 591 await waitJobs(servers)
@@ -623,7 +624,7 @@ describe('Test live', function () {
623 socket.emit('subscribe', { videoId }) 624 socket.emit('subscribe', { videoId })
624 625
625 const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID) 626 const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID)
626 await waitUntilLiveStarts(servers[0].url, servers[0].accessToken, liveVideoUUID) 627 await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoUUID)
627 await waitJobs(servers) 628 await waitJobs(servers)
628 629
629 expect(stateChanges).to.have.lengthOf(1) 630 expect(stateChanges).to.have.lengthOf(1)
@@ -653,7 +654,7 @@ describe('Test live', function () {
653 } 654 }
654 655
655 before(async function () { 656 before(async function () {
656 this.timeout(60000) 657 this.timeout(120000)
657 658
658 liveVideoId = await createLiveWrapper(false) 659 liveVideoId = await createLiveWrapper(false)
659 liveVideoReplayId = await createLiveWrapper(true) 660 liveVideoReplayId = await createLiveWrapper(true)
@@ -664,10 +665,13 @@ describe('Test live', function () {
664 ]) 665 ])
665 666
666 await Promise.all([ 667 await Promise.all([
667 waitUntilLiveStarts(servers[0].url, servers[0].accessToken, liveVideoId), 668 waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoId),
668 waitUntilLiveStarts(servers[0].url, servers[0].accessToken, liveVideoReplayId) 669 waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoReplayId)
669 ]) 670 ])
670 671
672 await waitUntilLiveSegmentGeneration(servers[0], liveVideoId, 0, 2)
673 await waitUntilLiveSegmentGeneration(servers[0], liveVideoReplayId, 0, 2)
674
671 await killallServers([ servers[0] ]) 675 await killallServers([ servers[0] ])
672 await reRunServer(servers[0]) 676 await reRunServer(servers[0])
673 677
@@ -677,14 +681,11 @@ describe('Test live', function () {
677 it('Should cleanup lives', async function () { 681 it('Should cleanup lives', async function () {
678 this.timeout(60000) 682 this.timeout(60000)
679 683
680 const res = await getVideo(servers[0].url, liveVideoId) 684 await waitUntilLiveEnded(servers[0].url, servers[0].accessToken, liveVideoId)
681 const video: VideoDetails = res.body
682
683 expect(video.state.id).to.equal(VideoState.LIVE_ENDED)
684 }) 685 })
685 686
686 it('Should save a live replay', async function () { 687 it('Should save a live replay', async function () {
687 this.timeout(60000) 688 this.timeout(120000)
688 689
689 await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoReplayId) 690 await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoReplayId)
690 }) 691 })
diff --git a/shared/extra-utils/videos/live.ts b/shared/extra-utils/videos/live.ts
index 4aa66622b..cbcfc09e4 100644
--- a/shared/extra-utils/videos/live.ts
+++ b/shared/extra-utils/videos/live.ts
@@ -6,11 +6,11 @@ import { pathExists, readdir } from 'fs-extra'
6import { omit } from 'lodash' 6import { omit } from 'lodash'
7import { join } from 'path' 7import { join } from 'path'
8import { LiveVideo, LiveVideoCreate, LiveVideoUpdate, VideoDetails, VideoState } from '@shared/models' 8import { LiveVideo, LiveVideoCreate, LiveVideoUpdate, VideoDetails, VideoState } from '@shared/models'
9import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
9import { buildAbsoluteFixturePath, buildServerDirectory, wait } from '../miscs/miscs' 10import { buildAbsoluteFixturePath, buildServerDirectory, wait } from '../miscs/miscs'
10import { makeGetRequest, makePutBodyRequest, makeUploadRequest } from '../requests/requests' 11import { makeGetRequest, makePutBodyRequest, makeUploadRequest } from '../requests/requests'
11import { ServerInfo } from '../server/servers' 12import { ServerInfo, waitUntilLog } from '../server/servers'
12import { getVideoWithToken } from './videos' 13import { getVideoWithToken } from './videos'
13import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
14 14
15function getLive (url: string, token: string, videoId: number | string, statusCodeExpected = HttpStatusCode.OK_200) { 15function getLive (url: string, token: string, videoId: number | string, statusCodeExpected = HttpStatusCode.OK_200) {
16 const path = '/api/v1/videos/live' 16 const path = '/api/v1/videos/live'
@@ -136,19 +136,20 @@ async function stopFfmpeg (command: ffmpeg.FfmpegCommand) {
136 await wait(500) 136 await wait(500)
137} 137}
138 138
139function waitUntilLiveStarts (url: string, token: string, videoId: number | string) {
140 return waitWhileLiveState(url, token, videoId, VideoState.WAITING_FOR_LIVE)
141}
142
143function waitUntilLivePublished (url: string, token: string, videoId: number | string) { 139function waitUntilLivePublished (url: string, token: string, videoId: number | string) {
144 return waitWhileLiveState(url, token, videoId, VideoState.PUBLISHED) 140 return waitUntilLiveState(url, token, videoId, VideoState.PUBLISHED)
145} 141}
146 142
147function waitUntilLiveEnded (url: string, token: string, videoId: number | string) { 143function waitUntilLiveEnded (url: string, token: string, videoId: number | string) {
148 return waitWhileLiveState(url, token, videoId, VideoState.LIVE_ENDED) 144 return waitUntilLiveState(url, token, videoId, VideoState.LIVE_ENDED)
145}
146
147function waitUntilLiveSegmentGeneration (server: ServerInfo, videoUUID: string, resolutionNum: number, segmentNum: number) {
148 const segmentName = `${resolutionNum}-00000${segmentNum}.ts`
149 return waitUntilLog(server, `${videoUUID}/${segmentName}`, 2, false)
149} 150}
150 151
151async function waitWhileLiveState (url: string, token: string, videoId: number | string, state: VideoState) { 152async function waitUntilLiveState (url: string, token: string, videoId: number | string, state: VideoState) {
152 let video: VideoDetails 153 let video: VideoDetails
153 154
154 do { 155 do {
@@ -156,7 +157,7 @@ async function waitWhileLiveState (url: string, token: string, videoId: number |
156 video = res.body 157 video = res.body
157 158
158 await wait(500) 159 await wait(500)
159 } while (video.state.id === state) 160 } while (video.state.id !== state)
160} 161}
161 162
162async function checkLiveCleanup (server: ServerInfo, videoUUID: string, resolutions: number[] = []) { 163async function checkLiveCleanup (server: ServerInfo, videoUUID: string, resolutions: number[] = []) {
@@ -200,10 +201,10 @@ export {
200 getPlaylistsCount, 201 getPlaylistsCount,
201 waitUntilLivePublished, 202 waitUntilLivePublished,
202 updateLive, 203 updateLive,
203 waitUntilLiveStarts,
204 createLive, 204 createLive,
205 runAndTestFfmpegStreamError, 205 runAndTestFfmpegStreamError,
206 checkLiveCleanup, 206 checkLiveCleanup,
207 waitUntilLiveSegmentGeneration,
207 stopFfmpeg, 208 stopFfmpeg,
208 sendRTMPStreamInVideo, 209 sendRTMPStreamInVideo,
209 waitUntilLiveEnded, 210 waitUntilLiveEnded,