Server: udpate async to 2.0.0

This commit is contained in:
Chocobozzz 2016-07-18 17:17:52 +02:00
parent d56ec0d412
commit 1a42c9e2c0
15 changed files with 85 additions and 72 deletions

View File

@ -34,7 +34,7 @@
"postinstall": "cd client && npm install" "postinstall": "cd client && npm install"
}, },
"dependencies": { "dependencies": {
"async": "^1.2.1", "async": "^2.0.0",
"bittorrent-tracker": "^8.0.0", "bittorrent-tracker": "^8.0.0",
"body-parser": "^1.12.4", "body-parser": "^1.12.4",
"concurrently": "^2.0.0", "concurrently": "^2.0.0",
@ -53,7 +53,6 @@
"morgan": "^1.5.3", "morgan": "^1.5.3",
"multer": "^1.1.0", "multer": "^1.1.0",
"node-ipc": "^8.0.0", "node-ipc": "^8.0.0",
"node-sass": "^3.4.2",
"openssl-wrapper": "^0.3.4", "openssl-wrapper": "^0.3.4",
"password-generator": "^2.0.2", "password-generator": "^2.0.2",
"request": "^2.57.0", "request": "^2.57.0",

View File

@ -1,8 +1,9 @@
'use strict' 'use strict'
const async = require('async') const each = require('async/each')
const express = require('express') const express = require('express')
const mongoose = require('mongoose') const mongoose = require('mongoose')
const waterfall = require('async/waterfall')
const logger = require('../../../helpers/logger') const logger = require('../../../helpers/logger')
const friends = require('../../../lib/friends') const friends = require('../../../lib/friends')
@ -31,7 +32,7 @@ module.exports = router
function addPods (req, res, next) { function addPods (req, res, next) {
const informations = req.body const informations = req.body
async.waterfall([ waterfall([
function addPod (callback) { function addPod (callback) {
const pod = new Pod(informations) const pod = new Pod(informations)
pod.save(function (err, podCreated) { pod.save(function (err, podCreated) {
@ -82,7 +83,7 @@ function makeFriends (req, res, next) {
function removePods (req, res, next) { function removePods (req, res, next) {
const url = req.body.signature.url const url = req.body.signature.url
async.waterfall([ waterfall([
function loadPod (callback) { function loadPod (callback) {
Pod.loadByUrl(url, callback) Pod.loadByUrl(url, callback)
}, },
@ -106,7 +107,7 @@ function removePods (req, res, next) {
}, },
function removeTheRemoteVideos (videosList, callback) { function removeTheRemoteVideos (videosList, callback) {
async.each(videosList, function (video, callbackEach) { each(videosList, function (video, callbackEach) {
video.remove(callbackEach) video.remove(callbackEach)
}, callback) }, callback)
} }

View File

@ -1,6 +1,7 @@
'use strict' 'use strict'
const async = require('async') const each = require('async/each')
const eachSeries = require('async/eachSeries')
const express = require('express') const express = require('express')
const mongoose = require('mongoose') const mongoose = require('mongoose')
@ -32,7 +33,7 @@ function remoteVideos (req, res, next) {
// We need to process in the same order to keep consistency // We need to process in the same order to keep consistency
// TODO: optimization // TODO: optimization
async.eachSeries(requests, function (request, callbackEach) { eachSeries(requests, function (request, callbackEach) {
const videoData = request.data const videoData = request.data
if (request.type === 'add') { if (request.type === 'add') {
@ -72,7 +73,7 @@ function removeRemoteVideo (videoToRemoveData, fromUrl, callback) {
logger.error('No remote video was found for this pod.', { magnetUri: videoToRemoveData.magnetUri, podUrl: fromUrl }) logger.error('No remote video was found for this pod.', { magnetUri: videoToRemoveData.magnetUri, podUrl: fromUrl })
} }
async.each(videosList, function (video, callbackEach) { each(videosList, function (video, callbackEach) {
logger.debug('Removing remote video %s.', video.magnetUri) logger.debug('Removing remote video %s.', video.magnetUri)
video.remove(callbackEach) video.remove(callbackEach)

View File

@ -1,10 +1,10 @@
'use strict' 'use strict'
const async = require('async')
const config = require('config') const config = require('config')
const express = require('express') const express = require('express')
const mongoose = require('mongoose') const mongoose = require('mongoose')
const multer = require('multer') const multer = require('multer')
const waterfall = require('async/waterfall')
const logger = require('../../../helpers/logger') const logger = require('../../../helpers/logger')
const friends = require('../../../lib/friends') const friends = require('../../../lib/friends')
@ -85,7 +85,7 @@ function addVideo (req, res, next) {
const videoFile = req.files.videofile[0] const videoFile = req.files.videofile[0]
const videoInfos = req.body const videoInfos = req.body
async.waterfall([ waterfall([
function insertIntoDB (callback) { function insertIntoDB (callback) {
const videoData = { const videoData = {
@ -152,7 +152,7 @@ function listVideos (req, res, next) {
function removeVideo (req, res, next) { function removeVideo (req, res, next) {
const videoId = req.params.id const videoId = req.params.id
async.waterfall([ waterfall([
function getVideo (callback) { function getVideo (callback) {
Video.load(videoId, callback) Video.load(videoId, callback)
}, },

View File

@ -1,11 +1,12 @@
'use strict' 'use strict'
const async = require('async')
const config = require('config') const config = require('config')
const each = require('async/each')
const mkdirp = require('mkdirp') const mkdirp = require('mkdirp')
const mongoose = require('mongoose') const mongoose = require('mongoose')
const passwordGenerator = require('password-generator') const passwordGenerator = require('password-generator')
const path = require('path') const path = require('path')
const series = require('async/series')
const checker = require('./checker') const checker = require('./checker')
const logger = require('../helpers/logger') const logger = require('../helpers/logger')
@ -19,7 +20,7 @@ const installer = {
} }
function installApplication (callback) { function installApplication (callback) {
async.series([ series([
function createDirectories (callbackAsync) { function createDirectories (callbackAsync) {
createDirectoriesIfNotExist(callbackAsync) createDirectoriesIfNotExist(callbackAsync)
}, },
@ -47,7 +48,7 @@ module.exports = installer
function createDirectoriesIfNotExist (callback) { function createDirectoriesIfNotExist (callback) {
const storages = config.get('storage') const storages = config.get('storage')
async.each(Object.keys(storages), function (key, callbackEach) { each(Object.keys(storages), function (key, callbackEach) {
const dir = storages[key] const dir = storages[key]
mkdirp(path.join(__dirname, '..', '..', dir), callbackEach) mkdirp(path.join(__dirname, '..', '..', dir), callbackEach)
}, callback) }, callback)

View File

@ -1,10 +1,13 @@
'use strict' 'use strict'
const async = require('async')
const config = require('config') const config = require('config')
const each = require('async/each')
const eachLimit = require('async/eachLimit')
const eachSeries = require('async/eachSeries')
const fs = require('fs') const fs = require('fs')
const mongoose = require('mongoose') const mongoose = require('mongoose')
const request = require('request') const request = require('request')
const waterfall = require('async/waterfall')
const constants = require('../initializers/constants') const constants = require('../initializers/constants')
const logger = require('../helpers/logger') const logger = require('../helpers/logger')
@ -57,7 +60,7 @@ function makeFriends (callback) {
const urls = config.get('network.friends') const urls = config.get('network.friends')
async.eachSeries(urls, function (url, callbackEach) { eachSeries(urls, function (url, callbackEach) {
computeForeignPodsList(url, podsScore, callbackEach) computeForeignPodsList(url, podsScore, callbackEach)
}, function (err) { }, function (err) {
if (err) return callback(err) if (err) return callback(err)
@ -77,7 +80,7 @@ function quitFriends (callback) {
// Flush pool requests // Flush pool requests
Request.flush() Request.flush()
async.waterfall([ waterfall([
function getPodsList (callbackAsync) { function getPodsList (callbackAsync) {
return Pod.list(callbackAsync) return Pod.list(callbackAsync)
}, },
@ -92,7 +95,7 @@ function quitFriends (callback) {
// Announce we quit them // Announce we quit them
// We don't care if the request fails // We don't care if the request fails
// The other pod will exclude us automatically after a while // The other pod will exclude us automatically after a while
async.eachLimit(pods, constants.REQUESTS_IN_PARALLEL, function (pod, callbackEach) { eachLimit(pods, constants.REQUESTS_IN_PARALLEL, function (pod, callbackEach) {
requestParams.toPod = pod requestParams.toPod = pod
requests.makeSecureRequest(requestParams, callbackEach) requests.makeSecureRequest(requestParams, callbackEach)
}, function (err) { }, function (err) {
@ -118,7 +121,7 @@ function quitFriends (callback) {
}, },
function removeTheRemoteVideos (videosList, callbackAsync) { function removeTheRemoteVideos (videosList, callbackAsync) {
async.each(videosList, function (video, callbackEach) { each(videosList, function (video, callbackEach) {
video.remove(callbackEach) video.remove(callbackEach)
}, callbackAsync) }, callbackAsync)
} }
@ -212,7 +215,7 @@ function makeRequestsToWinningPods (cert, podsList, callback) {
// Flush pool requests // Flush pool requests
Request.forceSend() Request.forceSend()
async.eachLimit(podsList, constants.REQUESTS_IN_PARALLEL, function (pod, callbackEach) { eachLimit(podsList, constants.REQUESTS_IN_PARALLEL, function (pod, callbackEach) {
const params = { const params = {
url: pod.url + '/api/' + constants.API_VERSION + '/pods/', url: pod.url + '/api/' + constants.API_VERSION + '/pods/',
method: 'POST', method: 'POST',

View File

@ -1,8 +1,10 @@
'use strict' 'use strict'
const async = require('async') const each = require('async/each')
const eachLimit = require('async/eachLimit')
const map = require('lodash/map') const map = require('lodash/map')
const mongoose = require('mongoose') const mongoose = require('mongoose')
const waterfall = require('async/waterfall')
const constants = require('../initializers/constants') const constants = require('../initializers/constants')
const logger = require('../helpers/logger') const logger = require('../helpers/logger')
@ -136,7 +138,7 @@ function makeRequests () {
const goodPods = [] const goodPods = []
const badPods = [] const badPods = []
async.eachLimit(Object.keys(requestsToMake), constants.REQUESTS_IN_PARALLEL, function (toPodId, callbackEach) { eachLimit(Object.keys(requestsToMake), constants.REQUESTS_IN_PARALLEL, function (toPodId, callbackEach) {
const requestToMake = requestsToMake[toPodId] const requestToMake = requestsToMake[toPodId]
// FIXME: mongodb request inside a loop :/ // FIXME: mongodb request inside a loop :/
@ -183,7 +185,7 @@ function makeRequests () {
// Remove pods with a score of 0 (too many requests where they were unreachable) // Remove pods with a score of 0 (too many requests where they were unreachable)
function removeBadPods () { function removeBadPods () {
async.waterfall([ waterfall([
function findBadPods (callback) { function findBadPods (callback) {
Pod.listBadPods(function (err, pods) { Pod.listBadPods(function (err, pods) {
if (err) { if (err) {
@ -217,7 +219,7 @@ function removeBadPods () {
return callback(null) return callback(null)
} }
async.each(videosList, function (video, callbackEach) { each(videosList, function (video, callbackEach) {
video.remove(callbackEach) video.remove(callbackEach)
}, function (err) { }, function (err) {
if (err) { if (err) {
@ -237,7 +239,7 @@ function removeBadPods () {
return callback(null) return callback(null)
} }
async.each(pods, function (pod, callbackEach) { each(pods, function (pod, callbackEach) {
pod.remove(callbackEach) pod.remove(callbackEach)
}, function (err) { }, function (err) {
if (err) return callback(err) if (err) return callback(err)

View File

@ -1,9 +1,10 @@
'use strict' 'use strict'
const async = require('async')
const config = require('config') const config = require('config')
const each = require('async/each')
const ffmpeg = require('fluent-ffmpeg') const ffmpeg = require('fluent-ffmpeg')
const fs = require('fs') const fs = require('fs')
const parallel = require('async/parallel')
const pathUtils = require('path') const pathUtils = require('path')
const mongoose = require('mongoose') const mongoose = require('mongoose')
@ -90,7 +91,7 @@ VideoSchema.pre('remove', function (next) {
) )
} }
async.parallel(tasks, next) parallel(tasks, next)
}) })
VideoSchema.pre('save', function (next) { VideoSchema.pre('save', function (next) {
@ -110,7 +111,7 @@ VideoSchema.pre('save', function (next) {
} }
) )
async.parallel(tasks, function (err, results) { parallel(tasks, function (err, results) {
if (err) return next(err) if (err) return next(err)
video.magnetUri = results[0].magnetURI video.magnetUri = results[0].magnetURI
@ -234,7 +235,7 @@ function seedAllExisting (callback) {
listOwned.call(this, function (err, videos) { listOwned.call(this, function (err, videos) {
if (err) return callback(err) if (err) return callback(err)
async.each(videos, function (video, callbackEach) { each(videos, function (video, callbackEach) {
const videoPath = pathUtils.join(uploadsDir, video.filename) const videoPath = pathUtils.join(uploadsDir, video.filename)
seed(videoPath, callbackEach) seed(videoPath, callbackEach)
}, callback) }, callback)
@ -246,7 +247,7 @@ function seedAllExisting (callback) {
function findWithCount (query, start, count, sort, callback) { function findWithCount (query, start, count, sort, callback) {
const self = this const self = this
async.parallel([ parallel([
function (asyncCallback) { function (asyncCallback) {
self.find(query).skip(start).limit(count).sort(sort).exec(asyncCallback) self.find(query).skip(start).limit(count).sort(sort).exec(asyncCallback)
}, },

View File

@ -1,10 +1,10 @@
'use strict' 'use strict'
const async = require('async')
const chai = require('chai') const chai = require('chai')
const expect = chai.expect const expect = chai.expect
const pathUtils = require('path') const pathUtils = require('path')
const request = require('supertest') const request = require('supertest')
const series = require('async/series')
const utils = require('./utils') const utils = require('./utils')
@ -57,7 +57,7 @@ describe('Test parameters validator', function () {
before(function (done) { before(function (done) {
this.timeout(20000) this.timeout(20000)
async.series([ series([
function (next) { function (next) {
utils.flushTests(next) utils.flushTests(next)
}, },

View File

@ -1,8 +1,9 @@
'use strict' 'use strict'
const async = require('async')
const chai = require('chai') const chai = require('chai')
const each = require('async/each')
const expect = chai.expect const expect = chai.expect
const series = require('async/series')
const utils = require('./utils') const utils = require('./utils')
@ -45,7 +46,7 @@ describe('Test advanced friends', function () {
utils.flushAndRunMultipleServers(6, function (serversRun, urlsRun) { utils.flushAndRunMultipleServers(6, function (serversRun, urlsRun) {
servers = serversRun servers = serversRun
async.each(servers, function (server, callbackEach) { each(servers, function (server, callbackEach) {
utils.loginAndGetAccessToken(server, function (err, accessToken) { utils.loginAndGetAccessToken(server, function (err, accessToken) {
if (err) return callbackEach(err) if (err) return callbackEach(err)
@ -59,7 +60,7 @@ describe('Test advanced friends', function () {
it('Should make friends with two pod each in a different group', function (done) { it('Should make friends with two pod each in a different group', function (done) {
this.timeout(20000) this.timeout(20000)
async.series([ series([
// Pod 3 makes friend with the first one // Pod 3 makes friend with the first one
function (next) { function (next) {
makeFriends(3, next) makeFriends(3, next)
@ -93,7 +94,7 @@ describe('Test advanced friends', function () {
it('Should quit all friends', function (done) { it('Should quit all friends', function (done) {
this.timeout(10000) this.timeout(10000)
async.series([ series([
function (next) { function (next) {
quitFriends(1, next) quitFriends(1, next)
}, },
@ -103,7 +104,7 @@ describe('Test advanced friends', function () {
function (err) { function (err) {
if (err) throw err if (err) throw err
async.each([ 1, 2, 3, 4, 5, 6 ], function (i, callback) { each([ 1, 2, 3, 4, 5, 6 ], function (i, callback) {
getFriendsList(i, function (err, res) { getFriendsList(i, function (err, res) {
if (err) throw err if (err) throw err
@ -119,7 +120,7 @@ describe('Test advanced friends', function () {
it('Should make friends with the pods 1, 2, 3', function (done) { it('Should make friends with the pods 1, 2, 3', function (done) {
this.timeout(150000) this.timeout(150000)
async.series([ series([
// Pods 1, 2, 3 and 4 become friends // Pods 1, 2, 3 and 4 become friends
function (next) { function (next) {
makeFriends(2, next) makeFriends(2, next)
@ -132,7 +133,7 @@ describe('Test advanced friends', function () {
}, },
// Check the pods 1, 2, 3 and 4 are friends // Check the pods 1, 2, 3 and 4 are friends
function (next) { function (next) {
async.each([ 1, 2, 3, 4 ], function (i, callback) { each([ 1, 2, 3, 4 ], function (i, callback) {
getFriendsList(i, function (err, res) { getFriendsList(i, function (err, res) {
if (err) throw err if (err) throw err
@ -211,7 +212,7 @@ describe('Test advanced friends', function () {
it('Should pod 1 quit friends', function (done) { it('Should pod 1 quit friends', function (done) {
this.timeout(25000) this.timeout(25000)
async.series([ series([
// Upload a video on server 3 for aditionnal tests // Upload a video on server 3 for aditionnal tests
function (next) { function (next) {
uploadVideo(3, next) uploadVideo(3, next)

View File

@ -1,8 +1,9 @@
'use strict' 'use strict'
const async = require('async')
const chai = require('chai') const chai = require('chai')
const each = require('async/each')
const expect = chai.expect const expect = chai.expect
const series = require('async/series')
const utils = require('./utils') const utils = require('./utils')
@ -45,7 +46,7 @@ describe('Test basic friends', function () {
utils.flushAndRunMultipleServers(3, function (serversRun, urlsRun) { utils.flushAndRunMultipleServers(3, function (serversRun, urlsRun) {
servers = serversRun servers = serversRun
async.each(servers, function (server, callbackEach) { each(servers, function (server, callbackEach) {
utils.loginAndGetAccessToken(server, function (err, accessToken) { utils.loginAndGetAccessToken(server, function (err, accessToken) {
if (err) return callbackEach(err) if (err) return callbackEach(err)
@ -57,7 +58,7 @@ describe('Test basic friends', function () {
}) })
it('Should not have friends', function (done) { it('Should not have friends', function (done) {
async.each(servers, function (server, callback) { each(servers, function (server, callback) {
utils.getFriendsList(server.url, function (err, res) { utils.getFriendsList(server.url, function (err, res) {
if (err) throw err if (err) throw err
@ -72,7 +73,7 @@ describe('Test basic friends', function () {
it('Should make friends', function (done) { it('Should make friends', function (done) {
this.timeout(10000) this.timeout(10000)
async.series([ series([
// The second pod make friend with the third // The second pod make friend with the third
function (next) { function (next) {
makeFriends(2, next) makeFriends(2, next)
@ -119,7 +120,7 @@ describe('Test basic friends', function () {
// Now each pod should be friend with the other ones // Now each pod should be friend with the other ones
function (err) { function (err) {
if (err) throw err if (err) throw err
async.each(servers, function (server, callback) { each(servers, function (server, callback) {
testMadeFriends(servers, server, callback) testMadeFriends(servers, server, callback)
}, done) }, done)
}) })
@ -131,7 +132,7 @@ describe('Test basic friends', function () {
}) })
it('Should quit friends of pod 2', function (done) { it('Should quit friends of pod 2', function (done) {
async.series([ series([
// Pod 1 quit friends // Pod 1 quit friends
function (next) { function (next) {
const server = servers[1] const server = servers[1]
@ -151,7 +152,7 @@ describe('Test basic friends', function () {
}, },
// Other pods shouldn't have pod 1 too // Other pods shouldn't have pod 1 too
function (next) { function (next) {
async.each([ servers[0].url, servers[2].url ], function (url, callback) { each([ servers[0].url, servers[2].url ], function (url, callback) {
utils.getFriendsList(url, function (err, res) { utils.getFriendsList(url, function (err, res) {
if (err) throw err if (err) throw err
@ -169,7 +170,7 @@ describe('Test basic friends', function () {
it('Should allow pod 2 to make friend again', function (done) { it('Should allow pod 2 to make friend again', function (done) {
const server = servers[1] const server = servers[1]
utils.makeFriends(server.url, server.accessToken, function () { utils.makeFriends(server.url, server.accessToken, function () {
async.each(servers, function (server, callback) { each(servers, function (server, callback) {
testMadeFriends(servers, server, callback) testMadeFriends(servers, server, callback)
}, done) }, done)
}) })

View File

@ -1,9 +1,10 @@
'use strict' 'use strict'
const async = require('async')
const chai = require('chai') const chai = require('chai')
const each = require('async/each')
const expect = chai.expect const expect = chai.expect
const pathUtils = require('path') const pathUtils = require('path')
const series = require('async/series')
const utils = require('./utils') const utils = require('./utils')
const webtorrent = require(pathUtils.join(__dirname, '../../lib/webtorrent')) const webtorrent = require(pathUtils.join(__dirname, '../../lib/webtorrent'))
@ -16,7 +17,7 @@ describe('Test multiple pods', function () {
before(function (done) { before(function (done) {
this.timeout(30000) this.timeout(30000)
async.series([ series([
// Run servers // Run servers
function (next) { function (next) {
utils.flushAndRunMultipleServers(3, function (serversRun) { utils.flushAndRunMultipleServers(3, function (serversRun) {
@ -26,7 +27,7 @@ describe('Test multiple pods', function () {
}, },
// Get the access tokens // Get the access tokens
function (next) { function (next) {
async.each(servers, function (server, callbackEach) { each(servers, function (server, callbackEach) {
utils.loginAndGetAccessToken(server, function (err, accessToken) { utils.loginAndGetAccessToken(server, function (err, accessToken) {
if (err) return callbackEach(err) if (err) return callbackEach(err)
@ -56,7 +57,7 @@ describe('Test multiple pods', function () {
}) })
it('Should not have videos for all pods', function (done) { it('Should not have videos for all pods', function (done) {
async.each(servers, function (server, callback) { each(servers, function (server, callback) {
utils.getVideosList(server.url, function (err, res) { utils.getVideosList(server.url, function (err, res) {
if (err) throw err if (err) throw err
@ -73,7 +74,7 @@ describe('Test multiple pods', function () {
it('Should upload the video on pod 1 and propagate on each pod', function (done) { it('Should upload the video on pod 1 and propagate on each pod', function (done) {
this.timeout(15000) this.timeout(15000)
async.series([ series([
function (next) { function (next) {
const name = 'my super name for pod 1' const name = 'my super name for pod 1'
const description = 'my super description for pod 1' const description = 'my super description for pod 1'
@ -88,7 +89,7 @@ describe('Test multiple pods', function () {
function (err) { function (err) {
if (err) throw err if (err) throw err
async.each(servers, function (server, callback) { each(servers, function (server, callback) {
let baseMagnet = null let baseMagnet = null
utils.getVideosList(server.url, function (err, res) { utils.getVideosList(server.url, function (err, res) {
@ -135,7 +136,7 @@ describe('Test multiple pods', function () {
it('Should upload the video on pod 2 and propagate on each pod', function (done) { it('Should upload the video on pod 2 and propagate on each pod', function (done) {
this.timeout(15000) this.timeout(15000)
async.series([ series([
function (next) { function (next) {
const name = 'my super name for pod 2' const name = 'my super name for pod 2'
const description = 'my super description for pod 2' const description = 'my super description for pod 2'
@ -150,7 +151,7 @@ describe('Test multiple pods', function () {
function (err) { function (err) {
if (err) throw err if (err) throw err
async.each(servers, function (server, callback) { each(servers, function (server, callback) {
let baseMagnet = null let baseMagnet = null
utils.getVideosList(server.url, function (err, res) { utils.getVideosList(server.url, function (err, res) {
@ -197,7 +198,7 @@ describe('Test multiple pods', function () {
it('Should upload two videos on pod 3 and propagate on each pod', function (done) { it('Should upload two videos on pod 3 and propagate on each pod', function (done) {
this.timeout(30000) this.timeout(30000)
async.series([ series([
function (next) { function (next) {
const name = 'my super name for pod 3' const name = 'my super name for pod 3'
const description = 'my super description for pod 3' const description = 'my super description for pod 3'
@ -220,7 +221,7 @@ describe('Test multiple pods', function () {
let baseMagnet = null let baseMagnet = null
// All pods should have this video // All pods should have this video
async.each(servers, function (server, callback) { each(servers, function (server, callback) {
utils.getVideosList(server.url, function (err, res) { utils.getVideosList(server.url, function (err, res) {
if (err) throw err if (err) throw err
@ -372,7 +373,7 @@ describe('Test multiple pods', function () {
it('Should remove the file 3 and 3-2 by asking pod 3', function (done) { it('Should remove the file 3 and 3-2 by asking pod 3', function (done) {
this.timeout(15000) this.timeout(15000)
async.series([ series([
function (next) { function (next) {
utils.removeVideo(servers[2].url, servers[2].accessToken, toRemove[0], next) utils.removeVideo(servers[2].url, servers[2].accessToken, toRemove[0], next)
}, },
@ -387,7 +388,7 @@ describe('Test multiple pods', function () {
}) })
it('Should have videos 1 and 3 on each pod', function (done) { it('Should have videos 1 and 3 on each pod', function (done) {
async.each(servers, function (server, callback) { each(servers, function (server, callback) {
utils.getVideosList(server.url, function (err, res) { utils.getVideosList(server.url, function (err, res) {
if (err) throw err if (err) throw err

View File

@ -1,11 +1,12 @@
'use strict' 'use strict'
const async = require('async')
const chai = require('chai') const chai = require('chai')
const each = require('async/each')
const expect = chai.expect const expect = chai.expect
const fs = require('fs') const fs = require('fs')
const keyBy = require('lodash/keyBy') const keyBy = require('lodash/keyBy')
const pathUtils = require('path') const pathUtils = require('path')
const series = require('async/series')
const webtorrent = require(pathUtils.join(__dirname, '../../lib/webtorrent')) const webtorrent = require(pathUtils.join(__dirname, '../../lib/webtorrent'))
webtorrent.silent = true webtorrent.silent = true
@ -20,7 +21,7 @@ describe('Test a single pod', function () {
before(function (done) { before(function (done) {
this.timeout(20000) this.timeout(20000)
async.series([ series([
function (next) { function (next) {
utils.flushTests(next) utils.flushTests(next)
}, },
@ -280,7 +281,7 @@ describe('Test a single pod', function () {
'video_short.mp4', 'video_short.ogv', 'video_short.webm', 'video_short.mp4', 'video_short.ogv', 'video_short.webm',
'video_short1.webm', 'video_short2.webm', 'video_short3.webm' 'video_short1.webm', 'video_short2.webm', 'video_short3.webm'
] ]
async.each(videos, function (video, callbackEach) { each(videos, function (video, callbackEach) {
const name = video + ' name' const name = video + ' name'
const description = video + ' description' const description = video + ' description'
const tags = [ 'tag1', 'tag2', 'tag3' ] const tags = [ 'tag1', 'tag2', 'tag3' ]
@ -318,7 +319,7 @@ describe('Test a single pod', function () {
// For the next test // For the next test
videosListBase = videos videosListBase = videos
async.each(videos, function (video, callbackEach) { each(videos, function (video, callbackEach) {
if (err) throw err if (err) throw err
const videoName = video.name.replace(' name', '') const videoName = video.name.replace(' name', '')

View File

@ -1,9 +1,9 @@
'use strict' 'use strict'
const async = require('async')
const chai = require('chai') const chai = require('chai')
const expect = chai.expect const expect = chai.expect
const pathUtils = require('path') const pathUtils = require('path')
const series = require('async/series')
const webtorrent = require(pathUtils.join(__dirname, '../../lib/webtorrent')) const webtorrent = require(pathUtils.join(__dirname, '../../lib/webtorrent'))
webtorrent.silent = true webtorrent.silent = true
@ -18,7 +18,7 @@ describe('Test users', function () {
before(function (done) { before(function (done) {
this.timeout(20000) this.timeout(20000)
async.series([ series([
function (next) { function (next) {
utils.flushTests(next) utils.flushTests(next)
}, },

View File

@ -1,8 +1,9 @@
'use strict' 'use strict'
const async = require('async') const each = require('each')
const program = require('commander')
const isEqual = require('lodash/isEqual') const isEqual = require('lodash/isEqual')
const program = require('commander')
const series = require('async/series')
process.env.NODE_ENV = 'test' process.env.NODE_ENV = 'test'
const constants = require('../../initializers/constants') const constants = require('../../initializers/constants')
@ -93,7 +94,7 @@ function getRandomNumServer (servers) {
function runServers (numberOfPods, callback) { function runServers (numberOfPods, callback) {
let servers = null let servers = null
async.series([ series([
// Run servers // Run servers
function (next) { function (next) {
utils.flushAndRunMultipleServers(numberOfPods, function (serversRun) { utils.flushAndRunMultipleServers(numberOfPods, function (serversRun) {
@ -103,7 +104,7 @@ function runServers (numberOfPods, callback) {
}, },
// Get the access tokens // Get the access tokens
function (next) { function (next) {
async.each(servers, function (server, callbackEach) { each(servers, function (server, callbackEach) {
utils.loginAndGetAccessToken(server, function (err, accessToken) { utils.loginAndGetAccessToken(server, function (err, accessToken) {
if (err) return callbackEach(err) if (err) return callbackEach(err)
@ -184,7 +185,7 @@ function remove (servers, numServer, callback) {
function checkIntegrity (servers, callback) { function checkIntegrity (servers, callback) {
const videos = [] const videos = []
async.each(servers, function (server, callback) { each(servers, function (server, callback) {
utils.getAllVideosListBy(server.url, function (err, res) { utils.getAllVideosListBy(server.url, function (err, res) {
if (err) throw err if (err) throw err
const serverVideos = res.body.data const serverVideos = res.body.data