]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/tests/api/multiple-servers.ts
Design confirm dialog
[github/Chocobozzz/PeerTube.git] / server / tests / api / multiple-servers.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 rateVideo,
14 removeVideo,
15 ServerInfo,
16 setAccessTokensToServers,
17 testVideoImage,
18 updateVideo,
19 uploadVideo,
20 wait,
21 webtorrentAdd,
22 addVideoChannel,
23 getVideoChannelsList,
24 getUserAccessToken,
25 doubleFollow
26 } from '../utils'
27 import { createUser } from '../utils/users'
28 import { viewVideo } from '../utils/videos'
29
30 const expect = chai.expect
31
32 describe('Test multiple servers', function () {
33 let servers: ServerInfo[] = []
34 const toRemove = []
35 let videoUUID = ''
36 let videoChannelId: number
37
38 before(async function () {
39 this.timeout(120000)
40
41 servers = await flushAndRunMultipleServers(3)
42
43 // Get the access tokens
44 await setAccessTokensToServers(servers)
45
46 const videoChannel = {
47 name: 'my channel',
48 description: 'super channel'
49 }
50 await addVideoChannel(servers[0].url, servers[0].accessToken, videoChannel)
51 const channelRes = await getVideoChannelsList(servers[0].url, 0, 1)
52 videoChannelId = channelRes.body.data[0].id
53
54 // Server 1 and server 2 follow each other
55 await doubleFollow(servers[0], servers[1])
56 // Server 1 and server 3 follow each other
57 await doubleFollow(servers[0], servers[2])
58 // Server 2 and server 3 follow each other
59 await doubleFollow(servers[1], servers[2])
60 })
61
62 it('Should not have videos for all servers', async function () {
63 for (const server of servers) {
64 const res = await getVideosList(server.url)
65 const videos = res.body.data
66 expect(videos).to.be.an('array')
67 expect(videos.length).to.equal(0)
68 }
69 })
70
71 describe('Should upload the video and propagate on each server', function () {
72 it('Should upload the video on server 1 and propagate on each server', async function () {
73 this.timeout(25000)
74
75 const videoAttributes = {
76 name: 'my super name for server 1',
77 category: 5,
78 licence: 4,
79 language: 9,
80 nsfw: true,
81 description: 'my super description for server 1',
82 tags: [ 'tag1p1', 'tag2p1' ],
83 channelId: videoChannelId,
84 fixture: 'video_short1.webm'
85 }
86 await uploadVideo(servers[0].url, servers[0].accessToken, videoAttributes)
87
88 await wait(10000)
89
90 // All servers should have this video
91 for (const server of servers) {
92 let baseMagnet = null
93
94 const res = await getVideosList(server.url)
95
96 const videos = res.body.data
97 expect(videos).to.be.an('array')
98 expect(videos.length).to.equal(1)
99 const video = videos[0]
100 expect(video.name).to.equal('my super name for server 1')
101 expect(video.category).to.equal(5)
102 expect(video.categoryLabel).to.equal('Sports')
103 expect(video.licence).to.equal(4)
104 expect(video.licenceLabel).to.equal('Attribution - Non Commercial')
105 expect(video.language).to.equal(9)
106 expect(video.languageLabel).to.equal('Japanese')
107 expect(video.nsfw).to.be.ok
108 expect(video.description).to.equal('my super description for server 1')
109 expect(video.serverHost).to.equal('localhost:9001')
110 expect(video.duration).to.equal(10)
111 expect(video.tags).to.deep.equal([ 'tag1p1', 'tag2p1' ])
112 expect(dateIsValid(video.createdAt)).to.be.true
113 expect(dateIsValid(video.updatedAt)).to.be.true
114 expect(video.accountName).to.equal('root')
115
116 const res2 = await getVideo(server.url, video.uuid)
117 const videoDetails = res2.body
118
119 expect(videoDetails.channel.name).to.equal('my channel')
120 expect(videoDetails.channel.description).to.equal('super channel')
121 expect(videoDetails.account.name).to.equal('root')
122 expect(dateIsValid(videoDetails.channel.createdAt)).to.be.true
123 expect(dateIsValid(videoDetails.channel.updatedAt)).to.be.true
124 expect(videoDetails.files).to.have.lengthOf(1)
125
126 const file = videoDetails.files[0]
127 const magnetUri = file.magnetUri
128 expect(file.magnetUri).to.have.lengthOf.above(2)
129 expect(file.torrentUrl).to
130 .equal(`http://${videoDetails.serverHost}/static/torrents/${videoDetails.uuid}-${file.resolution}.torrent`)
131 expect(file.fileUrl).to.equal(`http://${videoDetails.serverHost}/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 servers 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 server 2 and propagate on each server', async function () {
157 this.timeout(50000)
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 server 2',
168 category: 4,
169 licence: 3,
170 language: 11,
171 nsfw: true,
172 description: 'my super description for server 2',
173 tags: [ 'tag1p2', 'tag2p2', 'tag3p2' ],
174 fixture: 'video_short2.webm'
175 }
176 await uploadVideo(servers[1].url, userAccessToken, videoAttributes)
177
178 // Transcoding
179 await wait(30000)
180
181 // All servers 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 server 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 server 2')
200 expect(video.serverHost).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.accountName).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 servers 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 server 3 and propagate on each server', async function () {
260 this.timeout(45000)
261
262 const videoAttributes1 = {
263 name: 'my super name for server 3',
264 category: 6,
265 licence: 5,
266 language: 11,
267 nsfw: true,
268 description: 'my super description for server 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 server 3-2',
276 category: 7,
277 licence: 6,
278 language: 12,
279 nsfw: false,
280 description: 'my super description for server 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(10000)
287
288 let baseMagnet = null
289 // All servers 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 server 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 server 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 server 3')
317 expect(video1.serverHost).to.equal('localhost:9003')
318 expect(video1.duration).to.equal(5)
319 expect(video1.tags).to.deep.equal([ 'tag1p3' ])
320 expect(video1.accountName).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 server 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 server 3-2')
343 expect(video2.serverHost).to.equal('localhost:9003')
344 expect(video2.duration).to.equal(5)
345 expect(video2.tags).to.deep.equal([ 'tag2p3', 'tag3p3', 'tag4p3' ])
346 expect(video2.accountName).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 servers 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 server 3', async function () {
388 this.timeout(10000)
389
390 const res = await getVideosList(servers[2].url)
391
392 const video = res.body.data[0]
393 toRemove.push(res.body.data[2])
394 toRemove.push(res.body.data[3])
395
396 const res2 = await getVideo(servers[2].url, video.id)
397 const videoDetails = res2.body
398
399 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri)
400 expect(torrent.files).to.be.an('array')
401 expect(torrent.files.length).to.equal(1)
402 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
403 })
404
405 it('Should add the file 2 by asking server 1', async function () {
406 this.timeout(10000)
407
408 const res = await getVideosList(servers[0].url)
409
410 const video = res.body.data[1]
411 const res2 = await getVideo(servers[0].url, video.id)
412 const videoDetails = res2.body
413
414 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri)
415 expect(torrent.files).to.be.an('array')
416 expect(torrent.files.length).to.equal(1)
417 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
418 })
419
420 it('Should add the file 3 by asking server 2', async function () {
421 this.timeout(10000)
422
423 const res = await getVideosList(servers[1].url)
424
425 const video = res.body.data[2]
426 const res2 = await getVideo(servers[1].url, video.id)
427 const videoDetails = res2.body
428
429 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri)
430 expect(torrent.files).to.be.an('array')
431 expect(torrent.files.length).to.equal(1)
432 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
433 })
434
435 it('Should add the file 3-2 by asking server 1', async function () {
436 this.timeout(10000)
437
438 const res = await getVideosList(servers[0].url)
439
440 const video = res.body.data[3]
441 const res2 = await getVideo(servers[0].url, video.id)
442 const videoDetails = res2.body
443
444 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri)
445 expect(torrent.files).to.be.an('array')
446 expect(torrent.files.length).to.equal(1)
447 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
448 })
449
450 it('Should add the file 2 in 360p by asking server 1', async function () {
451 this.timeout(10000)
452
453 const res = await getVideosList(servers[0].url)
454
455 const video = res.body.data.find(v => v.name === 'my super name for server 2')
456 const res2 = await getVideo(servers[0].url, video.id)
457 const videoDetails = res2.body
458
459 const file = videoDetails.files.find(f => f.resolution === 360)
460 expect(file).not.to.be.undefined
461
462 const torrent = await webtorrentAdd(file.magnetUri)
463 expect(torrent.files).to.be.an('array')
464 expect(torrent.files.length).to.equal(1)
465 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
466 })
467 })
468
469 describe('Should update video views, likes and dislikes', function () {
470 let localVideosServer3 = []
471 let remoteVideosServer1 = []
472 let remoteVideosServer2 = []
473 let remoteVideosServer3 = []
474
475 before(async function () {
476 const res1 = await getVideosList(servers[0].url)
477 remoteVideosServer1 = res1.body.data.filter(video => video.isLocal === false).map(video => video.uuid)
478
479 const res2 = await getVideosList(servers[1].url)
480 remoteVideosServer2 = res2.body.data.filter(video => video.isLocal === false).map(video => video.uuid)
481
482 const res3 = await getVideosList(servers[2].url)
483 localVideosServer3 = res3.body.data.filter(video => video.isLocal === true).map(video => video.uuid)
484 remoteVideosServer3 = res3.body.data.filter(video => video.isLocal === false).map(video => video.uuid)
485 })
486
487 it('Should view multiple videos on owned servers', async function () {
488 this.timeout(10000)
489
490 const tasks: Promise<any>[] = []
491 tasks.push(viewVideo(servers[2].url, localVideosServer3[0]))
492 tasks.push(viewVideo(servers[2].url, localVideosServer3[0]))
493 tasks.push(viewVideo(servers[2].url, localVideosServer3[0]))
494 tasks.push(viewVideo(servers[2].url, localVideosServer3[1]))
495
496 await Promise.all(tasks)
497
498 await wait(5000)
499
500 for (const server of servers) {
501 const res = await getVideosList(server.url)
502
503 const videos = res.body.data
504 const video0 = videos.find(v => v.uuid === localVideosServer3[0])
505 const video1 = videos.find(v => v.uuid === localVideosServer3[1])
506
507 expect(video0.views).to.equal(3)
508 expect(video1.views).to.equal(1)
509 }
510 })
511
512 it('Should view multiple videos on each servers', async function () {
513 this.timeout(15000)
514
515 const tasks: Promise<any>[] = []
516 tasks.push(viewVideo(servers[0].url, remoteVideosServer1[0]))
517 tasks.push(viewVideo(servers[1].url, remoteVideosServer2[0]))
518 tasks.push(viewVideo(servers[1].url, remoteVideosServer2[0]))
519 tasks.push(viewVideo(servers[2].url, remoteVideosServer3[0]))
520 tasks.push(viewVideo(servers[2].url, remoteVideosServer3[1]))
521 tasks.push(viewVideo(servers[2].url, remoteVideosServer3[1]))
522 tasks.push(viewVideo(servers[2].url, remoteVideosServer3[1]))
523 tasks.push(viewVideo(servers[2].url, localVideosServer3[1]))
524 tasks.push(viewVideo(servers[2].url, localVideosServer3[1]))
525 tasks.push(viewVideo(servers[2].url, localVideosServer3[1]))
526
527 await Promise.all(tasks)
528
529 await wait(10000)
530
531 let baseVideos = null
532
533 for (const server of servers) {
534 const res = await getVideosList(server.url)
535
536 const videos = res.body.data
537
538 // Initialize base videos for future comparisons
539 if (baseVideos === null) {
540 baseVideos = videos
541 continue
542 }
543
544 for (const baseVideo of baseVideos) {
545 const sameVideo = videos.find(video => video.name === baseVideo.name)
546 expect(baseVideo.views).to.equal(sameVideo.views)
547 }
548 }
549 })
550
551 it('Should like and dislikes videos on different services', async function () {
552 this.timeout(20000)
553
554 const tasks: Promise<any>[] = []
555 tasks.push(rateVideo(servers[0].url, servers[0].accessToken, remoteVideosServer1[0], 'like'))
556 tasks.push(rateVideo(servers[0].url, servers[0].accessToken, remoteVideosServer1[0], 'dislike'))
557 tasks.push(rateVideo(servers[0].url, servers[0].accessToken, remoteVideosServer1[0], 'like'))
558 tasks.push(rateVideo(servers[2].url, servers[2].accessToken, localVideosServer3[1], 'like'))
559 tasks.push(rateVideo(servers[2].url, servers[2].accessToken, localVideosServer3[1], 'dislike'))
560 tasks.push(rateVideo(servers[2].url, servers[2].accessToken, remoteVideosServer3[1], 'dislike'))
561 tasks.push(rateVideo(servers[2].url, servers[2].accessToken, remoteVideosServer3[0], 'like'))
562
563 await Promise.all(tasks)
564
565 await wait(10000)
566
567 let baseVideos = null
568 for (const server of servers) {
569 const res = await getVideosList(server.url)
570
571 const videos = res.body.data
572
573 // Initialize base videos for future comparisons
574 if (baseVideos === null) {
575 baseVideos = videos
576 continue
577 }
578
579 for (const baseVideo of baseVideos) {
580 const sameVideo = videos.find(video => video.name === baseVideo.name)
581 expect(baseVideo.likes).to.equal(sameVideo.likes)
582 expect(baseVideo.dislikes).to.equal(sameVideo.dislikes)
583 }
584 }
585 })
586 })
587
588 describe('Should manipulate these videos', function () {
589 it('Should update the video 3 by asking server 3', async function () {
590 this.timeout(10000)
591
592 const attributes = {
593 name: 'my super video updated',
594 category: 10,
595 licence: 7,
596 language: 13,
597 nsfw: true,
598 description: 'my super description updated',
599 tags: [ 'tag_up_1', 'tag_up_2' ]
600 }
601
602 await updateVideo(servers[2].url, servers[2].accessToken, toRemove[0].id, attributes)
603
604 await wait(5000)
605 })
606
607 it('Should have the video 3 updated on each server', async function () {
608 this.timeout(10000)
609
610 for (const server of servers) {
611 const res = await getVideosList(server.url)
612
613 const videos = res.body.data
614 const videoUpdated = videos.find(video => video.name === 'my super video updated')
615
616 expect(!!videoUpdated).to.be.true
617 expect(videoUpdated.category).to.equal(10)
618 expect(videoUpdated.categoryLabel).to.equal('Entertainment')
619 expect(videoUpdated.licence).to.equal(7)
620 expect(videoUpdated.licenceLabel).to.equal('Public Domain Dedication')
621 expect(videoUpdated.language).to.equal(13)
622 expect(videoUpdated.languageLabel).to.equal('French')
623 expect(videoUpdated.nsfw).to.be.ok
624 expect(videoUpdated.description).to.equal('my super description updated')
625 expect(videoUpdated.tags).to.deep.equal([ 'tag_up_1', 'tag_up_2' ])
626 expect(dateIsValid(videoUpdated.updatedAt, 20000)).to.be.true
627
628 const res2 = await getVideo(server.url, videoUpdated.uuid)
629 const videoUpdatedDetails = res2.body
630
631 const file = videoUpdatedDetails .files[0]
632 expect(file.magnetUri).to.have.lengthOf.above(2)
633 expect(file.resolution).to.equal(720)
634 expect(file.resolutionLabel).to.equal('720p')
635 expect(file.size).to.equal(292677)
636
637 const test = await testVideoImage(server.url, 'video_short3.webm', videoUpdated.thumbnailPath)
638 expect(test).to.equal(true)
639
640 // Avoid "duplicate torrent" errors
641 const refreshWebTorrent = true
642 const torrent = await webtorrentAdd(videoUpdatedDetails .files[0].magnetUri, refreshWebTorrent)
643 expect(torrent.files).to.be.an('array')
644 expect(torrent.files.length).to.equal(1)
645 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
646 }
647 })
648
649 it('Should remove the videos 3 and 3-2 by asking server 3', async function () {
650 this.timeout(10000)
651
652 await removeVideo(servers[2].url, servers[2].accessToken, toRemove[0].id)
653 await removeVideo(servers[2].url, servers[2].accessToken, toRemove[1].id)
654
655 await wait(5000)
656 })
657
658 it('Should have videos 1 and 3 on each server', async function () {
659 for (const server of servers) {
660 const res = await getVideosList(server.url)
661
662 const videos = res.body.data
663 expect(videos).to.be.an('array')
664 expect(videos.length).to.equal(2)
665 expect(videos[0].name).not.to.equal(videos[1].name)
666 expect(videos[0].name).not.to.equal(toRemove[0].name)
667 expect(videos[1].name).not.to.equal(toRemove[0].name)
668 expect(videos[0].name).not.to.equal(toRemove[1].name)
669 expect(videos[1].name).not.to.equal(toRemove[1].name)
670
671 videoUUID = videos.find(video => video.name === 'my super name for server 1').uuid
672 }
673 })
674
675 it('Should get the same video by UUID on each server', async function () {
676 let baseVideo = null
677 for (const server of servers) {
678 const res = await getVideo(server.url, videoUUID)
679
680 const video = res.body
681
682 if (baseVideo === null) {
683 baseVideo = video
684 continue
685 }
686
687 expect(baseVideo.name).to.equal(video.name)
688 expect(baseVideo.uuid).to.equal(video.uuid)
689 expect(baseVideo.category).to.equal(video.category)
690 expect(baseVideo.language).to.equal(video.language)
691 expect(baseVideo.licence).to.equal(video.licence)
692 expect(baseVideo.category).to.equal(video.category)
693 expect(baseVideo.nsfw).to.equal(video.nsfw)
694 expect(baseVideo.accountName).to.equal(video.accountName)
695 expect(baseVideo.tags).to.deep.equal(video.tags)
696 }
697 })
698
699 it('Should get the preview from each server', async function () {
700 for (const server of servers) {
701 const res = await getVideo(server.url, videoUUID)
702 const video = res.body
703
704 const test = await testVideoImage(server.url, 'video_short1-preview.webm', video.previewPath)
705 expect(test).to.equal(true)
706 }
707 })
708 })
709
710 after(async function () {
711 killallServers(servers)
712
713 // Keep the logs if the test failed
714 if (this['ok']) {
715 await flushTests()
716 }
717 })
718 })