diff options
author | Chocobozzz <me@florianbigard.com> | 2019-05-17 11:56:12 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-05-17 14:04:54 +0200 |
commit | b345a8047bfde1efa1fdbd249f25f663151265a8 (patch) | |
tree | be930c523bee467673bec45fccd4cfb69d5f1cfd /server/tests/api/videos | |
parent | 7b992a86b107fc2917b993127df8e95a66ae94db (diff) | |
download | PeerTube-b345a8047bfde1efa1fdbd249f25f663151265a8.tar.gz PeerTube-b345a8047bfde1efa1fdbd249f25f663151265a8.tar.zst PeerTube-b345a8047bfde1efa1fdbd249f25f663151265a8.zip |
Add audio upload tests
Diffstat (limited to 'server/tests/api/videos')
-rw-r--r-- | server/tests/api/videos/video-hls.ts | 41 | ||||
-rw-r--r-- | server/tests/api/videos/video-transcoder.ts | 51 |
2 files changed, 81 insertions, 11 deletions
diff --git a/server/tests/api/videos/video-hls.ts b/server/tests/api/videos/video-hls.ts index 504c50dee..eacd9ab79 100644 --- a/server/tests/api/videos/video-hls.ts +++ b/server/tests/api/videos/video-hls.ts | |||
@@ -21,12 +21,11 @@ import { | |||
21 | import { VideoDetails } from '../../../../shared/models/videos' | 21 | import { VideoDetails } from '../../../../shared/models/videos' |
22 | import { VideoStreamingPlaylistType } from '../../../../shared/models/videos/video-streaming-playlist.type' | 22 | import { VideoStreamingPlaylistType } from '../../../../shared/models/videos/video-streaming-playlist.type' |
23 | import { join } from 'path' | 23 | import { join } from 'path' |
24 | import { DEFAULT_AUDIO_RESOLUTION } from '../../../initializers/constants' | ||
24 | 25 | ||
25 | const expect = chai.expect | 26 | const expect = chai.expect |
26 | 27 | ||
27 | async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string) { | 28 | async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string, resolutions = [ 240, 360, 480, 720 ]) { |
28 | const resolutions = [ 240, 360, 480, 720 ] | ||
29 | |||
30 | for (const server of servers) { | 29 | for (const server of servers) { |
31 | const res = await getVideo(server.url, videoUUID) | 30 | const res = await getVideo(server.url, videoUUID) |
32 | const videoDetails: VideoDetails = res.body | 31 | const videoDetails: VideoDetails = res.body |
@@ -41,9 +40,8 @@ async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string) { | |||
41 | 40 | ||
42 | const masterPlaylist = res2.text | 41 | const masterPlaylist = res2.text |
43 | 42 | ||
44 | expect(masterPlaylist).to.contain('#EXT-X-STREAM-INF:BANDWIDTH=55472,RESOLUTION=640x360,FRAME-RATE=25') | ||
45 | |||
46 | for (const resolution of resolutions) { | 43 | for (const resolution of resolutions) { |
44 | expect(masterPlaylist).to.match(new RegExp('#EXT-X-STREAM-INF:BANDWIDTH=\\d+,RESOLUTION=\\d+x' + resolution + ',FRAME-RATE=\\d+')) | ||
47 | expect(masterPlaylist).to.contain(`${resolution}.m3u8`) | 45 | expect(masterPlaylist).to.contain(`${resolution}.m3u8`) |
48 | } | 46 | } |
49 | } | 47 | } |
@@ -70,11 +68,21 @@ async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string) { | |||
70 | describe('Test HLS videos', function () { | 68 | describe('Test HLS videos', function () { |
71 | let servers: ServerInfo[] = [] | 69 | let servers: ServerInfo[] = [] |
72 | let videoUUID = '' | 70 | let videoUUID = '' |
71 | let videoAudioUUID = '' | ||
73 | 72 | ||
74 | before(async function () { | 73 | before(async function () { |
75 | this.timeout(120000) | 74 | this.timeout(120000) |
76 | 75 | ||
77 | servers = await flushAndRunMultipleServers(2, { transcoding: { enabled: true, hls: { enabled: true } } }) | 76 | const configOverride = { |
77 | transcoding: { | ||
78 | enabled: true, | ||
79 | allow_audio_files: true, | ||
80 | hls: { | ||
81 | enabled: true | ||
82 | } | ||
83 | } | ||
84 | } | ||
85 | servers = await flushAndRunMultipleServers(2, configOverride) | ||
78 | 86 | ||
79 | // Get the access tokens | 87 | // Get the access tokens |
80 | await setAccessTokensToServers(servers) | 88 | await setAccessTokensToServers(servers) |
@@ -86,16 +94,25 @@ describe('Test HLS videos', function () { | |||
86 | it('Should upload a video and transcode it to HLS', async function () { | 94 | it('Should upload a video and transcode it to HLS', async function () { |
87 | this.timeout(120000) | 95 | this.timeout(120000) |
88 | 96 | ||
89 | { | 97 | const res = await uploadVideo(servers[ 0 ].url, servers[ 0 ].accessToken, { name: 'video 1', fixture: 'video_short.webm' }) |
90 | const res = await uploadVideo(servers[ 0 ].url, servers[ 0 ].accessToken, { name: 'video 1', fixture: 'video_short.webm' }) | 98 | videoUUID = res.body.video.uuid |
91 | videoUUID = res.body.video.uuid | ||
92 | } | ||
93 | 99 | ||
94 | await waitJobs(servers) | 100 | await waitJobs(servers) |
95 | 101 | ||
96 | await checkHlsPlaylist(servers, videoUUID) | 102 | await checkHlsPlaylist(servers, videoUUID) |
97 | }) | 103 | }) |
98 | 104 | ||
105 | it('Should upload an audio file and transcode it to HLS', async function () { | ||
106 | this.timeout(120000) | ||
107 | |||
108 | const res = await uploadVideo(servers[ 0 ].url, servers[ 0 ].accessToken, { name: 'video audio', fixture: 'sample.ogg' }) | ||
109 | videoAudioUUID = res.body.video.uuid | ||
110 | |||
111 | await waitJobs(servers) | ||
112 | |||
113 | await checkHlsPlaylist(servers, videoAudioUUID, [ DEFAULT_AUDIO_RESOLUTION ]) | ||
114 | }) | ||
115 | |||
99 | it('Should update the video', async function () { | 116 | it('Should update the video', async function () { |
100 | await updateVideo(servers[0].url, servers[0].accessToken, videoUUID, { name: 'video 1 updated' }) | 117 | await updateVideo(servers[0].url, servers[0].accessToken, videoUUID, { name: 'video 1 updated' }) |
101 | 118 | ||
@@ -104,13 +121,15 @@ describe('Test HLS videos', function () { | |||
104 | await checkHlsPlaylist(servers, videoUUID) | 121 | await checkHlsPlaylist(servers, videoUUID) |
105 | }) | 122 | }) |
106 | 123 | ||
107 | it('Should delete the video', async function () { | 124 | it('Should delete videos', async function () { |
108 | await removeVideo(servers[0].url, servers[0].accessToken, videoUUID) | 125 | await removeVideo(servers[0].url, servers[0].accessToken, videoUUID) |
126 | await removeVideo(servers[0].url, servers[0].accessToken, videoAudioUUID) | ||
109 | 127 | ||
110 | await waitJobs(servers) | 128 | await waitJobs(servers) |
111 | 129 | ||
112 | for (const server of servers) { | 130 | for (const server of servers) { |
113 | await getVideo(server.url, videoUUID, 404) | 131 | await getVideo(server.url, videoUUID, 404) |
132 | await getVideo(server.url, videoAudioUUID, 404) | ||
114 | } | 133 | } |
115 | }) | 134 | }) |
116 | 135 | ||
diff --git a/server/tests/api/videos/video-transcoder.ts b/server/tests/api/videos/video-transcoder.ts index cfd0c8430..90ade1652 100644 --- a/server/tests/api/videos/video-transcoder.ts +++ b/server/tests/api/videos/video-transcoder.ts | |||
@@ -14,6 +14,7 @@ import { | |||
14 | getMyVideos, | 14 | getMyVideos, |
15 | getVideo, | 15 | getVideo, |
16 | getVideosList, | 16 | getVideosList, |
17 | makeGetRequest, | ||
17 | root, | 18 | root, |
18 | ServerInfo, | 19 | ServerInfo, |
19 | setAccessTokensToServers, | 20 | setAccessTokensToServers, |
@@ -365,6 +366,56 @@ describe('Test video transcoding', function () { | |||
365 | expect(await canDoQuickTranscode(buildAbsoluteFixturePath('video_short.webm'))).to.be.false | 366 | expect(await canDoQuickTranscode(buildAbsoluteFixturePath('video_short.webm'))).to.be.false |
366 | }) | 367 | }) |
367 | 368 | ||
369 | it('Should merge an audio file with the preview file', async function () { | ||
370 | this.timeout(60000) | ||
371 | |||
372 | const videoAttributesArg = { name: 'audio_with_preview', previewfile: 'preview.jpg', fixture: 'sample.ogg' } | ||
373 | await uploadVideo(servers[ 1 ].url, servers[ 1 ].accessToken, videoAttributesArg) | ||
374 | |||
375 | await waitJobs(servers) | ||
376 | |||
377 | for (const server of servers) { | ||
378 | const res = await getVideosList(server.url) | ||
379 | |||
380 | const video = res.body.data.find(v => v.name === 'audio_with_preview') | ||
381 | const res2 = await getVideo(server.url, video.id) | ||
382 | const videoDetails: VideoDetails = res2.body | ||
383 | |||
384 | expect(videoDetails.files).to.have.lengthOf(1) | ||
385 | |||
386 | await makeGetRequest({ url: server.url, path: videoDetails.thumbnailPath, statusCodeExpected: 200 }) | ||
387 | await makeGetRequest({ url: server.url, path: videoDetails.previewPath, statusCodeExpected: 200 }) | ||
388 | |||
389 | const magnetUri = videoDetails.files[ 0 ].magnetUri | ||
390 | expect(magnetUri).to.contain('.mp4') | ||
391 | } | ||
392 | }) | ||
393 | |||
394 | it('Should upload an audio file and choose a default background image', async function () { | ||
395 | this.timeout(60000) | ||
396 | |||
397 | const videoAttributesArg = { name: 'audio_without_preview', fixture: 'sample.ogg' } | ||
398 | await uploadVideo(servers[ 1 ].url, servers[ 1 ].accessToken, videoAttributesArg) | ||
399 | |||
400 | await waitJobs(servers) | ||
401 | |||
402 | for (const server of servers) { | ||
403 | const res = await getVideosList(server.url) | ||
404 | |||
405 | const video = res.body.data.find(v => v.name === 'audio_without_preview') | ||
406 | const res2 = await getVideo(server.url, video.id) | ||
407 | const videoDetails = res2.body | ||
408 | |||
409 | expect(videoDetails.files).to.have.lengthOf(1) | ||
410 | |||
411 | await makeGetRequest({ url: server.url, path: videoDetails.thumbnailPath, statusCodeExpected: 200 }) | ||
412 | await makeGetRequest({ url: server.url, path: videoDetails.previewPath, statusCodeExpected: 200 }) | ||
413 | |||
414 | const magnetUri = videoDetails.files[ 0 ].magnetUri | ||
415 | expect(magnetUri).to.contain('.mp4') | ||
416 | } | ||
417 | }) | ||
418 | |||
368 | after(async function () { | 419 | after(async function () { |
369 | await cleanupTests(servers) | 420 | await cleanupTests(servers) |
370 | }) | 421 | }) |