aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api')
-rw-r--r--server/tests/api/check-params/config.ts1
-rw-r--r--server/tests/api/server/config.ts14
-rw-r--r--server/tests/api/server/jobs.ts2
-rw-r--r--server/tests/api/travis-2.sh2
-rw-r--r--server/tests/api/videos/multiple-servers.ts4
-rw-r--r--server/tests/api/videos/services.ts4
-rw-r--r--server/tests/api/videos/video-hls.ts45
-rw-r--r--server/tests/api/videos/video-transcoder.ts51
8 files changed, 105 insertions, 18 deletions
diff --git a/server/tests/api/check-params/config.ts b/server/tests/api/check-params/config.ts
index 2a2ec606a..8155e11ab 100644
--- a/server/tests/api/check-params/config.ts
+++ b/server/tests/api/check-params/config.ts
@@ -59,6 +59,7 @@ describe('Test config API validators', function () {
59 transcoding: { 59 transcoding: {
60 enabled: true, 60 enabled: true,
61 allowAdditionalExtensions: true, 61 allowAdditionalExtensions: true,
62 allowAudioFiles: true,
62 threads: 1, 63 threads: 1,
63 resolutions: { 64 resolutions: {
64 '240p': false, 65 '240p': false,
diff --git a/server/tests/api/server/config.ts b/server/tests/api/server/config.ts
index ca389b7b6..8ea21158a 100644
--- a/server/tests/api/server/config.ts
+++ b/server/tests/api/server/config.ts
@@ -15,7 +15,7 @@ import {
15 registerUser, 15 registerUser,
16 reRunServer, ServerInfo, 16 reRunServer, ServerInfo,
17 setAccessTokensToServers, 17 setAccessTokensToServers,
18 updateCustomConfig 18 updateCustomConfig, uploadVideo
19} from '../../../../shared/extra-utils' 19} from '../../../../shared/extra-utils'
20import { ServerConfig } from '../../../../shared/models' 20import { ServerConfig } from '../../../../shared/models'
21 21
@@ -52,6 +52,7 @@ function checkInitialConfig (server: ServerInfo, data: CustomConfig) {
52 expect(data.user.videoQuotaDaily).to.equal(-1) 52 expect(data.user.videoQuotaDaily).to.equal(-1)
53 expect(data.transcoding.enabled).to.be.false 53 expect(data.transcoding.enabled).to.be.false
54 expect(data.transcoding.allowAdditionalExtensions).to.be.false 54 expect(data.transcoding.allowAdditionalExtensions).to.be.false
55 expect(data.transcoding.allowAudioFiles).to.be.false
55 expect(data.transcoding.threads).to.equal(2) 56 expect(data.transcoding.threads).to.equal(2)
56 expect(data.transcoding.resolutions['240p']).to.be.true 57 expect(data.transcoding.resolutions['240p']).to.be.true
57 expect(data.transcoding.resolutions['360p']).to.be.true 58 expect(data.transcoding.resolutions['360p']).to.be.true
@@ -102,6 +103,7 @@ function checkUpdatedConfig (data: CustomConfig) {
102 expect(data.transcoding.enabled).to.be.true 103 expect(data.transcoding.enabled).to.be.true
103 expect(data.transcoding.threads).to.equal(1) 104 expect(data.transcoding.threads).to.equal(1)
104 expect(data.transcoding.allowAdditionalExtensions).to.be.true 105 expect(data.transcoding.allowAdditionalExtensions).to.be.true
106 expect(data.transcoding.allowAudioFiles).to.be.true
105 expect(data.transcoding.resolutions['240p']).to.be.false 107 expect(data.transcoding.resolutions['240p']).to.be.false
106 expect(data.transcoding.resolutions['360p']).to.be.true 108 expect(data.transcoding.resolutions['360p']).to.be.true
107 expect(data.transcoding.resolutions['480p']).to.be.true 109 expect(data.transcoding.resolutions['480p']).to.be.true
@@ -158,6 +160,9 @@ describe('Test config', function () {
158 expect(data.video.file.extensions).to.contain('.webm') 160 expect(data.video.file.extensions).to.contain('.webm')
159 expect(data.video.file.extensions).to.contain('.ogv') 161 expect(data.video.file.extensions).to.contain('.ogv')
160 162
163 await uploadVideo(server.url, server.accessToken, { fixture: 'video_short.mkv' }, 400)
164 await uploadVideo(server.url, server.accessToken, { fixture: 'sample.ogg' }, 400)
165
161 expect(data.contactForm.enabled).to.be.true 166 expect(data.contactForm.enabled).to.be.true
162 }) 167 })
163 168
@@ -215,6 +220,7 @@ describe('Test config', function () {
215 transcoding: { 220 transcoding: {
216 enabled: true, 221 enabled: true,
217 allowAdditionalExtensions: true, 222 allowAdditionalExtensions: true,
223 allowAudioFiles: true,
218 threads: 1, 224 threads: 1,
219 resolutions: { 225 resolutions: {
220 '240p': false, 226 '240p': false,
@@ -269,6 +275,12 @@ describe('Test config', function () {
269 expect(data.video.file.extensions).to.contain('.ogv') 275 expect(data.video.file.extensions).to.contain('.ogv')
270 expect(data.video.file.extensions).to.contain('.flv') 276 expect(data.video.file.extensions).to.contain('.flv')
271 expect(data.video.file.extensions).to.contain('.mkv') 277 expect(data.video.file.extensions).to.contain('.mkv')
278 expect(data.video.file.extensions).to.contain('.mp3')
279 expect(data.video.file.extensions).to.contain('.ogg')
280 expect(data.video.file.extensions).to.contain('.flac')
281
282 await uploadVideo(server.url, server.accessToken, { fixture: 'video_short.mkv' }, 200)
283 await uploadVideo(server.url, server.accessToken, { fixture: 'sample.ogg' }, 200)
272 }) 284 })
273 285
274 it('Should have the configuration updated after a restart', async function () { 286 it('Should have the configuration updated after a restart', async function () {
diff --git a/server/tests/api/server/jobs.ts b/server/tests/api/server/jobs.ts
index 634654626..3ab2fe120 100644
--- a/server/tests/api/server/jobs.ts
+++ b/server/tests/api/server/jobs.ts
@@ -26,7 +26,7 @@ describe('Test jobs', function () {
26 }) 26 })
27 27
28 it('Should create some jobs', async function () { 28 it('Should create some jobs', async function () {
29 this.timeout(30000) 29 this.timeout(60000)
30 30
31 await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video1' }) 31 await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video1' })
32 await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video2' }) 32 await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video2' })
diff --git a/server/tests/api/travis-2.sh b/server/tests/api/travis-2.sh
index 82c1864b4..ba7a061b0 100644
--- a/server/tests/api/travis-2.sh
+++ b/server/tests/api/travis-2.sh
@@ -5,5 +5,5 @@ set -eu
5serverFiles=$(find server/tests/api/server -type f | grep -v index.ts | xargs echo) 5serverFiles=$(find server/tests/api/server -type f | grep -v index.ts | xargs echo)
6usersFiles=$(find server/tests/api/users -type f | grep -v index.ts | xargs echo) 6usersFiles=$(find server/tests/api/users -type f | grep -v index.ts | xargs echo)
7 7
8MOCHA_PARALLEL=true mocha-parallel-tests --max-parallel $1 --timeout 5000 --exit --require ts-node/register --bail \ 8MOCHA_PARALLEL=true mocha --timeout 5000 --exit --require ts-node/register --bail \
9 $serverFiles $usersFiles 9 $serverFiles $usersFiles
diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts
index 09b461200..e9625e5f7 100644
--- a/server/tests/api/videos/multiple-servers.ts
+++ b/server/tests/api/videos/multiple-servers.ts
@@ -215,7 +215,7 @@ describe('Test multiple servers', function () {
215 files: [ 215 files: [
216 { 216 {
217 resolution: 240, 217 resolution: 240,
218 size: 187000 218 size: 189000
219 }, 219 },
220 { 220 {
221 resolution: 360, 221 resolution: 360,
@@ -223,7 +223,7 @@ describe('Test multiple servers', function () {
223 }, 223 },
224 { 224 {
225 resolution: 480, 225 resolution: 480,
226 size: 383000 226 size: 384000
227 }, 227 },
228 { 228 {
229 resolution: 720, 229 resolution: 720,
diff --git a/server/tests/api/videos/services.ts b/server/tests/api/videos/services.ts
index 38e232e5f..17172331f 100644
--- a/server/tests/api/videos/services.ts
+++ b/server/tests/api/videos/services.ts
@@ -41,8 +41,8 @@ describe('Test services', function () {
41 expect(res.body.width).to.equal(560) 41 expect(res.body.width).to.equal(560)
42 expect(res.body.height).to.equal(315) 42 expect(res.body.height).to.equal(315)
43 expect(res.body.thumbnail_url).to.equal(expectedThumbnailUrl) 43 expect(res.body.thumbnail_url).to.equal(expectedThumbnailUrl)
44 expect(res.body.thumbnail_width).to.equal(560) 44 expect(res.body.thumbnail_width).to.equal(850)
45 expect(res.body.thumbnail_height).to.equal(315) 45 expect(res.body.thumbnail_height).to.equal(480)
46 }) 46 })
47 47
48 it('Should have a valid oEmbed response with small max height query', async function () { 48 it('Should have a valid oEmbed response with small max height query', async function () {
diff --git a/server/tests/api/videos/video-hls.ts b/server/tests/api/videos/video-hls.ts
index 504c50dee..39178bb1a 100644
--- a/server/tests/api/videos/video-hls.ts
+++ b/server/tests/api/videos/video-hls.ts
@@ -21,12 +21,11 @@ import {
21import { VideoDetails } from '../../../../shared/models/videos' 21import { VideoDetails } from '../../../../shared/models/videos'
22import { VideoStreamingPlaylistType } from '../../../../shared/models/videos/video-streaming-playlist.type' 22import { VideoStreamingPlaylistType } from '../../../../shared/models/videos/video-streaming-playlist.type'
23import { join } from 'path' 23import { join } from 'path'
24import { DEFAULT_AUDIO_RESOLUTION } from '../../../initializers/constants'
24 25
25const expect = chai.expect 26const expect = chai.expect
26 27
27async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string) { 28async 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) {
70describe('Test HLS videos', function () { 68describe('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,17 +94,28 @@ 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 () {
117 this.timeout(10000)
118
100 await updateVideo(servers[0].url, servers[0].accessToken, videoUUID, { name: 'video 1 updated' }) 119 await updateVideo(servers[0].url, servers[0].accessToken, videoUUID, { name: 'video 1 updated' })
101 120
102 await waitJobs(servers) 121 await waitJobs(servers)
@@ -104,13 +123,17 @@ describe('Test HLS videos', function () {
104 await checkHlsPlaylist(servers, videoUUID) 123 await checkHlsPlaylist(servers, videoUUID)
105 }) 124 })
106 125
107 it('Should delete the video', async function () { 126 it('Should delete videos', async function () {
127 this.timeout(10000)
128
108 await removeVideo(servers[0].url, servers[0].accessToken, videoUUID) 129 await removeVideo(servers[0].url, servers[0].accessToken, videoUUID)
130 await removeVideo(servers[0].url, servers[0].accessToken, videoAudioUUID)
109 131
110 await waitJobs(servers) 132 await waitJobs(servers)
111 133
112 for (const server of servers) { 134 for (const server of servers) {
113 await getVideo(server.url, videoUUID, 404) 135 await getVideo(server.url, videoUUID, 404)
136 await getVideo(server.url, videoAudioUUID, 404)
114 } 137 }
115 }) 138 })
116 139
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 })