aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/videos/multiple-servers.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-15 10:02:54 +0200
committerChocobozzz <me@florianbigard.com>2021-07-20 15:27:18 +0200
commitd23dd9fbfc4d26026352c10f81d2795ceaf2908a (patch)
treeda82286d423c5e834a1ee2dcd5970076b8263cf1 /server/tests/api/videos/multiple-servers.ts
parent7926c5f9b3ffcabb1ffb0dcfa5e48b8e0b88fbc0 (diff)
downloadPeerTube-d23dd9fbfc4d26026352c10f81d2795ceaf2908a.tar.gz
PeerTube-d23dd9fbfc4d26026352c10f81d2795ceaf2908a.tar.zst
PeerTube-d23dd9fbfc4d26026352c10f81d2795ceaf2908a.zip
Introduce videos command
Diffstat (limited to 'server/tests/api/videos/multiple-servers.ts')
-rw-r--r--server/tests/api/videos/multiple-servers.ts334
1 files changed, 158 insertions, 176 deletions
diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts
index 169bb2e23..5c13ac629 100644
--- a/server/tests/api/videos/multiple-servers.ts
+++ b/server/tests/api/videos/multiple-servers.ts
@@ -13,17 +13,9 @@ import {
13 dateIsValid, 13 dateIsValid,
14 doubleFollow, 14 doubleFollow,
15 flushAndRunMultipleServers, 15 flushAndRunMultipleServers,
16 getLocalVideos,
17 getVideo,
18 getVideosList,
19 rateVideo,
20 removeVideo,
21 ServerInfo, 16 ServerInfo,
22 setAccessTokensToServers, 17 setAccessTokensToServers,
23 testImage, 18 testImage,
24 updateVideo,
25 uploadVideo,
26 viewVideo,
27 wait, 19 wait,
28 waitJobs, 20 waitJobs,
29 webtorrentAdd 21 webtorrentAdd
@@ -67,10 +59,9 @@ describe('Test multiple servers', function () {
67 59
68 it('Should not have videos for all servers', async function () { 60 it('Should not have videos for all servers', async function () {
69 for (const server of servers) { 61 for (const server of servers) {
70 const res = await getVideosList(server.url) 62 const { data } = await server.videosCommand.list()
71 const videos = res.body.data 63 expect(data).to.be.an('array')
72 expect(videos).to.be.an('array') 64 expect(data.length).to.equal(0)
73 expect(videos.length).to.equal(0)
74 } 65 }
75 }) 66 })
76 67
@@ -78,7 +69,7 @@ describe('Test multiple servers', function () {
78 it('Should upload the video on server 1 and propagate on each server', async function () { 69 it('Should upload the video on server 1 and propagate on each server', async function () {
79 this.timeout(25000) 70 this.timeout(25000)
80 71
81 const videoAttributes = { 72 const attributes = {
82 name: 'my super name for server 1', 73 name: 'my super name for server 1',
83 category: 5, 74 category: 5,
84 licence: 4, 75 licence: 4,
@@ -91,7 +82,7 @@ describe('Test multiple servers', function () {
91 channelId: videoChannelId, 82 channelId: videoChannelId,
92 fixture: 'video_short1.webm' 83 fixture: 'video_short1.webm'
93 } 84 }
94 await uploadVideo(servers[0].url, servers[0].accessToken, videoAttributes) 85 await servers[0].videosCommand.upload({ attributes })
95 86
96 await waitJobs(servers) 87 await waitJobs(servers)
97 88
@@ -134,14 +125,13 @@ describe('Test multiple servers', function () {
134 ] 125 ]
135 } 126 }
136 127
137 const res = await getVideosList(server.url) 128 const { data } = await server.videosCommand.list()
138 const videos = res.body.data 129 expect(data).to.be.an('array')
139 expect(videos).to.be.an('array') 130 expect(data.length).to.equal(1)
140 expect(videos.length).to.equal(1) 131 const video = data[0]
141 const video = videos[0]
142 132
143 await completeVideoCheck(server.url, video, checkAttributes) 133 await completeVideoCheck(server, video, checkAttributes)
144 publishedAt = video.publishedAt 134 publishedAt = video.publishedAt as string
145 } 135 }
146 }) 136 })
147 137
@@ -155,7 +145,7 @@ describe('Test multiple servers', function () {
155 await servers[1].usersCommand.create({ username: user.username, password: user.password }) 145 await servers[1].usersCommand.create({ username: user.username, password: user.password })
156 const userAccessToken = await servers[1].loginCommand.getAccessToken(user) 146 const userAccessToken = await servers[1].loginCommand.getAccessToken(user)
157 147
158 const videoAttributes = { 148 const attributes = {
159 name: 'my super name for server 2', 149 name: 'my super name for server 2',
160 category: 4, 150 category: 4,
161 licence: 3, 151 licence: 3,
@@ -168,7 +158,7 @@ describe('Test multiple servers', function () {
168 thumbnailfile: 'thumbnail.jpg', 158 thumbnailfile: 'thumbnail.jpg',
169 previewfile: 'preview.jpg' 159 previewfile: 'preview.jpg'
170 } 160 }
171 await uploadVideo(servers[1].url, userAccessToken, videoAttributes, HttpStatusCode.OK_200, 'resumable') 161 await servers[1].videosCommand.upload({ token: userAccessToken, attributes, mode: 'resumable' })
172 162
173 // Transcoding 163 // Transcoding
174 await waitJobs(servers) 164 await waitJobs(servers)
@@ -223,65 +213,67 @@ describe('Test multiple servers', function () {
223 previewfile: 'preview' 213 previewfile: 'preview'
224 } 214 }
225 215
226 const res = await getVideosList(server.url) 216 const { data } = await server.videosCommand.list()
227 const videos = res.body.data 217 expect(data).to.be.an('array')
228 expect(videos).to.be.an('array') 218 expect(data.length).to.equal(2)
229 expect(videos.length).to.equal(2) 219 const video = data[1]
230 const video = videos[1]
231 220
232 await completeVideoCheck(server.url, video, checkAttributes) 221 await completeVideoCheck(server, video, checkAttributes)
233 } 222 }
234 }) 223 })
235 224
236 it('Should upload two videos on server 3 and propagate on each server', async function () { 225 it('Should upload two videos on server 3 and propagate on each server', async function () {
237 this.timeout(45000) 226 this.timeout(45000)
238 227
239 const videoAttributes1 = { 228 {
240 name: 'my super name for server 3', 229 const attributes = {
241 category: 6, 230 name: 'my super name for server 3',
242 licence: 5, 231 category: 6,
243 language: 'de', 232 licence: 5,
244 nsfw: true, 233 language: 'de',
245 description: 'my super description for server 3', 234 nsfw: true,
246 support: 'my super support text for server 3', 235 description: 'my super description for server 3',
247 tags: [ 'tag1p3' ], 236 support: 'my super support text for server 3',
248 fixture: 'video_short3.webm' 237 tags: [ 'tag1p3' ],
238 fixture: 'video_short3.webm'
239 }
240 await servers[2].videosCommand.upload({ attributes })
249 } 241 }
250 await uploadVideo(servers[2].url, servers[2].accessToken, videoAttributes1) 242
251 243 {
252 const videoAttributes2 = { 244 const attributes = {
253 name: 'my super name for server 3-2', 245 name: 'my super name for server 3-2',
254 category: 7, 246 category: 7,
255 licence: 6, 247 licence: 6,
256 language: 'ko', 248 language: 'ko',
257 nsfw: false, 249 nsfw: false,
258 description: 'my super description for server 3-2', 250 description: 'my super description for server 3-2',
259 support: 'my super support text for server 3-2', 251 support: 'my super support text for server 3-2',
260 tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ], 252 tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ],
261 fixture: 'video_short.webm' 253 fixture: 'video_short.webm'
254 }
255 await servers[2].videosCommand.upload({ attributes })
262 } 256 }
263 await uploadVideo(servers[2].url, servers[2].accessToken, videoAttributes2)
264 257
265 await waitJobs(servers) 258 await waitJobs(servers)
266 259
267 // All servers should have this video 260 // All servers should have this video
268 for (const server of servers) { 261 for (const server of servers) {
269 const isLocal = server.url === 'http://localhost:' + servers[2].port 262 const isLocal = server.url === 'http://localhost:' + servers[2].port
270 const res = await getVideosList(server.url) 263 const { data } = await server.videosCommand.list()
271 264
272 const videos = res.body.data 265 expect(data).to.be.an('array')
273 expect(videos).to.be.an('array') 266 expect(data.length).to.equal(4)
274 expect(videos.length).to.equal(4)
275 267
276 // We not sure about the order of the two last uploads 268 // We not sure about the order of the two last uploads
277 let video1 = null 269 let video1 = null
278 let video2 = null 270 let video2 = null
279 if (videos[2].name === 'my super name for server 3') { 271 if (data[2].name === 'my super name for server 3') {
280 video1 = videos[2] 272 video1 = data[2]
281 video2 = videos[3] 273 video2 = data[3]
282 } else { 274 } else {
283 video1 = videos[3] 275 video1 = data[3]
284 video2 = videos[2] 276 video2 = data[2]
285 } 277 }
286 278
287 const checkAttributesVideo1 = { 279 const checkAttributesVideo1 = {
@@ -316,7 +308,7 @@ describe('Test multiple servers', function () {
316 } 308 }
317 ] 309 ]
318 } 310 }
319 await completeVideoCheck(server.url, video1, checkAttributesVideo1) 311 await completeVideoCheck(server, video1, checkAttributesVideo1)
320 312
321 const checkAttributesVideo2 = { 313 const checkAttributesVideo2 = {
322 name: 'my super name for server 3-2', 314 name: 'my super name for server 3-2',
@@ -350,38 +342,38 @@ describe('Test multiple servers', function () {
350 } 342 }
351 ] 343 ]
352 } 344 }
353 await completeVideoCheck(server.url, video2, checkAttributesVideo2) 345 await completeVideoCheck(server, video2, checkAttributesVideo2)
354 } 346 }
355 }) 347 })
356 }) 348 })
357 349
358 describe('It should list local videos', function () { 350 describe('It should list local videos', function () {
359 it('Should list only local videos on server 1', async function () { 351 it('Should list only local videos on server 1', async function () {
360 const { body } = await getLocalVideos(servers[0].url) 352 const { data, total } = await servers[0].videosCommand.list({ filter: 'local' })
361 353
362 expect(body.total).to.equal(1) 354 expect(total).to.equal(1)
363 expect(body.data).to.be.an('array') 355 expect(data).to.be.an('array')
364 expect(body.data.length).to.equal(1) 356 expect(data.length).to.equal(1)
365 expect(body.data[0].name).to.equal('my super name for server 1') 357 expect(data[0].name).to.equal('my super name for server 1')
366 }) 358 })
367 359
368 it('Should list only local videos on server 2', async function () { 360 it('Should list only local videos on server 2', async function () {
369 const { body } = await getLocalVideos(servers[1].url) 361 const { data, total } = await servers[1].videosCommand.list({ filter: 'local' })
370 362
371 expect(body.total).to.equal(1) 363 expect(total).to.equal(1)
372 expect(body.data).to.be.an('array') 364 expect(data).to.be.an('array')
373 expect(body.data.length).to.equal(1) 365 expect(data.length).to.equal(1)
374 expect(body.data[0].name).to.equal('my super name for server 2') 366 expect(data[0].name).to.equal('my super name for server 2')
375 }) 367 })
376 368
377 it('Should list only local videos on server 3', async function () { 369 it('Should list only local videos on server 3', async function () {
378 const { body } = await getLocalVideos(servers[2].url) 370 const { data, total } = await servers[2].videosCommand.list({ filter: 'local' })
379 371
380 expect(body.total).to.equal(2) 372 expect(total).to.equal(2)
381 expect(body.data).to.be.an('array') 373 expect(data).to.be.an('array')
382 expect(body.data.length).to.equal(2) 374 expect(data.length).to.equal(2)
383 expect(body.data[0].name).to.equal('my super name for server 3') 375 expect(data[0].name).to.equal('my super name for server 3')
384 expect(body.data[1].name).to.equal('my super name for server 3-2') 376 expect(data[1].name).to.equal('my super name for server 3-2')
385 }) 377 })
386 }) 378 })
387 379
@@ -389,15 +381,13 @@ describe('Test multiple servers', function () {
389 it('Should add the file 1 by asking server 3', async function () { 381 it('Should add the file 1 by asking server 3', async function () {
390 this.timeout(10000) 382 this.timeout(10000)
391 383
392 const res = await getVideosList(servers[2].url) 384 const { data } = await servers[2].videosCommand.list()
393
394 const video = res.body.data[0]
395 toRemove.push(res.body.data[2])
396 toRemove.push(res.body.data[3])
397 385
398 const res2 = await getVideo(servers[2].url, video.id) 386 const video = data[0]
399 const videoDetails = res2.body 387 toRemove.push(data[2])
388 toRemove.push(data[3])
400 389
390 const videoDetails = await servers[2].videosCommand.get({ id: video.id })
401 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true) 391 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
402 expect(torrent.files).to.be.an('array') 392 expect(torrent.files).to.be.an('array')
403 expect(torrent.files.length).to.equal(1) 393 expect(torrent.files.length).to.equal(1)
@@ -407,11 +397,10 @@ describe('Test multiple servers', function () {
407 it('Should add the file 2 by asking server 1', async function () { 397 it('Should add the file 2 by asking server 1', async function () {
408 this.timeout(10000) 398 this.timeout(10000)
409 399
410 const res = await getVideosList(servers[0].url) 400 const { data } = await servers[0].videosCommand.list()
411 401
412 const video = res.body.data[1] 402 const video = data[1]
413 const res2 = await getVideo(servers[0].url, video.id) 403 const videoDetails = await servers[0].videosCommand.get({ id: video.id })
414 const videoDetails = res2.body
415 404
416 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true) 405 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
417 expect(torrent.files).to.be.an('array') 406 expect(torrent.files).to.be.an('array')
@@ -422,11 +411,10 @@ describe('Test multiple servers', function () {
422 it('Should add the file 3 by asking server 2', async function () { 411 it('Should add the file 3 by asking server 2', async function () {
423 this.timeout(10000) 412 this.timeout(10000)
424 413
425 const res = await getVideosList(servers[1].url) 414 const { data } = await servers[1].videosCommand.list()
426 415
427 const video = res.body.data[2] 416 const video = data[2]
428 const res2 = await getVideo(servers[1].url, video.id) 417 const videoDetails = await servers[1].videosCommand.get({ id: video.id })
429 const videoDetails = res2.body
430 418
431 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true) 419 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
432 expect(torrent.files).to.be.an('array') 420 expect(torrent.files).to.be.an('array')
@@ -437,11 +425,10 @@ describe('Test multiple servers', function () {
437 it('Should add the file 3-2 by asking server 1', async function () { 425 it('Should add the file 3-2 by asking server 1', async function () {
438 this.timeout(10000) 426 this.timeout(10000)
439 427
440 const res = await getVideosList(servers[0].url) 428 const { data } = await servers[0].videosCommand.list()
441 429
442 const video = res.body.data[3] 430 const video = data[3]
443 const res2 = await getVideo(servers[0].url, video.id) 431 const videoDetails = await servers[0].videosCommand.get({ id: video.id })
444 const videoDetails = res2.body
445 432
446 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri) 433 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri)
447 expect(torrent.files).to.be.an('array') 434 expect(torrent.files).to.be.an('array')
@@ -452,11 +439,10 @@ describe('Test multiple servers', function () {
452 it('Should add the file 2 in 360p by asking server 1', async function () { 439 it('Should add the file 2 in 360p by asking server 1', async function () {
453 this.timeout(10000) 440 this.timeout(10000)
454 441
455 const res = await getVideosList(servers[0].url) 442 const { data } = await servers[0].videosCommand.list()
456 443
457 const video = res.body.data.find(v => v.name === 'my super name for server 2') 444 const video = data.find(v => v.name === 'my super name for server 2')
458 const res2 = await getVideo(servers[0].url, video.id) 445 const videoDetails = await servers[0].videosCommand.get({ id: video.id })
459 const videoDetails = res2.body
460 446
461 const file = videoDetails.files.find(f => f.resolution.id === 360) 447 const file = videoDetails.files.find(f => f.resolution.id === 360)
462 expect(file).not.to.be.undefined 448 expect(file).not.to.be.undefined
@@ -475,30 +461,36 @@ describe('Test multiple servers', function () {
475 let remoteVideosServer3 = [] 461 let remoteVideosServer3 = []
476 462
477 before(async function () { 463 before(async function () {
478 const res1 = await getVideosList(servers[0].url) 464 {
479 remoteVideosServer1 = res1.body.data.filter(video => video.isLocal === false).map(video => video.uuid) 465 const { data } = await servers[0].videosCommand.list()
466 remoteVideosServer1 = data.filter(video => video.isLocal === false).map(video => video.uuid)
467 }
480 468
481 const res2 = await getVideosList(servers[1].url) 469 {
482 remoteVideosServer2 = res2.body.data.filter(video => video.isLocal === false).map(video => video.uuid) 470 const { data } = await servers[1].videosCommand.list()
471 remoteVideosServer2 = data.filter(video => video.isLocal === false).map(video => video.uuid)
472 }
483 473
484 const res3 = await getVideosList(servers[2].url) 474 {
485 localVideosServer3 = res3.body.data.filter(video => video.isLocal === true).map(video => video.uuid) 475 const { data } = await servers[2].videosCommand.list()
486 remoteVideosServer3 = res3.body.data.filter(video => video.isLocal === false).map(video => video.uuid) 476 localVideosServer3 = data.filter(video => video.isLocal === true).map(video => video.uuid)
477 remoteVideosServer3 = data.filter(video => video.isLocal === false).map(video => video.uuid)
478 }
487 }) 479 })
488 480
489 it('Should view multiple videos on owned servers', async function () { 481 it('Should view multiple videos on owned servers', async function () {
490 this.timeout(30000) 482 this.timeout(30000)
491 483
492 await viewVideo(servers[2].url, localVideosServer3[0]) 484 await servers[2].videosCommand.view({ id: localVideosServer3[0] })
493 await wait(1000) 485 await wait(1000)
494 486
495 await viewVideo(servers[2].url, localVideosServer3[0]) 487 await servers[2].videosCommand.view({ id: localVideosServer3[0] })
496 await viewVideo(servers[2].url, localVideosServer3[1]) 488 await servers[2].videosCommand.view({ id: localVideosServer3[1] })
497 489
498 await wait(1000) 490 await wait(1000)
499 491
500 await viewVideo(servers[2].url, localVideosServer3[0]) 492 await servers[2].videosCommand.view({ id: localVideosServer3[0] })
501 await viewVideo(servers[2].url, localVideosServer3[0]) 493 await servers[2].videosCommand.view({ id: localVideosServer3[0] })
502 494
503 await waitJobs(servers) 495 await waitJobs(servers)
504 496
@@ -508,11 +500,10 @@ describe('Test multiple servers', function () {
508 await waitJobs(servers) 500 await waitJobs(servers)
509 501
510 for (const server of servers) { 502 for (const server of servers) {
511 const res = await getVideosList(server.url) 503 const { data } = await server.videosCommand.list()
512 504
513 const videos = res.body.data 505 const video0 = data.find(v => v.uuid === localVideosServer3[0])
514 const video0 = videos.find(v => v.uuid === localVideosServer3[0]) 506 const video1 = data.find(v => v.uuid === localVideosServer3[1])
515 const video1 = videos.find(v => v.uuid === localVideosServer3[1])
516 507
517 expect(video0.views).to.equal(3) 508 expect(video0.views).to.equal(3)
518 expect(video1.views).to.equal(1) 509 expect(video1.views).to.equal(1)
@@ -523,16 +514,16 @@ describe('Test multiple servers', function () {
523 this.timeout(45000) 514 this.timeout(45000)
524 515
525 const tasks: Promise<any>[] = [] 516 const tasks: Promise<any>[] = []
526 tasks.push(viewVideo(servers[0].url, remoteVideosServer1[0])) 517 tasks.push(servers[0].videosCommand.view({ id: remoteVideosServer1[0] }))
527 tasks.push(viewVideo(servers[1].url, remoteVideosServer2[0])) 518 tasks.push(servers[1].videosCommand.view({ id: remoteVideosServer2[0] }))
528 tasks.push(viewVideo(servers[1].url, remoteVideosServer2[0])) 519 tasks.push(servers[1].videosCommand.view({ id: remoteVideosServer2[0] }))
529 tasks.push(viewVideo(servers[2].url, remoteVideosServer3[0])) 520 tasks.push(servers[2].videosCommand.view({ id: remoteVideosServer3[0] }))
530 tasks.push(viewVideo(servers[2].url, remoteVideosServer3[1])) 521 tasks.push(servers[2].videosCommand.view({ id: remoteVideosServer3[1] }))
531 tasks.push(viewVideo(servers[2].url, remoteVideosServer3[1])) 522 tasks.push(servers[2].videosCommand.view({ id: remoteVideosServer3[1] }))
532 tasks.push(viewVideo(servers[2].url, remoteVideosServer3[1])) 523 tasks.push(servers[2].videosCommand.view({ id: remoteVideosServer3[1] }))
533 tasks.push(viewVideo(servers[2].url, localVideosServer3[1])) 524 tasks.push(servers[2].videosCommand.view({ id: localVideosServer3[1] }))
534 tasks.push(viewVideo(servers[2].url, localVideosServer3[1])) 525 tasks.push(servers[2].videosCommand.view({ id: localVideosServer3[1] }))
535 tasks.push(viewVideo(servers[2].url, localVideosServer3[1])) 526 tasks.push(servers[2].videosCommand.view({ id: localVideosServer3[1] }))
536 527
537 await Promise.all(tasks) 528 await Promise.all(tasks)
538 529
@@ -546,18 +537,16 @@ describe('Test multiple servers', function () {
546 let baseVideos = null 537 let baseVideos = null
547 538
548 for (const server of servers) { 539 for (const server of servers) {
549 const res = await getVideosList(server.url) 540 const { data } = await server.videosCommand.list()
550
551 const videos = res.body.data
552 541
553 // Initialize base videos for future comparisons 542 // Initialize base videos for future comparisons
554 if (baseVideos === null) { 543 if (baseVideos === null) {
555 baseVideos = videos 544 baseVideos = data
556 continue 545 continue
557 } 546 }
558 547
559 for (const baseVideo of baseVideos) { 548 for (const baseVideo of baseVideos) {
560 const sameVideo = videos.find(video => video.name === baseVideo.name) 549 const sameVideo = data.find(video => video.name === baseVideo.name)
561 expect(baseVideo.views).to.equal(sameVideo.views) 550 expect(baseVideo.views).to.equal(sameVideo.views)
562 } 551 }
563 } 552 }
@@ -566,17 +555,17 @@ describe('Test multiple servers', function () {
566 it('Should like and dislikes videos on different services', async function () { 555 it('Should like and dislikes videos on different services', async function () {
567 this.timeout(50000) 556 this.timeout(50000)
568 557
569 await rateVideo(servers[0].url, servers[0].accessToken, remoteVideosServer1[0], 'like') 558 await servers[0].videosCommand.rate({ id: remoteVideosServer1[0], rating: 'like' })
570 await wait(500) 559 await wait(500)
571 await rateVideo(servers[0].url, servers[0].accessToken, remoteVideosServer1[0], 'dislike') 560 await servers[0].videosCommand.rate({ id: remoteVideosServer1[0], rating: 'dislike' })
572 await wait(500) 561 await wait(500)
573 await rateVideo(servers[0].url, servers[0].accessToken, remoteVideosServer1[0], 'like') 562 await servers[0].videosCommand.rate({ id: remoteVideosServer1[0], rating: 'like' })
574 await rateVideo(servers[2].url, servers[2].accessToken, localVideosServer3[1], 'like') 563 await servers[2].videosCommand.rate({ id: localVideosServer3[1], rating: 'like' })
575 await wait(500) 564 await wait(500)
576 await rateVideo(servers[2].url, servers[2].accessToken, localVideosServer3[1], 'dislike') 565 await servers[2].videosCommand.rate({ id: localVideosServer3[1], rating: 'dislike' })
577 await rateVideo(servers[2].url, servers[2].accessToken, remoteVideosServer3[1], 'dislike') 566 await servers[2].videosCommand.rate({ id: remoteVideosServer3[1], rating: 'dislike' })
578 await wait(500) 567 await wait(500)
579 await rateVideo(servers[2].url, servers[2].accessToken, remoteVideosServer3[0], 'like') 568 await servers[2].videosCommand.rate({ id: remoteVideosServer3[0], rating: 'like' })
580 569
581 await waitJobs(servers) 570 await waitJobs(servers)
582 await wait(5000) 571 await wait(5000)
@@ -584,18 +573,16 @@ describe('Test multiple servers', function () {
584 573
585 let baseVideos = null 574 let baseVideos = null
586 for (const server of servers) { 575 for (const server of servers) {
587 const res = await getVideosList(server.url) 576 const { data } = await server.videosCommand.list()
588
589 const videos = res.body.data
590 577
591 // Initialize base videos for future comparisons 578 // Initialize base videos for future comparisons
592 if (baseVideos === null) { 579 if (baseVideos === null) {
593 baseVideos = videos 580 baseVideos = data
594 continue 581 continue
595 } 582 }
596 583
597 for (const baseVideo of baseVideos) { 584 for (const baseVideo of baseVideos) {
598 const sameVideo = videos.find(video => video.name === baseVideo.name) 585 const sameVideo = data.find(video => video.name === baseVideo.name)
599 expect(baseVideo.likes).to.equal(sameVideo.likes) 586 expect(baseVideo.likes).to.equal(sameVideo.likes)
600 expect(baseVideo.dislikes).to.equal(sameVideo.dislikes) 587 expect(baseVideo.dislikes).to.equal(sameVideo.dislikes)
601 } 588 }
@@ -621,7 +608,7 @@ describe('Test multiple servers', function () {
621 previewfile: 'preview.jpg' 608 previewfile: 'preview.jpg'
622 } 609 }
623 610
624 await updateVideo(servers[2].url, servers[2].accessToken, toRemove[0].id, attributes) 611 await servers[2].videosCommand.update({ id: toRemove[0].id, attributes })
625 612
626 await waitJobs(servers) 613 await waitJobs(servers)
627 }) 614 })
@@ -630,10 +617,9 @@ describe('Test multiple servers', function () {
630 this.timeout(10000) 617 this.timeout(10000)
631 618
632 for (const server of servers) { 619 for (const server of servers) {
633 const res = await getVideosList(server.url) 620 const { data } = await server.videosCommand.list()
634 621
635 const videos = res.body.data 622 const videoUpdated = data.find(video => video.name === 'my super video updated')
636 const videoUpdated = videos.find(video => video.name === 'my super video updated')
637 expect(!!videoUpdated).to.be.true 623 expect(!!videoUpdated).to.be.true
638 624
639 const isLocal = server.url === 'http://localhost:' + servers[2].port 625 const isLocal = server.url === 'http://localhost:' + servers[2].port
@@ -672,15 +658,15 @@ describe('Test multiple servers', function () {
672 thumbnailfile: 'thumbnail', 658 thumbnailfile: 'thumbnail',
673 previewfile: 'preview' 659 previewfile: 'preview'
674 } 660 }
675 await completeVideoCheck(server.url, videoUpdated, checkAttributes) 661 await completeVideoCheck(server, videoUpdated, checkAttributes)
676 } 662 }
677 }) 663 })
678 664
679 it('Should remove the videos 3 and 3-2 by asking server 3', async function () { 665 it('Should remove the videos 3 and 3-2 by asking server 3', async function () {
680 this.timeout(10000) 666 this.timeout(10000)
681 667
682 await removeVideo(servers[2].url, servers[2].accessToken, toRemove[0].id) 668 await servers[2].videosCommand.remove({ id: toRemove[0].id })
683 await removeVideo(servers[2].url, servers[2].accessToken, toRemove[1].id) 669 await servers[2].videosCommand.remove({ id: toRemove[1].id })
684 670
685 await waitJobs(servers) 671 await waitJobs(servers)
686 }) 672 })
@@ -694,27 +680,24 @@ describe('Test multiple servers', function () {
694 680
695 it('Should have videos 1 and 3 on each server', async function () { 681 it('Should have videos 1 and 3 on each server', async function () {
696 for (const server of servers) { 682 for (const server of servers) {
697 const res = await getVideosList(server.url) 683 const { data } = await server.videosCommand.list()
698 684
699 const videos = res.body.data 685 expect(data).to.be.an('array')
700 expect(videos).to.be.an('array') 686 expect(data.length).to.equal(2)
701 expect(videos.length).to.equal(2) 687 expect(data[0].name).not.to.equal(data[1].name)
702 expect(videos[0].name).not.to.equal(videos[1].name) 688 expect(data[0].name).not.to.equal(toRemove[0].name)
703 expect(videos[0].name).not.to.equal(toRemove[0].name) 689 expect(data[1].name).not.to.equal(toRemove[0].name)
704 expect(videos[1].name).not.to.equal(toRemove[0].name) 690 expect(data[0].name).not.to.equal(toRemove[1].name)
705 expect(videos[0].name).not.to.equal(toRemove[1].name) 691 expect(data[1].name).not.to.equal(toRemove[1].name)
706 expect(videos[1].name).not.to.equal(toRemove[1].name) 692
707 693 videoUUID = data.find(video => video.name === 'my super name for server 1').uuid
708 videoUUID = videos.find(video => video.name === 'my super name for server 1').uuid
709 } 694 }
710 }) 695 })
711 696
712 it('Should get the same video by UUID on each server', async function () { 697 it('Should get the same video by UUID on each server', async function () {
713 let baseVideo = null 698 let baseVideo = null
714 for (const server of servers) { 699 for (const server of servers) {
715 const res = await getVideo(server.url, videoUUID) 700 const video = await server.videosCommand.get({ id: videoUUID })
716
717 const video = res.body
718 701
719 if (baseVideo === null) { 702 if (baseVideo === null) {
720 baseVideo = video 703 baseVideo = video
@@ -737,8 +720,7 @@ describe('Test multiple servers', function () {
737 720
738 it('Should get the preview from each server', async function () { 721 it('Should get the preview from each server', async function () {
739 for (const server of servers) { 722 for (const server of servers) {
740 const res = await getVideo(server.url, videoUUID) 723 const video = await server.videosCommand.get({ id: videoUUID })
741 const video = res.body
742 724
743 await testImage(server.url, 'video_short1-preview.webm', video.previewPath) 725 await testImage(server.url, 'video_short1-preview.webm', video.previewPath)
744 } 726 }
@@ -975,14 +957,14 @@ describe('Test multiple servers', function () {
975 downloadEnabled: false 957 downloadEnabled: false
976 } 958 }
977 959
978 await updateVideo(servers[0].url, servers[0].accessToken, videoUUID, attributes) 960 await servers[0].videosCommand.update({ id: videoUUID, attributes })
979 961
980 await waitJobs(servers) 962 await waitJobs(servers)
981 963
982 for (const server of servers) { 964 for (const server of servers) {
983 const res = await getVideo(server.url, videoUUID) 965 const video = await server.videosCommand.get({ id: videoUUID })
984 expect(res.body.commentsEnabled).to.be.false 966 expect(video.commentsEnabled).to.be.false
985 expect(res.body.downloadEnabled).to.be.false 967 expect(video.downloadEnabled).to.be.false
986 968
987 const text = 'my super forbidden comment' 969 const text = 'my super forbidden comment'
988 await server.commentsCommand.createThread({ videoId: videoUUID, text, expectedStatus: HttpStatusCode.CONFLICT_409 }) 970 await server.commentsCommand.createThread({ videoId: videoUUID, text, expectedStatus: HttpStatusCode.CONFLICT_409 })
@@ -1010,8 +992,8 @@ describe('Test multiple servers', function () {
1010 await waitJobs(servers) 992 await waitJobs(servers)
1011 993
1012 for (const server of servers) { 994 for (const server of servers) {
1013 const res = await getVideosList(server.url) 995 const { data } = await server.videosCommand.list()
1014 const video = res.body.data.find(v => v.name === 'minimum parameters') 996 const video = data.find(v => v.name === 'minimum parameters')
1015 997
1016 const isLocal = server.url === 'http://localhost:' + servers[1].port 998 const isLocal = server.url === 'http://localhost:' + servers[1].port
1017 const checkAttributes = { 999 const checkAttributes = {
@@ -1058,7 +1040,7 @@ describe('Test multiple servers', function () {
1058 } 1040 }
1059 ] 1041 ]
1060 } 1042 }
1061 await completeVideoCheck(server.url, video, checkAttributes) 1043 await completeVideoCheck(server, video, checkAttributes)
1062 } 1044 }
1063 }) 1045 })
1064 }) 1046 })