]>
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) | |
109 | expect(file.resolution).to.equal(0) | |
110 | expect(file.resolutionLabel).to.equal('original') | |
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 () { | |
132 | this.timeout(60000) | |
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 | ||
146 | // Transcoding, so wait more that 22 seconds | |
147 | await wait(42000) | |
148 | ||
149 | // All pods should have this video | |
150 | for (const server of servers) { | |
151 | let baseMagnet = null | |
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 | ||
175 | expect(video.files).to.have.lengthOf(1) | |
176 | ||
177 | const file = video.files[0] | |
178 | const magnetUri = file.magnetUri | |
179 | expect(file.magnetUri).to.have.lengthOf.above(2) | |
180 | expect(file.resolution).to.equal(0) | |
181 | expect(file.resolutionLabel).to.equal('original') | |
182 | expect(file.size).to.equal(942961) | |
183 | ||
184 | if (server.url !== 'http://localhost:9002') { | |
185 | expect(video.isLocal).to.be.false | |
186 | } else { | |
187 | expect(video.isLocal).to.be.true | |
188 | } | |
189 | ||
190 | // All pods should have the same magnet Uri | |
191 | if (baseMagnet === null) { | |
192 | baseMagnet = magnetUri | |
193 | } else { | |
194 | expect(baseMagnet).to.equal(magnetUri) | |
195 | } | |
196 | ||
197 | const test = await testVideoImage(server.url, 'video_short2.webm', video.thumbnailPath) | |
198 | expect(test).to.equal(true) | |
199 | } | |
200 | }) | |
201 | ||
202 | it('Should upload two videos on pod 3 and propagate on each pod', async function () { | |
203 | this.timeout(45000) | |
204 | ||
205 | const videoAttributes1 = { | |
206 | name: 'my super name for pod 3', | |
207 | category: 6, | |
208 | licence: 5, | |
209 | language: 11, | |
210 | nsfw: true, | |
211 | description: 'my super description for pod 3', | |
212 | tags: [ 'tag1p3' ], | |
213 | fixture: 'video_short3.webm' | |
214 | } | |
215 | await uploadVideo(servers[2].url, servers[2].accessToken, videoAttributes1) | |
216 | ||
217 | const videoAttributes2 = { | |
218 | name: 'my super name for pod 3-2', | |
219 | category: 7, | |
220 | licence: 6, | |
221 | language: 12, | |
222 | nsfw: false, | |
223 | description: 'my super description for pod 3-2', | |
224 | tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ], | |
225 | fixture: 'video_short.webm' | |
226 | } | |
227 | await uploadVideo(servers[2].url, servers[2].accessToken, videoAttributes2) | |
228 | ||
229 | await wait(33000) | |
230 | ||
231 | let baseMagnet = null | |
232 | // All pods should have this video | |
233 | for (const server of servers) { | |
234 | const res = await getVideosList(server.url) | |
235 | ||
236 | const videos = res.body.data | |
237 | expect(videos).to.be.an('array') | |
238 | expect(videos.length).to.equal(4) | |
239 | ||
240 | // We not sure about the order of the two last uploads | |
241 | let video1 = null | |
242 | let video2 = null | |
243 | if (videos[2].name === 'my super name for pod 3') { | |
244 | video1 = videos[2] | |
245 | video2 = videos[3] | |
246 | } else { | |
247 | video1 = videos[3] | |
248 | video2 = videos[2] | |
249 | } | |
250 | ||
251 | expect(video1.name).to.equal('my super name for pod 3') | |
252 | expect(video1.category).to.equal(6) | |
253 | expect(video1.categoryLabel).to.equal('Travels') | |
254 | expect(video1.licence).to.equal(5) | |
255 | expect(video1.licenceLabel).to.equal('Attribution - Non Commercial - Share Alike') | |
256 | expect(video1.language).to.equal(11) | |
257 | expect(video1.languageLabel).to.equal('German') | |
258 | expect(video1.nsfw).to.be.ok | |
259 | expect(video1.description).to.equal('my super description for pod 3') | |
260 | expect(video1.podHost).to.equal('localhost:9003') | |
261 | expect(video1.duration).to.equal(5) | |
262 | expect(video1.tags).to.deep.equal([ 'tag1p3' ]) | |
263 | expect(video1.author).to.equal('root') | |
264 | expect(dateIsValid(video1.createdAt)).to.be.true | |
265 | expect(dateIsValid(video1.updatedAt)).to.be.true | |
266 | ||
267 | expect(video1.files).to.have.lengthOf(1) | |
268 | ||
269 | const file1 = video1.files[0] | |
270 | expect(file1.magnetUri).to.have.lengthOf.above(2) | |
271 | expect(file1.resolution).to.equal(0) | |
272 | expect(file1.resolutionLabel).to.equal('original') | |
273 | expect(file1.size).to.equal(292677) | |
274 | ||
275 | expect(video2.name).to.equal('my super name for pod 3-2') | |
276 | expect(video2.category).to.equal(7) | |
277 | expect(video2.categoryLabel).to.equal('Gaming') | |
278 | expect(video2.licence).to.equal(6) | |
279 | expect(video2.licenceLabel).to.equal('Attribution - Non Commercial - No Derivatives') | |
280 | expect(video2.language).to.equal(12) | |
281 | expect(video2.languageLabel).to.equal('Korean') | |
282 | expect(video2.nsfw).to.be.false | |
283 | expect(video2.description).to.equal('my super description for pod 3-2') | |
284 | expect(video2.podHost).to.equal('localhost:9003') | |
285 | expect(video2.duration).to.equal(5) | |
286 | expect(video2.tags).to.deep.equal([ 'tag2p3', 'tag3p3', 'tag4p3' ]) | |
287 | expect(video2.author).to.equal('root') | |
288 | expect(dateIsValid(video2.createdAt)).to.be.true | |
289 | expect(dateIsValid(video2.updatedAt)).to.be.true | |
290 | ||
291 | expect(video2.files).to.have.lengthOf(1) | |
292 | ||
293 | const file2 = video2.files[0] | |
294 | const magnetUri2 = file2.magnetUri | |
295 | expect(file2.magnetUri).to.have.lengthOf.above(2) | |
296 | expect(file2.resolution).to.equal(0) | |
297 | expect(file2.resolutionLabel).to.equal('original') | |
298 | expect(file2.size).to.equal(218910) | |
299 | ||
300 | if (server.url !== 'http://localhost:9003') { | |
301 | expect(video1.isLocal).to.be.false | |
302 | expect(video2.isLocal).to.be.false | |
303 | } else { | |
304 | expect(video1.isLocal).to.be.true | |
305 | expect(video2.isLocal).to.be.true | |
306 | } | |
307 | ||
308 | // All pods should have the same magnet Uri | |
309 | if (baseMagnet === null) { | |
310 | baseMagnet = magnetUri2 | |
311 | } else { | |
312 | expect(baseMagnet).to.equal(magnetUri2) | |
313 | } | |
314 | ||
315 | const test1 = await testVideoImage(server.url, 'video_short3.webm', video1.thumbnailPath) | |
316 | expect(test1).to.equal(true) | |
317 | ||
318 | const test2 = await testVideoImage(server.url, 'video_short.webm', video2.thumbnailPath) | |
319 | expect(test2).to.equal(true) | |
320 | } | |
321 | }) | |
322 | }) | |
323 | ||
324 | describe('Should seed the uploaded video', function () { | |
325 | it('Should add the file 1 by asking pod 3', async function () { | |
326 | // Yes, this could be long | |
327 | this.timeout(200000) | |
328 | ||
329 | const res = await getVideosList(servers[2].url) | |
330 | ||
331 | const video = res.body.data[0] | |
332 | toRemove.push(res.body.data[2]) | |
333 | toRemove.push(res.body.data[3]) | |
334 | ||
335 | const torrent = await webtorrentAdd(video.files[0].magnetUri) | |
336 | expect(torrent.files).to.be.an('array') | |
337 | expect(torrent.files.length).to.equal(1) | |
338 | expect(torrent.files[0].path).to.exist.and.to.not.equal('') | |
339 | }) | |
340 | ||
341 | it('Should add the file 2 by asking pod 1', async function () { | |
342 | // Yes, this could be long | |
343 | this.timeout(200000) | |
344 | ||
345 | const res = await getVideosList(servers[0].url) | |
346 | ||
347 | const video = res.body.data[1] | |
348 | ||
349 | const torrent = await webtorrentAdd(video.files[0].magnetUri) | |
350 | expect(torrent.files).to.be.an('array') | |
351 | expect(torrent.files.length).to.equal(1) | |
352 | expect(torrent.files[0].path).to.exist.and.to.not.equal('') | |
353 | }) | |
354 | ||
355 | it('Should add the file 3 by asking pod 2', async function () { | |
356 | // Yes, this could be long | |
357 | this.timeout(200000) | |
358 | ||
359 | const res = await getVideosList(servers[1].url) | |
360 | ||
361 | const video = res.body.data[2] | |
362 | ||
363 | const torrent = await webtorrentAdd(video.files[0].magnetUri) | |
364 | expect(torrent.files).to.be.an('array') | |
365 | expect(torrent.files.length).to.equal(1) | |
366 | expect(torrent.files[0].path).to.exist.and.to.not.equal('') | |
367 | }) | |
368 | ||
369 | it('Should add the file 3-2 by asking pod 1', async function () { | |
370 | // Yes, this could be long | |
371 | this.timeout(200000) | |
372 | ||
373 | const res = await getVideosList(servers[0].url) | |
374 | ||
375 | const video = res.body.data[3] | |
376 | ||
377 | const torrent = await webtorrentAdd(video.files[0].magnetUri) | |
378 | expect(torrent.files).to.be.an('array') | |
379 | expect(torrent.files.length).to.equal(1) | |
380 | expect(torrent.files[0].path).to.exist.and.to.not.equal('') | |
381 | }) | |
382 | }) | |
383 | ||
384 | describe('Should update video views, likes and dislikes', function () { | |
385 | let localVideosPod3 = [] | |
386 | let remoteVideosPod1 = [] | |
387 | let remoteVideosPod2 = [] | |
388 | let remoteVideosPod3 = [] | |
389 | ||
390 | before(async function () { | |
391 | const res1 = await getVideosList(servers[0].url) | |
392 | remoteVideosPod1 = res1.body.data.filter(video => video.isLocal === false).map(video => video.id) | |
393 | ||
394 | const res2 = await getVideosList(servers[1].url) | |
395 | remoteVideosPod2 = res2.body.data.filter(video => video.isLocal === false).map(video => video.id) | |
396 | ||
397 | const res3 = await getVideosList(servers[2].url) | |
398 | localVideosPod3 = res3.body.data.filter(video => video.isLocal === true).map(video => video.id) | |
399 | remoteVideosPod3 = res3.body.data.filter(video => video.isLocal === false).map(video => video.id) | |
400 | }) | |
401 | ||
402 | it('Should view multiple videos on owned servers', async function () { | |
403 | this.timeout(30000) | |
404 | ||
405 | const tasks: Promise<any>[] = [] | |
406 | tasks.push(getVideo(servers[2].url, localVideosPod3[0])) | |
407 | tasks.push(getVideo(servers[2].url, localVideosPod3[0])) | |
408 | tasks.push(getVideo(servers[2].url, localVideosPod3[0])) | |
409 | tasks.push(getVideo(servers[2].url, localVideosPod3[1])) | |
410 | ||
411 | await Promise.all(tasks) | |
412 | ||
413 | await wait(22000) | |
414 | ||
415 | for (const server of servers) { | |
416 | const res = await getVideosList(server.url) | |
417 | ||
418 | const videos = res.body.data | |
419 | expect(videos.find(video => video.views === 3)).to.be.an('object') | |
420 | expect(videos.find(video => video.views === 1)).to.be.an('object') | |
421 | } | |
422 | }) | |
423 | ||
424 | it('Should view multiple videos on each servers', async function () { | |
425 | this.timeout(30000) | |
426 | ||
427 | const tasks: Promise<any>[] = [] | |
428 | tasks.push(getVideo(servers[0].url, remoteVideosPod1[0])) | |
429 | tasks.push(getVideo(servers[1].url, remoteVideosPod2[0])) | |
430 | tasks.push(getVideo(servers[1].url, remoteVideosPod2[0])) | |
431 | tasks.push(getVideo(servers[2].url, remoteVideosPod3[0])) | |
432 | tasks.push(getVideo(servers[2].url, remoteVideosPod3[1])) | |
433 | tasks.push(getVideo(servers[2].url, remoteVideosPod3[1])) | |
434 | tasks.push(getVideo(servers[2].url, remoteVideosPod3[1])) | |
435 | tasks.push(getVideo(servers[2].url, localVideosPod3[1])) | |
436 | tasks.push(getVideo(servers[2].url, localVideosPod3[1])) | |
437 | tasks.push(getVideo(servers[2].url, localVideosPod3[1])) | |
438 | ||
439 | await Promise.all(tasks) | |
440 | ||
441 | await wait(22000) | |
442 | ||
443 | let baseVideos = null | |
444 | ||
445 | for (const server of servers) { | |
446 | const res = await getVideosList(server.url) | |
447 | ||
448 | const videos = res.body.data | |
449 | ||
450 | // Initialize base videos for future comparisons | |
451 | if (baseVideos === null) { | |
452 | baseVideos = videos | |
453 | return | |
454 | } | |
455 | ||
456 | for (const baseVideo of baseVideos) { | |
457 | const sameVideo = videos.find(video => video.name === baseVideo.name) | |
458 | expect(baseVideo.views).to.equal(sameVideo.views) | |
459 | } | |
460 | } | |
461 | }) | |
462 | ||
463 | it('Should like and dislikes videos on different services', async function () { | |
464 | this.timeout(30000) | |
465 | ||
466 | const tasks: Promise<any>[] = [] | |
467 | tasks.push(rateVideo(servers[0].url, servers[0].accessToken, remoteVideosPod1[0], 'like')) | |
468 | tasks.push(rateVideo(servers[0].url, servers[0].accessToken, remoteVideosPod1[0], 'dislike')) | |
469 | tasks.push(rateVideo(servers[0].url, servers[0].accessToken, remoteVideosPod1[0], 'like')) | |
470 | tasks.push(rateVideo(servers[2].url, servers[2].accessToken, localVideosPod3[1], 'like')) | |
471 | tasks.push(rateVideo(servers[2].url, servers[2].accessToken, localVideosPod3[1], 'dislike')) | |
472 | tasks.push(rateVideo(servers[2].url, servers[2].accessToken, remoteVideosPod3[1], 'dislike')) | |
473 | tasks.push(rateVideo(servers[2].url, servers[2].accessToken, remoteVideosPod3[0], 'like')) | |
474 | ||
475 | await Promise.all(tasks) | |
476 | ||
477 | await wait(22000) | |
478 | ||
479 | let baseVideos = null | |
480 | for (const server of servers) { | |
481 | const res = await getVideosList(server.url) | |
482 | ||
483 | const videos = res.body.data | |
484 | ||
485 | // Initialize base videos for future comparisons | |
486 | if (baseVideos === null) { | |
487 | baseVideos = videos | |
488 | return | |
489 | } | |
490 | ||
491 | baseVideos.forEach(baseVideo => { | |
492 | const sameVideo = videos.find(video => video.name === baseVideo.name) | |
493 | expect(baseVideo.likes).to.equal(sameVideo.likes) | |
494 | expect(baseVideo.dislikes).to.equal(sameVideo.dislikes) | |
495 | }) | |
496 | } | |
497 | }) | |
498 | }) | |
499 | ||
500 | describe('Should manipulate these videos', function () { | |
501 | it('Should update the video 3 by asking pod 3', async function () { | |
502 | this.timeout(15000) | |
503 | ||
504 | const attributes = { | |
505 | name: 'my super video updated', | |
506 | category: 10, | |
507 | licence: 7, | |
508 | language: 13, | |
509 | nsfw: true, | |
510 | description: 'my super description updated', | |
511 | tags: [ 'tag_up_1', 'tag_up_2' ] | |
512 | } | |
513 | ||
514 | await updateVideo(servers[2].url, servers[2].accessToken, toRemove[0].id, attributes) | |
515 | ||
516 | await wait(11000) | |
517 | }) | |
518 | ||
519 | it('Should have the video 3 updated on each pod', async function () { | |
520 | this.timeout(200000) | |
521 | ||
522 | for (const server of servers) { | |
523 | const res = await getVideosList(server.url) | |
524 | ||
525 | const videos = res.body.data | |
526 | const videoUpdated = videos.find(video => video.name === 'my super video updated') | |
527 | ||
528 | expect(!!videoUpdated).to.be.true | |
529 | expect(videoUpdated.category).to.equal(10) | |
530 | expect(videoUpdated.categoryLabel).to.equal('Entertainment') | |
531 | expect(videoUpdated.licence).to.equal(7) | |
532 | expect(videoUpdated.licenceLabel).to.equal('Public Domain Dedication') | |
533 | expect(videoUpdated.language).to.equal(13) | |
534 | expect(videoUpdated.languageLabel).to.equal('French') | |
535 | expect(videoUpdated.nsfw).to.be.ok | |
536 | expect(videoUpdated.description).to.equal('my super description updated') | |
537 | expect(videoUpdated.tags).to.deep.equal([ 'tag_up_1', 'tag_up_2' ]) | |
538 | expect(dateIsValid(videoUpdated.updatedAt, 20000)).to.be.true | |
539 | ||
540 | const file = videoUpdated.files[0] | |
541 | expect(file.magnetUri).to.have.lengthOf.above(2) | |
542 | expect(file.resolution).to.equal(0) | |
543 | expect(file.resolutionLabel).to.equal('original') | |
544 | expect(file.size).to.equal(292677) | |
545 | ||
546 | const test = await testVideoImage(server.url, 'video_short3.webm', videoUpdated.thumbnailPath) | |
547 | expect(test).to.equal(true) | |
548 | ||
549 | // Avoid "duplicate torrent" errors | |
550 | const refreshWebTorrent = true | |
551 | const torrent = await webtorrentAdd(videoUpdated.files[0].magnetUri, refreshWebTorrent) | |
552 | expect(torrent.files).to.be.an('array') | |
553 | expect(torrent.files.length).to.equal(1) | |
554 | expect(torrent.files[0].path).to.exist.and.to.not.equal('') | |
555 | } | |
556 | }) | |
557 | ||
558 | it('Should remove the videos 3 and 3-2 by asking pod 3', async function () { | |
559 | this.timeout(15000) | |
560 | ||
561 | await removeVideo(servers[2].url, servers[2].accessToken, toRemove[0].id) | |
562 | await removeVideo(servers[2].url, servers[2].accessToken, toRemove[1].id) | |
563 | ||
564 | await wait(11000) | |
565 | }) | |
566 | ||
567 | it('Should have videos 1 and 3 on each pod', async function () { | |
568 | for (const server of servers) { | |
569 | const res = await getVideosList(server.url) | |
570 | ||
571 | const videos = res.body.data | |
572 | expect(videos).to.be.an('array') | |
573 | expect(videos.length).to.equal(2) | |
574 | expect(videos[0].name).not.to.equal(videos[1].name) | |
575 | expect(videos[0].name).not.to.equal(toRemove[0].name) | |
576 | expect(videos[1].name).not.to.equal(toRemove[0].name) | |
577 | expect(videos[0].name).not.to.equal(toRemove[1].name) | |
578 | expect(videos[1].name).not.to.equal(toRemove[1].name) | |
579 | ||
580 | videoUUID = videos.find(video => video.name === 'my super name for pod 1').uuid | |
581 | } | |
582 | }) | |
583 | ||
584 | it('Should get the same video by UUID on each pod', async function () { | |
585 | let baseVideo = null | |
586 | for (const server of servers) { | |
587 | const res = await getVideo(server.url, videoUUID) | |
588 | ||
589 | const video = res.body | |
590 | ||
591 | if (baseVideo === null) { | |
592 | baseVideo = video | |
593 | return | |
594 | } | |
595 | ||
596 | expect(baseVideo.name).to.equal(video.name) | |
597 | expect(baseVideo.uuid).to.equal(video.uuid) | |
598 | expect(baseVideo.category).to.equal(video.category) | |
599 | expect(baseVideo.language).to.equal(video.language) | |
600 | expect(baseVideo.licence).to.equal(video.licence) | |
601 | expect(baseVideo.category).to.equal(video.category) | |
602 | expect(baseVideo.nsfw).to.equal(video.nsfw) | |
603 | expect(baseVideo.author).to.equal(video.author) | |
604 | expect(baseVideo.tags).to.deep.equal(video.tags) | |
605 | } | |
606 | }) | |
607 | ||
608 | it('Should get the preview from each pod', async function () { | |
609 | for (const server of servers) { | |
610 | const res = await getVideo(server.url, videoUUID) | |
611 | const video = res.body | |
612 | ||
613 | const test = await testVideoImage(server.url, 'video_short1-preview.webm', video.previewPath) | |
614 | expect(test).to.equal(true) | |
615 | } | |
616 | }) | |
617 | }) | |
618 | ||
619 | after(async function () { | |
620 | killallServers(servers) | |
621 | ||
622 | // Keep the logs if the test failed | |
623 | if (this['ok']) { | |
624 | await flushTests() | |
625 | } | |
626 | }) | |
627 | }) |