]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/live/live.ts
Merge branch 'release/3.3.0' into develop
[github/Chocobozzz/PeerTube.git] / server / tests / api / live / live.ts
index 2cce1f4485d73360eb480c7af04d74a3e3612dcb..d555cff194ff89c533fbf077c6e5e136de41fbda 100644 (file)
@@ -2,22 +2,20 @@
 
 import 'mocha'
 import * as chai from 'chai'
-import { join } from 'path'
+import { basename, join } from 'path'
 import { ffprobePromise, getVideoStreamFromFile } from '@server/helpers/ffprobe-utils'
-import { HttpStatusCode } from '@shared/core-utils'
 import {
-  checkLiveCleanup,
+  checkLiveCleanupAfterSave,
   checkLiveSegmentHash,
   checkResolutionsInMasterPlaylist,
   cleanupTests,
+  createMultipleServers,
   doubleFollow,
-  flushAndRunMultipleServers,
   killallServers,
   LiveCommand,
   makeRawRequest,
-  reRunServer,
+  PeerTubeServer,
   sendRTMPStream,
-  ServerInfo,
   setAccessTokensToServers,
   setDefaultVideoChannel,
   stopFfmpeg,
@@ -27,18 +25,26 @@ import {
   waitJobs,
   waitUntilLivePublishedOnAllServers
 } from '@shared/extra-utils'
-import { LiveVideo, LiveVideoCreate, VideoDetails, VideoPrivacy, VideoState, VideoStreamingPlaylistType } from '@shared/models'
+import {
+  HttpStatusCode,
+  LiveVideo,
+  LiveVideoCreate,
+  VideoDetails,
+  VideoPrivacy,
+  VideoState,
+  VideoStreamingPlaylistType
+} from '@shared/models'
 
 const expect = chai.expect
 
 describe('Test live', function () {
-  let servers: ServerInfo[] = []
+  let servers: PeerTubeServer[] = []
   let commands: LiveCommand[]
 
   before(async function () {
     this.timeout(120000)
 
-    servers = await flushAndRunMultipleServers(2)
+    servers = await createMultipleServers(2)
 
     // Get the access tokens
     await setAccessTokensToServers(servers)
@@ -500,6 +506,10 @@ describe('Test live', function () {
         await makeRawRequest(hlsPlaylist.playlistUrl, HttpStatusCode.OK_200)
         await makeRawRequest(hlsPlaylist.segmentsSha256Url, HttpStatusCode.OK_200)
 
+        // We should have generated random filenames
+        expect(basename(hlsPlaylist.playlistUrl)).to.not.equal('master.m3u8')
+        expect(basename(hlsPlaylist.segmentsSha256Url)).to.not.equal('segments-sha256.json')
+
         expect(hlsPlaylist.files).to.have.lengthOf(resolutions.length)
 
         for (const resolution of resolutions) {
@@ -514,7 +524,9 @@ describe('Test live', function () {
             expect(file.fps).to.be.approximately(30, 2)
           }
 
-          const filename = `${video.uuid}-${resolution}-fragmented.mp4`
+          const filename = basename(file.fileUrl)
+          expect(filename).to.not.contain(video.uuid)
+
           const segmentPath = servers[0].servers.buildDirectory(join('streaming-playlists', 'hls', video.uuid, filename))
 
           const probe = await ffprobePromise(segmentPath)
@@ -531,7 +543,7 @@ describe('Test live', function () {
     it('Should correctly have cleaned up the live files', async function () {
       this.timeout(30000)
 
-      await checkLiveCleanup(servers[0], liveVideoId, [ 240, 360, 720 ])
+      await checkLiveCleanupAfterSave(servers[0], liveVideoId, [ 240, 360, 720 ])
     })
   })
 
@@ -571,7 +583,7 @@ describe('Test live', function () {
       await commands[0].waitUntilSegmentGeneration({ videoUUID: liveVideoReplayId, resolution: 0, segment: 2 })
 
       await killallServers([ servers[0] ])
-      await reRunServer(servers[0])
+      await servers[0].run()
 
       await wait(5000)
     })