From 13e13377918b65c30b9334920fef4b43e70b964e Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 22 Jul 2021 08:46:55 +0200 Subject: [PATCH] Speed up plugin transcoding tests --- scripts/benchmark.ts | 6 +- scripts/ci.sh | 2 +- .../main.js | 7 +- .../tests/fixtures/video_very_short_240p.mp4 | Bin 0 -> 9352 bytes server/tests/plugins/plugin-transcoding.ts | 152 +++++++++--------- 5 files changed, 86 insertions(+), 81 deletions(-) create mode 100644 server/tests/fixtures/video_very_short_240p.mp4 diff --git a/scripts/benchmark.ts b/scripts/benchmark.ts index 83b932909..5dcf9b01b 100644 --- a/scripts/benchmark.ts +++ b/scripts/benchmark.ts @@ -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 diff --git a/scripts/ci.sh b/scripts/ci.sh index 7862888b8..71b1be53b 100755 --- a/scripts/ci.sh +++ b/scripts/ci.sh @@ -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 diff --git a/server/tests/fixtures/peertube-plugin-test-transcoding-one/main.js b/server/tests/fixtures/peertube-plugin-test-transcoding-one/main.js index 59b136947..c4ae777f5 100644 --- a/server/tests/fixtures/peertube-plugin-test-transcoding-one/main.js +++ b/server/tests/fixtures/peertube-plugin-test-transcoding-one/main.js @@ -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 index 0000000000000000000000000000000000000000..95b6be92a1dd8d75fe5beb36729f2cca259fd6dc GIT binary patch literal 9352 zcmeHNc{o*F+u!C&rpy^Srb-#kF&uN|LWGbZ)8U-Mi8DCom@7k+M24awMJmdWii8T4 zO2$e=l9VAu5+UJRo0L4g&+}f__r2Hk{qe4=-(G9o>)yZh+xOb*KHJ_w5QMxhLP#POLkB*EtSobLmphH$-|lNSDNU7ofoPW+ z{uHEyRzb)kJjqlX0)<8)sLDuX4TP$SiYFR{2LmPwz(LW%%6OZ+3POLEA@IcFJi&k= znG)=a!_yH;NTjm75>g2TjNWuQMN?5RFfdRdfPlr3eK8~jGSy2Fo<+f%PV@ynWD1=? zCebtzo)`~|rw*7Bhu2X?U~wM4WKSO*lqOOWiNKIBzQHt{4l+nt6B&d;DI{y{X^~8c^d)Ci`H#LC0;;hCebPq5_rr=0!UStXwT`*F>sXn-1z^$XCiu}=ZBN9lU zi=cVpNH|Y_x{eAGmPy6HA*JGI-r#hqr`ylVg~zF$I-XQKg6IL_3SSoJ=qM>GAQ67> z#poav(4a|yiRWufkPcb{7-)1HMMniepnydJHw0Kiz=iPx>kqFc6b?aLEV!5`NNa9( zVn-!o+U(BDOv(1EzCJ#`-mz?_55wq12>N2?m{l2dCgkOzYW(RS7K7+lnn7rDUR(s? z+LrgZ&&k9t>(;AR;DgV9Q|fuU{baL|YeGv*jO#Q{-VOst zyEZ7}Yinp$`%9^d=9UpLC|!Y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whv)^K@VKE324HA%U?Ve z%u9|!b911l30Msoun@=G8%WFx)cNiD`qOg^Jq$M75X1z*2PVX4gH!Gd5Uclxw{?Ry!v)@pNbm@)3Sb8i2yhDE zHoz+Yu)BCA0JZ?Q0)zvc2B-u8Px*WxR(xUrdI0VKdjZY>R0F&Ln1LYvbpQqc9sv6R zG6C)Z0DgYJF97%ji~s@NtS>}yDdyw9*CfxdWlCkl>PR9905Q9U^pOP_+>`z)cl?~`) zmn7qnAIX@Twvdb$egBK*u?_ZXPN#Kh+<_FQQ%VvaAB?JMfa6#i}*!cv<6doQf z1NI3ss0H=-;W36Wa9BZN0Tz}u+`D=qR?uRAL;Wj-{_p`dt0gIP1?Yp{%K7aGW@d)Z zS=wg>ec~P*)w69)b=U8Hg zqq4{kzIOcd=Urllx7i{OoCX&C;h&I2yT}qdtb5T8ZsDK)V7vUZOD?g4ZSd2+eu;g< z61(gY`=%v!`6YIRC3fTzJDdvO7y;c3^kwPK0odW|fXDxf|4a;)rR6mst*$Wz0MD3f z;sHtlo&bCSsTXWPUUh(-0Ca#e^S1#2egVKQ0QdzQ006%L;1?(ZXa@lNf`DI869DiF0)D}h0ObHJ0AIna zA_SlU?v=GPFA5gk2vo8!{5Uv&zt2CiiPAj0D8RBf0y}}(=68XIKbDRGZ6_jbz6MQ5 wV(HT>NU~H6g#t7FEb@efM`W2xbTa(wCI^X`;MI~E8h*3%KQLsUSpWb4 literal 0 HcmV?d00001 diff --git a/server/tests/plugins/plugin-transcoding.ts b/server/tests/plugins/plugin-transcoding.ts index 0bf1fab01..c14c34c7e 100644 --- a/server/tests/plugins/plugin-transcoding.ts +++ b/server/tests/plugins/plugin-transcoding.ts @@ -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')) -- 2.41.0