diff options
author | Chocobozzz <me@florianbigard.com> | 2022-08-05 15:05:20 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-08-09 09:18:07 +0200 |
commit | 5e2afe4290103bf0d54ae7b3e62781f2a00487c9 (patch) | |
tree | 84e084135c60d208fc9afcee63180d3200f763e6 /server/tests/api/videos | |
parent | 64fd6158fd276f258bcfc4bb0c8fc2f64a220a11 (diff) | |
download | PeerTube-5e2afe4290103bf0d54ae7b3e62781f2a00487c9.tar.gz PeerTube-5e2afe4290103bf0d54ae7b3e62781f2a00487c9.tar.zst PeerTube-5e2afe4290103bf0d54ae7b3e62781f2a00487c9.zip |
Limit import depending on transcoding resolutions
Diffstat (limited to 'server/tests/api/videos')
-rw-r--r-- | server/tests/api/videos/video-imports.ts | 98 |
1 files changed, 85 insertions, 13 deletions
diff --git a/server/tests/api/videos/video-imports.ts b/server/tests/api/videos/video-imports.ts index cf9f7d0cb..603e2d234 100644 --- a/server/tests/api/videos/video-imports.ts +++ b/server/tests/api/videos/video-imports.ts | |||
@@ -6,7 +6,7 @@ import { pathExists, readdir, remove } from 'fs-extra' | |||
6 | import { join } from 'path' | 6 | import { join } from 'path' |
7 | import { FIXTURE_URLS, testCaptionFile, testImage } from '@server/tests/shared' | 7 | import { FIXTURE_URLS, testCaptionFile, testImage } from '@server/tests/shared' |
8 | import { areHttpImportTestsDisabled } from '@shared/core-utils' | 8 | import { areHttpImportTestsDisabled } from '@shared/core-utils' |
9 | import { HttpStatusCode, Video, VideoImportState, VideoPrivacy, VideoResolution, VideoState } from '@shared/models' | 9 | import { CustomConfig, HttpStatusCode, Video, VideoImportState, VideoPrivacy, VideoResolution, VideoState } from '@shared/models' |
10 | import { | 10 | import { |
11 | cleanupTests, | 11 | cleanupTests, |
12 | createMultipleServers, | 12 | createMultipleServers, |
@@ -17,6 +17,7 @@ import { | |||
17 | setDefaultVideoChannel, | 17 | setDefaultVideoChannel, |
18 | waitJobs | 18 | waitJobs |
19 | } from '@shared/server-commands' | 19 | } from '@shared/server-commands' |
20 | import { DeepPartial } from '@shared/typescript-utils' | ||
20 | 21 | ||
21 | async function checkVideosServer1 (server: PeerTubeServer, idHttp: string, idMagnet: string, idTorrent: string) { | 22 | async function checkVideosServer1 (server: PeerTubeServer, idHttp: string, idMagnet: string, idTorrent: string) { |
22 | const videoHttp = await server.videos.get({ id: idHttp }) | 23 | const videoHttp = await server.videos.get({ id: idHttp }) |
@@ -105,6 +106,16 @@ describe('Test video imports', function () { | |||
105 | await setAccessTokensToServers(servers) | 106 | await setAccessTokensToServers(servers) |
106 | await setDefaultVideoChannel(servers) | 107 | await setDefaultVideoChannel(servers) |
107 | 108 | ||
109 | for (const server of servers) { | ||
110 | await server.config.updateExistingSubConfig({ | ||
111 | newConfig: { | ||
112 | transcoding: { | ||
113 | alwaysTranscodeOriginalResolution: false | ||
114 | } | ||
115 | } | ||
116 | }) | ||
117 | } | ||
118 | |||
108 | await doubleFollow(servers[0], servers[1]) | 119 | await doubleFollow(servers[0], servers[1]) |
109 | }) | 120 | }) |
110 | 121 | ||
@@ -306,10 +317,11 @@ describe('Test video imports', function () { | |||
306 | it('Should import no HDR version on a HDR video', async function () { | 317 | it('Should import no HDR version on a HDR video', async function () { |
307 | this.timeout(300_000) | 318 | this.timeout(300_000) |
308 | 319 | ||
309 | const config = { | 320 | const config: DeepPartial<CustomConfig> = { |
310 | transcoding: { | 321 | transcoding: { |
311 | enabled: true, | 322 | enabled: true, |
312 | resolutions: { | 323 | resolutions: { |
324 | '0p': false, | ||
313 | '144p': true, | 325 | '144p': true, |
314 | '240p': true, | 326 | '240p': true, |
315 | '360p': false, | 327 | '360p': false, |
@@ -321,19 +333,9 @@ describe('Test video imports', function () { | |||
321 | }, | 333 | }, |
322 | webtorrent: { enabled: true }, | 334 | webtorrent: { enabled: true }, |
323 | hls: { enabled: false } | 335 | hls: { enabled: false } |
324 | }, | ||
325 | import: { | ||
326 | videos: { | ||
327 | http: { | ||
328 | enabled: true | ||
329 | }, | ||
330 | torrent: { | ||
331 | enabled: true | ||
332 | } | ||
333 | } | ||
334 | } | 336 | } |
335 | } | 337 | } |
336 | await servers[0].config.updateCustomSubConfig({ newConfig: config }) | 338 | await servers[0].config.updateExistingSubConfig({ newConfig: config }) |
337 | 339 | ||
338 | const attributes = { | 340 | const attributes = { |
339 | name: 'hdr video', | 341 | name: 'hdr video', |
@@ -353,6 +355,76 @@ describe('Test video imports', function () { | |||
353 | expect(maxResolution, 'expected max resolution not met').to.equals(VideoResolution.H_240P) | 355 | expect(maxResolution, 'expected max resolution not met').to.equals(VideoResolution.H_240P) |
354 | }) | 356 | }) |
355 | 357 | ||
358 | it('Should not import resolution higher than enabled transcoding resolution', async function () { | ||
359 | this.timeout(300_000) | ||
360 | |||
361 | const config: DeepPartial<CustomConfig> = { | ||
362 | transcoding: { | ||
363 | enabled: true, | ||
364 | resolutions: { | ||
365 | '0p': false, | ||
366 | '144p': true, | ||
367 | '240p': false, | ||
368 | '360p': false, | ||
369 | '480p': false, | ||
370 | '720p': false, | ||
371 | '1080p': false, | ||
372 | '1440p': false, | ||
373 | '2160p': false | ||
374 | }, | ||
375 | alwaysTranscodeOriginalResolution: false | ||
376 | } | ||
377 | } | ||
378 | await servers[0].config.updateExistingSubConfig({ newConfig: config }) | ||
379 | |||
380 | const attributes = { | ||
381 | name: 'small resolution video', | ||
382 | targetUrl: FIXTURE_URLS.youtube, | ||
383 | channelId: servers[0].store.channel.id, | ||
384 | privacy: VideoPrivacy.PUBLIC | ||
385 | } | ||
386 | const { video: videoImported } = await servers[0].imports.importVideo({ attributes }) | ||
387 | const videoUUID = videoImported.uuid | ||
388 | |||
389 | await waitJobs(servers) | ||
390 | |||
391 | // test resolution | ||
392 | const video = await servers[0].videos.get({ id: videoUUID }) | ||
393 | expect(video.name).to.equal('small resolution video') | ||
394 | expect(video.files).to.have.lengthOf(1) | ||
395 | expect(video.files[0].resolution.id).to.equal(144) | ||
396 | }) | ||
397 | |||
398 | it('Should import resolution higher than enabled transcoding resolution', async function () { | ||
399 | this.timeout(300_000) | ||
400 | |||
401 | const config: DeepPartial<CustomConfig> = { | ||
402 | transcoding: { | ||
403 | alwaysTranscodeOriginalResolution: true | ||
404 | } | ||
405 | } | ||
406 | await servers[0].config.updateExistingSubConfig({ newConfig: config }) | ||
407 | |||
408 | const attributes = { | ||
409 | name: 'bigger resolution video', | ||
410 | targetUrl: FIXTURE_URLS.youtube, | ||
411 | channelId: servers[0].store.channel.id, | ||
412 | privacy: VideoPrivacy.PUBLIC | ||
413 | } | ||
414 | const { video: videoImported } = await servers[0].imports.importVideo({ attributes }) | ||
415 | const videoUUID = videoImported.uuid | ||
416 | |||
417 | await waitJobs(servers) | ||
418 | |||
419 | // test resolution | ||
420 | const video = await servers[0].videos.get({ id: videoUUID }) | ||
421 | expect(video.name).to.equal('bigger resolution video') | ||
422 | |||
423 | expect(video.files).to.have.lengthOf(2) | ||
424 | expect(video.files.find(f => f.resolution.id === 240)).to.exist | ||
425 | expect(video.files.find(f => f.resolution.id === 144)).to.exist | ||
426 | }) | ||
427 | |||
356 | it('Should import a peertube video', async function () { | 428 | it('Should import a peertube video', async function () { |
357 | this.timeout(120_000) | 429 | this.timeout(120_000) |
358 | 430 | ||