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