Speed up plugin transcoding tests

This commit is contained in:
Chocobozzz 2021-07-22 08:46:55 +02:00
parent 7c94e1e7b6
commit 13e1337791
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
5 changed files with 97 additions and 92 deletions

View File

@ -1,10 +1,10 @@
import { registerTSPaths } from '../server/helpers/register-ts-paths'
registerTSPaths()
import * as autocannon from 'autocannon' import * as autocannon from 'autocannon'
import { writeJson } from 'fs-extra' import { writeJson } from 'fs-extra'
import { createSingleServer, killallServers, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils' import { createSingleServer, killallServers, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils'
import { Video, VideoPrivacy } from '@shared/models' import { Video, VideoPrivacy } from '@shared/models'
import { registerTSPaths } from '../server/helpers/register-ts-paths'
registerTSPaths()
let server: PeerTubeServer let server: PeerTubeServer
let video: Video let video: Video

View File

@ -77,7 +77,7 @@ elif [ "$1" = "api-2" ]; then
serverFiles=$(findTestFiles ./dist/server/tests/api/server) serverFiles=$(findTestFiles ./dist/server/tests/api/server)
usersFiles=$(findTestFiles ./dist/server/tests/api/users) 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 elif [ "$1" = "api-3" ]; then
npm run build:server npm run build:server

View File

@ -18,12 +18,12 @@ async function register ({ transcodingManager }) {
const builder = (options) => { const builder = (options) => {
return { return {
outputOptions: [ 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 = () => { const builder = () => {
return { return {
inputOptions: [ inputOptions: [
'-r 5' '-r 50'
] ]
} }
} }
@ -82,7 +82,6 @@ async function register ({ transcodingManager }) {
} }
} }
async function unregister () { async function unregister () {
return return
} }

Binary file not shown.

View File

@ -110,9 +110,11 @@ describe('Test transcoding plugins', function () {
const config = await server.config.getConfig() const config = await server.config.getConfig()
expect(config.transcoding.availableProfiles).to.have.members([ 'default', 'low-vod', 'input-options-vod', 'bad-scale-vod' ]) 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' ])
}) })
describe('VOD', function () {
it('Should not use the plugin profile if not chosen by the admin', async function () { it('Should not use the plugin profile if not chosen by the admin', async function () {
this.timeout(240000) this.timeout(240000)
@ -157,13 +159,16 @@ describe('Test transcoding plugins', function () {
expect(video.files).to.have.lengthOf(1) expect(video.files).to.have.lengthOf(1)
expect(video.streamingPlaylists).to.have.lengthOf(0) expect(video.streamingPlaylists).to.have.lengthOf(0)
}) })
})
describe('Live', function () {
it('Should not use the plugin profile if not chosen by the admin', async function () { it('Should not use the plugin profile if not chosen by the admin', async function () {
this.timeout(240000) this.timeout(240000)
const liveVideoId = await createLiveWrapper(server) const liveVideoId = await createLiveWrapper(server)
await server.live.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_short2.webm' }) await server.live.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_very_short_240p.mp4' })
await server.live.waitUntilPublished({ videoId: liveVideoId }) await server.live.waitUntilPublished({ videoId: liveVideoId })
await waitJobs([ server ]) await waitJobs([ server ])
@ -173,15 +178,15 @@ describe('Test transcoding plugins', function () {
it('Should use the live profile', async function () { it('Should use the live profile', async function () {
this.timeout(240000) this.timeout(240000)
await updateConf(server, 'low-vod', 'low-live') await updateConf(server, 'low-vod', 'high-live')
const liveVideoId = await createLiveWrapper(server) const liveVideoId = await createLiveWrapper(server)
await server.live.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_short2.webm' }) await server.live.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_very_short_240p.mp4' })
await server.live.waitUntilPublished({ videoId: liveVideoId }) await server.live.waitUntilPublished({ videoId: liveVideoId })
await waitJobs([ server ]) await waitJobs([ server ])
await checkLiveFPS(liveVideoId, 'below', 12) await checkLiveFPS(liveVideoId, 'above', 45)
}) })
it('Should apply the input options on live profile', async function () { it('Should apply the input options on live profile', async function () {
@ -191,11 +196,11 @@ describe('Test transcoding plugins', function () {
const liveVideoId = await createLiveWrapper(server) const liveVideoId = await createLiveWrapper(server)
await server.live.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_short2.webm' }) await server.live.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_very_short_240p.mp4' })
await server.live.waitUntilPublished({ videoId: liveVideoId }) await server.live.waitUntilPublished({ videoId: liveVideoId })
await waitJobs([ server ]) await waitJobs([ server ])
await checkLiveFPS(liveVideoId, 'below', 6) await checkLiveFPS(liveVideoId, 'above', 45)
}) })
it('Should apply the scale filter name on live profile', async function () { it('Should apply the scale filter name on live profile', async function () {
@ -205,7 +210,7 @@ describe('Test transcoding plugins', function () {
const liveVideoId = await createLiveWrapper(server) const liveVideoId = await createLiveWrapper(server)
const command = await server.live.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_short2.webm' }) const command = await server.live.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_very_short_240p.mp4' })
await testFfmpegStreamError(command, true) await testFfmpegStreamError(command, true)
}) })
@ -219,11 +224,12 @@ describe('Test transcoding plugins', function () {
expect(config.transcoding.availableProfiles).to.deep.equal([ 'default' ]) expect(config.transcoding.availableProfiles).to.deep.equal([ 'default' ])
expect(config.live.transcoding.availableProfiles).to.deep.equal([ 'default' ]) expect(config.live.transcoding.availableProfiles).to.deep.equal([ 'default' ])
const videoUUID = (await server.videos.quickUpload({ name: 'video' })).uuid const videoUUID = (await server.videos.quickUpload({ name: 'video', fixture: 'video_very_short_240p.mp4' })).uuid
await waitJobs([ server ]) 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 () { it('Should use the new vod encoders', async function () {
this.timeout(240000) 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 ]) await waitJobs([ server ])
const path = server.servers.buildDirectory(join('videos', videoUUID + '-240.mp4')) const path = server.servers.buildDirectory(join('videos', videoUUID + '-240.mp4'))