X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fcli%2Fcreate-transcoding-job.ts;h=c2e3840c59b360e6d6bb28cb7e2efba9a6509bf4;hb=fbad87b0472f574409f7aa3ae7f8b54927d0cdd6;hp=fe1c0c03d7753a4a769293b83ed02bac14234ee6;hpb=2186386cca113506791583cb07d6ccacba7af4e0;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/cli/create-transcoding-job.ts b/server/tests/cli/create-transcoding-job.ts index fe1c0c03d..c2e3840c5 100644 --- a/server/tests/cli/create-transcoding-job.ts +++ b/server/tests/cli/create-transcoding-job.ts @@ -3,25 +3,26 @@ import 'mocha' import * as chai from 'chai' import { VideoDetails } from '../../../shared/models/videos' -const expect = chai.expect - import { + doubleFollow, execCLI, + flushAndRunMultipleServers, flushTests, getEnvCli, + getVideo, getVideosList, killallServers, - parseTorrentVideo, - runServer, ServerInfo, setAccessTokensToServers, - uploadVideo, - wait, - getVideo, flushAndRunMultipleServers, doubleFollow + uploadVideo, wait } from '../utils' +import { waitJobs } from '../utils/server/jobs' + +const expect = chai.expect describe('Test create transcoding jobs', function () { let servers: ServerInfo[] = [] + let video1UUID: string let video2UUID: string before(async function () { @@ -36,11 +37,12 @@ describe('Test create transcoding jobs', function () { await doubleFollow(servers[0], servers[1]) // Upload two videos for our needs - await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video1' }) - const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video2' }) - video2UUID = res.body.video.uuid + const res1 = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video1' }) + video1UUID = res1.body.video.uuid + const res2 = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video2' }) + video2UUID = res2.body.video.uuid - await wait(3000) + await waitJobs(servers) }) it('Should have two video files on each server', async function () { @@ -65,7 +67,7 @@ describe('Test create transcoding jobs', function () { const env = getEnvCli(servers[0]) await execCLI(`${env} npm run create-transcoding-job -- -v ${video2UUID}`) - await wait(40000) + await waitJobs(servers) for (const server of servers) { const res = await getVideosList(server.url) @@ -100,12 +102,31 @@ describe('Test create transcoding jobs', function () { } }) - after(async function () { - killallServers(servers) + it('Should run a transcoding job on video 1 with resolution', async function () { + this.timeout(60000) + + const env = getEnvCli(servers[0]) + await execCLI(`${env} npm run create-transcoding-job -- -v ${video1UUID} -r 480`) + + await waitJobs(servers) + + for (const server of servers) { + const res = await getVideosList(server.url) + const videos = res.body.data + expect(videos).to.have.lengthOf(2) + + const res2 = await getVideo(server.url, video1UUID) + const videoDetail: VideoDetails = res2.body + + expect(videoDetail.files).to.have.lengthOf(2) - // Keep the logs if the test failed - if (this['ok']) { - await flushTests() + expect(videoDetail.files[0].resolution.id).to.equal(720) + + expect(videoDetail.files[1].resolution.id).to.equal(480) } }) + + after(async function () { + killallServers(servers) + }) })