Fix live tests
This commit is contained in:
parent
e0fea785bf
commit
0d8de2756f
|
@ -5,11 +5,11 @@ import { sequelizeTypescript } from '../../../initializers/database'
|
||||||
import { ActorModel } from '../../../models/activitypub/actor'
|
import { ActorModel } from '../../../models/activitypub/actor'
|
||||||
import { VideoModel } from '../../../models/video/video'
|
import { VideoModel } from '../../../models/video/video'
|
||||||
import { VideoCommentModel } from '../../../models/video/video-comment'
|
import { VideoCommentModel } from '../../../models/video/video-comment'
|
||||||
import { markCommentAsDeleted } from '../../video-comment'
|
|
||||||
import { forwardVideoRelatedActivity } from '../send/utils'
|
|
||||||
import { VideoPlaylistModel } from '../../../models/video/video-playlist'
|
import { VideoPlaylistModel } from '../../../models/video/video-playlist'
|
||||||
import { APProcessorOptions } from '../../../types/activitypub-processor.model'
|
import { APProcessorOptions } from '../../../types/activitypub-processor.model'
|
||||||
import { MAccountActor, MActor, MActorSignature, MChannelActor, MChannelActorAccountActor } from '../../../types/models'
|
import { MAccountActor, MActor, MActorSignature, MChannelActor, MChannelActorAccountActor, MCommentOwnerVideo } from '../../../types/models'
|
||||||
|
import { markCommentAsDeleted } from '../../video-comment'
|
||||||
|
import { forwardVideoRelatedActivity } from '../send/utils'
|
||||||
|
|
||||||
async function processDeleteActivity (options: APProcessorOptions<ActivityDelete>) {
|
async function processDeleteActivity (options: APProcessorOptions<ActivityDelete>) {
|
||||||
const { activity, byActor } = options
|
const { activity, byActor } = options
|
||||||
|
@ -121,7 +121,10 @@ async function processDeleteVideoChannel (videoChannelToRemove: MChannelActor) {
|
||||||
logger.info('Remote video channel %s removed.', videoChannelToRemove.Actor.url)
|
logger.info('Remote video channel %s removed.', videoChannelToRemove.Actor.url)
|
||||||
}
|
}
|
||||||
|
|
||||||
function processDeleteVideoComment (byActor: MActorSignature, videoComment: VideoCommentModel, activity: ActivityDelete) {
|
function processDeleteVideoComment (byActor: MActorSignature, videoComment: MCommentOwnerVideo, activity: ActivityDelete) {
|
||||||
|
// Already deleted
|
||||||
|
if (videoComment.isDeleted()) return
|
||||||
|
|
||||||
logger.debug('Removing remote video comment "%s".', videoComment.url)
|
logger.debug('Removing remote video comment "%s".', videoComment.url)
|
||||||
|
|
||||||
return sequelizeTypescript.transaction(async t => {
|
return sequelizeTypescript.transaction(async t => {
|
||||||
|
|
|
@ -287,16 +287,17 @@ class LiveManager {
|
||||||
for (let i = 0; i < allResolutions.length; i++) {
|
for (let i = 0; i < allResolutions.length; i++) {
|
||||||
const resolution = allResolutions[i]
|
const resolution = allResolutions[i]
|
||||||
|
|
||||||
VideoFileModel.upsert({
|
const file = new VideoFileModel({
|
||||||
resolution,
|
resolution,
|
||||||
size: -1,
|
size: -1,
|
||||||
extname: '.ts',
|
extname: '.ts',
|
||||||
infoHash: null,
|
infoHash: null,
|
||||||
fps,
|
fps,
|
||||||
videoStreamingPlaylistId: playlist.id
|
videoStreamingPlaylistId: playlist.id
|
||||||
}).catch(err => {
|
|
||||||
logger.error('Cannot create file for live streaming.', { err })
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
VideoFileModel.customUpsert(file, 'streaming-playlist', null)
|
||||||
|
.catch(err => logger.error('Cannot create file for live streaming.', { err }))
|
||||||
}
|
}
|
||||||
|
|
||||||
const outPath = getHLSDirectory(videoLive.Video)
|
const outPath = getHLSDirectory(videoLive.Video)
|
||||||
|
|
|
@ -22,7 +22,7 @@ import {
|
||||||
updateLive,
|
updateLive,
|
||||||
uploadVideoAndGetId,
|
uploadVideoAndGetId,
|
||||||
userLogin,
|
userLogin,
|
||||||
waitUntilLiveStarts
|
waitUntilLivePublished
|
||||||
} from '../../../../shared/extra-utils'
|
} from '../../../../shared/extra-utils'
|
||||||
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
||||||
|
|
||||||
|
@ -409,7 +409,7 @@ describe('Test video lives API validator', function () {
|
||||||
|
|
||||||
const command = sendRTMPStream(live.rtmpUrl, live.streamKey)
|
const command = sendRTMPStream(live.rtmpUrl, live.streamKey)
|
||||||
|
|
||||||
await waitUntilLiveStarts(server.url, server.accessToken, videoId)
|
await waitUntilLivePublished(server.url, server.accessToken, videoId)
|
||||||
await updateLive(server.url, server.accessToken, videoId, {}, HttpStatusCode.BAD_REQUEST_400)
|
await updateLive(server.url, server.accessToken, videoId, {}, HttpStatusCode.BAD_REQUEST_400)
|
||||||
|
|
||||||
await stopFfmpeg(command)
|
await stopFfmpeg(command)
|
||||||
|
@ -423,7 +423,7 @@ describe('Test video lives API validator', function () {
|
||||||
|
|
||||||
const command = sendRTMPStream(live.rtmpUrl, live.streamKey)
|
const command = sendRTMPStream(live.rtmpUrl, live.streamKey)
|
||||||
|
|
||||||
await waitUntilLiveStarts(server.url, server.accessToken, videoId)
|
await waitUntilLivePublished(server.url, server.accessToken, videoId)
|
||||||
|
|
||||||
await runAndTestFfmpegStreamError(server.url, server.accessToken, videoId, true)
|
await runAndTestFfmpegStreamError(server.url, server.accessToken, videoId, true)
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ import {
|
||||||
updateLive,
|
updateLive,
|
||||||
wait,
|
wait,
|
||||||
waitJobs,
|
waitJobs,
|
||||||
waitUntilLiveStarts
|
waitUntilLivePublished
|
||||||
} from '../../../../shared/extra-utils'
|
} from '../../../../shared/extra-utils'
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
|
@ -116,7 +116,7 @@ describe('Permenant live', function () {
|
||||||
const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, videoUUID)
|
const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, videoUUID)
|
||||||
|
|
||||||
for (const server of servers) {
|
for (const server of servers) {
|
||||||
await waitUntilLiveStarts(server.url, server.accessToken, videoUUID)
|
await waitUntilLivePublished(server.url, server.accessToken, videoUUID)
|
||||||
}
|
}
|
||||||
|
|
||||||
await checkVideoState(videoUUID, VideoState.PUBLISHED)
|
await checkVideoState(videoUUID, VideoState.PUBLISHED)
|
||||||
|
@ -171,7 +171,7 @@ describe('Permenant live', function () {
|
||||||
const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, videoUUID)
|
const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, videoUUID)
|
||||||
|
|
||||||
for (const server of servers) {
|
for (const server of servers) {
|
||||||
await waitUntilLiveStarts(server.url, server.accessToken, videoUUID)
|
await waitUntilLivePublished(server.url, server.accessToken, videoUUID)
|
||||||
}
|
}
|
||||||
|
|
||||||
await checkVideoState(videoUUID, VideoState.PUBLISHED)
|
await checkVideoState(videoUUID, VideoState.PUBLISHED)
|
||||||
|
|
|
@ -23,7 +23,7 @@ import {
|
||||||
updateCustomSubConfig,
|
updateCustomSubConfig,
|
||||||
updateVideo,
|
updateVideo,
|
||||||
waitJobs,
|
waitJobs,
|
||||||
waitUntilLiveStarts
|
waitUntilLivePublished
|
||||||
} from '../../../../shared/extra-utils'
|
} from '../../../../shared/extra-utils'
|
||||||
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ describe('Save replay setting', function () {
|
||||||
this.timeout(20000)
|
this.timeout(20000)
|
||||||
|
|
||||||
ffmpegCommand = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID)
|
ffmpegCommand = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID)
|
||||||
await waitUntilLiveStarts(servers[0].url, servers[0].accessToken, liveVideoUUID)
|
await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoUUID)
|
||||||
|
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
|
@ -156,7 +156,7 @@ describe('Save replay setting', function () {
|
||||||
liveVideoUUID = await createLiveWrapper(false)
|
liveVideoUUID = await createLiveWrapper(false)
|
||||||
|
|
||||||
ffmpegCommand = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID)
|
ffmpegCommand = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID)
|
||||||
await waitUntilLiveStarts(servers[0].url, servers[0].accessToken, liveVideoUUID)
|
await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoUUID)
|
||||||
|
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
|
await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
|
||||||
|
@ -182,7 +182,7 @@ describe('Save replay setting', function () {
|
||||||
liveVideoUUID = await createLiveWrapper(false)
|
liveVideoUUID = await createLiveWrapper(false)
|
||||||
|
|
||||||
ffmpegCommand = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID)
|
ffmpegCommand = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID)
|
||||||
await waitUntilLiveStarts(servers[0].url, servers[0].accessToken, liveVideoUUID)
|
await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoUUID)
|
||||||
|
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
|
await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
|
||||||
|
@ -216,7 +216,7 @@ describe('Save replay setting', function () {
|
||||||
this.timeout(20000)
|
this.timeout(20000)
|
||||||
|
|
||||||
ffmpegCommand = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID)
|
ffmpegCommand = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID)
|
||||||
await waitUntilLiveStarts(servers[0].url, servers[0].accessToken, liveVideoUUID)
|
await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoUUID)
|
||||||
|
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
|
@ -259,7 +259,7 @@ describe('Save replay setting', function () {
|
||||||
liveVideoUUID = await createLiveWrapper(true)
|
liveVideoUUID = await createLiveWrapper(true)
|
||||||
|
|
||||||
ffmpegCommand = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID)
|
ffmpegCommand = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID)
|
||||||
await waitUntilLiveStarts(servers[0].url, servers[0].accessToken, liveVideoUUID)
|
await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoUUID)
|
||||||
|
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
|
await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
|
||||||
|
@ -285,7 +285,7 @@ describe('Save replay setting', function () {
|
||||||
liveVideoUUID = await createLiveWrapper(true)
|
liveVideoUUID = await createLiveWrapper(true)
|
||||||
|
|
||||||
ffmpegCommand = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID)
|
ffmpegCommand = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID)
|
||||||
await waitUntilLiveStarts(servers[0].url, servers[0].accessToken, liveVideoUUID)
|
await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoUUID)
|
||||||
|
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
|
await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
|
||||||
|
|
|
@ -7,6 +7,7 @@ import { join } from 'path'
|
||||||
import { ffprobePromise, getVideoStreamFromFile } from '@server/helpers/ffprobe-utils'
|
import { ffprobePromise, getVideoStreamFromFile } from '@server/helpers/ffprobe-utils'
|
||||||
import { getLiveNotificationSocket } from '@shared/extra-utils/socket/socket-io'
|
import { getLiveNotificationSocket } from '@shared/extra-utils/socket/socket-io'
|
||||||
import { LiveVideo, LiveVideoCreate, Video, VideoDetails, VideoPrivacy, VideoState, VideoStreamingPlaylistType } from '@shared/models'
|
import { LiveVideo, LiveVideoCreate, Video, VideoDetails, VideoPrivacy, VideoState, VideoStreamingPlaylistType } from '@shared/models'
|
||||||
|
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
||||||
import {
|
import {
|
||||||
addVideoToBlacklist,
|
addVideoToBlacklist,
|
||||||
buildServerDirectory,
|
buildServerDirectory,
|
||||||
|
@ -41,10 +42,9 @@ import {
|
||||||
waitJobs,
|
waitJobs,
|
||||||
waitUntilLiveEnded,
|
waitUntilLiveEnded,
|
||||||
waitUntilLivePublished,
|
waitUntilLivePublished,
|
||||||
waitUntilLiveStarts,
|
waitUntilLiveSegmentGeneration,
|
||||||
waitUntilLog
|
waitUntilLog
|
||||||
} from '../../../../shared/extra-utils'
|
} from '../../../../shared/extra-utils'
|
||||||
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
|
|
||||||
|
@ -329,8 +329,9 @@ describe('Test live', function () {
|
||||||
await checkResolutionsInMasterPlaylist(hlsPlaylist.playlistUrl, resolutions)
|
await checkResolutionsInMasterPlaylist(hlsPlaylist.playlistUrl, resolutions)
|
||||||
|
|
||||||
for (let i = 0; i < resolutions.length; i++) {
|
for (let i = 0; i < resolutions.length; i++) {
|
||||||
const segmentName = `${i}-000001.ts`
|
const segmentNum = 1
|
||||||
await waitUntilLog(servers[0], `${video.uuid}/${segmentName}`, 2, false)
|
const segmentName = `${i}-00000${segmentNum}.ts`
|
||||||
|
await waitUntilLiveSegmentGeneration(servers[0], video.uuid, i, segmentNum)
|
||||||
|
|
||||||
const res = await getPlaylist(`${servers[0].url}/static/streaming-playlists/hls/${video.uuid}/${i}.m3u8`)
|
const res = await getPlaylist(`${servers[0].url}/static/streaming-playlists/hls/${video.uuid}/${i}.m3u8`)
|
||||||
const subPlaylist = res.text
|
const subPlaylist = res.text
|
||||||
|
@ -374,7 +375,7 @@ describe('Test live', function () {
|
||||||
liveVideoId = await createLiveWrapper(false)
|
liveVideoId = await createLiveWrapper(false)
|
||||||
|
|
||||||
const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoId)
|
const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoId)
|
||||||
await waitUntilLiveStarts(servers[0].url, servers[0].accessToken, liveVideoId)
|
await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoId)
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
await testVideoResolutions(liveVideoId, [ 720 ])
|
await testVideoResolutions(liveVideoId, [ 720 ])
|
||||||
|
@ -390,7 +391,7 @@ describe('Test live', function () {
|
||||||
liveVideoId = await createLiveWrapper(false)
|
liveVideoId = await createLiveWrapper(false)
|
||||||
|
|
||||||
const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoId)
|
const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoId)
|
||||||
await waitUntilLiveStarts(servers[0].url, servers[0].accessToken, liveVideoId)
|
await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoId)
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
await testVideoResolutions(liveVideoId, resolutions)
|
await testVideoResolutions(liveVideoId, resolutions)
|
||||||
|
@ -407,7 +408,7 @@ describe('Test live', function () {
|
||||||
liveVideoId = await createLiveWrapper(true)
|
liveVideoId = await createLiveWrapper(true)
|
||||||
|
|
||||||
const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoId, 'video_short2.webm')
|
const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoId, 'video_short2.webm')
|
||||||
await waitUntilLiveStarts(servers[0].url, servers[0].accessToken, liveVideoId)
|
await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoId)
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
await testVideoResolutions(liveVideoId, resolutions)
|
await testVideoResolutions(liveVideoId, resolutions)
|
||||||
|
@ -495,7 +496,7 @@ describe('Test live', function () {
|
||||||
liveVideoId = res.body.video.uuid
|
liveVideoId = res.body.video.uuid
|
||||||
|
|
||||||
command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoId)
|
command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoId)
|
||||||
await waitUntilLiveStarts(servers[0].url, servers[0].accessToken, liveVideoId)
|
await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoId)
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -584,7 +585,7 @@ describe('Test live', function () {
|
||||||
const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID)
|
const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID)
|
||||||
|
|
||||||
for (const server of servers) {
|
for (const server of servers) {
|
||||||
await waitUntilLiveStarts(server.url, server.accessToken, liveVideoUUID)
|
await waitUntilLivePublished(server.url, server.accessToken, liveVideoUUID)
|
||||||
}
|
}
|
||||||
|
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
@ -623,7 +624,7 @@ describe('Test live', function () {
|
||||||
socket.emit('subscribe', { videoId })
|
socket.emit('subscribe', { videoId })
|
||||||
|
|
||||||
const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID)
|
const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID)
|
||||||
await waitUntilLiveStarts(servers[0].url, servers[0].accessToken, liveVideoUUID)
|
await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoUUID)
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
expect(stateChanges).to.have.lengthOf(1)
|
expect(stateChanges).to.have.lengthOf(1)
|
||||||
|
@ -653,7 +654,7 @@ describe('Test live', function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
before(async function () {
|
before(async function () {
|
||||||
this.timeout(60000)
|
this.timeout(120000)
|
||||||
|
|
||||||
liveVideoId = await createLiveWrapper(false)
|
liveVideoId = await createLiveWrapper(false)
|
||||||
liveVideoReplayId = await createLiveWrapper(true)
|
liveVideoReplayId = await createLiveWrapper(true)
|
||||||
|
@ -664,10 +665,13 @@ describe('Test live', function () {
|
||||||
])
|
])
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
waitUntilLiveStarts(servers[0].url, servers[0].accessToken, liveVideoId),
|
waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoId),
|
||||||
waitUntilLiveStarts(servers[0].url, servers[0].accessToken, liveVideoReplayId)
|
waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoReplayId)
|
||||||
])
|
])
|
||||||
|
|
||||||
|
await waitUntilLiveSegmentGeneration(servers[0], liveVideoId, 0, 2)
|
||||||
|
await waitUntilLiveSegmentGeneration(servers[0], liveVideoReplayId, 0, 2)
|
||||||
|
|
||||||
await killallServers([ servers[0] ])
|
await killallServers([ servers[0] ])
|
||||||
await reRunServer(servers[0])
|
await reRunServer(servers[0])
|
||||||
|
|
||||||
|
@ -677,14 +681,11 @@ describe('Test live', function () {
|
||||||
it('Should cleanup lives', async function () {
|
it('Should cleanup lives', async function () {
|
||||||
this.timeout(60000)
|
this.timeout(60000)
|
||||||
|
|
||||||
const res = await getVideo(servers[0].url, liveVideoId)
|
await waitUntilLiveEnded(servers[0].url, servers[0].accessToken, liveVideoId)
|
||||||
const video: VideoDetails = res.body
|
|
||||||
|
|
||||||
expect(video.state.id).to.equal(VideoState.LIVE_ENDED)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should save a live replay', async function () {
|
it('Should save a live replay', async function () {
|
||||||
this.timeout(60000)
|
this.timeout(120000)
|
||||||
|
|
||||||
await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoReplayId)
|
await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoReplayId)
|
||||||
})
|
})
|
||||||
|
|
|
@ -6,11 +6,11 @@ import { pathExists, readdir } from 'fs-extra'
|
||||||
import { omit } from 'lodash'
|
import { omit } from 'lodash'
|
||||||
import { join } from 'path'
|
import { join } from 'path'
|
||||||
import { LiveVideo, LiveVideoCreate, LiveVideoUpdate, VideoDetails, VideoState } from '@shared/models'
|
import { LiveVideo, LiveVideoCreate, LiveVideoUpdate, VideoDetails, VideoState } from '@shared/models'
|
||||||
|
import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
|
||||||
import { buildAbsoluteFixturePath, buildServerDirectory, wait } from '../miscs/miscs'
|
import { buildAbsoluteFixturePath, buildServerDirectory, wait } from '../miscs/miscs'
|
||||||
import { makeGetRequest, makePutBodyRequest, makeUploadRequest } from '../requests/requests'
|
import { makeGetRequest, makePutBodyRequest, makeUploadRequest } from '../requests/requests'
|
||||||
import { ServerInfo } from '../server/servers'
|
import { ServerInfo, waitUntilLog } from '../server/servers'
|
||||||
import { getVideoWithToken } from './videos'
|
import { getVideoWithToken } from './videos'
|
||||||
import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
|
|
||||||
|
|
||||||
function getLive (url: string, token: string, videoId: number | string, statusCodeExpected = HttpStatusCode.OK_200) {
|
function getLive (url: string, token: string, videoId: number | string, statusCodeExpected = HttpStatusCode.OK_200) {
|
||||||
const path = '/api/v1/videos/live'
|
const path = '/api/v1/videos/live'
|
||||||
|
@ -136,19 +136,20 @@ async function stopFfmpeg (command: ffmpeg.FfmpegCommand) {
|
||||||
await wait(500)
|
await wait(500)
|
||||||
}
|
}
|
||||||
|
|
||||||
function waitUntilLiveStarts (url: string, token: string, videoId: number | string) {
|
|
||||||
return waitWhileLiveState(url, token, videoId, VideoState.WAITING_FOR_LIVE)
|
|
||||||
}
|
|
||||||
|
|
||||||
function waitUntilLivePublished (url: string, token: string, videoId: number | string) {
|
function waitUntilLivePublished (url: string, token: string, videoId: number | string) {
|
||||||
return waitWhileLiveState(url, token, videoId, VideoState.PUBLISHED)
|
return waitUntilLiveState(url, token, videoId, VideoState.PUBLISHED)
|
||||||
}
|
}
|
||||||
|
|
||||||
function waitUntilLiveEnded (url: string, token: string, videoId: number | string) {
|
function waitUntilLiveEnded (url: string, token: string, videoId: number | string) {
|
||||||
return waitWhileLiveState(url, token, videoId, VideoState.LIVE_ENDED)
|
return waitUntilLiveState(url, token, videoId, VideoState.LIVE_ENDED)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function waitWhileLiveState (url: string, token: string, videoId: number | string, state: VideoState) {
|
function waitUntilLiveSegmentGeneration (server: ServerInfo, videoUUID: string, resolutionNum: number, segmentNum: number) {
|
||||||
|
const segmentName = `${resolutionNum}-00000${segmentNum}.ts`
|
||||||
|
return waitUntilLog(server, `${videoUUID}/${segmentName}`, 2, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function waitUntilLiveState (url: string, token: string, videoId: number | string, state: VideoState) {
|
||||||
let video: VideoDetails
|
let video: VideoDetails
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
@ -156,7 +157,7 @@ async function waitWhileLiveState (url: string, token: string, videoId: number |
|
||||||
video = res.body
|
video = res.body
|
||||||
|
|
||||||
await wait(500)
|
await wait(500)
|
||||||
} while (video.state.id === state)
|
} while (video.state.id !== state)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function checkLiveCleanup (server: ServerInfo, videoUUID: string, resolutions: number[] = []) {
|
async function checkLiveCleanup (server: ServerInfo, videoUUID: string, resolutions: number[] = []) {
|
||||||
|
@ -200,10 +201,10 @@ export {
|
||||||
getPlaylistsCount,
|
getPlaylistsCount,
|
||||||
waitUntilLivePublished,
|
waitUntilLivePublished,
|
||||||
updateLive,
|
updateLive,
|
||||||
waitUntilLiveStarts,
|
|
||||||
createLive,
|
createLive,
|
||||||
runAndTestFfmpegStreamError,
|
runAndTestFfmpegStreamError,
|
||||||
checkLiveCleanup,
|
checkLiveCleanup,
|
||||||
|
waitUntilLiveSegmentGeneration,
|
||||||
stopFfmpeg,
|
stopFfmpeg,
|
||||||
sendRTMPStreamInVideo,
|
sendRTMPStreamInVideo,
|
||||||
waitUntilLiveEnded,
|
waitUntilLiveEnded,
|
||||||
|
|
Loading…
Reference in New Issue