aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/multiple-pods.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/multiple-pods.js')
-rw-r--r--server/tests/api/multiple-pods.js89
1 files changed, 77 insertions, 12 deletions
diff --git a/server/tests/api/multiple-pods.js b/server/tests/api/multiple-pods.js
index e02b6180b..552f10c6f 100644
--- a/server/tests/api/multiple-pods.js
+++ b/server/tests/api/multiple-pods.js
@@ -4,6 +4,7 @@
4 4
5const chai = require('chai') 5const chai = require('chai')
6const each = require('async/each') 6const each = require('async/each')
7const eachSeries = require('async/eachSeries')
7const expect = chai.expect 8const expect = chai.expect
8const parallel = require('async/parallel') 9const parallel = require('async/parallel')
9const series = require('async/series') 10const series = require('async/series')
@@ -378,7 +379,7 @@ describe('Test multiple pods', function () {
378 }) 379 })
379 }) 380 })
380 381
381 describe('Should update video views', function () { 382 describe('Should update video views, likes and dislikes', function () {
382 let localVideosPod3 = [] 383 let localVideosPod3 = []
383 let remoteVideosPod1 = [] 384 let remoteVideosPod1 = []
384 let remoteVideosPod2 = [] 385 let remoteVideosPod2 = []
@@ -419,7 +420,7 @@ describe('Test multiple pods', function () {
419 ], done) 420 ], done)
420 }) 421 })
421 422
422 it('Should views multiple videos on owned servers', function (done) { 423 it('Should view multiple videos on owned servers', function (done) {
423 this.timeout(30000) 424 this.timeout(30000)
424 425
425 parallel([ 426 parallel([
@@ -440,18 +441,18 @@ describe('Test multiple pods', function () {
440 }, 441 },
441 442
442 function (callback) { 443 function (callback) {
443 setTimeout(done, 22000) 444 setTimeout(callback, 22000)
444 } 445 }
445 ], function (err) { 446 ], function (err) {
446 if (err) throw err 447 if (err) throw err
447 448
448 each(servers, function (server, callback) { 449 eachSeries(servers, function (server, callback) {
449 videosUtils.getVideosList(server.url, function (err, res) { 450 videosUtils.getVideosList(server.url, function (err, res) {
450 if (err) throw err 451 if (err) throw err
451 452
452 const videos = res.body.data 453 const videos = res.body.data
453 expect(videos.find(video => video.views === 3)).to.be.exist 454 expect(videos.find(video => video.views === 3)).to.exist
454 expect(videos.find(video => video.views === 1)).to.be.exist 455 expect(videos.find(video => video.views === 1)).to.exist
455 456
456 callback() 457 callback()
457 }) 458 })
@@ -459,7 +460,7 @@ describe('Test multiple pods', function () {
459 }) 460 })
460 }) 461 })
461 462
462 it('Should views multiple videos on each servers', function (done) { 463 it('Should view multiple videos on each servers', function (done) {
463 this.timeout(30000) 464 this.timeout(30000)
464 465
465 parallel([ 466 parallel([
@@ -504,17 +505,17 @@ describe('Test multiple pods', function () {
504 }, 505 },
505 506
506 function (callback) { 507 function (callback) {
507 setTimeout(done, 22000) 508 setTimeout(callback, 22000)
508 } 509 }
509 ], function (err) { 510 ], function (err) {
510 if (err) throw err 511 if (err) throw err
511 512
512 let baseVideos = null 513 let baseVideos = null
513 each(servers, function (server, callback) { 514 eachSeries(servers, function (server, callback) {
514 videosUtils.getVideosList(server.url, function (err, res) { 515 videosUtils.getVideosList(server.url, function (err, res) {
515 if (err) throw err 516 if (err) throw err
516 517
517 const videos = res.body 518 const videos = res.body.data
518 519
519 // Initialize base videos for future comparisons 520 // Initialize base videos for future comparisons
520 if (baseVideos === null) { 521 if (baseVideos === null) {
@@ -522,10 +523,74 @@ describe('Test multiple pods', function () {
522 return callback() 523 return callback()
523 } 524 }
524 525
525 for (let i = 0; i < baseVideos.length; i++) { 526 baseVideos.forEach(baseVideo => {
526 expect(baseVideos[i].views).to.equal(videos[i].views) 527 const sameVideo = videos.find(video => video.name === baseVideo.name)
528 expect(baseVideo.views).to.equal(sameVideo.views)
529 })
530
531 callback()
532 })
533 }, done)
534 })
535 })
536
537 it('Should like and dislikes videos on different services', function (done) {
538 this.timeout(30000)
539
540 parallel([
541 function (callback) {
542 videosUtils.rateVideo(servers[0].url, servers[0].accessToken, remoteVideosPod1[0], 'like', callback)
543 },
544
545 function (callback) {
546 videosUtils.rateVideo(servers[0].url, servers[0].accessToken, remoteVideosPod1[0], 'dislike', callback)
547 },
548
549 function (callback) {
550 videosUtils.rateVideo(servers[0].url, servers[0].accessToken, remoteVideosPod1[0], 'like', callback)
551 },
552
553 function (callback) {
554 videosUtils.rateVideo(servers[2].url, servers[2].accessToken, localVideosPod3[1], 'like', callback)
555 },
556
557 function (callback) {
558 videosUtils.rateVideo(servers[2].url, servers[2].accessToken, localVideosPod3[1], 'dislike', callback)
559 },
560
561 function (callback) {
562 videosUtils.rateVideo(servers[2].url, servers[2].accessToken, remoteVideosPod3[1], 'dislike', callback)
563 },
564
565 function (callback) {
566 videosUtils.rateVideo(servers[2].url, servers[2].accessToken, remoteVideosPod3[0], 'like', callback)
567 },
568
569 function (callback) {
570 setTimeout(callback, 22000)
571 }
572 ], function (err) {
573 if (err) throw err
574
575 let baseVideos = null
576 eachSeries(servers, function (server, callback) {
577 videosUtils.getVideosList(server.url, function (err, res) {
578 if (err) throw err
579
580 const videos = res.body.data
581
582 // Initialize base videos for future comparisons
583 if (baseVideos === null) {
584 baseVideos = videos
585 return callback()
527 } 586 }
528 587
588 baseVideos.forEach(baseVideo => {
589 const sameVideo = videos.find(video => video.name === baseVideo.name)
590 expect(baseVideo.likes).to.equal(sameVideo.likes)
591 expect(baseVideo.dislikes).to.equal(sameVideo.dislikes)
592 })
593
529 callback() 594 callback()
530 }) 595 })
531 }, done) 596 }, done)