X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fvideos%2Fvideo-transcoder.ts;h=5ad02df2fc786c95c6d9eca312313eedf8402ebe;hb=1896bca09e088b0da9d5e845407ecebae330618c;hp=32f566506a957e6ecaf2275263f1e02b02091986;hpb=454c20fa7cdb05eba7f1be3c83389b54807af0b3;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/videos/video-transcoder.ts b/server/tests/api/videos/video-transcoder.ts index 32f566506..5ad02df2f 100644 --- a/server/tests/api/videos/video-transcoder.ts +++ b/server/tests/api/videos/video-transcoder.ts @@ -5,7 +5,9 @@ import * as chai from 'chai' import { FfprobeData } from 'fluent-ffmpeg' import { omit } from 'lodash' import { join } from 'path' +import { Job } from '@shared/models' import { VIDEO_TRANSCODING_FPS } from '../../../../server/initializers/constants' +import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' import { buildAbsoluteFixturePath, buildServerDirectory, @@ -14,6 +16,7 @@ import { flushAndRunMultipleServers, generateHighBitrateVideo, generateVideoWithFramerate, + getJobsListPaginationAndSort, getMyVideos, getServerFileSize, getVideo, @@ -37,12 +40,12 @@ import { getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffprobe-utils' -import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' const expect = chai.expect describe('Test video transcoding', function () { let servers: ServerInfo[] = [] + let video4k: string before(async function () { this.timeout(30_000) @@ -508,7 +511,9 @@ describe('Test video transcoding', function () { const resolutions = [ 240, 360, 480, 720, 1080 ] for (const r of resolutions) { - expect(await getServerFileSize(servers[1], `videos/${videoUUID}-${r}.mp4`)).to.be.below(60_000) + const path = `videos/${videoUUID}-${r}.mp4` + const size = await getServerFileSize(servers[1], path) + expect(size, `${path} not below ${60_000}`).to.be.below(60_000) } }) @@ -578,14 +583,14 @@ describe('Test video transcoding', function () { } const resUpload = await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes) - const videoUUID = resUpload.body.video.uuid + video4k = resUpload.body.video.uuid await waitJobs(servers) const resolutions = [ 240, 360, 480, 720, 1080, 1440, 2160 ] for (const server of servers) { - const res = await getVideo(server.url, videoUUID) + const res = await getVideo(server.url, video4k) const videoDetails: VideoDetails = res.body expect(videoDetails.files).to.have.lengthOf(resolutions.length) @@ -597,6 +602,41 @@ describe('Test video transcoding', function () { } }) + it('Should have the appropriate priorities for transcoding jobs', async function () { + const res = await getJobsListPaginationAndSort({ + url: servers[1].url, + accessToken: servers[1].accessToken, + start: 0, + count: 100, + sort: '-createdAt', + jobType: 'video-transcoding' + }) + + const jobs = res.body.data as Job[] + + const transcodingJobs = jobs.filter(j => j.data.videoUUID === video4k) + + expect(transcodingJobs).to.have.lengthOf(14) + + const hlsJobs = transcodingJobs.filter(j => j.data.type === 'new-resolution-to-hls') + const webtorrentJobs = transcodingJobs.filter(j => j.data.type === 'new-resolution-to-webtorrent') + const optimizeJobs = transcodingJobs.filter(j => j.data.type === 'optimize-to-webtorrent') + + expect(hlsJobs).to.have.lengthOf(7) + expect(webtorrentJobs).to.have.lengthOf(6) + expect(optimizeJobs).to.have.lengthOf(1) + + for (const j of optimizeJobs) { + expect(j.priority).to.be.greaterThan(11) + expect(j.priority).to.be.lessThan(50) + } + + for (const j of hlsJobs.concat(webtorrentJobs)) { + expect(j.priority).to.be.greaterThan(100) + expect(j.priority).to.be.lessThan(150) + } + }) + after(async function () { await cleanupTests(servers) })