aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/videos/video-transcoder.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-01-25 11:33:26 +0100
committerChocobozzz <chocobozzz@cpy.re>2021-01-25 14:38:52 +0100
commit6939cbac48e0a9823b34577836480ae3c28186be (patch)
tree9ee44d4d26931ee0550121acd4f19e83b4c5caf3 /server/tests/api/videos/video-transcoder.ts
parent77d7e851dccf17dcc89e8fcc2db3f655d1e63f95 (diff)
downloadPeerTube-6939cbac48e0a9823b34577836480ae3c28186be.tar.gz
PeerTube-6939cbac48e0a9823b34577836480ae3c28186be.tar.zst
PeerTube-6939cbac48e0a9823b34577836480ae3c28186be.zip
Safely remove webtorrent files
Only remove them on max quality HLS playlist generation
Diffstat (limited to 'server/tests/api/videos/video-transcoder.ts')
-rw-r--r--server/tests/api/videos/video-transcoder.ts44
1 files changed, 41 insertions, 3 deletions
diff --git a/server/tests/api/videos/video-transcoder.ts b/server/tests/api/videos/video-transcoder.ts
index 32f566506..631230f26 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'
5import { FfprobeData } from 'fluent-ffmpeg' 5import { FfprobeData } from 'fluent-ffmpeg'
6import { omit } from 'lodash' 6import { omit } from 'lodash'
7import { join } from 'path' 7import { join } from 'path'
8import { Job } from '@shared/models'
8import { VIDEO_TRANSCODING_FPS } from '../../../../server/initializers/constants' 9import { VIDEO_TRANSCODING_FPS } from '../../../../server/initializers/constants'
10import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
9import { 11import {
10 buildAbsoluteFixturePath, 12 buildAbsoluteFixturePath,
11 buildServerDirectory, 13 buildServerDirectory,
@@ -14,6 +16,7 @@ import {
14 flushAndRunMultipleServers, 16 flushAndRunMultipleServers,
15 generateHighBitrateVideo, 17 generateHighBitrateVideo,
16 generateVideoWithFramerate, 18 generateVideoWithFramerate,
19 getJobsListPaginationAndSort,
17 getMyVideos, 20 getMyVideos,
18 getServerFileSize, 21 getServerFileSize,
19 getVideo, 22 getVideo,
@@ -37,12 +40,12 @@ import {
37 getVideoFileFPS, 40 getVideoFileFPS,
38 getVideoFileResolution 41 getVideoFileResolution
39} from '../../../helpers/ffprobe-utils' 42} from '../../../helpers/ffprobe-utils'
40import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
41 43
42const expect = chai.expect 44const expect = chai.expect
43 45
44describe('Test video transcoding', function () { 46describe('Test video transcoding', function () {
45 let servers: ServerInfo[] = [] 47 let servers: ServerInfo[] = []
48 let video4k: string
46 49
47 before(async function () { 50 before(async function () {
48 this.timeout(30_000) 51 this.timeout(30_000)
@@ -578,14 +581,14 @@ describe('Test video transcoding', function () {
578 } 581 }
579 582
580 const resUpload = await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes) 583 const resUpload = await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes)
581 const videoUUID = resUpload.body.video.uuid 584 video4k = resUpload.body.video.uuid
582 585
583 await waitJobs(servers) 586 await waitJobs(servers)
584 587
585 const resolutions = [ 240, 360, 480, 720, 1080, 1440, 2160 ] 588 const resolutions = [ 240, 360, 480, 720, 1080, 1440, 2160 ]
586 589
587 for (const server of servers) { 590 for (const server of servers) {
588 const res = await getVideo(server.url, videoUUID) 591 const res = await getVideo(server.url, video4k)
589 const videoDetails: VideoDetails = res.body 592 const videoDetails: VideoDetails = res.body
590 593
591 expect(videoDetails.files).to.have.lengthOf(resolutions.length) 594 expect(videoDetails.files).to.have.lengthOf(resolutions.length)
@@ -597,6 +600,41 @@ describe('Test video transcoding', function () {
597 } 600 }
598 }) 601 })
599 602
603 it('Should have the appropriate priorities for transcoding jobs', async function () {
604 const res = await getJobsListPaginationAndSort({
605 url: servers[1].url,
606 accessToken: servers[1].accessToken,
607 start: 0,
608 count: 100,
609 sort: '-createdAt',
610 jobType: 'video-transcoding'
611 })
612
613 const jobs = res.body.data as Job[]
614
615 const transcodingJobs = jobs.filter(j => j.data.videoUUID === video4k)
616
617 expect(transcodingJobs).to.have.lengthOf(14)
618
619 const hlsJobs = transcodingJobs.filter(j => j.data.type === 'new-resolution-to-hls')
620 const webtorrentJobs = transcodingJobs.filter(j => j.data.type === 'new-resolution-to-webtorrent')
621 const optimizeJobs = transcodingJobs.filter(j => j.data.type === 'optimize-to-webtorrent')
622
623 expect(hlsJobs).to.have.lengthOf(7)
624 expect(webtorrentJobs).to.have.lengthOf(6)
625 expect(optimizeJobs).to.have.lengthOf(1)
626
627 for (const j of optimizeJobs) {
628 expect(j.priority).to.be.greaterThan(11)
629 expect(j.priority).to.be.lessThan(50)
630 }
631
632 for (const j of hlsJobs.concat(webtorrentJobs)) {
633 expect(j.priority).to.be.greaterThan(100)
634 expect(j.priority).to.be.lessThan(150)
635 }
636 })
637
600 after(async function () { 638 after(async function () {
601 await cleanupTests(servers) 639 await cleanupTests(servers)
602 }) 640 })