diff options
Diffstat (limited to 'server/tests/api/multiple-pods.js')
-rw-r--r-- | server/tests/api/multiple-pods.js | 60 |
1 files changed, 59 insertions, 1 deletions
diff --git a/server/tests/api/multiple-pods.js b/server/tests/api/multiple-pods.js index df12ba0e9..871db54be 100644 --- a/server/tests/api/multiple-pods.js +++ b/server/tests/api/multiple-pods.js | |||
@@ -3,6 +3,7 @@ | |||
3 | const chai = require('chai') | 3 | const chai = require('chai') |
4 | const each = require('async/each') | 4 | const each = require('async/each') |
5 | const expect = chai.expect | 5 | const expect = chai.expect |
6 | const parallel = require('async/parallel') | ||
6 | const series = require('async/series') | 7 | const series = require('async/series') |
7 | const WebTorrent = require('webtorrent') | 8 | const WebTorrent = require('webtorrent') |
8 | const webtorrent = new WebTorrent() | 9 | const webtorrent = new WebTorrent() |
@@ -375,6 +376,63 @@ describe('Test multiple pods', function () { | |||
375 | }) | 376 | }) |
376 | }) | 377 | }) |
377 | 378 | ||
379 | describe('Should update video views', function () { | ||
380 | let videoId1 | ||
381 | let videoId2 | ||
382 | |||
383 | before(function (done) { | ||
384 | videosUtils.getVideosList(servers[2].url, function (err, res) { | ||
385 | if (err) throw err | ||
386 | |||
387 | const videos = res.body.data.filter(video => video.isLocal === true) | ||
388 | videoId1 = videos[0].id | ||
389 | videoId2 = videos[1].id | ||
390 | |||
391 | done() | ||
392 | }) | ||
393 | }) | ||
394 | |||
395 | it('Should views multiple videos on owned servers', function (done) { | ||
396 | this.timeout(30000) | ||
397 | |||
398 | parallel([ | ||
399 | function (callback) { | ||
400 | videosUtils.getVideo(servers[2].url, videoId1, callback) | ||
401 | }, | ||
402 | |||
403 | function (callback) { | ||
404 | videosUtils.getVideo(servers[2].url, videoId1, callback) | ||
405 | }, | ||
406 | |||
407 | function (callback) { | ||
408 | videosUtils.getVideo(servers[2].url, videoId1, callback) | ||
409 | }, | ||
410 | |||
411 | function (callback) { | ||
412 | videosUtils.getVideo(servers[2].url, videoId2, callback) | ||
413 | } | ||
414 | ], function (err) { | ||
415 | if (err) throw err | ||
416 | |||
417 | setTimeout(done, 22000) | ||
418 | }) | ||
419 | }) | ||
420 | |||
421 | it('Should have views updated on each pod', function (done) { | ||
422 | each(servers, function (server, callback) { | ||
423 | videosUtils.getVideosList(server.url, function (err, res) { | ||
424 | if (err) throw err | ||
425 | |||
426 | const videos = res.body.data | ||
427 | expect(videos.find(video => video.views === 3)).to.be.exist | ||
428 | expect(videos.find(video => video.views === 1)).to.be.exist | ||
429 | |||
430 | callback() | ||
431 | }) | ||
432 | }, done) | ||
433 | }) | ||
434 | }) | ||
435 | /* | ||
378 | describe('Should manipulate these videos', function () { | 436 | describe('Should manipulate these videos', function () { |
379 | it('Should update the video 3 by asking pod 3', function (done) { | 437 | it('Should update the video 3 by asking pod 3', function (done) { |
380 | this.timeout(15000) | 438 | this.timeout(15000) |
@@ -462,7 +520,7 @@ describe('Test multiple pods', function () { | |||
462 | }, done) | 520 | }, done) |
463 | }) | 521 | }) |
464 | }) | 522 | }) |
465 | 523 | */ | |
466 | after(function (done) { | 524 | after(function (done) { |
467 | servers.forEach(function (server) { | 525 | servers.forEach(function (server) { |
468 | process.kill(-server.app.pid) | 526 | process.kill(-server.app.pid) |