aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-05-17 11:56:12 +0200
committerChocobozzz <me@florianbigard.com>2019-05-17 14:04:54 +0200
commitb345a8047bfde1efa1fdbd249f25f663151265a8 (patch)
treebe930c523bee467673bec45fccd4cfb69d5f1cfd
parent7b992a86b107fc2917b993127df8e95a66ae94db (diff)
downloadPeerTube-b345a8047bfde1efa1fdbd249f25f663151265a8.tar.gz
PeerTube-b345a8047bfde1efa1fdbd249f25f663151265a8.tar.zst
PeerTube-b345a8047bfde1efa1fdbd249f25f663151265a8.zip
Add audio upload tests
-rw-r--r--client/src/app/+my-account/my-account-videos/my-account-videos.component.html2
-rw-r--r--client/src/app/shared/buttons/button.component.ts2
-rw-r--r--client/src/app/shared/buttons/delete-button.component.html2
-rw-r--r--client/src/app/shared/buttons/edit-button.component.html2
-rw-r--r--config/test-2.yaml1
-rw-r--r--server/controllers/api/videos/index.ts11
-rw-r--r--server/initializers/constants.ts4
-rw-r--r--server/tests/api/server/config.ts11
-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/video-hls.ts41
-rw-r--r--server/tests/api/videos/video-transcoder.ts51
-rw-r--r--server/tests/fixtures/sample.oggbin0 -> 105243 bytes
13 files changed, 109 insertions, 22 deletions
diff --git a/client/src/app/+my-account/my-account-videos/my-account-videos.component.html b/client/src/app/+my-account/my-account-videos/my-account-videos.component.html
index d7993fdc2..38b48f1d6 100644
--- a/client/src/app/+my-account/my-account-videos/my-account-videos.component.html
+++ b/client/src/app/+my-account/my-account-videos/my-account-videos.component.html
@@ -19,7 +19,7 @@
19 <my-edit-button [routerLink]="[ '/videos', 'update', video.uuid ]"></my-edit-button> 19 <my-edit-button [routerLink]="[ '/videos', 'update', video.uuid ]"></my-edit-button>
20 20
21 <my-button i18n-label label="Change ownership" 21 <my-button i18n-label label="Change ownership"
22 className="action-button-change-ownership" 22 className="action-button-change-ownership grey-button"
23 icon="im-with-her" 23 icon="im-with-her"
24 (click)="changeOwnership($event, video)" 24 (click)="changeOwnership($event, video)"
25 ></my-button> 25 ></my-button>
diff --git a/client/src/app/shared/buttons/button.component.ts b/client/src/app/shared/buttons/button.component.ts
index 6d34d07f4..cf334e8d5 100644
--- a/client/src/app/shared/buttons/button.component.ts
+++ b/client/src/app/shared/buttons/button.component.ts
@@ -9,7 +9,7 @@ import { GlobalIconName } from '@app/shared/images/global-icon.component'
9 9
10export class ButtonComponent { 10export class ButtonComponent {
11 @Input() label = '' 11 @Input() label = ''
12 @Input() className: 'orange-button' | 'grey-button' = 'grey-button' 12 @Input() className = 'grey-button'
13 @Input() icon: GlobalIconName = undefined 13 @Input() icon: GlobalIconName = undefined
14 @Input() title: string = undefined 14 @Input() title: string = undefined
15 15
diff --git a/client/src/app/shared/buttons/delete-button.component.html b/client/src/app/shared/buttons/delete-button.component.html
index 4d12a84c0..d278e7015 100644
--- a/client/src/app/shared/buttons/delete-button.component.html
+++ b/client/src/app/shared/buttons/delete-button.component.html
@@ -1,4 +1,4 @@
1<span class="action-button action-button-delete" [title]="getTitle()" role="button"> 1<span class="action-button action-button-delete grey-button" [title]="getTitle()" role="button">
2 <my-global-icon iconName="delete"></my-global-icon> 2 <my-global-icon iconName="delete"></my-global-icon>
3 3
4 <span class="button-label" *ngIf="label">{{ label }}</span> 4 <span class="button-label" *ngIf="label">{{ label }}</span>
diff --git a/client/src/app/shared/buttons/edit-button.component.html b/client/src/app/shared/buttons/edit-button.component.html
index da3addbae..3d7cd4780 100644
--- a/client/src/app/shared/buttons/edit-button.component.html
+++ b/client/src/app/shared/buttons/edit-button.component.html
@@ -1,4 +1,4 @@
1<a class="action-button action-button-edit" [routerLink]="routerLink" i18n-title title="Edit"> 1<a class="action-button action-button-edit grey-button" [routerLink]="routerLink" i18n-title title="Edit">
2 <my-global-icon iconName="edit"></my-global-icon> 2 <my-global-icon iconName="edit"></my-global-icon>
3 3
4 <span class="button-label" *ngIf="label">{{ label }}</span> 4 <span class="button-label" *ngIf="label">{{ label }}</span>
diff --git a/config/test-2.yaml b/config/test-2.yaml
index a5515afa4..de7300366 100644
--- a/config/test-2.yaml
+++ b/config/test-2.yaml
@@ -31,3 +31,4 @@ signup:
31transcoding: 31transcoding:
32 enabled: true 32 enabled: true
33 allow_additional_extensions: true 33 allow_additional_extensions: true
34 allow_audio_files: true
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts
index a2a615a79..40a2c972b 100644
--- a/server/controllers/api/videos/index.ts
+++ b/server/controllers/api/videos/index.ts
@@ -1,12 +1,19 @@
1import * as express from 'express' 1import * as express from 'express'
2import { extname, join } from 'path' 2import { extname, join } from 'path'
3import { VideoCreate, VideoPrivacy, VideoResolution, VideoState, VideoUpdate } from '../../../../shared' 3import { VideoCreate, VideoPrivacy, VideoState, VideoUpdate } from '../../../../shared'
4import { getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffmpeg-utils' 4import { getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffmpeg-utils'
5import { logger } from '../../../helpers/logger' 5import { logger } from '../../../helpers/logger'
6import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger' 6import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger'
7import { getFormattedObjects, getServerActor } from '../../../helpers/utils' 7import { getFormattedObjects, getServerActor } from '../../../helpers/utils'
8import { autoBlacklistVideoIfNeeded } from '../../../lib/video-blacklist' 8import { autoBlacklistVideoIfNeeded } from '../../../lib/video-blacklist'
9import { MIMETYPES, VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES, DEFAULT_AUDIO_RESOLUTION } from '../../../initializers/constants' 9import {
10 DEFAULT_AUDIO_RESOLUTION,
11 MIMETYPES,
12 VIDEO_CATEGORIES,
13 VIDEO_LANGUAGES,
14 VIDEO_LICENCES,
15 VIDEO_PRIVACIES
16} from '../../../initializers/constants'
10import { 17import {
11 changeVideoChannelShare, 18 changeVideoChannelShare,
12 federateVideoIfNeeded, 19 federateVideoIfNeeded,
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts
index 718d0893b..8a11101ff 100644
--- a/server/initializers/constants.ts
+++ b/server/initializers/constants.ts
@@ -509,8 +509,8 @@ const THUMBNAILS_SIZE = {
509 height: 122 509 height: 122
510} 510}
511const PREVIEWS_SIZE = { 511const PREVIEWS_SIZE = {
512 width: 560, 512 width: 850,
513 height: 315 513 height: 480
514} 514}
515const AVATARS_SIZE = { 515const AVATARS_SIZE = {
516 width: 120, 516 width: 120,
diff --git a/server/tests/api/server/config.ts b/server/tests/api/server/config.ts
index 2ad477c99..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
@@ -160,6 +160,9 @@ describe('Test config', function () {
160 expect(data.video.file.extensions).to.contain('.webm') 160 expect(data.video.file.extensions).to.contain('.webm')
161 expect(data.video.file.extensions).to.contain('.ogv') 161 expect(data.video.file.extensions).to.contain('.ogv')
162 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
163 expect(data.contactForm.enabled).to.be.true 166 expect(data.contactForm.enabled).to.be.true
164 }) 167 })
165 168
@@ -272,6 +275,12 @@ describe('Test config', function () {
272 expect(data.video.file.extensions).to.contain('.ogv') 275 expect(data.video.file.extensions).to.contain('.ogv')
273 expect(data.video.file.extensions).to.contain('.flv') 276 expect(data.video.file.extensions).to.contain('.flv')
274 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)
275 }) 284 })
276 285
277 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/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 {
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,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 })
diff --git a/server/tests/fixtures/sample.ogg b/server/tests/fixtures/sample.ogg
new file mode 100644
index 000000000..0d7f43eb7
--- /dev/null
+++ b/server/tests/fixtures/sample.ogg
Binary files differ