aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/api/live/live-save-replay.ts34
-rw-r--r--server/tests/shared/live.ts24
2 files changed, 56 insertions, 2 deletions
diff --git a/server/tests/api/live/live-save-replay.ts b/server/tests/api/live/live-save-replay.ts
index 7ddcb04ef..007af51e9 100644
--- a/server/tests/api/live/live-save-replay.ts
+++ b/server/tests/api/live/live-save-replay.ts
@@ -441,6 +441,40 @@ describe('Save replay setting', function () {
441 await checkVideosExist(liveVideoUUID, false, HttpStatusCode.NOT_FOUND_404) 441 await checkVideosExist(liveVideoUUID, false, HttpStatusCode.NOT_FOUND_404)
442 await checkLiveCleanup(servers[0], liveVideoUUID, []) 442 await checkLiveCleanup(servers[0], liveVideoUUID, [])
443 }) 443 })
444
445 it('Should correctly save replays with multiple sessions', async function () {
446 this.timeout(120000)
447
448 liveVideoUUID = await createLiveWrapper({ permanent: true, replay: true })
449 await waitJobs(servers)
450
451 // Streaming session #1
452 ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
453 await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID)
454 await stopFfmpeg(ffmpegCommand)
455 await servers[0].live.waitUntilWaiting({ videoId: liveVideoUUID })
456
457 // Streaming session #2
458 ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
459 await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID)
460 await stopFfmpeg(ffmpegCommand)
461 await waitUntilLiveWaitingOnAllServers(servers, liveVideoUUID)
462
463 // Wait for replays
464 await waitJobs(servers)
465
466 const { total, data: sessions } = await servers[0].live.listSessions({ videoId: liveVideoUUID })
467
468 expect(total).to.equal(2)
469 expect(sessions).to.have.lengthOf(2)
470
471 for (const session of sessions) {
472 expect(session.error).to.be.null
473 expect(session.replayVideo).to.exist
474
475 await servers[0].videos.get({ id: session.replayVideo.uuid })
476 }
477 })
444 }) 478 })
445 479
446 after(async function () { 480 after(async function () {
diff --git a/server/tests/shared/live.ts b/server/tests/shared/live.ts
index 6ee4899b0..4bd4786fc 100644
--- a/server/tests/shared/live.ts
+++ b/server/tests/shared/live.ts
@@ -3,15 +3,35 @@
3import { expect } from 'chai' 3import { expect } from 'chai'
4import { pathExists, readdir } from 'fs-extra' 4import { pathExists, readdir } from 'fs-extra'
5import { join } from 'path' 5import { join } from 'path'
6import { LiveVideo } from '@shared/models'
6import { PeerTubeServer } from '@shared/server-commands' 7import { PeerTubeServer } from '@shared/server-commands'
7 8
8async function checkLiveCleanup (server: PeerTubeServer, videoUUID: string, savedResolutions: number[] = []) { 9async function checkLiveCleanup (server: PeerTubeServer, videoUUID: string, savedResolutions: number[] = []) {
10 let live: LiveVideo
11
12 try {
13 live = await server.live.get({ videoId: videoUUID })
14 } catch {}
15
9 const basePath = server.servers.buildDirectory('streaming-playlists') 16 const basePath = server.servers.buildDirectory('streaming-playlists')
10 const hlsPath = join(basePath, 'hls', videoUUID) 17 const hlsPath = join(basePath, 'hls', videoUUID)
11 18
12 if (savedResolutions.length === 0) { 19 if (savedResolutions.length === 0) {
13 const result = await pathExists(hlsPath) 20
14 expect(result).to.be.false 21 if (live?.permanentLive) {
22 expect(await pathExists(hlsPath)).to.be.true
23
24 const hlsFiles = await readdir(hlsPath)
25 expect(hlsFiles).to.have.lengthOf(1) // Only replays directory
26
27 const replayDir = join(hlsPath, 'replay')
28 expect(await pathExists(replayDir)).to.be.true
29
30 const replayFiles = await readdir(join(hlsPath, 'replay'))
31 expect(replayFiles).to.have.lengthOf(0)
32 } else {
33 expect(await pathExists(hlsPath)).to.be.false
34 }
15 35
16 return 36 return
17 } 37 }