aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/api/check-params/config.ts4
-rw-r--r--server/tests/api/live/live.ts73
-rw-r--r--server/tests/api/server/config.ts8
-rw-r--r--server/tests/api/transcoding/transcoder.ts80
-rw-r--r--server/tests/shared/streaming-playlists.ts3
5 files changed, 159 insertions, 9 deletions
diff --git a/server/tests/api/check-params/config.ts b/server/tests/api/check-params/config.ts
index 99fb24a5b..2f9f553ab 100644
--- a/server/tests/api/check-params/config.ts
+++ b/server/tests/api/check-params/config.ts
@@ -114,6 +114,7 @@ describe('Test config API validators', function () {
114 '1440p': false, 114 '1440p': false,
115 '2160p': false 115 '2160p': false
116 }, 116 },
117 alwaysTranscodeOriginalResolution: false,
117 webtorrent: { 118 webtorrent: {
118 enabled: true 119 enabled: true
119 }, 120 },
@@ -145,7 +146,8 @@ describe('Test config API validators', function () {
145 '1080p': true, 146 '1080p': true,
146 '1440p': true, 147 '1440p': true,
147 '2160p': true 148 '2160p': true
148 } 149 },
150 alwaysTranscodeOriginalResolution: false
149 } 151 }
150 }, 152 },
151 videoStudio: { 153 videoStudio: {
diff --git a/server/tests/api/live/live.ts b/server/tests/api/live/live.ts
index 2d47c131b..f6ad5c82e 100644
--- a/server/tests/api/live/live.ts
+++ b/server/tests/api/live/live.ts
@@ -4,7 +4,7 @@ import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { basename, join } from 'path' 5import { basename, join } from 'path'
6import { ffprobePromise, getVideoStream } from '@server/helpers/ffmpeg' 6import { ffprobePromise, getVideoStream } from '@server/helpers/ffmpeg'
7import { checkLiveCleanup, checkLiveSegmentHash, checkResolutionsInMasterPlaylist, testImage } from '@server/tests/shared' 7import { checkLiveSegmentHash, checkResolutionsInMasterPlaylist, getAllFiles, testImage } from '@server/tests/shared'
8import { wait } from '@shared/core-utils' 8import { wait } from '@shared/core-utils'
9import { 9import {
10 HttpStatusCode, 10 HttpStatusCode,
@@ -468,7 +468,7 @@ describe('Test live', function () {
468 await waitUntilLivePublishedOnAllServers(servers, liveVideoId) 468 await waitUntilLivePublishedOnAllServers(servers, liveVideoId)
469 await waitJobs(servers) 469 await waitJobs(servers)
470 470
471 await testVideoResolutions(liveVideoId, resolutions) 471 await testVideoResolutions(liveVideoId, resolutions.concat([ 720 ]))
472 472
473 await stopFfmpeg(ffmpegCommand) 473 await stopFfmpeg(ffmpegCommand)
474 }) 474 })
@@ -580,10 +580,73 @@ describe('Test live', function () {
580 } 580 }
581 }) 581 })
582 582
583 it('Should correctly have cleaned up the live files', async function () { 583 it('Should not generate an upper resolution than original file', async function () {
584 this.timeout(30000) 584 this.timeout(400_000)
585
586 const resolutions = [ 240, 480 ]
587 await updateConf(resolutions)
588
589 await servers[0].config.updateExistingSubConfig({
590 newConfig: {
591 live: {
592 transcoding: {
593 alwaysTranscodeOriginalResolution: false
594 }
595 }
596 }
597 })
598
599 liveVideoId = await createLiveWrapper(true)
600
601 const ffmpegCommand = await commands[0].sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_short2.webm' })
602 await waitUntilLivePublishedOnAllServers(servers, liveVideoId)
603 await waitJobs(servers)
604
605 await testVideoResolutions(liveVideoId, resolutions)
606
607 await stopFfmpeg(ffmpegCommand)
608 await commands[0].waitUntilEnded({ videoId: liveVideoId })
609
610 await waitJobs(servers)
611
612 await waitUntilLivePublishedOnAllServers(servers, liveVideoId)
613
614 const video = await servers[0].videos.get({ id: liveVideoId })
615 const hlsFiles = video.streamingPlaylists[0].files
616
617 expect(video.files).to.have.lengthOf(0)
618 expect(hlsFiles).to.have.lengthOf(resolutions.length)
619
620 // eslint-disable-next-line @typescript-eslint/require-array-sort-compare
621 expect(getAllFiles(video).map(f => f.resolution.id).sort()).to.deep.equal(resolutions)
622 })
623
624 it('Should only keep the original resolution if all resolutions are disabled', async function () {
625 this.timeout(400_000)
626
627 await updateConf([])
628 liveVideoId = await createLiveWrapper(true)
629
630 const ffmpegCommand = await commands[0].sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_short2.webm' })
631 await waitUntilLivePublishedOnAllServers(servers, liveVideoId)
632 await waitJobs(servers)
633
634 await testVideoResolutions(liveVideoId, [ 720 ])
635
636 await stopFfmpeg(ffmpegCommand)
637 await commands[0].waitUntilEnded({ videoId: liveVideoId })
638
639 await waitJobs(servers)
640
641 await waitUntilLivePublishedOnAllServers(servers, liveVideoId)
642
643 const video = await servers[0].videos.get({ id: liveVideoId })
644 const hlsFiles = video.streamingPlaylists[0].files
645
646 expect(video.files).to.have.lengthOf(0)
647 expect(hlsFiles).to.have.lengthOf(1)
585 648
586 await checkLiveCleanup(servers[0], liveVideoId, [ 240, 360, 720 ]) 649 expect(hlsFiles[0].resolution.id).to.equal(720)
587 }) 650 })
588 }) 651 })
589 652
diff --git a/server/tests/api/server/config.ts b/server/tests/api/server/config.ts
index 0f2fb5493..efc57b345 100644
--- a/server/tests/api/server/config.ts
+++ b/server/tests/api/server/config.ts
@@ -77,6 +77,7 @@ function checkInitialConfig (server: PeerTubeServer, data: CustomConfig) {
77 expect(data.transcoding.resolutions['1080p']).to.be.true 77 expect(data.transcoding.resolutions['1080p']).to.be.true
78 expect(data.transcoding.resolutions['1440p']).to.be.true 78 expect(data.transcoding.resolutions['1440p']).to.be.true
79 expect(data.transcoding.resolutions['2160p']).to.be.true 79 expect(data.transcoding.resolutions['2160p']).to.be.true
80 expect(data.transcoding.alwaysTranscodeOriginalResolution).to.be.true
80 expect(data.transcoding.webtorrent.enabled).to.be.true 81 expect(data.transcoding.webtorrent.enabled).to.be.true
81 expect(data.transcoding.hls.enabled).to.be.true 82 expect(data.transcoding.hls.enabled).to.be.true
82 83
@@ -97,6 +98,7 @@ function checkInitialConfig (server: PeerTubeServer, data: CustomConfig) {
97 expect(data.live.transcoding.resolutions['1080p']).to.be.false 98 expect(data.live.transcoding.resolutions['1080p']).to.be.false
98 expect(data.live.transcoding.resolutions['1440p']).to.be.false 99 expect(data.live.transcoding.resolutions['1440p']).to.be.false
99 expect(data.live.transcoding.resolutions['2160p']).to.be.false 100 expect(data.live.transcoding.resolutions['2160p']).to.be.false
101 expect(data.live.transcoding.alwaysTranscodeOriginalResolution).to.be.true
100 102
101 expect(data.videoStudio.enabled).to.be.false 103 expect(data.videoStudio.enabled).to.be.false
102 104
@@ -181,6 +183,7 @@ function checkUpdatedConfig (data: CustomConfig) {
181 expect(data.transcoding.resolutions['720p']).to.be.false 183 expect(data.transcoding.resolutions['720p']).to.be.false
182 expect(data.transcoding.resolutions['1080p']).to.be.false 184 expect(data.transcoding.resolutions['1080p']).to.be.false
183 expect(data.transcoding.resolutions['2160p']).to.be.false 185 expect(data.transcoding.resolutions['2160p']).to.be.false
186 expect(data.transcoding.alwaysTranscodeOriginalResolution).to.be.false
184 expect(data.transcoding.hls.enabled).to.be.false 187 expect(data.transcoding.hls.enabled).to.be.false
185 expect(data.transcoding.webtorrent.enabled).to.be.true 188 expect(data.transcoding.webtorrent.enabled).to.be.true
186 189
@@ -200,6 +203,7 @@ function checkUpdatedConfig (data: CustomConfig) {
200 expect(data.live.transcoding.resolutions['720p']).to.be.true 203 expect(data.live.transcoding.resolutions['720p']).to.be.true
201 expect(data.live.transcoding.resolutions['1080p']).to.be.true 204 expect(data.live.transcoding.resolutions['1080p']).to.be.true
202 expect(data.live.transcoding.resolutions['2160p']).to.be.true 205 expect(data.live.transcoding.resolutions['2160p']).to.be.true
206 expect(data.live.transcoding.alwaysTranscodeOriginalResolution).to.be.false
203 207
204 expect(data.videoStudio.enabled).to.be.true 208 expect(data.videoStudio.enabled).to.be.true
205 209
@@ -318,6 +322,7 @@ const newCustomConfig: CustomConfig = {
318 '1440p': false, 322 '1440p': false,
319 '2160p': false 323 '2160p': false
320 }, 324 },
325 alwaysTranscodeOriginalResolution: false,
321 webtorrent: { 326 webtorrent: {
322 enabled: true 327 enabled: true
323 }, 328 },
@@ -347,7 +352,8 @@ const newCustomConfig: CustomConfig = {
347 '1080p': true, 352 '1080p': true,
348 '1440p': true, 353 '1440p': true,
349 '2160p': true 354 '2160p': true
350 } 355 },
356 alwaysTranscodeOriginalResolution: false
351 } 357 }
352 }, 358 },
353 videoStudio: { 359 videoStudio: {
diff --git a/server/tests/api/transcoding/transcoder.ts b/server/tests/api/transcoding/transcoder.ts
index 245c4c012..48a20e1d5 100644
--- a/server/tests/api/transcoding/transcoder.ts
+++ b/server/tests/api/transcoding/transcoder.ts
@@ -7,11 +7,11 @@ import { canDoQuickTranscode } from '@server/helpers/ffmpeg'
7import { generateHighBitrateVideo, generateVideoWithFramerate, getAllFiles } from '@server/tests/shared' 7import { generateHighBitrateVideo, generateVideoWithFramerate, getAllFiles } from '@server/tests/shared'
8import { buildAbsoluteFixturePath, getMaxBitrate, getMinLimitBitrate } from '@shared/core-utils' 8import { buildAbsoluteFixturePath, getMaxBitrate, getMinLimitBitrate } from '@shared/core-utils'
9import { 9import {
10 getAudioStream,
11 buildFileMetadata, 10 buildFileMetadata,
11 getAudioStream,
12 getVideoStreamBitrate, 12 getVideoStreamBitrate,
13 getVideoStreamFPS,
14 getVideoStreamDimensionsInfo, 13 getVideoStreamDimensionsInfo,
14 getVideoStreamFPS,
15 hasAudioStream 15 hasAudioStream
16} from '@shared/extra-utils' 16} from '@shared/extra-utils'
17import { HttpStatusCode, VideoState } from '@shared/models' 17import { HttpStatusCode, VideoState } from '@shared/models'
@@ -727,6 +727,82 @@ describe('Test video transcoding', function () {
727 }) 727 })
728 }) 728 })
729 729
730 describe('Bounded transcoding', function () {
731
732 it('Should not generate an upper resolution than original file', async function () {
733 this.timeout(120_000)
734
735 await servers[0].config.updateExistingSubConfig({
736 newConfig: {
737 transcoding: {
738 enabled: true,
739 hls: { enabled: true },
740 webtorrent: { enabled: true },
741 resolutions: {
742 '0p': false,
743 '144p': false,
744 '240p': true,
745 '360p': false,
746 '480p': true,
747 '720p': false,
748 '1080p': false,
749 '1440p': false,
750 '2160p': false
751 },
752 alwaysTranscodeOriginalResolution: false
753 }
754 }
755 })
756
757 const { uuid } = await servers[0].videos.quickUpload({ name: 'video', fixture: 'video_short.webm' })
758 await waitJobs(servers)
759
760 const video = await servers[0].videos.get({ id: uuid })
761 const hlsFiles = video.streamingPlaylists[0].files
762
763 expect(video.files).to.have.lengthOf(2)
764 expect(hlsFiles).to.have.lengthOf(2)
765
766 // eslint-disable-next-line @typescript-eslint/require-array-sort-compare
767 const resolutions = getAllFiles(video).map(f => f.resolution.id).sort()
768 expect(resolutions).to.deep.equal([ 240, 240, 480, 480 ])
769 })
770
771 it('Should only keep the original resolution if all resolutions are disabled', async function () {
772 this.timeout(120_000)
773
774 await servers[0].config.updateExistingSubConfig({
775 newConfig: {
776 transcoding: {
777 resolutions: {
778 '0p': false,
779 '144p': false,
780 '240p': false,
781 '360p': false,
782 '480p': false,
783 '720p': false,
784 '1080p': false,
785 '1440p': false,
786 '2160p': false
787 }
788 }
789 }
790 })
791
792 const { uuid } = await servers[0].videos.quickUpload({ name: 'video', fixture: 'video_short.webm' })
793 await waitJobs(servers)
794
795 const video = await servers[0].videos.get({ id: uuid })
796 const hlsFiles = video.streamingPlaylists[0].files
797
798 expect(video.files).to.have.lengthOf(1)
799 expect(hlsFiles).to.have.lengthOf(1)
800
801 expect(video.files[0].resolution.id).to.equal(720)
802 expect(hlsFiles[0].resolution.id).to.equal(720)
803 })
804 })
805
730 after(async function () { 806 after(async function () {
731 await cleanupTests(servers) 807 await cleanupTests(servers)
732 }) 808 })
diff --git a/server/tests/shared/streaming-playlists.ts b/server/tests/shared/streaming-playlists.ts
index 7ca707f2e..4d82b3654 100644
--- a/server/tests/shared/streaming-playlists.ts
+++ b/server/tests/shared/streaming-playlists.ts
@@ -68,6 +68,9 @@ async function checkResolutionsInMasterPlaylist (options: {
68 68
69 expect(masterPlaylist).to.match(reg) 69 expect(masterPlaylist).to.match(reg)
70 } 70 }
71
72 const playlistsLength = masterPlaylist.split('\n').filter(line => line.startsWith('#EXT-X-STREAM-INF:BANDWIDTH='))
73 expect(playlistsLength).to.have.lengthOf(resolutions.length)
71} 74}
72 75
73export { 76export {