aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/live/live-save-replay.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/live/live-save-replay.ts')
-rw-r--r--server/tests/api/live/live-save-replay.ts72
1 files changed, 71 insertions, 1 deletions
diff --git a/server/tests/api/live/live-save-replay.ts b/server/tests/api/live/live-save-replay.ts
index fc6acc624..7ddcb04ef 100644
--- a/server/tests/api/live/live-save-replay.ts
+++ b/server/tests/api/live/live-save-replay.ts
@@ -5,7 +5,7 @@ import * as chai from 'chai'
5import { FfmpegCommand } from 'fluent-ffmpeg' 5import { FfmpegCommand } from 'fluent-ffmpeg'
6import { checkLiveCleanup } from '@server/tests/shared' 6import { checkLiveCleanup } from '@server/tests/shared'
7import { wait } from '@shared/core-utils' 7import { wait } from '@shared/core-utils'
8import { HttpStatusCode, LiveVideoCreate, VideoPrivacy, VideoState } from '@shared/models' 8import { HttpStatusCode, LiveVideoCreate, LiveVideoError, VideoPrivacy, VideoState } from '@shared/models'
9import { 9import {
10 cleanupTests, 10 cleanupTests,
11 ConfigCommand, 11 ConfigCommand,
@@ -143,6 +143,9 @@ describe('Save replay setting', function () {
143 }) 143 })
144 144
145 describe('With save replay disabled', function () { 145 describe('With save replay disabled', function () {
146 let sessionStartDateMin: Date
147 let sessionStartDateMax: Date
148 let sessionEndDateMin: Date
146 149
147 it('Should correctly create and federate the "waiting for stream" live', async function () { 150 it('Should correctly create and federate the "waiting for stream" live', async function () {
148 this.timeout(20000) 151 this.timeout(20000)
@@ -160,7 +163,9 @@ describe('Save replay setting', function () {
160 163
161 ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) 164 ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
162 165
166 sessionStartDateMin = new Date()
163 await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID) 167 await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID)
168 sessionStartDateMax = new Date()
164 169
165 await waitJobs(servers) 170 await waitJobs(servers)
166 171
@@ -171,6 +176,7 @@ describe('Save replay setting', function () {
171 it('Should correctly delete the video files after the stream ended', async function () { 176 it('Should correctly delete the video files after the stream ended', async function () {
172 this.timeout(40000) 177 this.timeout(40000)
173 178
179 sessionEndDateMin = new Date()
174 await stopFfmpeg(ffmpegCommand) 180 await stopFfmpeg(ffmpegCommand)
175 181
176 for (const server of servers) { 182 for (const server of servers) {
@@ -186,6 +192,24 @@ describe('Save replay setting', function () {
186 await checkLiveCleanup(servers[0], liveVideoUUID, []) 192 await checkLiveCleanup(servers[0], liveVideoUUID, [])
187 }) 193 })
188 194
195 it('Should have appropriate ended session', async function () {
196 const { data, total } = await servers[0].live.listSessions({ videoId: liveVideoUUID })
197 expect(total).to.equal(1)
198 expect(data).to.have.lengthOf(1)
199
200 const session = data[0]
201
202 const startDate = new Date(session.startDate)
203 expect(startDate).to.be.above(sessionStartDateMin)
204 expect(startDate).to.be.below(sessionStartDateMax)
205
206 expect(session.endDate).to.exist
207 expect(new Date(session.endDate)).to.be.above(sessionEndDateMin)
208
209 expect(session.error).to.not.exist
210 expect(session.replayVideo).to.not.exist
211 })
212
189 it('Should correctly terminate the stream on blacklist and delete the live', async function () { 213 it('Should correctly terminate the stream on blacklist and delete the live', async function () {
190 this.timeout(40000) 214 this.timeout(40000)
191 215
@@ -201,6 +225,15 @@ describe('Save replay setting', function () {
201 await checkLiveCleanup(servers[0], liveVideoUUID, []) 225 await checkLiveCleanup(servers[0], liveVideoUUID, [])
202 }) 226 })
203 227
228 it('Should have blacklisted session error', async function () {
229 const session = await servers[0].live.findLatestSession({ videoId: liveVideoUUID })
230 expect(session.startDate).to.exist
231 expect(session.endDate).to.exist
232
233 expect(session.error).to.equal(LiveVideoError.BLACKLISTED)
234 expect(session.replayVideo).to.not.exist
235 })
236
204 it('Should correctly terminate the stream on delete and delete the video', async function () { 237 it('Should correctly terminate the stream on delete and delete the video', async function () {
205 this.timeout(40000) 238 this.timeout(40000)
206 239
@@ -249,6 +282,22 @@ describe('Save replay setting', function () {
249 await checkVideoState(liveVideoUUID, VideoState.PUBLISHED) 282 await checkVideoState(liveVideoUUID, VideoState.PUBLISHED)
250 }) 283 })
251 284
285 it('Should find the replay live session', async function () {
286 const session = await servers[0].live.getReplaySession({ videoId: liveVideoUUID })
287
288 expect(session).to.exist
289
290 expect(session.startDate).to.exist
291 expect(session.endDate).to.exist
292
293 expect(session.error).to.not.exist
294
295 expect(session.replayVideo).to.exist
296 expect(session.replayVideo.id).to.exist
297 expect(session.replayVideo.shortUUID).to.exist
298 expect(session.replayVideo.uuid).to.equal(liveVideoUUID)
299 })
300
252 it('Should update the saved live and correctly federate the updated attributes', async function () { 301 it('Should update the saved live and correctly federate the updated attributes', async function () {
253 this.timeout(30000) 302 this.timeout(30000)
254 303
@@ -337,6 +386,27 @@ describe('Save replay setting', function () {
337 lastReplayUUID = video.uuid 386 lastReplayUUID = video.uuid
338 }) 387 })
339 388
389 it('Should have appropriate ended session and replay live session', async function () {
390 const { data, total } = await servers[0].live.listSessions({ videoId: liveVideoUUID })
391 expect(total).to.equal(1)
392 expect(data).to.have.lengthOf(1)
393
394 const sessionFromLive = data[0]
395 const sessionFromReplay = await servers[0].live.getReplaySession({ videoId: lastReplayUUID })
396
397 for (const session of [ sessionFromLive, sessionFromReplay ]) {
398 expect(session.startDate).to.exist
399 expect(session.endDate).to.exist
400
401 expect(session.error).to.not.exist
402
403 expect(session.replayVideo).to.exist
404 expect(session.replayVideo.id).to.exist
405 expect(session.replayVideo.shortUUID).to.exist
406 expect(session.replayVideo.uuid).to.equal(lastReplayUUID)
407 }
408 })
409
340 it('Should have cleaned up the live files', async function () { 410 it('Should have cleaned up the live files', async function () {
341 await checkLiveCleanup(servers[0], liveVideoUUID, []) 411 await checkLiveCleanup(servers[0], liveVideoUUID, [])
342 }) 412 })