]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Speed up plugin transcoding tests
authorChocobozzz <me@florianbigard.com>
Thu, 22 Jul 2021 06:46:55 +0000 (08:46 +0200)
committerChocobozzz <me@florianbigard.com>
Thu, 22 Jul 2021 06:55:14 +0000 (08:55 +0200)
scripts/benchmark.ts
scripts/ci.sh
server/tests/fixtures/peertube-plugin-test-transcoding-one/main.js
server/tests/fixtures/video_very_short_240p.mp4 [new file with mode: 0644]
server/tests/plugins/plugin-transcoding.ts

index 83b9329090cd0adf9a167903168cc13ec523703f..5dcf9b01b51472d37f04d2d47e003a19126c7fdc 100644 (file)
@@ -1,10 +1,10 @@
+import { registerTSPaths } from '../server/helpers/register-ts-paths'
+registerTSPaths()
+
 import * as autocannon from 'autocannon'
 import { writeJson } from 'fs-extra'
 import { createSingleServer, killallServers, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils'
 import { Video, VideoPrivacy } from '@shared/models'
-import { registerTSPaths } from '../server/helpers/register-ts-paths'
-
-registerTSPaths()
 
 let server: PeerTubeServer
 let video: Video
index 7862888b8e2e019176846ea71da52fda57d50bd1..71b1be53b78e39db3ee00f4879de3a51d5c94aef 100755 (executable)
@@ -77,7 +77,7 @@ elif [ "$1" = "api-2" ]; then
     serverFiles=$(findTestFiles ./dist/server/tests/api/server)
     usersFiles=$(findTestFiles ./dist/server/tests/api/users)
 
-    MOCHA_PARALLEL=true runTest "$1" 3 $serverFiles $usersFiles $liveFiles
+    MOCHA_PARALLEL=true runTest "$1" 3 $liveFiles $serverFiles $usersFiles
 elif [ "$1" = "api-3" ]; then
     npm run build:server
 
index 59b1369471b2c86e31a0a6612fa6a8c703b07e83..c4ae777f55f0b4426a29107ed79b00b89df49e44 100644 (file)
@@ -18,12 +18,12 @@ async function register ({ transcodingManager }) {
       const builder = (options) => {
         return {
           outputOptions: [
-            '-r:' + options.streamNum + ' 5'
+            '-r:' + options.streamNum + ' 50'
           ]
         }
       }
 
-      transcodingManager.addLiveProfile('libx264', 'low-live', builder)
+      transcodingManager.addLiveProfile('libx264', 'high-live', builder)
     }
   }
 
@@ -45,7 +45,7 @@ async function register ({ transcodingManager }) {
       const builder = () => {
         return {
           inputOptions: [
-            '-r 5'
+            '-r 50'
           ]
         }
       }
@@ -82,7 +82,6 @@ async function register ({ transcodingManager }) {
   }
 }
 
-
 async function unregister () {
   return
 }
diff --git a/server/tests/fixtures/video_very_short_240p.mp4 b/server/tests/fixtures/video_very_short_240p.mp4
new file mode 100644 (file)
index 0000000..95b6be9
Binary files /dev/null and b/server/tests/fixtures/video_very_short_240p.mp4 differ
index 0bf1fab01b387fdea612d01aa87c9aabc20e223c..c14c34c7ec774dd22714d8ec805f8c1cb7e7da4f 100644 (file)
@@ -110,119 +110,125 @@ describe('Test transcoding plugins', function () {
       const config = await server.config.getConfig()
 
       expect(config.transcoding.availableProfiles).to.have.members([ 'default', 'low-vod', 'input-options-vod', 'bad-scale-vod' ])
-      expect(config.live.transcoding.availableProfiles).to.have.members([ 'default', 'low-live', 'input-options-live', 'bad-scale-live' ])
+      expect(config.live.transcoding.availableProfiles).to.have.members([ 'default', 'high-live', 'input-options-live', 'bad-scale-live' ])
     })
 
-    it('Should not use the plugin profile if not chosen by the admin', async function () {
-      this.timeout(240000)
+    describe('VOD', function () {
 
-      const videoUUID = (await server.videos.quickUpload({ name: 'video' })).uuid
-      await waitJobs([ server ])
+      it('Should not use the plugin profile if not chosen by the admin', async function () {
+        this.timeout(240000)
 
-      await checkVideoFPS(videoUUID, 'above', 20)
-    })
+        const videoUUID = (await server.videos.quickUpload({ name: 'video' })).uuid
+        await waitJobs([ server ])
 
-    it('Should use the vod profile', async function () {
-      this.timeout(240000)
+        await checkVideoFPS(videoUUID, 'above', 20)
+      })
 
-      await updateConf(server, 'low-vod', 'default')
+      it('Should use the vod profile', async function () {
+        this.timeout(240000)
 
-      const videoUUID = (await server.videos.quickUpload({ name: 'video' })).uuid
-      await waitJobs([ server ])
+        await updateConf(server, 'low-vod', 'default')
 
-      await checkVideoFPS(videoUUID, 'below', 12)
-    })
+        const videoUUID = (await server.videos.quickUpload({ name: 'video' })).uuid
+        await waitJobs([ server ])
 
-    it('Should apply input options in vod profile', async function () {
-      this.timeout(240000)
+        await checkVideoFPS(videoUUID, 'below', 12)
+      })
 
-      await updateConf(server, 'input-options-vod', 'default')
+      it('Should apply input options in vod profile', async function () {
+        this.timeout(240000)
 
-      const videoUUID = (await server.videos.quickUpload({ name: 'video' })).uuid
-      await waitJobs([ server ])
+        await updateConf(server, 'input-options-vod', 'default')
 
-      await checkVideoFPS(videoUUID, 'below', 6)
-    })
+        const videoUUID = (await server.videos.quickUpload({ name: 'video' })).uuid
+        await waitJobs([ server ])
 
-    it('Should apply the scale filter in vod profile', async function () {
-      this.timeout(240000)
+        await checkVideoFPS(videoUUID, 'below', 6)
+      })
 
-      await updateConf(server, 'bad-scale-vod', 'default')
+      it('Should apply the scale filter in vod profile', async function () {
+        this.timeout(240000)
 
-      const videoUUID = (await server.videos.quickUpload({ name: 'video' })).uuid
-      await waitJobs([ server ])
+        await updateConf(server, 'bad-scale-vod', 'default')
+
+        const videoUUID = (await server.videos.quickUpload({ name: 'video' })).uuid
+        await waitJobs([ server ])
 
-      // Transcoding failed
-      const video = await server.videos.get({ id: videoUUID })
-      expect(video.files).to.have.lengthOf(1)
-      expect(video.streamingPlaylists).to.have.lengthOf(0)
+        // Transcoding failed
+        const video = await server.videos.get({ id: videoUUID })
+        expect(video.files).to.have.lengthOf(1)
+        expect(video.streamingPlaylists).to.have.lengthOf(0)
+      })
     })
 
-    it('Should not use the plugin profile if not chosen by the admin', async function () {
-      this.timeout(240000)
+    describe('Live', function () {
 
-      const liveVideoId = await createLiveWrapper(server)
+      it('Should not use the plugin profile if not chosen by the admin', async function () {
+        this.timeout(240000)
 
-      await server.live.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_short2.webm' })
-      await server.live.waitUntilPublished({ videoId: liveVideoId })
-      await waitJobs([ server ])
+        const liveVideoId = await createLiveWrapper(server)
 
-      await checkLiveFPS(liveVideoId, 'above', 20)
-    })
+        await server.live.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_very_short_240p.mp4' })
+        await server.live.waitUntilPublished({ videoId: liveVideoId })
+        await waitJobs([ server ])
 
-    it('Should use the live profile', async function () {
-      this.timeout(240000)
+        await checkLiveFPS(liveVideoId, 'above', 20)
+      })
 
-      await updateConf(server, 'low-vod', 'low-live')
+      it('Should use the live profile', async function () {
+        this.timeout(240000)
 
-      const liveVideoId = await createLiveWrapper(server)
+        await updateConf(server, 'low-vod', 'high-live')
 
-      await server.live.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_short2.webm' })
-      await server.live.waitUntilPublished({ videoId: liveVideoId })
-      await waitJobs([ server ])
+        const liveVideoId = await createLiveWrapper(server)
 
-      await checkLiveFPS(liveVideoId, 'below', 12)
-    })
+        await server.live.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_very_short_240p.mp4' })
+        await server.live.waitUntilPublished({ videoId: liveVideoId })
+        await waitJobs([ server ])
 
-    it('Should apply the input options on live profile', async function () {
-      this.timeout(240000)
+        await checkLiveFPS(liveVideoId, 'above', 45)
+      })
 
-      await updateConf(server, 'low-vod', 'input-options-live')
+      it('Should apply the input options on live profile', async function () {
+        this.timeout(240000)
 
-      const liveVideoId = await createLiveWrapper(server)
+        await updateConf(server, 'low-vod', 'input-options-live')
 
-      await server.live.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_short2.webm' })
-      await server.live.waitUntilPublished({ videoId: liveVideoId })
-      await waitJobs([ server ])
+        const liveVideoId = await createLiveWrapper(server)
 
-      await checkLiveFPS(liveVideoId, 'below', 6)
-    })
+        await server.live.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_very_short_240p.mp4' })
+        await server.live.waitUntilPublished({ videoId: liveVideoId })
+        await waitJobs([ server ])
 
-    it('Should apply the scale filter name on live profile', async function () {
-      this.timeout(240000)
+        await checkLiveFPS(liveVideoId, 'above', 45)
+      })
 
-      await updateConf(server, 'low-vod', 'bad-scale-live')
+      it('Should apply the scale filter name on live profile', async function () {
+        this.timeout(240000)
 
-      const liveVideoId = await createLiveWrapper(server)
+        await updateConf(server, 'low-vod', 'bad-scale-live')
 
-      const command = await server.live.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_short2.webm' })
-      await testFfmpegStreamError(command, true)
-    })
+        const liveVideoId = await createLiveWrapper(server)
 
-    it('Should default to the default profile if the specified profile does not exist', async function () {
-      this.timeout(240000)
+        const command = await server.live.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_very_short_240p.mp4' })
+        await testFfmpegStreamError(command, true)
+      })
 
-      await server.plugins.uninstall({ npmName: 'peertube-plugin-test-transcoding-one' })
+      it('Should default to the default profile if the specified profile does not exist', async function () {
+        this.timeout(240000)
 
-      const config = await server.config.getConfig()
+        await server.plugins.uninstall({ npmName: 'peertube-plugin-test-transcoding-one' })
 
-      expect(config.transcoding.availableProfiles).to.deep.equal([ 'default' ])
-      expect(config.live.transcoding.availableProfiles).to.deep.equal([ 'default' ])
+        const config = await server.config.getConfig()
 
-      const videoUUID = (await server.videos.quickUpload({ name: 'video' })).uuid
-      await waitJobs([ server ])
+        expect(config.transcoding.availableProfiles).to.deep.equal([ 'default' ])
+        expect(config.live.transcoding.availableProfiles).to.deep.equal([ 'default' ])
+
+        const videoUUID = (await server.videos.quickUpload({ name: 'video', fixture: 'video_very_short_240p.mp4' })).uuid
+        await waitJobs([ server ])
 
-      await checkVideoFPS(videoUUID, 'above', 20)
+        await checkVideoFPS(videoUUID, 'above', 20)
+      })
     })
 
   })
@@ -238,7 +244,7 @@ describe('Test transcoding plugins', function () {
     it('Should use the new vod encoders', async function () {
       this.timeout(240000)
 
-      const videoUUID = (await server.videos.quickUpload({ name: 'video', fixture: 'video_short_240p.mp4' })).uuid
+      const videoUUID = (await server.videos.quickUpload({ name: 'video', fixture: 'video_very_short_240p.mp4' })).uuid
       await waitJobs([ server ])
 
       const path = server.servers.buildDirectory(join('videos', videoUUID + '-240.mp4'))