X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fplugins%2Fplugin-transcoding.ts;h=c14c34c7ec774dd22714d8ec805f8c1cb7e7da4f;hb=13e13377918b65c30b9334920fef4b43e70b964e;hp=a3613293a43932a6d38f8868f06fee1d1fbe3108;hpb=d23dd9fbfc4d26026352c10f81d2795ceaf2908a;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/plugins/plugin-transcoding.ts b/server/tests/plugins/plugin-transcoding.ts index a3613293a..c14c34c7e 100644 --- a/server/tests/plugins/plugin-transcoding.ts +++ b/server/tests/plugins/plugin-transcoding.ts @@ -6,9 +6,9 @@ import { join } from 'path' import { getAudioStream, getVideoFileFPS, getVideoStreamFromFile } from '@server/helpers/ffprobe-utils' import { cleanupTests, - flushAndRunServer, + createSingleServer, + PeerTubeServer, PluginsCommand, - ServerInfo, setAccessTokensToServers, setDefaultVideoChannel, testFfmpegStreamError, @@ -16,20 +16,20 @@ import { } from '@shared/extra-utils' import { VideoPrivacy } from '@shared/models' -async function createLiveWrapper (server: ServerInfo) { +async function createLiveWrapper (server: PeerTubeServer) { const liveAttributes = { name: 'live video', - channelId: server.videoChannel.id, + channelId: server.store.channel.id, privacy: VideoPrivacy.PUBLIC } - const { uuid } = await server.liveCommand.create({ fields: liveAttributes }) + const { uuid } = await server.live.create({ fields: liveAttributes }) return uuid } -function updateConf (server: ServerInfo, vodProfile: string, liveProfile: string) { - return server.configCommand.updateCustomSubConfig({ +function updateConf (server: PeerTubeServer, vodProfile: string, liveProfile: string) { + return server.config.updateCustomSubConfig({ newConfig: { transcoding: { enabled: true, @@ -64,12 +64,12 @@ function updateConf (server: ServerInfo, vodProfile: string, liveProfile: string } describe('Test transcoding plugins', function () { - let server: ServerInfo + let server: PeerTubeServer before(async function () { this.timeout(60000) - server = await flushAndRunServer(1) + server = await createSingleServer(1) await setAccessTokensToServers([ server ]) await setDefaultVideoChannel([ server ]) @@ -79,7 +79,7 @@ describe('Test transcoding plugins', function () { describe('When using a plugin adding profiles to existing encoders', function () { async function checkVideoFPS (uuid: string, type: 'above' | 'below', fps: number) { - const video = await server.videosCommand.get({ id: uuid }) + const video = await server.videos.get({ id: uuid }) const files = video.files.concat(...video.streamingPlaylists.map(p => p.files)) for (const file of files) { @@ -103,126 +103,132 @@ describe('Test transcoding plugins', function () { } before(async function () { - await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-transcoding-one') }) + await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-transcoding-one') }) }) it('Should have the appropriate available profiles', async function () { - const config = await server.configCommand.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.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.videosCommand.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.videosCommand.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.videosCommand.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.videosCommand.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.videosCommand.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.liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_short2.webm' }) - await server.liveCommand.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.liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_short2.webm' }) - await server.liveCommand.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.liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_short2.webm' }) - await server.liveCommand.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.liveCommand.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.pluginsCommand.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.configCommand.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.videosCommand.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) + }) }) }) @@ -230,7 +236,7 @@ describe('Test transcoding plugins', function () { describe('When using a plugin adding new encoders', function () { before(async function () { - await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-transcoding-two') }) + await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-transcoding-two') }) await updateConf(server, 'test-vod-profile', 'test-live-profile') }) @@ -238,10 +244,10 @@ describe('Test transcoding plugins', function () { it('Should use the new vod encoders', async function () { this.timeout(240000) - const videoUUID = (await server.videosCommand.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.serversCommand.buildDirectory(join('videos', videoUUID + '-240.mp4')) + const path = server.servers.buildDirectory(join('videos', videoUUID + '-240.mp4')) const audioProbe = await getAudioStream(path) expect(audioProbe.audioStream.codec_name).to.equal('opus') @@ -254,8 +260,8 @@ describe('Test transcoding plugins', function () { const liveVideoId = await createLiveWrapper(server) - await server.liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_short2.webm' }) - await server.liveCommand.waitUntilPublished({ videoId: liveVideoId }) + await server.live.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_short2.webm' }) + await server.live.waitUntilPublished({ videoId: liveVideoId }) await waitJobs([ server ]) const playlistUrl = `${server.url}/static/streaming-playlists/hls/${liveVideoId}/0.m3u8`