aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/videos
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/videos')
-rw-r--r--server/tests/api/videos/multiple-servers.ts45
-rw-r--r--server/tests/api/videos/services.ts14
-rw-r--r--server/tests/api/videos/single-server.ts23
-rw-r--r--server/tests/api/videos/video-abuse.ts9
-rw-r--r--server/tests/api/videos/video-change-ownership.ts8
-rw-r--r--server/tests/api/videos/video-channels.ts8
-rw-r--r--server/tests/api/videos/video-comments.ts6
-rw-r--r--server/tests/api/videos/video-hls.ts54
-rw-r--r--server/tests/api/videos/video-playlists.ts4
-rw-r--r--server/tests/api/videos/video-transcoder.ts89
-rw-r--r--server/tests/api/videos/videos-views-cleaner.ts16
11 files changed, 182 insertions, 94 deletions
diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts
index 68c1e9a8d..e9625e5f7 100644
--- a/server/tests/api/videos/multiple-servers.ts
+++ b/server/tests/api/videos/multiple-servers.ts
@@ -9,18 +9,17 @@ import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/
9import { 9import {
10 addVideoChannel, 10 addVideoChannel,
11 checkTmpIsEmpty, 11 checkTmpIsEmpty,
12 checkVideoFilesWereRemoved, cleanupTests, 12 checkVideoFilesWereRemoved,
13 cleanupTests,
13 completeVideoCheck, 14 completeVideoCheck,
14 createUser, 15 createUser,
15 dateIsValid, 16 dateIsValid,
16 doubleFollow, 17 doubleFollow,
17 flushAndRunMultipleServers, 18 flushAndRunMultipleServers,
18 flushTests,
19 getLocalVideos, 19 getLocalVideos,
20 getVideo, 20 getVideo,
21 getVideoChannelsList, 21 getVideoChannelsList,
22 getVideosList, 22 getVideosList,
23 killallServers,
24 rateVideo, 23 rateVideo,
25 removeVideo, 24 removeVideo,
26 ServerInfo, 25 ServerInfo,
@@ -110,7 +109,7 @@ describe('Test multiple servers', function () {
110 // All servers should have this video 109 // All servers should have this video
111 let publishedAt: string = null 110 let publishedAt: string = null
112 for (const server of servers) { 111 for (const server of servers) {
113 const isLocal = server.url === 'http://localhost:9001' 112 const isLocal = server.port === servers[0].port
114 const checkAttributes = { 113 const checkAttributes = {
115 name: 'my super name for server 1', 114 name: 'my super name for server 1',
116 category: 5, 115 category: 5,
@@ -122,7 +121,7 @@ describe('Test multiple servers', function () {
122 originallyPublishedAt: '2019-02-10T13:38:14.449Z', 121 originallyPublishedAt: '2019-02-10T13:38:14.449Z',
123 account: { 122 account: {
124 name: 'root', 123 name: 'root',
125 host: 'localhost:9001' 124 host: 'localhost:' + servers[0].port
126 }, 125 },
127 isLocal, 126 isLocal,
128 publishedAt, 127 publishedAt,
@@ -187,7 +186,7 @@ describe('Test multiple servers', function () {
187 186
188 // All servers should have this video 187 // All servers should have this video
189 for (const server of servers) { 188 for (const server of servers) {
190 const isLocal = server.url === 'http://localhost:9002' 189 const isLocal = server.url === 'http://localhost:' + servers[1].port
191 const checkAttributes = { 190 const checkAttributes = {
192 name: 'my super name for server 2', 191 name: 'my super name for server 2',
193 category: 4, 192 category: 4,
@@ -198,7 +197,7 @@ describe('Test multiple servers', function () {
198 support: 'my super support text for server 2', 197 support: 'my super support text for server 2',
199 account: { 198 account: {
200 name: 'user1', 199 name: 'user1',
201 host: 'localhost:9002' 200 host: 'localhost:' + servers[1].port
202 }, 201 },
203 isLocal, 202 isLocal,
204 commentsEnabled: true, 203 commentsEnabled: true,
@@ -216,7 +215,7 @@ describe('Test multiple servers', function () {
216 files: [ 215 files: [
217 { 216 {
218 resolution: 240, 217 resolution: 240,
219 size: 187000 218 size: 189000
220 }, 219 },
221 { 220 {
222 resolution: 360, 221 resolution: 360,
@@ -224,7 +223,7 @@ describe('Test multiple servers', function () {
224 }, 223 },
225 { 224 {
226 resolution: 480, 225 resolution: 480,
227 size: 383000 226 size: 384000
228 }, 227 },
229 { 228 {
230 resolution: 720, 229 resolution: 720,
@@ -278,7 +277,7 @@ describe('Test multiple servers', function () {
278 277
279 // All servers should have this video 278 // All servers should have this video
280 for (const server of servers) { 279 for (const server of servers) {
281 const isLocal = server.url === 'http://localhost:9003' 280 const isLocal = server.url === 'http://localhost:' + servers[2].port
282 const res = await getVideosList(server.url) 281 const res = await getVideosList(server.url)
283 282
284 const videos = res.body.data 283 const videos = res.body.data
@@ -306,7 +305,7 @@ describe('Test multiple servers', function () {
306 support: 'my super support text for server 3', 305 support: 'my super support text for server 3',
307 account: { 306 account: {
308 name: 'root', 307 name: 'root',
309 host: 'localhost:9003' 308 host: 'localhost:' + servers[2].port
310 }, 309 },
311 isLocal, 310 isLocal,
312 duration: 5, 311 duration: 5,
@@ -340,7 +339,7 @@ describe('Test multiple servers', function () {
340 support: 'my super support text for server 3-2', 339 support: 'my super support text for server 3-2',
341 account: { 340 account: {
342 name: 'root', 341 name: 'root',
343 host: 'localhost:9003' 342 host: 'localhost:' + servers[2].port
344 }, 343 },
345 commentsEnabled: true, 344 commentsEnabled: true,
346 downloadEnabled: true, 345 downloadEnabled: true,
@@ -646,7 +645,7 @@ describe('Test multiple servers', function () {
646 const videoUpdated = videos.find(video => video.name === 'my super video updated') 645 const videoUpdated = videos.find(video => video.name === 'my super video updated')
647 expect(!!videoUpdated).to.be.true 646 expect(!!videoUpdated).to.be.true
648 647
649 const isLocal = server.url === 'http://localhost:9003' 648 const isLocal = server.url === 'http://localhost:' + servers[2].port
650 const checkAttributes = { 649 const checkAttributes = {
651 name: 'my super video updated', 650 name: 'my super video updated',
652 category: 10, 651 category: 10,
@@ -658,7 +657,7 @@ describe('Test multiple servers', function () {
658 originallyPublishedAt: '2019-02-11T13:38:14.449Z', 657 originallyPublishedAt: '2019-02-11T13:38:14.449Z',
659 account: { 658 account: {
660 name: 'root', 659 name: 'root',
661 host: 'localhost:9003' 660 host: 'localhost:' + servers[2].port
662 }, 661 },
663 isLocal, 662 isLocal,
664 duration: 5, 663 duration: 5,
@@ -813,7 +812,7 @@ describe('Test multiple servers', function () {
813 expect(comment).to.not.be.undefined 812 expect(comment).to.not.be.undefined
814 expect(comment.inReplyToCommentId).to.be.null 813 expect(comment.inReplyToCommentId).to.be.null
815 expect(comment.account.name).to.equal('root') 814 expect(comment.account.name).to.equal('root')
816 expect(comment.account.host).to.equal('localhost:9001') 815 expect(comment.account.host).to.equal('localhost:' + servers[0].port)
817 expect(comment.totalReplies).to.equal(3) 816 expect(comment.totalReplies).to.equal(3)
818 expect(dateIsValid(comment.createdAt as string)).to.be.true 817 expect(dateIsValid(comment.createdAt as string)).to.be.true
819 expect(dateIsValid(comment.updatedAt as string)).to.be.true 818 expect(dateIsValid(comment.updatedAt as string)).to.be.true
@@ -824,7 +823,7 @@ describe('Test multiple servers', function () {
824 expect(comment).to.not.be.undefined 823 expect(comment).to.not.be.undefined
825 expect(comment.inReplyToCommentId).to.be.null 824 expect(comment.inReplyToCommentId).to.be.null
826 expect(comment.account.name).to.equal('root') 825 expect(comment.account.name).to.equal('root')
827 expect(comment.account.host).to.equal('localhost:9003') 826 expect(comment.account.host).to.equal('localhost:' + servers[2].port)
828 expect(comment.totalReplies).to.equal(0) 827 expect(comment.totalReplies).to.equal(0)
829 expect(dateIsValid(comment.createdAt as string)).to.be.true 828 expect(dateIsValid(comment.createdAt as string)).to.be.true
830 expect(dateIsValid(comment.updatedAt as string)).to.be.true 829 expect(dateIsValid(comment.updatedAt as string)).to.be.true
@@ -842,25 +841,25 @@ describe('Test multiple servers', function () {
842 const tree: VideoCommentThreadTree = res2.body 841 const tree: VideoCommentThreadTree = res2.body
843 expect(tree.comment.text).equal('my super first comment') 842 expect(tree.comment.text).equal('my super first comment')
844 expect(tree.comment.account.name).equal('root') 843 expect(tree.comment.account.name).equal('root')
845 expect(tree.comment.account.host).equal('localhost:9001') 844 expect(tree.comment.account.host).equal('localhost:' + servers[0].port)
846 expect(tree.children).to.have.lengthOf(2) 845 expect(tree.children).to.have.lengthOf(2)
847 846
848 const firstChild = tree.children[0] 847 const firstChild = tree.children[0]
849 expect(firstChild.comment.text).to.equal('my super answer to thread 1') 848 expect(firstChild.comment.text).to.equal('my super answer to thread 1')
850 expect(firstChild.comment.account.name).equal('root') 849 expect(firstChild.comment.account.name).equal('root')
851 expect(firstChild.comment.account.host).equal('localhost:9002') 850 expect(firstChild.comment.account.host).equal('localhost:' + servers[1].port)
852 expect(firstChild.children).to.have.lengthOf(1) 851 expect(firstChild.children).to.have.lengthOf(1)
853 852
854 childOfFirstChild = firstChild.children[0] 853 childOfFirstChild = firstChild.children[0]
855 expect(childOfFirstChild.comment.text).to.equal('my super answer to answer of thread 1') 854 expect(childOfFirstChild.comment.text).to.equal('my super answer to answer of thread 1')
856 expect(childOfFirstChild.comment.account.name).equal('root') 855 expect(childOfFirstChild.comment.account.name).equal('root')
857 expect(childOfFirstChild.comment.account.host).equal('localhost:9003') 856 expect(childOfFirstChild.comment.account.host).equal('localhost:' + servers[2].port)
858 expect(childOfFirstChild.children).to.have.lengthOf(0) 857 expect(childOfFirstChild.children).to.have.lengthOf(0)
859 858
860 const secondChild = tree.children[1] 859 const secondChild = tree.children[1]
861 expect(secondChild.comment.text).to.equal('my second answer to thread 1') 860 expect(secondChild.comment.text).to.equal('my second answer to thread 1')
862 expect(secondChild.comment.account.name).equal('root') 861 expect(secondChild.comment.account.name).equal('root')
863 expect(secondChild.comment.account.host).equal('localhost:9003') 862 expect(secondChild.comment.account.host).equal('localhost:' + servers[2].port)
864 expect(secondChild.children).to.have.lengthOf(0) 863 expect(secondChild.children).to.have.lengthOf(0)
865 } 864 }
866 }) 865 })
@@ -915,7 +914,7 @@ describe('Test multiple servers', function () {
915 expect(comment).to.not.be.undefined 914 expect(comment).to.not.be.undefined
916 expect(comment.inReplyToCommentId).to.be.null 915 expect(comment.inReplyToCommentId).to.be.null
917 expect(comment.account.name).to.equal('root') 916 expect(comment.account.name).to.equal('root')
918 expect(comment.account.host).to.equal('localhost:9003') 917 expect(comment.account.host).to.equal('localhost:' + servers[2].port)
919 expect(comment.totalReplies).to.equal(0) 918 expect(comment.totalReplies).to.equal(0)
920 expect(dateIsValid(comment.createdAt as string)).to.be.true 919 expect(dateIsValid(comment.createdAt as string)).to.be.true
921 expect(dateIsValid(comment.updatedAt as string)).to.be.true 920 expect(dateIsValid(comment.updatedAt as string)).to.be.true
@@ -971,7 +970,7 @@ describe('Test multiple servers', function () {
971 const res = await getVideosList(server.url) 970 const res = await getVideosList(server.url)
972 const video = res.body.data.find(v => v.name === 'minimum parameters') 971 const video = res.body.data.find(v => v.name === 'minimum parameters')
973 972
974 const isLocal = server.url === 'http://localhost:9002' 973 const isLocal = server.url === 'http://localhost:' + servers[1].port
975 const checkAttributes = { 974 const checkAttributes = {
976 name: 'minimum parameters', 975 name: 'minimum parameters',
977 category: null, 976 category: null,
@@ -982,7 +981,7 @@ describe('Test multiple servers', function () {
982 support: null, 981 support: null,
983 account: { 982 account: {
984 name: 'root', 983 name: 'root',
985 host: 'localhost:9002' 984 host: 'localhost:' + servers[1].port
986 }, 985 },
987 isLocal, 986 isLocal,
988 duration: 5, 987 duration: 5,
diff --git a/server/tests/api/videos/services.ts b/server/tests/api/videos/services.ts
index e9ad947b2..17172331f 100644
--- a/server/tests/api/videos/services.ts
+++ b/server/tests/api/videos/services.ts
@@ -27,13 +27,13 @@ describe('Test services', function () {
27 }) 27 })
28 28
29 it('Should have a valid oEmbed response', async function () { 29 it('Should have a valid oEmbed response', async function () {
30 const oembedUrl = 'http://localhost:9001/videos/watch/' + server.video.uuid 30 const oembedUrl = 'http://localhost:' + server.port + '/videos/watch/' + server.video.uuid
31 31
32 const res = await getOEmbed(server.url, oembedUrl) 32 const res = await getOEmbed(server.url, oembedUrl)
33 const expectedHtml = '<iframe width="560" height="315" sandbox="allow-same-origin allow-scripts" ' + 33 const expectedHtml = '<iframe width="560" height="315" sandbox="allow-same-origin allow-scripts" ' +
34 `src="http://localhost:9001/videos/embed/${server.video.uuid}" ` + 34 `src="http://localhost:${server.port}/videos/embed/${server.video.uuid}" ` +
35 'frameborder="0" allowfullscreen></iframe>' 35 'frameborder="0" allowfullscreen></iframe>'
36 const expectedThumbnailUrl = 'http://localhost:9001/static/previews/' + server.video.uuid + '.jpg' 36 const expectedThumbnailUrl = 'http://localhost:' + server.port + '/static/previews/' + server.video.uuid + '.jpg'
37 37
38 expect(res.body.html).to.equal(expectedHtml) 38 expect(res.body.html).to.equal(expectedHtml)
39 expect(res.body.title).to.equal(server.video.name) 39 expect(res.body.title).to.equal(server.video.name)
@@ -41,19 +41,19 @@ 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 () {
49 const oembedUrl = 'http://localhost:9001/videos/watch/' + server.video.uuid 49 const oembedUrl = 'http://localhost:' + server.port + '/videos/watch/' + server.video.uuid
50 const format = 'json' 50 const format = 'json'
51 const maxHeight = 50 51 const maxHeight = 50
52 const maxWidth = 50 52 const maxWidth = 50
53 53
54 const res = await getOEmbed(server.url, oembedUrl, format, maxHeight, maxWidth) 54 const res = await getOEmbed(server.url, oembedUrl, format, maxHeight, maxWidth)
55 const expectedHtml = '<iframe width="50" height="50" sandbox="allow-same-origin allow-scripts" ' + 55 const expectedHtml = '<iframe width="50" height="50" sandbox="allow-same-origin allow-scripts" ' +
56 `src="http://localhost:9001/videos/embed/${server.video.uuid}" ` + 56 `src="http://localhost:${server.port}/videos/embed/${server.video.uuid}" ` +
57 'frameborder="0" allowfullscreen></iframe>' 57 'frameborder="0" allowfullscreen></iframe>'
58 58
59 expect(res.body.html).to.equal(expectedHtml) 59 expect(res.body.html).to.equal(expectedHtml)
diff --git a/server/tests/api/videos/single-server.ts b/server/tests/api/videos/single-server.ts
index 1f366b642..d8f394ac7 100644
--- a/server/tests/api/videos/single-server.ts
+++ b/server/tests/api/videos/single-server.ts
@@ -37,7 +37,7 @@ describe('Test a single server', function () {
37 let videoUUID = '' 37 let videoUUID = ''
38 let videosListBase: any[] = null 38 let videosListBase: any[] = null
39 39
40 const getCheckAttributes = { 40 const getCheckAttributes = () => ({
41 name: 'my super name', 41 name: 'my super name',
42 category: 2, 42 category: 2,
43 licence: 6, 43 licence: 6,
@@ -47,7 +47,7 @@ describe('Test a single server', function () {
47 support: 'my super support text', 47 support: 'my super support text',
48 account: { 48 account: {
49 name: 'root', 49 name: 'root',
50 host: 'localhost:9001' 50 host: 'localhost:' + server.port
51 }, 51 },
52 isLocal: true, 52 isLocal: true,
53 duration: 5, 53 duration: 5,
@@ -68,9 +68,9 @@ describe('Test a single server', function () {
68 size: 218910 68 size: 218910
69 } 69 }
70 ] 70 ]
71 } 71 })
72 72
73 const updateCheckAttributes = { 73 const updateCheckAttributes = () => ({
74 name: 'my super video updated', 74 name: 'my super video updated',
75 category: 4, 75 category: 4,
76 licence: 2, 76 licence: 2,
@@ -80,7 +80,7 @@ describe('Test a single server', function () {
80 support: 'my super support text updated', 80 support: 'my super support text updated',
81 account: { 81 account: {
82 name: 'root', 82 name: 'root',
83 host: 'localhost:9001' 83 host: 'localhost:' + server.port
84 }, 84 },
85 isLocal: true, 85 isLocal: true,
86 tags: [ 'tagup1', 'tagup2' ], 86 tags: [ 'tagup1', 'tagup2' ],
@@ -101,7 +101,7 @@ describe('Test a single server', function () {
101 size: 292677 101 size: 292677
102 } 102 }
103 ] 103 ]
104 } 104 })
105 105
106 before(async function () { 106 before(async function () {
107 this.timeout(30000) 107 this.timeout(30000)
@@ -182,7 +182,7 @@ describe('Test a single server', function () {
182 expect(res.body.data.length).to.equal(1) 182 expect(res.body.data.length).to.equal(1)
183 183
184 const video = res.body.data[0] 184 const video = res.body.data[0]
185 await completeVideoCheck(server.url, video, getCheckAttributes) 185 await completeVideoCheck(server.url, video, getCheckAttributes())
186 }) 186 })
187 187
188 it('Should get the video by UUID', async function () { 188 it('Should get the video by UUID', async function () {
@@ -191,7 +191,7 @@ describe('Test a single server', function () {
191 const res = await getVideo(server.url, videoUUID) 191 const res = await getVideo(server.url, videoUUID)
192 192
193 const video = res.body 193 const video = res.body
194 await completeVideoCheck(server.url, video, getCheckAttributes) 194 await completeVideoCheck(server.url, video, getCheckAttributes())
195 }) 195 })
196 196
197 it('Should have the views updated', async function () { 197 it('Should have the views updated', async function () {
@@ -376,7 +376,7 @@ describe('Test a single server', function () {
376 const res = await getVideo(server.url, videoId) 376 const res = await getVideo(server.url, videoId)
377 const video = res.body 377 const video = res.body
378 378
379 await completeVideoCheck(server.url, video, updateCheckAttributes) 379 await completeVideoCheck(server.url, video, updateCheckAttributes())
380 }) 380 })
381 381
382 it('Should update only the tags of a video', async function () { 382 it('Should update only the tags of a video', async function () {
@@ -388,7 +388,7 @@ describe('Test a single server', function () {
388 const res = await getVideo(server.url, videoId) 388 const res = await getVideo(server.url, videoId)
389 const video = res.body 389 const video = res.body
390 390
391 await completeVideoCheck(server.url, video, Object.assign(updateCheckAttributes, attributes)) 391 await completeVideoCheck(server.url, video, Object.assign(updateCheckAttributes(), attributes))
392 }) 392 })
393 393
394 it('Should update only the description of a video', async function () { 394 it('Should update only the description of a video', async function () {
@@ -400,7 +400,8 @@ describe('Test a single server', function () {
400 const res = await getVideo(server.url, videoId) 400 const res = await getVideo(server.url, videoId)
401 const video = res.body 401 const video = res.body
402 402
403 await completeVideoCheck(server.url, video, Object.assign(updateCheckAttributes, attributes)) 403 const expectedAttributes = Object.assign(updateCheckAttributes(), { tags: [ 'supertag', 'tag1', 'tag2' ] }, attributes)
404 await completeVideoCheck(server.url, video, expectedAttributes)
404 }) 405 })
405 406
406 it('Should like a video', async function () { 407 it('Should like a video', async function () {
diff --git a/server/tests/api/videos/video-abuse.ts b/server/tests/api/videos/video-abuse.ts
index 7318497d5..a2f3ee161 100644
--- a/server/tests/api/videos/video-abuse.ts
+++ b/server/tests/api/videos/video-abuse.ts
@@ -9,7 +9,6 @@ import {
9 flushAndRunMultipleServers, 9 flushAndRunMultipleServers,
10 getVideoAbusesList, 10 getVideoAbusesList,
11 getVideosList, 11 getVideosList,
12 killallServers,
13 reportVideoAbuse, 12 reportVideoAbuse,
14 ServerInfo, 13 ServerInfo,
15 setAccessTokensToServers, 14 setAccessTokensToServers,
@@ -90,7 +89,7 @@ describe('Test video abuses', function () {
90 const abuse: VideoAbuse = res1.body.data[0] 89 const abuse: VideoAbuse = res1.body.data[0]
91 expect(abuse.reason).to.equal('my super bad reason') 90 expect(abuse.reason).to.equal('my super bad reason')
92 expect(abuse.reporterAccount.name).to.equal('root') 91 expect(abuse.reporterAccount.name).to.equal('root')
93 expect(abuse.reporterAccount.host).to.equal('localhost:9001') 92 expect(abuse.reporterAccount.host).to.equal('localhost:' + servers[0].port)
94 expect(abuse.video.id).to.equal(servers[0].video.id) 93 expect(abuse.video.id).to.equal(servers[0].video.id)
95 94
96 const res2 = await getVideoAbusesList(servers[1].url, servers[1].accessToken) 95 const res2 = await getVideoAbusesList(servers[1].url, servers[1].accessToken)
@@ -118,7 +117,7 @@ describe('Test video abuses', function () {
118 const abuse1: VideoAbuse = res1.body.data[0] 117 const abuse1: VideoAbuse = res1.body.data[0]
119 expect(abuse1.reason).to.equal('my super bad reason') 118 expect(abuse1.reason).to.equal('my super bad reason')
120 expect(abuse1.reporterAccount.name).to.equal('root') 119 expect(abuse1.reporterAccount.name).to.equal('root')
121 expect(abuse1.reporterAccount.host).to.equal('localhost:9001') 120 expect(abuse1.reporterAccount.host).to.equal('localhost:' + servers[0].port)
122 expect(abuse1.video.id).to.equal(servers[0].video.id) 121 expect(abuse1.video.id).to.equal(servers[0].video.id)
123 expect(abuse1.state.id).to.equal(VideoAbuseState.PENDING) 122 expect(abuse1.state.id).to.equal(VideoAbuseState.PENDING)
124 expect(abuse1.state.label).to.equal('Pending') 123 expect(abuse1.state.label).to.equal('Pending')
@@ -127,7 +126,7 @@ describe('Test video abuses', function () {
127 const abuse2: VideoAbuse = res1.body.data[1] 126 const abuse2: VideoAbuse = res1.body.data[1]
128 expect(abuse2.reason).to.equal('my super bad reason 2') 127 expect(abuse2.reason).to.equal('my super bad reason 2')
129 expect(abuse2.reporterAccount.name).to.equal('root') 128 expect(abuse2.reporterAccount.name).to.equal('root')
130 expect(abuse2.reporterAccount.host).to.equal('localhost:9001') 129 expect(abuse2.reporterAccount.host).to.equal('localhost:' + servers[0].port)
131 expect(abuse2.video.id).to.equal(servers[1].video.id) 130 expect(abuse2.video.id).to.equal(servers[1].video.id)
132 expect(abuse2.state.id).to.equal(VideoAbuseState.PENDING) 131 expect(abuse2.state.id).to.equal(VideoAbuseState.PENDING)
133 expect(abuse2.state.label).to.equal('Pending') 132 expect(abuse2.state.label).to.equal('Pending')
@@ -141,7 +140,7 @@ describe('Test video abuses', function () {
141 abuseServer2 = res2.body.data[0] 140 abuseServer2 = res2.body.data[0]
142 expect(abuseServer2.reason).to.equal('my super bad reason 2') 141 expect(abuseServer2.reason).to.equal('my super bad reason 2')
143 expect(abuseServer2.reporterAccount.name).to.equal('root') 142 expect(abuseServer2.reporterAccount.name).to.equal('root')
144 expect(abuseServer2.reporterAccount.host).to.equal('localhost:9001') 143 expect(abuseServer2.reporterAccount.host).to.equal('localhost:' + servers[0].port)
145 expect(abuseServer2.state.id).to.equal(VideoAbuseState.PENDING) 144 expect(abuseServer2.state.id).to.equal(VideoAbuseState.PENDING)
146 expect(abuseServer2.state.label).to.equal('Pending') 145 expect(abuseServer2.state.label).to.equal('Pending')
147 expect(abuseServer2.moderationComment).to.be.null 146 expect(abuseServer2.moderationComment).to.be.null
diff --git a/server/tests/api/videos/video-change-ownership.ts b/server/tests/api/videos/video-change-ownership.ts
index 1c0327d40..3a3add71b 100644
--- a/server/tests/api/videos/video-change-ownership.ts
+++ b/server/tests/api/videos/video-change-ownership.ts
@@ -4,7 +4,8 @@ import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { 5import {
6 acceptChangeOwnership, 6 acceptChangeOwnership,
7 changeVideoOwnership, cleanupTests, 7 changeVideoOwnership,
8 cleanupTests,
8 createUser, 9 createUser,
9 doubleFollow, 10 doubleFollow,
10 flushAndRunMultipleServers, 11 flushAndRunMultipleServers,
@@ -13,7 +14,6 @@ import {
13 getVideo, 14 getVideo,
14 getVideoChangeOwnershipList, 15 getVideoChangeOwnershipList,
15 getVideosList, 16 getVideosList,
16 killallServers,
17 refuseChangeOwnership, 17 refuseChangeOwnership,
18 ServerInfo, 18 ServerInfo,
19 setAccessTokensToServers, 19 setAccessTokensToServers,
@@ -203,8 +203,8 @@ describe('Test video change ownership - nominal', function () {
203 } 203 }
204 }) 204 })
205 205
206 after(function () { 206 after(async function () {
207 killallServers(servers) 207 await cleanupTests(servers)
208 }) 208 })
209}) 209})
210 210
diff --git a/server/tests/api/videos/video-channels.ts b/server/tests/api/videos/video-channels.ts
index 345e96f43..41fe3be5c 100644
--- a/server/tests/api/videos/video-channels.ts
+++ b/server/tests/api/videos/video-channels.ts
@@ -41,7 +41,7 @@ describe('Test video channels', function () {
41 let videoUUID: string 41 let videoUUID: string
42 42
43 before(async function () { 43 before(async function () {
44 this.timeout(30000) 44 this.timeout(60000)
45 45
46 servers = await flushAndRunMultipleServers(2) 46 servers = await flushAndRunMultipleServers(2)
47 47
@@ -213,7 +213,7 @@ describe('Test video channels', function () {
213 this.timeout(10000) 213 this.timeout(10000)
214 214
215 for (const server of servers) { 215 for (const server of servers) {
216 const channelURI = 'second_video_channel@localhost:9001' 216 const channelURI = 'second_video_channel@localhost:' + servers[0].port
217 const res1 = await getVideoChannelVideos(server.url, server.accessToken, channelURI, 0, 5) 217 const res1 = await getVideoChannelVideos(server.url, server.accessToken, channelURI, 0, 5)
218 expect(res1.body.total).to.equal(1) 218 expect(res1.body.total).to.equal(1)
219 expect(res1.body.data).to.be.an('array') 219 expect(res1.body.data).to.be.an('array')
@@ -234,11 +234,11 @@ describe('Test video channels', function () {
234 this.timeout(10000) 234 this.timeout(10000)
235 235
236 for (const server of servers) { 236 for (const server of servers) {
237 const secondChannelURI = 'second_video_channel@localhost:9001' 237 const secondChannelURI = 'second_video_channel@localhost:' + servers[0].port
238 const res1 = await getVideoChannelVideos(server.url, server.accessToken, secondChannelURI, 0, 5) 238 const res1 = await getVideoChannelVideos(server.url, server.accessToken, secondChannelURI, 0, 5)
239 expect(res1.body.total).to.equal(0) 239 expect(res1.body.total).to.equal(0)
240 240
241 const channelURI = 'root_channel@localhost:9001' 241 const channelURI = 'root_channel@localhost:' + servers[0].port
242 const res2 = await getVideoChannelVideos(server.url, server.accessToken, channelURI, 0, 5) 242 const res2 = await getVideoChannelVideos(server.url, server.accessToken, channelURI, 0, 5)
243 expect(res2.body.total).to.equal(1) 243 expect(res2.body.total).to.equal(1)
244 244
diff --git a/server/tests/api/videos/video-comments.ts b/server/tests/api/videos/video-comments.ts
index 22fd8c058..82182cc7c 100644
--- a/server/tests/api/videos/video-comments.ts
+++ b/server/tests/api/videos/video-comments.ts
@@ -66,8 +66,8 @@ describe('Test video comments', function () {
66 expect(comment.videoId).to.equal(videoId) 66 expect(comment.videoId).to.equal(videoId)
67 expect(comment.id).to.equal(comment.threadId) 67 expect(comment.id).to.equal(comment.threadId)
68 expect(comment.account.name).to.equal('root') 68 expect(comment.account.name).to.equal('root')
69 expect(comment.account.host).to.equal('localhost:9001') 69 expect(comment.account.host).to.equal('localhost:' + server.port)
70 expect(comment.account.url).to.equal('http://localhost:9001/accounts/root') 70 expect(comment.account.url).to.equal('http://localhost:' + server.port + '/accounts/root')
71 expect(comment.totalReplies).to.equal(0) 71 expect(comment.totalReplies).to.equal(0)
72 expect(dateIsValid(comment.createdAt as string)).to.be.true 72 expect(dateIsValid(comment.createdAt as string)).to.be.true
73 expect(dateIsValid(comment.updatedAt as string)).to.be.true 73 expect(dateIsValid(comment.updatedAt as string)).to.be.true
@@ -86,7 +86,7 @@ describe('Test video comments', function () {
86 expect(comment.videoId).to.equal(videoId) 86 expect(comment.videoId).to.equal(videoId)
87 expect(comment.id).to.equal(comment.threadId) 87 expect(comment.id).to.equal(comment.threadId)
88 expect(comment.account.name).to.equal('root') 88 expect(comment.account.name).to.equal('root')
89 expect(comment.account.host).to.equal('localhost:9001') 89 expect(comment.account.host).to.equal('localhost:' + server.port)
90 90
91 await testImage(server.url, 'avatar-resized', comment.account.avatar.path, '.png') 91 await testImage(server.url, 'avatar-resized', comment.account.avatar.path, '.png')
92 92
diff --git a/server/tests/api/videos/video-hls.ts b/server/tests/api/videos/video-hls.ts
index 22031c18b..39178bb1a 100644
--- a/server/tests/api/videos/video-hls.ts
+++ b/server/tests/api/videos/video-hls.ts
@@ -5,13 +5,12 @@ import 'mocha'
5import { 5import {
6 checkDirectoryIsEmpty, 6 checkDirectoryIsEmpty,
7 checkSegmentHash, 7 checkSegmentHash,
8 checkTmpIsEmpty, cleanupTests, 8 checkTmpIsEmpty,
9 cleanupTests,
9 doubleFollow, 10 doubleFollow,
10 flushAndRunMultipleServers, 11 flushAndRunMultipleServers,
11 flushTests,
12 getPlaylist, 12 getPlaylist,
13 getVideo, 13 getVideo,
14 killallServers,
15 removeVideo, 14 removeVideo,
16 ServerInfo, 15 ServerInfo,
17 setAccessTokensToServers, 16 setAccessTokensToServers,
@@ -22,12 +21,11 @@ import {
22import { VideoDetails } from '../../../../shared/models/videos' 21import { VideoDetails } from '../../../../shared/models/videos'
23import { VideoStreamingPlaylistType } from '../../../../shared/models/videos/video-streaming-playlist.type' 22import { VideoStreamingPlaylistType } from '../../../../shared/models/videos/video-streaming-playlist.type'
24import { join } from 'path' 23import { join } from 'path'
24import { DEFAULT_AUDIO_RESOLUTION } from '../../../initializers/constants'
25 25
26const expect = chai.expect 26const expect = chai.expect
27 27
28async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string) { 28async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string, resolutions = [ 240, 360, 480, 720 ]) {
29 const resolutions = [ 240, 360, 480, 720 ]
30
31 for (const server of servers) { 29 for (const server of servers) {
32 const res = await getVideo(server.url, videoUUID) 30 const res = await getVideo(server.url, videoUUID)
33 const videoDetails: VideoDetails = res.body 31 const videoDetails: VideoDetails = res.body
@@ -42,16 +40,15 @@ async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string) {
42 40
43 const masterPlaylist = res2.text 41 const masterPlaylist = res2.text
44 42
45 expect(masterPlaylist).to.contain('#EXT-X-STREAM-INF:BANDWIDTH=55472,RESOLUTION=640x360,FRAME-RATE=25')
46
47 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+'))
48 expect(masterPlaylist).to.contain(`${resolution}.m3u8`) 45 expect(masterPlaylist).to.contain(`${resolution}.m3u8`)
49 } 46 }
50 } 47 }
51 48
52 { 49 {
53 for (const resolution of resolutions) { 50 for (const resolution of resolutions) {
54 const res2 = await getPlaylist(`http://localhost:9001/static/streaming-playlists/hls/${videoUUID}/${resolution}.m3u8`) 51 const res2 = await getPlaylist(`http://localhost:${servers[0].port}/static/streaming-playlists/hls/${videoUUID}/${resolution}.m3u8`)
55 52
56 const subPlaylist = res2.text 53 const subPlaylist = res2.text
57 expect(subPlaylist).to.contain(`${videoUUID}-${resolution}-fragmented.mp4`) 54 expect(subPlaylist).to.contain(`${videoUUID}-${resolution}-fragmented.mp4`)
@@ -59,7 +56,7 @@ async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string) {
59 } 56 }
60 57
61 { 58 {
62 const baseUrl = 'http://localhost:9001/static/streaming-playlists/hls' 59 const baseUrl = 'http://localhost:' + servers[0].port + '/static/streaming-playlists/hls'
63 60
64 for (const resolution of resolutions) { 61 for (const resolution of resolutions) {
65 await checkSegmentHash(baseUrl, baseUrl, videoUUID, resolution, hlsPlaylist) 62 await checkSegmentHash(baseUrl, baseUrl, videoUUID, resolution, hlsPlaylist)
@@ -71,11 +68,21 @@ async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string) {
71describe('Test HLS videos', function () { 68describe('Test HLS videos', function () {
72 let servers: ServerInfo[] = [] 69 let servers: ServerInfo[] = []
73 let videoUUID = '' 70 let videoUUID = ''
71 let videoAudioUUID = ''
74 72
75 before(async function () { 73 before(async function () {
76 this.timeout(120000) 74 this.timeout(120000)
77 75
78 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)
79 86
80 // Get the access tokens 87 // Get the access tokens
81 await setAccessTokensToServers(servers) 88 await setAccessTokensToServers(servers)
@@ -87,17 +94,28 @@ describe('Test HLS videos', function () {
87 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 () {
88 this.timeout(120000) 95 this.timeout(120000)
89 96
90 { 97 const res = await uploadVideo(servers[ 0 ].url, servers[ 0 ].accessToken, { name: 'video 1', fixture: 'video_short.webm' })
91 const res = await uploadVideo(servers[ 0 ].url, servers[ 0 ].accessToken, { name: 'video 1', fixture: 'video_short.webm' }) 98 videoUUID = res.body.video.uuid
92 videoUUID = res.body.video.uuid
93 }
94 99
95 await waitJobs(servers) 100 await waitJobs(servers)
96 101
97 await checkHlsPlaylist(servers, videoUUID) 102 await checkHlsPlaylist(servers, videoUUID)
98 }) 103 })
99 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
100 it('Should update the video', async function () { 116 it('Should update the video', async function () {
117 this.timeout(10000)
118
101 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' })
102 120
103 await waitJobs(servers) 121 await waitJobs(servers)
@@ -105,13 +123,17 @@ describe('Test HLS videos', function () {
105 await checkHlsPlaylist(servers, videoUUID) 123 await checkHlsPlaylist(servers, videoUUID)
106 }) 124 })
107 125
108 it('Should delete the video', async function () { 126 it('Should delete videos', async function () {
127 this.timeout(10000)
128
109 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)
110 131
111 await waitJobs(servers) 132 await waitJobs(servers)
112 133
113 for (const server of servers) { 134 for (const server of servers) {
114 await getVideo(server.url, videoUUID, 404) 135 await getVideo(server.url, videoUUID, 404)
136 await getVideo(server.url, videoAudioUUID, 404)
115 } 137 }
116 }) 138 })
117 139
diff --git a/server/tests/api/videos/video-playlists.ts b/server/tests/api/videos/video-playlists.ts
index e4d817ff8..83a2f3d4d 100644
--- a/server/tests/api/videos/video-playlists.ts
+++ b/server/tests/api/videos/video-playlists.ts
@@ -358,7 +358,7 @@ describe('Test video playlists', function () {
358 358
359 for (const server of servers) { 359 for (const server of servers) {
360 const results = [ 360 const results = [
361 await getAccountPlaylistsList(server.url, 'root@localhost:9002', 0, 5, '-createdAt'), 361 await getAccountPlaylistsList(server.url, 'root@localhost:' + servers[1].port, 0, 5, '-createdAt'),
362 await getVideoPlaylistsList(server.url, 0, 2, '-createdAt') 362 await getVideoPlaylistsList(server.url, 0, 2, '-createdAt')
363 ] 363 ]
364 364
@@ -757,7 +757,7 @@ describe('Test video playlists', function () {
757 this.timeout(30000) 757 this.timeout(30000)
758 758
759 for (const server of servers) { 759 for (const server of servers) {
760 await checkPlaylistFilesWereRemoved(playlistServer1UUID, server.serverNumber) 760 await checkPlaylistFilesWereRemoved(playlistServer1UUID, server.internalServerNumber)
761 } 761 }
762 }) 762 })
763 763
diff --git a/server/tests/api/videos/video-transcoder.ts b/server/tests/api/videos/video-transcoder.ts
index 3cd43e99b..90ade1652 100644
--- a/server/tests/api/videos/video-transcoder.ts
+++ b/server/tests/api/videos/video-transcoder.ts
@@ -4,24 +4,25 @@ import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { omit } from 'lodash' 5import { omit } from 'lodash'
6import { getMaxBitrate, VideoDetails, VideoResolution, VideoState } from '../../../../shared/models/videos' 6import { getMaxBitrate, VideoDetails, VideoResolution, VideoState } from '../../../../shared/models/videos'
7import { audio, getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffmpeg-utils' 7import { audio, canDoQuickTranscode, getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffmpeg-utils'
8import { 8import {
9 buildAbsoluteFixturePath, cleanupTests, 9 buildAbsoluteFixturePath,
10 cleanupTests,
10 doubleFollow, 11 doubleFollow,
11 flushAndRunMultipleServers, 12 flushAndRunMultipleServers,
12 generateHighBitrateVideo, 13 generateHighBitrateVideo,
13 getMyVideos, 14 getMyVideos,
14 getVideo, 15 getVideo,
15 getVideosList, 16 getVideosList,
16 killallServers, 17 makeGetRequest,
17 root, 18 root,
18 ServerInfo, 19 ServerInfo,
19 setAccessTokensToServers, 20 setAccessTokensToServers,
20 uploadVideo, 21 uploadVideo,
22 waitJobs,
21 webtorrentAdd 23 webtorrentAdd
22} from '../../../../shared/extra-utils' 24} from '../../../../shared/extra-utils'
23import { extname, join } from 'path' 25import { join } from 'path'
24import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
25import { VIDEO_TRANSCODING_FPS } from '../../../../server/initializers/constants' 26import { VIDEO_TRANSCODING_FPS } from '../../../../server/initializers/constants'
26 27
27const expect = chai.expect 28const expect = chai.expect
@@ -121,7 +122,7 @@ describe('Test video transcoding', function () {
121 122
122 expect(videoDetails.files).to.have.lengthOf(4) 123 expect(videoDetails.files).to.have.lengthOf(4)
123 124
124 const path = join(root(), 'test2', 'videos', video.uuid + '-240.mp4') 125 const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-240.mp4')
125 const probe = await audio.get(path) 126 const probe = await audio.get(path)
126 127
127 if (probe.audioStream) { 128 if (probe.audioStream) {
@@ -152,7 +153,7 @@ describe('Test video transcoding', function () {
152 const videoDetails: VideoDetails = res2.body 153 const videoDetails: VideoDetails = res2.body
153 154
154 expect(videoDetails.files).to.have.lengthOf(4) 155 expect(videoDetails.files).to.have.lengthOf(4)
155 const path = join(root(), 'test2', 'videos', video.uuid + '-240.mp4') 156 const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-240.mp4')
156 const probe = await audio.get(path) 157 const probe = await audio.get(path)
157 expect(probe).to.not.have.property('audioStream') 158 expect(probe).to.not.have.property('audioStream')
158 } 159 }
@@ -179,7 +180,7 @@ describe('Test video transcoding', function () {
179 expect(videoDetails.files).to.have.lengthOf(4) 180 expect(videoDetails.files).to.have.lengthOf(4)
180 const fixturePath = buildAbsoluteFixturePath(videoAttributes.fixture) 181 const fixturePath = buildAbsoluteFixturePath(videoAttributes.fixture)
181 const fixtureVideoProbe = await audio.get(fixturePath) 182 const fixtureVideoProbe = await audio.get(fixturePath)
182 const path = join(root(), 'test2', 'videos', video.uuid + '-240.mp4') 183 const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-240.mp4')
183 const videoProbe = await audio.get(path) 184 const videoProbe = await audio.get(path)
184 if (videoProbe.audioStream && fixtureVideoProbe.audioStream) { 185 if (videoProbe.audioStream && fixtureVideoProbe.audioStream) {
185 const toOmit = [ 'max_bit_rate', 'duration', 'duration_ts', 'nb_frames', 'start_time', 'start_pts' ] 186 const toOmit = [ 'max_bit_rate', 'duration', 'duration_ts', 'nb_frames', 'start_time', 'start_pts' ]
@@ -216,13 +217,13 @@ describe('Test video transcoding', function () {
216 expect(videoDetails.files[ 3 ].fps).to.be.below(31) 217 expect(videoDetails.files[ 3 ].fps).to.be.below(31)
217 218
218 for (const resolution of [ '240', '360', '480' ]) { 219 for (const resolution of [ '240', '360', '480' ]) {
219 const path = join(root(), 'test2', 'videos', video.uuid + '-' + resolution + '.mp4') 220 const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-' + resolution + '.mp4')
220 const fps = await getVideoFileFPS(path) 221 const fps = await getVideoFileFPS(path)
221 222
222 expect(fps).to.be.below(31) 223 expect(fps).to.be.below(31)
223 } 224 }
224 225
225 const path = join(root(), 'test2', 'videos', video.uuid + '-720.mp4') 226 const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-720.mp4')
226 const fps = await getVideoFileFPS(path) 227 const fps = await getVideoFileFPS(path)
227 228
228 expect(fps).to.be.above(58).and.below(62) 229 expect(fps).to.be.above(58).and.below(62)
@@ -310,7 +311,7 @@ describe('Test video transcoding', function () {
310 const video = res.body.data.find(v => v.name === videoAttributes.name) 311 const video = res.body.data.find(v => v.name === videoAttributes.name)
311 312
312 for (const resolution of ['240', '360', '480', '720', '1080']) { 313 for (const resolution of ['240', '360', '480', '720', '1080']) {
313 const path = join(root(), 'test2', 'videos', video.uuid + '-' + resolution + '.mp4') 314 const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-' + resolution + '.mp4')
314 const bitrate = await getVideoFileBitrate(path) 315 const bitrate = await getVideoFileBitrate(path)
315 const fps = await getVideoFileFPS(path) 316 const fps = await getVideoFileFPS(path)
316 const resolution2 = await getVideoFileResolution(path) 317 const resolution2 = await getVideoFileResolution(path)
@@ -324,6 +325,15 @@ describe('Test video transcoding', function () {
324 it('Should accept and transcode additional extensions', async function () { 325 it('Should accept and transcode additional extensions', async function () {
325 this.timeout(300000) 326 this.timeout(300000)
326 327
328 let tempFixturePath: string
329
330 {
331 tempFixturePath = await generateHighBitrateVideo()
332
333 const bitrate = await getVideoFileBitrate(tempFixturePath)
334 expect(bitrate).to.be.above(getMaxBitrate(VideoResolution.H_1080P, 60, VIDEO_TRANSCODING_FPS))
335 }
336
327 for (const fixture of [ 'video_short.mkv', 'video_short.avi' ]) { 337 for (const fixture of [ 'video_short.mkv', 'video_short.avi' ]) {
328 const videoAttributes = { 338 const videoAttributes = {
329 name: fixture, 339 name: fixture,
@@ -349,6 +359,63 @@ describe('Test video transcoding', function () {
349 } 359 }
350 }) 360 })
351 361
362 it('Should correctly detect if quick transcode is possible', async function () {
363 this.timeout(10000)
364
365 expect(await canDoQuickTranscode(buildAbsoluteFixturePath('video_short.mp4'))).to.be.true
366 expect(await canDoQuickTranscode(buildAbsoluteFixturePath('video_short.webm'))).to.be.false
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
352 after(async function () { 419 after(async function () {
353 await cleanupTests(servers) 420 await cleanupTests(servers)
354 }) 421 })
diff --git a/server/tests/api/videos/videos-views-cleaner.ts b/server/tests/api/videos/videos-views-cleaner.ts
index c21d46d56..fbddd40f4 100644
--- a/server/tests/api/videos/videos-views-cleaner.ts
+++ b/server/tests/api/videos/videos-views-cleaner.ts
@@ -10,7 +10,7 @@ import {
10 flushAndRunServer, 10 flushAndRunServer,
11 ServerInfo, 11 ServerInfo,
12 setAccessTokensToServers, 12 setAccessTokensToServers,
13 uploadVideo, uploadVideoAndGetId, viewVideo, wait, countVideoViewsOf, doubleFollow, waitJobs, cleanupTests 13 uploadVideo, uploadVideoAndGetId, viewVideo, wait, countVideoViewsOf, doubleFollow, waitJobs, cleanupTests, closeAllSequelize
14} from '../../../../shared/extra-utils' 14} from '../../../../shared/extra-utils'
15import { getVideosOverview } from '../../../../shared/extra-utils/overviews/overviews' 15import { getVideosOverview } from '../../../../shared/extra-utils/overviews/overviews'
16import { VideosOverview } from '../../../../shared/models/overviews' 16import { VideosOverview } from '../../../../shared/models/overviews'
@@ -58,14 +58,14 @@ describe('Test video views cleaner', function () {
58 58
59 { 59 {
60 for (const server of servers) { 60 for (const server of servers) {
61 const total = await countVideoViewsOf(server.serverNumber, videoIdServer1) 61 const total = await countVideoViewsOf(server.internalServerNumber, videoIdServer1)
62 expect(total).to.equal(2) 62 expect(total).to.equal(2)
63 } 63 }
64 } 64 }
65 65
66 { 66 {
67 for (const server of servers) { 67 for (const server of servers) {
68 const total = await countVideoViewsOf(server.serverNumber, videoIdServer2) 68 const total = await countVideoViewsOf(server.internalServerNumber, videoIdServer2)
69 expect(total).to.equal(2) 69 expect(total).to.equal(2)
70 } 70 }
71 } 71 }
@@ -74,8 +74,6 @@ describe('Test video views cleaner', function () {
74 it('Should clean old video views', async function () { 74 it('Should clean old video views', async function () {
75 this.timeout(50000) 75 this.timeout(50000)
76 76
77 this.timeout(50000)
78
79 killallServers([ servers[0] ]) 77 killallServers([ servers[0] ])
80 78
81 await reRunServer(servers[0], { views: { videos: { remote: { max_age: '5 seconds' } } } }) 79 await reRunServer(servers[0], { views: { videos: { remote: { max_age: '5 seconds' } } } })
@@ -86,21 +84,23 @@ describe('Test video views cleaner', function () {
86 84
87 { 85 {
88 for (const server of servers) { 86 for (const server of servers) {
89 const total = await countVideoViewsOf(server.serverNumber, videoIdServer1) 87 const total = await countVideoViewsOf(server.internalServerNumber, videoIdServer1)
90 expect(total).to.equal(2) 88 expect(total).to.equal(2)
91 } 89 }
92 } 90 }
93 91
94 { 92 {
95 const totalServer1 = await countVideoViewsOf(servers[0].serverNumber, videoIdServer2) 93 const totalServer1 = await countVideoViewsOf(servers[0].internalServerNumber, videoIdServer2)
96 expect(totalServer1).to.equal(0) 94 expect(totalServer1).to.equal(0)
97 95
98 const totalServer2 = await countVideoViewsOf(servers[1].serverNumber, videoIdServer2) 96 const totalServer2 = await countVideoViewsOf(servers[1].internalServerNumber, videoIdServer2)
99 expect(totalServer2).to.equal(2) 97 expect(totalServer2).to.equal(2)
100 } 98 }
101 }) 99 })
102 100
103 after(async function () { 101 after(async function () {
102 await closeAllSequelize(servers)
103
104 await cleanupTests(servers) 104 await cleanupTests(servers)
105 }) 105 })
106}) 106})