]>
Commit | Line | Data |
---|---|---|
0e1dc3e7 C |
1 | /* tslint:disable:no-unused-expression */ |
2 | ||
3 | import 'mocha' | |
4 | import * as chai from 'chai' | |
5 | ||
6 | import { | |
7 | dateIsValid, | |
8 | flushAndRunMultipleServers, | |
9 | flushTests, | |
10 | getVideo, | |
11 | getVideosList, | |
12 | killallServers, | |
13 | makeFriends, | |
14 | rateVideo, | |
15 | removeVideo, | |
16 | ServerInfo, | |
17 | setAccessTokensToServers, | |
18 | testVideoImage, | |
19 | updateVideo, | |
20 | uploadVideo, | |
21 | wait, | |
22 | webtorrentAdd | |
23 | } from '../utils' | |
24 | ||
25 | const expect = chai.expect | |
26 | ||
27 | describe('Test multiple pods', function () { | |
28 | let servers: ServerInfo[] = [] | |
29 | const toRemove = [] | |
30 | let videoUUID = '' | |
31 | ||
32 | before(async function () { | |
33 | this.timeout(120000) | |
34 | ||
35 | servers = await flushAndRunMultipleServers(3) | |
36 | ||
37 | // Get the access tokens | |
38 | await setAccessTokensToServers(servers) | |
39 | ||
40 | // The second pod make friend with the third | |
41 | await makeFriends(servers[1].url, servers[1].accessToken) | |
42 | ||
43 | // Wait for the request between pods | |
44 | await wait(10000) | |
45 | ||
46 | // Pod 1 make friends too | |
47 | await makeFriends(servers[0].url, servers[0].accessToken) | |
48 | }) | |
49 | ||
50 | it('Should not have videos for all pods', async function () { | |
51 | for (const server of servers) { | |
52 | const res = await getVideosList(server.url) | |
53 | const videos = res.body.data | |
54 | expect(videos).to.be.an('array') | |
55 | expect(videos.length).to.equal(0) | |
56 | } | |
57 | }) | |
58 | ||
59 | describe('Should upload the video and propagate on each pod', function () { | |
60 | it('Should upload the video on pod 1 and propagate on each pod', async function () { | |
61 | // Pod 1 has video transcoding activated | |
62 | this.timeout(15000) | |
63 | ||
64 | const videoAttributes = { | |
65 | name: 'my super name for pod 1', | |
66 | category: 5, | |
67 | licence: 4, | |
68 | language: 9, | |
69 | nsfw: true, | |
70 | description: 'my super description for pod 1', | |
71 | tags: [ 'tag1p1', 'tag2p1' ], | |
72 | fixture: 'video_short1.webm' | |
73 | } | |
74 | await uploadVideo(servers[0].url, servers[0].accessToken, videoAttributes) | |
75 | ||
76 | await wait(11000) | |
77 | ||
78 | // All pods should have this video | |
79 | for (const server of servers) { | |
80 | let baseMagnet = null | |
81 | ||
82 | const res = await getVideosList(server.url) | |
83 | ||
84 | const videos = res.body.data | |
85 | expect(videos).to.be.an('array') | |
86 | expect(videos.length).to.equal(1) | |
87 | const video = videos[0] | |
88 | expect(video.name).to.equal('my super name for pod 1') | |
89 | expect(video.category).to.equal(5) | |
90 | expect(video.categoryLabel).to.equal('Sports') | |
91 | expect(video.licence).to.equal(4) | |
92 | expect(video.licenceLabel).to.equal('Attribution - Non Commercial') | |
93 | expect(video.language).to.equal(9) | |
94 | expect(video.languageLabel).to.equal('Japanese') | |
95 | expect(video.nsfw).to.be.ok | |
96 | expect(video.description).to.equal('my super description for pod 1') | |
97 | expect(video.podHost).to.equal('localhost:9001') | |
98 | expect(video.duration).to.equal(10) | |
99 | expect(video.tags).to.deep.equal([ 'tag1p1', 'tag2p1' ]) | |
100 | expect(dateIsValid(video.createdAt)).to.be.true | |
101 | expect(dateIsValid(video.updatedAt)).to.be.true | |
102 | expect(video.author).to.equal('root') | |
103 | ||
104 | expect(video.files).to.have.lengthOf(1) | |
105 | ||
106 | const file = video.files[0] | |
107 | const magnetUri = file.magnetUri | |
108 | expect(file.magnetUri).to.have.lengthOf.above(2) | |
14d3270f C |
109 | expect(file.resolution).to.equal(720) |
110 | expect(file.resolutionLabel).to.equal('720p') | |
0e1dc3e7 C |
111 | expect(file.size).to.equal(572456) |
112 | ||
113 | if (server.url !== 'http://localhost:9001') { | |
114 | expect(video.isLocal).to.be.false | |
115 | } else { | |
116 | expect(video.isLocal).to.be.true | |
117 | } | |
118 | ||
119 | // All pods should have the same magnet Uri | |
120 | if (baseMagnet === null) { | |
121 | baseMagnet = magnetUri | |
122 | } else { | |
123 | expect(baseMagnet).to.equal(magnetUri) | |
124 | } | |
125 | ||
126 | const test = await testVideoImage(server.url, 'video_short1.webm', video.thumbnailPath) | |
127 | expect(test).to.equal(true) | |
128 | } | |
129 | }) | |
130 | ||
131 | it('Should upload the video on pod 2 and propagate on each pod', async function () { | |
40298b02 | 132 | this.timeout(120000) |
0e1dc3e7 C |
133 | |
134 | const videoAttributes = { | |
135 | name: 'my super name for pod 2', | |
136 | category: 4, | |
137 | licence: 3, | |
138 | language: 11, | |
139 | nsfw: true, | |
140 | description: 'my super description for pod 2', | |
141 | tags: [ 'tag1p2', 'tag2p2', 'tag3p2' ], | |
142 | fixture: 'video_short2.webm' | |
143 | } | |
144 | await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes) | |
145 | ||
40298b02 C |
146 | // Transcoding, so wait more than 22000 |
147 | await wait(60000) | |
0e1dc3e7 C |
148 | |
149 | // All pods should have this video | |
150 | for (const server of servers) { | |
40298b02 | 151 | let baseMagnet = {} |
0e1dc3e7 C |
152 | |
153 | const res = await getVideosList(server.url) | |
154 | ||
155 | const videos = res.body.data | |
156 | expect(videos).to.be.an('array') | |
157 | expect(videos.length).to.equal(2) | |
158 | const video = videos[1] | |
159 | expect(video.name).to.equal('my super name for pod 2') | |
160 | expect(video.category).to.equal(4) | |
161 | expect(video.categoryLabel).to.equal('Art') | |
162 | expect(video.licence).to.equal(3) | |
163 | expect(video.licenceLabel).to.equal('Attribution - No Derivatives') | |
164 | expect(video.language).to.equal(11) | |
165 | expect(video.languageLabel).to.equal('German') | |
166 | expect(video.nsfw).to.be.true | |
167 | expect(video.description).to.equal('my super description for pod 2') | |
168 | expect(video.podHost).to.equal('localhost:9002') | |
169 | expect(video.duration).to.equal(5) | |
170 | expect(video.tags).to.deep.equal([ 'tag1p2', 'tag2p2', 'tag3p2' ]) | |
171 | expect(dateIsValid(video.createdAt)).to.be.true | |
172 | expect(dateIsValid(video.updatedAt)).to.be.true | |
173 | expect(video.author).to.equal('root') | |
174 | ||
14d3270f | 175 | expect(video.files).to.have.lengthOf(4) |
0e1dc3e7 | 176 | |
40298b02 C |
177 | // Check common attributes |
178 | for (const file of video.files) { | |
179 | expect(file.magnetUri).to.have.lengthOf.above(2) | |
0e1dc3e7 | 180 | |
40298b02 C |
181 | if (server.url !== 'http://localhost:9002') { |
182 | expect(video.isLocal).to.be.false | |
183 | } else { | |
184 | expect(video.isLocal).to.be.true | |
185 | } | |
0e1dc3e7 | 186 | |
40298b02 C |
187 | // All pods should have the same magnet Uri |
188 | if (baseMagnet[file.resolution] === undefined) { | |
189 | baseMagnet[file.resolution] = file.magnet | |
190 | } else { | |
191 | expect(baseMagnet[file.resolution]).to.equal(file.magnet) | |
192 | } | |
0e1dc3e7 C |
193 | } |
194 | ||
ecb455b6 | 195 | const file240p = video.files.find(f => f.resolution === 240) |
40298b02 C |
196 | expect(file240p).not.to.be.undefined |
197 | expect(file240p.resolutionLabel).to.equal('240p') | |
aa8b6df4 | 198 | expect(file240p.size).to.be.above(130000).and.below(150000) |
40298b02 | 199 | |
ecb455b6 | 200 | const file360p = video.files.find(f => f.resolution === 360) |
40298b02 C |
201 | expect(file360p).not.to.be.undefined |
202 | expect(file360p.resolutionLabel).to.equal('360p') | |
aa8b6df4 | 203 | expect(file360p.size).to.be.above(160000).and.below(180000) |
40298b02 | 204 | |
ecb455b6 | 205 | const file480p = video.files.find(f => f.resolution === 480) |
40298b02 C |
206 | expect(file480p).not.to.be.undefined |
207 | expect(file480p.resolutionLabel).to.equal('480p') | |
aa8b6df4 | 208 | expect(file480p.size).to.be.above(200000).and.below(220000) |
40298b02 | 209 | |
ecb455b6 | 210 | const file720p = video.files.find(f => f.resolution === 720) |
40298b02 C |
211 | expect(file720p).not.to.be.undefined |
212 | expect(file720p.resolutionLabel).to.equal('720p') | |
14d3270f | 213 | expect(file720p.size).to.be.above(700000).and.below(7200000) |
40298b02 | 214 | |
0e1dc3e7 C |
215 | const test = await testVideoImage(server.url, 'video_short2.webm', video.thumbnailPath) |
216 | expect(test).to.equal(true) | |
217 | } | |
218 | }) | |
219 | ||
220 | it('Should upload two videos on pod 3 and propagate on each pod', async function () { | |
221 | this.timeout(45000) | |
222 | ||
223 | const videoAttributes1 = { | |
224 | name: 'my super name for pod 3', | |
225 | category: 6, | |
226 | licence: 5, | |
227 | language: 11, | |
228 | nsfw: true, | |
229 | description: 'my super description for pod 3', | |
230 | tags: [ 'tag1p3' ], | |
231 | fixture: 'video_short3.webm' | |
232 | } | |
233 | await uploadVideo(servers[2].url, servers[2].accessToken, videoAttributes1) | |
234 | ||
235 | const videoAttributes2 = { | |
236 | name: 'my super name for pod 3-2', | |
237 | category: 7, | |
238 | licence: 6, | |
239 | language: 12, | |
240 | nsfw: false, | |
241 | description: 'my super description for pod 3-2', | |
242 | tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ], | |
243 | fixture: 'video_short.webm' | |
244 | } | |
245 | await uploadVideo(servers[2].url, servers[2].accessToken, videoAttributes2) | |
246 | ||
247 | await wait(33000) | |
248 | ||
249 | let baseMagnet = null | |
250 | // All pods should have this video | |
251 | for (const server of servers) { | |
252 | const res = await getVideosList(server.url) | |
253 | ||
254 | const videos = res.body.data | |
255 | expect(videos).to.be.an('array') | |
256 | expect(videos.length).to.equal(4) | |
257 | ||
258 | // We not sure about the order of the two last uploads | |
259 | let video1 = null | |
260 | let video2 = null | |
261 | if (videos[2].name === 'my super name for pod 3') { | |
262 | video1 = videos[2] | |
263 | video2 = videos[3] | |
264 | } else { | |
265 | video1 = videos[3] | |
266 | video2 = videos[2] | |
267 | } | |
268 | ||
269 | expect(video1.name).to.equal('my super name for pod 3') | |
270 | expect(video1.category).to.equal(6) | |
271 | expect(video1.categoryLabel).to.equal('Travels') | |
272 | expect(video1.licence).to.equal(5) | |
273 | expect(video1.licenceLabel).to.equal('Attribution - Non Commercial - Share Alike') | |
274 | expect(video1.language).to.equal(11) | |
275 | expect(video1.languageLabel).to.equal('German') | |
276 | expect(video1.nsfw).to.be.ok | |
277 | expect(video1.description).to.equal('my super description for pod 3') | |
278 | expect(video1.podHost).to.equal('localhost:9003') | |
279 | expect(video1.duration).to.equal(5) | |
280 | expect(video1.tags).to.deep.equal([ 'tag1p3' ]) | |
281 | expect(video1.author).to.equal('root') | |
282 | expect(dateIsValid(video1.createdAt)).to.be.true | |
283 | expect(dateIsValid(video1.updatedAt)).to.be.true | |
284 | ||
285 | expect(video1.files).to.have.lengthOf(1) | |
286 | ||
287 | const file1 = video1.files[0] | |
288 | expect(file1.magnetUri).to.have.lengthOf.above(2) | |
14d3270f C |
289 | expect(file1.resolution).to.equal(720) |
290 | expect(file1.resolutionLabel).to.equal('720p') | |
0e1dc3e7 C |
291 | expect(file1.size).to.equal(292677) |
292 | ||
293 | expect(video2.name).to.equal('my super name for pod 3-2') | |
294 | expect(video2.category).to.equal(7) | |
295 | expect(video2.categoryLabel).to.equal('Gaming') | |
296 | expect(video2.licence).to.equal(6) | |
297 | expect(video2.licenceLabel).to.equal('Attribution - Non Commercial - No Derivatives') | |
298 | expect(video2.language).to.equal(12) | |
299 | expect(video2.languageLabel).to.equal('Korean') | |
300 | expect(video2.nsfw).to.be.false | |
301 | expect(video2.description).to.equal('my super description for pod 3-2') | |
302 | expect(video2.podHost).to.equal('localhost:9003') | |
303 | expect(video2.duration).to.equal(5) | |
304 | expect(video2.tags).to.deep.equal([ 'tag2p3', 'tag3p3', 'tag4p3' ]) | |
305 | expect(video2.author).to.equal('root') | |
306 | expect(dateIsValid(video2.createdAt)).to.be.true | |
307 | expect(dateIsValid(video2.updatedAt)).to.be.true | |
308 | ||
309 | expect(video2.files).to.have.lengthOf(1) | |
310 | ||
311 | const file2 = video2.files[0] | |
312 | const magnetUri2 = file2.magnetUri | |
313 | expect(file2.magnetUri).to.have.lengthOf.above(2) | |
14d3270f C |
314 | expect(file2.resolution).to.equal(720) |
315 | expect(file2.resolutionLabel).to.equal('720p') | |
0e1dc3e7 C |
316 | expect(file2.size).to.equal(218910) |
317 | ||
318 | if (server.url !== 'http://localhost:9003') { | |
319 | expect(video1.isLocal).to.be.false | |
320 | expect(video2.isLocal).to.be.false | |
321 | } else { | |
322 | expect(video1.isLocal).to.be.true | |
323 | expect(video2.isLocal).to.be.true | |
324 | } | |
325 | ||
326 | // All pods should have the same magnet Uri | |
327 | if (baseMagnet === null) { | |
328 | baseMagnet = magnetUri2 | |
329 | } else { | |
330 | expect(baseMagnet).to.equal(magnetUri2) | |
331 | } | |
332 | ||
333 | const test1 = await testVideoImage(server.url, 'video_short3.webm', video1.thumbnailPath) | |
334 | expect(test1).to.equal(true) | |
335 | ||
336 | const test2 = await testVideoImage(server.url, 'video_short.webm', video2.thumbnailPath) | |
337 | expect(test2).to.equal(true) | |
338 | } | |
339 | }) | |
340 | }) | |
341 | ||
342 | describe('Should seed the uploaded video', function () { | |
343 | it('Should add the file 1 by asking pod 3', async function () { | |
344 | // Yes, this could be long | |
345 | this.timeout(200000) | |
346 | ||
347 | const res = await getVideosList(servers[2].url) | |
348 | ||
349 | const video = res.body.data[0] | |
350 | toRemove.push(res.body.data[2]) | |
351 | toRemove.push(res.body.data[3]) | |
352 | ||
353 | const torrent = await webtorrentAdd(video.files[0].magnetUri) | |
354 | expect(torrent.files).to.be.an('array') | |
355 | expect(torrent.files.length).to.equal(1) | |
356 | expect(torrent.files[0].path).to.exist.and.to.not.equal('') | |
357 | }) | |
358 | ||
359 | it('Should add the file 2 by asking pod 1', async function () { | |
360 | // Yes, this could be long | |
361 | this.timeout(200000) | |
362 | ||
363 | const res = await getVideosList(servers[0].url) | |
364 | ||
365 | const video = res.body.data[1] | |
366 | ||
367 | const torrent = await webtorrentAdd(video.files[0].magnetUri) | |
368 | expect(torrent.files).to.be.an('array') | |
369 | expect(torrent.files.length).to.equal(1) | |
370 | expect(torrent.files[0].path).to.exist.and.to.not.equal('') | |
371 | }) | |
372 | ||
373 | it('Should add the file 3 by asking pod 2', async function () { | |
374 | // Yes, this could be long | |
375 | this.timeout(200000) | |
376 | ||
377 | const res = await getVideosList(servers[1].url) | |
378 | ||
379 | const video = res.body.data[2] | |
380 | ||
381 | const torrent = await webtorrentAdd(video.files[0].magnetUri) | |
382 | expect(torrent.files).to.be.an('array') | |
383 | expect(torrent.files.length).to.equal(1) | |
384 | expect(torrent.files[0].path).to.exist.and.to.not.equal('') | |
385 | }) | |
386 | ||
387 | it('Should add the file 3-2 by asking pod 1', async function () { | |
388 | // Yes, this could be long | |
389 | this.timeout(200000) | |
390 | ||
391 | const res = await getVideosList(servers[0].url) | |
392 | ||
393 | const video = res.body.data[3] | |
394 | ||
395 | const torrent = await webtorrentAdd(video.files[0].magnetUri) | |
396 | expect(torrent.files).to.be.an('array') | |
397 | expect(torrent.files.length).to.equal(1) | |
398 | expect(torrent.files[0].path).to.exist.and.to.not.equal('') | |
399 | }) | |
14d3270f C |
400 | |
401 | it('Should add the file 2 in 360p by asking pod 1', async function () { | |
402 | // Yes, this could be long | |
403 | this.timeout(200000) | |
404 | ||
405 | const res = await getVideosList(servers[0].url) | |
406 | ||
407 | const video = res.body.data.find(v => v.name === 'my super name for pod 2') | |
408 | const file = video.files.find(f => f.resolution === 360) | |
409 | expect(file).not.to.be.undefined | |
410 | ||
411 | const torrent = await webtorrentAdd(file.magnetUri) | |
412 | expect(torrent.files).to.be.an('array') | |
413 | expect(torrent.files.length).to.equal(1) | |
414 | expect(torrent.files[0].path).to.exist.and.to.not.equal('') | |
415 | }) | |
0e1dc3e7 C |
416 | }) |
417 | ||
418 | describe('Should update video views, likes and dislikes', function () { | |
419 | let localVideosPod3 = [] | |
420 | let remoteVideosPod1 = [] | |
421 | let remoteVideosPod2 = [] | |
422 | let remoteVideosPod3 = [] | |
423 | ||
424 | before(async function () { | |
425 | const res1 = await getVideosList(servers[0].url) | |
426 | remoteVideosPod1 = res1.body.data.filter(video => video.isLocal === false).map(video => video.id) | |
427 | ||
428 | const res2 = await getVideosList(servers[1].url) | |
429 | remoteVideosPod2 = res2.body.data.filter(video => video.isLocal === false).map(video => video.id) | |
430 | ||
431 | const res3 = await getVideosList(servers[2].url) | |
432 | localVideosPod3 = res3.body.data.filter(video => video.isLocal === true).map(video => video.id) | |
433 | remoteVideosPod3 = res3.body.data.filter(video => video.isLocal === false).map(video => video.id) | |
434 | }) | |
435 | ||
436 | it('Should view multiple videos on owned servers', async function () { | |
437 | this.timeout(30000) | |
438 | ||
439 | const tasks: Promise<any>[] = [] | |
440 | tasks.push(getVideo(servers[2].url, localVideosPod3[0])) | |
441 | tasks.push(getVideo(servers[2].url, localVideosPod3[0])) | |
442 | tasks.push(getVideo(servers[2].url, localVideosPod3[0])) | |
443 | tasks.push(getVideo(servers[2].url, localVideosPod3[1])) | |
444 | ||
445 | await Promise.all(tasks) | |
446 | ||
447 | await wait(22000) | |
448 | ||
449 | for (const server of servers) { | |
450 | const res = await getVideosList(server.url) | |
451 | ||
452 | const videos = res.body.data | |
453 | expect(videos.find(video => video.views === 3)).to.be.an('object') | |
454 | expect(videos.find(video => video.views === 1)).to.be.an('object') | |
455 | } | |
456 | }) | |
457 | ||
458 | it('Should view multiple videos on each servers', async function () { | |
459 | this.timeout(30000) | |
460 | ||
461 | const tasks: Promise<any>[] = [] | |
462 | tasks.push(getVideo(servers[0].url, remoteVideosPod1[0])) | |
463 | tasks.push(getVideo(servers[1].url, remoteVideosPod2[0])) | |
464 | tasks.push(getVideo(servers[1].url, remoteVideosPod2[0])) | |
465 | tasks.push(getVideo(servers[2].url, remoteVideosPod3[0])) | |
466 | tasks.push(getVideo(servers[2].url, remoteVideosPod3[1])) | |
467 | tasks.push(getVideo(servers[2].url, remoteVideosPod3[1])) | |
468 | tasks.push(getVideo(servers[2].url, remoteVideosPod3[1])) | |
469 | tasks.push(getVideo(servers[2].url, localVideosPod3[1])) | |
470 | tasks.push(getVideo(servers[2].url, localVideosPod3[1])) | |
471 | tasks.push(getVideo(servers[2].url, localVideosPod3[1])) | |
472 | ||
473 | await Promise.all(tasks) | |
474 | ||
475 | await wait(22000) | |
476 | ||
477 | let baseVideos = null | |
478 | ||
479 | for (const server of servers) { | |
480 | const res = await getVideosList(server.url) | |
481 | ||
482 | const videos = res.body.data | |
483 | ||
484 | // Initialize base videos for future comparisons | |
485 | if (baseVideos === null) { | |
486 | baseVideos = videos | |
487 | return | |
488 | } | |
489 | ||
490 | for (const baseVideo of baseVideos) { | |
491 | const sameVideo = videos.find(video => video.name === baseVideo.name) | |
492 | expect(baseVideo.views).to.equal(sameVideo.views) | |
493 | } | |
494 | } | |
495 | }) | |
496 | ||
497 | it('Should like and dislikes videos on different services', async function () { | |
498 | this.timeout(30000) | |
499 | ||
500 | const tasks: Promise<any>[] = [] | |
501 | tasks.push(rateVideo(servers[0].url, servers[0].accessToken, remoteVideosPod1[0], 'like')) | |
502 | tasks.push(rateVideo(servers[0].url, servers[0].accessToken, remoteVideosPod1[0], 'dislike')) | |
503 | tasks.push(rateVideo(servers[0].url, servers[0].accessToken, remoteVideosPod1[0], 'like')) | |
504 | tasks.push(rateVideo(servers[2].url, servers[2].accessToken, localVideosPod3[1], 'like')) | |
505 | tasks.push(rateVideo(servers[2].url, servers[2].accessToken, localVideosPod3[1], 'dislike')) | |
506 | tasks.push(rateVideo(servers[2].url, servers[2].accessToken, remoteVideosPod3[1], 'dislike')) | |
507 | tasks.push(rateVideo(servers[2].url, servers[2].accessToken, remoteVideosPod3[0], 'like')) | |
508 | ||
509 | await Promise.all(tasks) | |
510 | ||
511 | await wait(22000) | |
512 | ||
513 | let baseVideos = null | |
514 | for (const server of servers) { | |
515 | const res = await getVideosList(server.url) | |
516 | ||
517 | const videos = res.body.data | |
518 | ||
519 | // Initialize base videos for future comparisons | |
520 | if (baseVideos === null) { | |
521 | baseVideos = videos | |
522 | return | |
523 | } | |
524 | ||
525 | baseVideos.forEach(baseVideo => { | |
526 | const sameVideo = videos.find(video => video.name === baseVideo.name) | |
527 | expect(baseVideo.likes).to.equal(sameVideo.likes) | |
528 | expect(baseVideo.dislikes).to.equal(sameVideo.dislikes) | |
529 | }) | |
530 | } | |
531 | }) | |
532 | }) | |
533 | ||
534 | describe('Should manipulate these videos', function () { | |
535 | it('Should update the video 3 by asking pod 3', async function () { | |
536 | this.timeout(15000) | |
537 | ||
538 | const attributes = { | |
539 | name: 'my super video updated', | |
540 | category: 10, | |
541 | licence: 7, | |
542 | language: 13, | |
543 | nsfw: true, | |
544 | description: 'my super description updated', | |
545 | tags: [ 'tag_up_1', 'tag_up_2' ] | |
546 | } | |
547 | ||
548 | await updateVideo(servers[2].url, servers[2].accessToken, toRemove[0].id, attributes) | |
549 | ||
550 | await wait(11000) | |
551 | }) | |
552 | ||
553 | it('Should have the video 3 updated on each pod', async function () { | |
554 | this.timeout(200000) | |
555 | ||
556 | for (const server of servers) { | |
557 | const res = await getVideosList(server.url) | |
558 | ||
559 | const videos = res.body.data | |
560 | const videoUpdated = videos.find(video => video.name === 'my super video updated') | |
561 | ||
562 | expect(!!videoUpdated).to.be.true | |
563 | expect(videoUpdated.category).to.equal(10) | |
564 | expect(videoUpdated.categoryLabel).to.equal('Entertainment') | |
565 | expect(videoUpdated.licence).to.equal(7) | |
566 | expect(videoUpdated.licenceLabel).to.equal('Public Domain Dedication') | |
567 | expect(videoUpdated.language).to.equal(13) | |
568 | expect(videoUpdated.languageLabel).to.equal('French') | |
569 | expect(videoUpdated.nsfw).to.be.ok | |
570 | expect(videoUpdated.description).to.equal('my super description updated') | |
571 | expect(videoUpdated.tags).to.deep.equal([ 'tag_up_1', 'tag_up_2' ]) | |
572 | expect(dateIsValid(videoUpdated.updatedAt, 20000)).to.be.true | |
573 | ||
574 | const file = videoUpdated.files[0] | |
575 | expect(file.magnetUri).to.have.lengthOf.above(2) | |
14d3270f C |
576 | expect(file.resolution).to.equal(720) |
577 | expect(file.resolutionLabel).to.equal('720p') | |
0e1dc3e7 C |
578 | expect(file.size).to.equal(292677) |
579 | ||
580 | const test = await testVideoImage(server.url, 'video_short3.webm', videoUpdated.thumbnailPath) | |
581 | expect(test).to.equal(true) | |
582 | ||
583 | // Avoid "duplicate torrent" errors | |
584 | const refreshWebTorrent = true | |
585 | const torrent = await webtorrentAdd(videoUpdated.files[0].magnetUri, refreshWebTorrent) | |
586 | expect(torrent.files).to.be.an('array') | |
587 | expect(torrent.files.length).to.equal(1) | |
588 | expect(torrent.files[0].path).to.exist.and.to.not.equal('') | |
589 | } | |
590 | }) | |
591 | ||
592 | it('Should remove the videos 3 and 3-2 by asking pod 3', async function () { | |
593 | this.timeout(15000) | |
594 | ||
595 | await removeVideo(servers[2].url, servers[2].accessToken, toRemove[0].id) | |
596 | await removeVideo(servers[2].url, servers[2].accessToken, toRemove[1].id) | |
597 | ||
598 | await wait(11000) | |
599 | }) | |
600 | ||
601 | it('Should have videos 1 and 3 on each pod', async function () { | |
602 | for (const server of servers) { | |
603 | const res = await getVideosList(server.url) | |
604 | ||
605 | const videos = res.body.data | |
606 | expect(videos).to.be.an('array') | |
607 | expect(videos.length).to.equal(2) | |
608 | expect(videos[0].name).not.to.equal(videos[1].name) | |
609 | expect(videos[0].name).not.to.equal(toRemove[0].name) | |
610 | expect(videos[1].name).not.to.equal(toRemove[0].name) | |
611 | expect(videos[0].name).not.to.equal(toRemove[1].name) | |
612 | expect(videos[1].name).not.to.equal(toRemove[1].name) | |
613 | ||
614 | videoUUID = videos.find(video => video.name === 'my super name for pod 1').uuid | |
615 | } | |
616 | }) | |
617 | ||
618 | it('Should get the same video by UUID on each pod', async function () { | |
619 | let baseVideo = null | |
620 | for (const server of servers) { | |
621 | const res = await getVideo(server.url, videoUUID) | |
622 | ||
623 | const video = res.body | |
624 | ||
625 | if (baseVideo === null) { | |
626 | baseVideo = video | |
627 | return | |
628 | } | |
629 | ||
630 | expect(baseVideo.name).to.equal(video.name) | |
631 | expect(baseVideo.uuid).to.equal(video.uuid) | |
632 | expect(baseVideo.category).to.equal(video.category) | |
633 | expect(baseVideo.language).to.equal(video.language) | |
634 | expect(baseVideo.licence).to.equal(video.licence) | |
635 | expect(baseVideo.category).to.equal(video.category) | |
636 | expect(baseVideo.nsfw).to.equal(video.nsfw) | |
637 | expect(baseVideo.author).to.equal(video.author) | |
638 | expect(baseVideo.tags).to.deep.equal(video.tags) | |
639 | } | |
640 | }) | |
641 | ||
642 | it('Should get the preview from each pod', async function () { | |
643 | for (const server of servers) { | |
644 | const res = await getVideo(server.url, videoUUID) | |
645 | const video = res.body | |
646 | ||
647 | const test = await testVideoImage(server.url, 'video_short1-preview.webm', video.previewPath) | |
648 | expect(test).to.equal(true) | |
649 | } | |
650 | }) | |
651 | }) | |
652 | ||
653 | after(async function () { | |
654 | killallServers(servers) | |
655 | ||
656 | // Keep the logs if the test failed | |
657 | if (this['ok']) { | |
658 | await flushTests() | |
659 | } | |
660 | }) | |
661 | }) |