]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/live/live.ts
Merge branch 'release/4.0.0' into develop
[github/Chocobozzz/PeerTube.git] / server / tests / api / live / live.ts
index ba952aff57c2204e45fa45f2b4cb62447ebef8cd..3f9355d2de6a3265ae696262e8843fd127408a3f 100644 (file)
@@ -4,10 +4,18 @@ import 'mocha'
 import * as chai from 'chai'
 import { basename, join } from 'path'
 import { ffprobePromise, getVideoStreamFromFile } from '@server/helpers/ffprobe-utils'
+import { checkLiveCleanupAfterSave, checkLiveSegmentHash, checkResolutionsInMasterPlaylist, testImage } from '@server/tests/shared'
+import { wait } from '@shared/core-utils'
+import {
+  HttpStatusCode,
+  LiveVideo,
+  LiveVideoCreate,
+  VideoDetails,
+  VideoPrivacy,
+  VideoState,
+  VideoStreamingPlaylistType
+} from '@shared/models'
 import {
-  checkLiveCleanupAfterSave,
-  checkLiveSegmentHash,
-  checkResolutionsInMasterPlaylist,
   cleanupTests,
   createMultipleServers,
   doubleFollow,
@@ -20,20 +28,9 @@ import {
   setDefaultVideoChannel,
   stopFfmpeg,
   testFfmpegStreamError,
-  testImage,
-  wait,
   waitJobs,
   waitUntilLivePublishedOnAllServers
-} from '@shared/extra-utils'
-import {
-  HttpStatusCode,
-  LiveVideo,
-  LiveVideoCreate,
-  VideoDetails,
-  VideoPrivacy,
-  VideoState,
-  VideoStreamingPlaylistType
-} from '@shared/models'
+} from '@shared/server-commands'
 
 const expect = chai.expect
 
@@ -421,6 +418,7 @@ describe('Test live', function () {
             transcoding: {
               enabled: true,
               resolutions: {
+                '144p': resolutions.includes(144),
                 '240p': resolutions.includes(240),
                 '360p': resolutions.includes(360),
                 '480p': resolutions.includes(480),
@@ -439,7 +437,7 @@ describe('Test live', function () {
     })
 
     it('Should enable transcoding without additional resolutions', async function () {
-      this.timeout(60000)
+      this.timeout(120000)
 
       liveVideoId = await createLiveWrapper(false)
 
@@ -453,7 +451,7 @@ describe('Test live', function () {
     })
 
     it('Should enable transcoding with some resolutions', async function () {
-      this.timeout(60000)
+      this.timeout(120000)
 
       const resolutions = [ 240, 480 ]
       await updateConf(resolutions)
@@ -497,7 +495,7 @@ describe('Test live', function () {
     })
 
     it('Should enable transcoding with some resolutions and correctly save them', async function () {
-      this.timeout(200000)
+      this.timeout(400_000)
 
       const resolutions = [ 240, 360, 720 ]
 
@@ -517,10 +515,16 @@ describe('Test live', function () {
 
       await waitUntilLivePublishedOnAllServers(servers, liveVideoId)
 
-      const bitrateLimits = {
-        720: 5000 * 1000, // 60FPS
-        360: 1100 * 1000,
-        240: 600 * 1000
+      const maxBitrateLimits = {
+        720: 6500 * 1000, // 60FPS
+        360: 1250 * 1000,
+        240: 700 * 1000
+      }
+
+      const minBitrateLimits = {
+        720: 5500 * 1000,
+        360: 1000 * 1000,
+        240: 550 * 1000
       }
 
       for (const server of servers) {
@@ -560,7 +564,8 @@ describe('Test live', function () {
           const probe = await ffprobePromise(segmentPath)
           const videoStream = await getVideoStreamFromFile(segmentPath, probe)
 
-          expect(probe.format.bit_rate).to.be.below(bitrateLimits[videoStream.height])
+          expect(probe.format.bit_rate).to.be.below(maxBitrateLimits[videoStream.height])
+          expect(probe.format.bit_rate).to.be.at.least(minBitrateLimits[videoStream.height])
 
           await makeRawRequest(file.torrentUrl, HttpStatusCode.OK_200)
           await makeRawRequest(file.fileUrl, HttpStatusCode.OK_200)