import * as chai from 'chai'
import { FfmpegCommand } from 'fluent-ffmpeg'
import { LiveVideoCreate, VideoDetails, VideoPrivacy, VideoState } from '@shared/models'
+import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
import {
addVideoToBlacklist,
checkLiveCleanup,
createLive,
doubleFollow,
flushAndRunMultipleServers,
+ getCustomConfigResolutions,
getVideo,
getVideosList,
removeVideo,
testFfmpegStreamError,
updateCustomSubConfig,
updateVideo,
+ wait,
waitJobs,
- waitUntilLivePublished
+ waitUntilLiveEnded,
+ waitUntilLivePublished,
+ waitUntilLiveSaved
} from '../../../../shared/extra-utils'
-import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
const expect = chai.expect
}
}
+ async function waitUntilLivePublishedOnAllServers (videoId: string) {
+ for (const server of servers) {
+ await waitUntilLivePublished(server.url, server.accessToken, videoId)
+ }
+ }
+
+ async function waitUntilLiveSavedOnAllServers (videoId: string) {
+ for (const server of servers) {
+ await waitUntilLiveSaved(server.url, server.accessToken, videoId)
+ }
+ }
+
before(async function () {
this.timeout(120000)
maxDuration: -1,
transcoding: {
enabled: false,
- resolutions: {
- '240p': true,
- '360p': true,
- '480p': true,
- '720p': true,
- '1080p': true,
- '1440p': true,
- '2160p': true
- }
+ resolutions: getCustomConfigResolutions(true)
}
}
})
})
it('Should correctly have updated the live and federated it when streaming in the live', async function () {
- this.timeout(20000)
+ this.timeout(30000)
ffmpegCommand = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID)
- await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoUUID)
+
+ await waitUntilLivePublishedOnAllServers(liveVideoUUID)
await waitJobs(servers)
await stopFfmpeg(ffmpegCommand)
+ for (const server of servers) {
+ await waitUntilLiveEnded(server.url, server.accessToken, liveVideoUUID)
+ }
await waitJobs(servers)
// Live still exist, but cannot be played anymore
await checkVideosExist(liveVideoUUID, false, HttpStatusCode.OK_200)
await checkVideoState(liveVideoUUID, VideoState.LIVE_ENDED)
- await waitJobs(servers)
-
// No resolutions saved since we did not save replay
await checkLiveCleanup(servers[0], liveVideoUUID, [])
})
liveVideoUUID = await createLiveWrapper(false)
ffmpegCommand = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID)
- await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoUUID)
+
+ await waitUntilLivePublishedOnAllServers(liveVideoUUID)
await waitJobs(servers)
await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
await getVideo(servers[0].url, liveVideoUUID, HttpStatusCode.UNAUTHORIZED_401)
await getVideo(servers[1].url, liveVideoUUID, HttpStatusCode.NOT_FOUND_404)
+ await wait(5000)
+ await waitJobs(servers)
await checkLiveCleanup(servers[0], liveVideoUUID, [])
})
liveVideoUUID = await createLiveWrapper(false)
ffmpegCommand = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID)
- await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoUUID)
+
+ await waitUntilLivePublishedOnAllServers(liveVideoUUID)
await waitJobs(servers)
await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
removeVideo(servers[0].url, servers[0].accessToken, liveVideoUUID)
])
+ await wait(5000)
await waitJobs(servers)
await checkVideosExist(liveVideoUUID, false, HttpStatusCode.NOT_FOUND_404)
this.timeout(20000)
ffmpegCommand = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID)
- await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoUUID)
+ await waitUntilLivePublishedOnAllServers(liveVideoUUID)
await waitJobs(servers)
await stopFfmpeg(ffmpegCommand)
+ await waitUntilLiveSavedOnAllServers(liveVideoUUID)
await waitJobs(servers)
// Live has been transcoded
liveVideoUUID = await createLiveWrapper(true)
ffmpegCommand = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID)
- await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoUUID)
+ await waitUntilLivePublishedOnAllServers(liveVideoUUID)
await waitJobs(servers)
await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
await getVideo(servers[0].url, liveVideoUUID, HttpStatusCode.UNAUTHORIZED_401)
await getVideo(servers[1].url, liveVideoUUID, HttpStatusCode.NOT_FOUND_404)
+ await wait(5000)
+ await waitJobs(servers)
await checkLiveCleanup(servers[0], liveVideoUUID, [ 720 ])
})
liveVideoUUID = await createLiveWrapper(true)
ffmpegCommand = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID)
- await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoUUID)
+ await waitUntilLivePublishedOnAllServers(liveVideoUUID)
await waitJobs(servers)
await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
testFfmpegStreamError(ffmpegCommand, true)
])
+ await wait(5000)
await waitJobs(servers)
await checkVideosExist(liveVideoUUID, false, HttpStatusCode.NOT_FOUND_404)