aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--package.json3
-rw-r--r--server/controllers/api/v1/pods.js9
-rw-r--r--server/controllers/api/v1/remote.js7
-rw-r--r--server/controllers/api/v1/videos.js6
-rw-r--r--server/initializers/installer.js7
-rw-r--r--server/lib/friends.js15
-rw-r--r--server/models/request.js12
-rw-r--r--server/models/video.js11
-rw-r--r--server/tests/api/checkParams.js4
-rw-r--r--server/tests/api/friendsAdvanced.js17
-rw-r--r--server/tests/api/friendsBasic.js17
-rw-r--r--server/tests/api/multiplePods.js25
-rw-r--r--server/tests/api/singlePod.js9
-rw-r--r--server/tests/api/users.js4
-rw-r--r--server/tests/real-world/real-world.js11
15 files changed, 85 insertions, 72 deletions
diff --git a/package.json b/package.json
index d5f758f4d..9a0d4ecaa 100644
--- a/package.json
+++ b/package.json
@@ -34,7 +34,7 @@
34 "postinstall": "cd client && npm install" 34 "postinstall": "cd client && npm install"
35 }, 35 },
36 "dependencies": { 36 "dependencies": {
37 "async": "^1.2.1", 37 "async": "^2.0.0",
38 "bittorrent-tracker": "^8.0.0", 38 "bittorrent-tracker": "^8.0.0",
39 "body-parser": "^1.12.4", 39 "body-parser": "^1.12.4",
40 "concurrently": "^2.0.0", 40 "concurrently": "^2.0.0",
@@ -53,7 +53,6 @@
53 "morgan": "^1.5.3", 53 "morgan": "^1.5.3",
54 "multer": "^1.1.0", 54 "multer": "^1.1.0",
55 "node-ipc": "^8.0.0", 55 "node-ipc": "^8.0.0",
56 "node-sass": "^3.4.2",
57 "openssl-wrapper": "^0.3.4", 56 "openssl-wrapper": "^0.3.4",
58 "password-generator": "^2.0.2", 57 "password-generator": "^2.0.2",
59 "request": "^2.57.0", 58 "request": "^2.57.0",
diff --git a/server/controllers/api/v1/pods.js b/server/controllers/api/v1/pods.js
index 4413fbc1e..2bc761fef 100644
--- a/server/controllers/api/v1/pods.js
+++ b/server/controllers/api/v1/pods.js
@@ -1,8 +1,9 @@
1'use strict' 1'use strict'
2 2
3const async = require('async') 3const each = require('async/each')
4const express = require('express') 4const express = require('express')
5const mongoose = require('mongoose') 5const mongoose = require('mongoose')
6const waterfall = require('async/waterfall')
6 7
7const logger = require('../../../helpers/logger') 8const logger = require('../../../helpers/logger')
8const friends = require('../../../lib/friends') 9const friends = require('../../../lib/friends')
@@ -31,7 +32,7 @@ module.exports = router
31function addPods (req, res, next) { 32function addPods (req, res, next) {
32 const informations = req.body 33 const informations = req.body
33 34
34 async.waterfall([ 35 waterfall([
35 function addPod (callback) { 36 function addPod (callback) {
36 const pod = new Pod(informations) 37 const pod = new Pod(informations)
37 pod.save(function (err, podCreated) { 38 pod.save(function (err, podCreated) {
@@ -82,7 +83,7 @@ function makeFriends (req, res, next) {
82function removePods (req, res, next) { 83function removePods (req, res, next) {
83 const url = req.body.signature.url 84 const url = req.body.signature.url
84 85
85 async.waterfall([ 86 waterfall([
86 function loadPod (callback) { 87 function loadPod (callback) {
87 Pod.loadByUrl(url, callback) 88 Pod.loadByUrl(url, callback)
88 }, 89 },
@@ -106,7 +107,7 @@ function removePods (req, res, next) {
106 }, 107 },
107 108
108 function removeTheRemoteVideos (videosList, callback) { 109 function removeTheRemoteVideos (videosList, callback) {
109 async.each(videosList, function (video, callbackEach) { 110 each(videosList, function (video, callbackEach) {
110 video.remove(callbackEach) 111 video.remove(callbackEach)
111 }, callback) 112 }, callback)
112 } 113 }
diff --git a/server/controllers/api/v1/remote.js b/server/controllers/api/v1/remote.js
index 9c2ca86e0..f452986b8 100644
--- a/server/controllers/api/v1/remote.js
+++ b/server/controllers/api/v1/remote.js
@@ -1,6 +1,7 @@
1'use strict' 1'use strict'
2 2
3const async = require('async') 3const each = require('async/each')
4const eachSeries = require('async/eachSeries')
4const express = require('express') 5const express = require('express')
5const mongoose = require('mongoose') 6const mongoose = require('mongoose')
6 7
@@ -32,7 +33,7 @@ function remoteVideos (req, res, next) {
32 33
33 // We need to process in the same order to keep consistency 34 // We need to process in the same order to keep consistency
34 // TODO: optimization 35 // TODO: optimization
35 async.eachSeries(requests, function (request, callbackEach) { 36 eachSeries(requests, function (request, callbackEach) {
36 const videoData = request.data 37 const videoData = request.data
37 38
38 if (request.type === 'add') { 39 if (request.type === 'add') {
@@ -72,7 +73,7 @@ function removeRemoteVideo (videoToRemoveData, fromUrl, callback) {
72 logger.error('No remote video was found for this pod.', { magnetUri: videoToRemoveData.magnetUri, podUrl: fromUrl }) 73 logger.error('No remote video was found for this pod.', { magnetUri: videoToRemoveData.magnetUri, podUrl: fromUrl })
73 } 74 }
74 75
75 async.each(videosList, function (video, callbackEach) { 76 each(videosList, function (video, callbackEach) {
76 logger.debug('Removing remote video %s.', video.magnetUri) 77 logger.debug('Removing remote video %s.', video.magnetUri)
77 78
78 video.remove(callbackEach) 79 video.remove(callbackEach)
diff --git a/server/controllers/api/v1/videos.js b/server/controllers/api/v1/videos.js
index a37e9278e..1f939b077 100644
--- a/server/controllers/api/v1/videos.js
+++ b/server/controllers/api/v1/videos.js
@@ -1,10 +1,10 @@
1'use strict' 1'use strict'
2 2
3const async = require('async')
4const config = require('config') 3const config = require('config')
5const express = require('express') 4const express = require('express')
6const mongoose = require('mongoose') 5const mongoose = require('mongoose')
7const multer = require('multer') 6const multer = require('multer')
7const waterfall = require('async/waterfall')
8 8
9const logger = require('../../../helpers/logger') 9const logger = require('../../../helpers/logger')
10const friends = require('../../../lib/friends') 10const friends = require('../../../lib/friends')
@@ -85,7 +85,7 @@ function addVideo (req, res, next) {
85 const videoFile = req.files.videofile[0] 85 const videoFile = req.files.videofile[0]
86 const videoInfos = req.body 86 const videoInfos = req.body
87 87
88 async.waterfall([ 88 waterfall([
89 89
90 function insertIntoDB (callback) { 90 function insertIntoDB (callback) {
91 const videoData = { 91 const videoData = {
@@ -152,7 +152,7 @@ function listVideos (req, res, next) {
152function removeVideo (req, res, next) { 152function removeVideo (req, res, next) {
153 const videoId = req.params.id 153 const videoId = req.params.id
154 154
155 async.waterfall([ 155 waterfall([
156 function getVideo (callback) { 156 function getVideo (callback) {
157 Video.load(videoId, callback) 157 Video.load(videoId, callback)
158 }, 158 },
diff --git a/server/initializers/installer.js b/server/initializers/installer.js
index 014efbcb7..490084104 100644
--- a/server/initializers/installer.js
+++ b/server/initializers/installer.js
@@ -1,11 +1,12 @@
1'use strict' 1'use strict'
2 2
3const async = require('async')
4const config = require('config') 3const config = require('config')
4const each = require('async/each')
5const mkdirp = require('mkdirp') 5const mkdirp = require('mkdirp')
6const mongoose = require('mongoose') 6const mongoose = require('mongoose')
7const passwordGenerator = require('password-generator') 7const passwordGenerator = require('password-generator')
8const path = require('path') 8const path = require('path')
9const series = require('async/series')
9 10
10const checker = require('./checker') 11const checker = require('./checker')
11const logger = require('../helpers/logger') 12const logger = require('../helpers/logger')
@@ -19,7 +20,7 @@ const installer = {
19} 20}
20 21
21function installApplication (callback) { 22function installApplication (callback) {
22 async.series([ 23 series([
23 function createDirectories (callbackAsync) { 24 function createDirectories (callbackAsync) {
24 createDirectoriesIfNotExist(callbackAsync) 25 createDirectoriesIfNotExist(callbackAsync)
25 }, 26 },
@@ -47,7 +48,7 @@ module.exports = installer
47function createDirectoriesIfNotExist (callback) { 48function createDirectoriesIfNotExist (callback) {
48 const storages = config.get('storage') 49 const storages = config.get('storage')
49 50
50 async.each(Object.keys(storages), function (key, callbackEach) { 51 each(Object.keys(storages), function (key, callbackEach) {
51 const dir = storages[key] 52 const dir = storages[key]
52 mkdirp(path.join(__dirname, '..', '..', dir), callbackEach) 53 mkdirp(path.join(__dirname, '..', '..', dir), callbackEach)
53 }, callback) 54 }, callback)
diff --git a/server/lib/friends.js b/server/lib/friends.js
index a85f4e19a..6e1516b94 100644
--- a/server/lib/friends.js
+++ b/server/lib/friends.js
@@ -1,10 +1,13 @@
1'use strict' 1'use strict'
2 2
3const async = require('async')
4const config = require('config') 3const config = require('config')
4const each = require('async/each')
5const eachLimit = require('async/eachLimit')
6const eachSeries = require('async/eachSeries')
5const fs = require('fs') 7const fs = require('fs')
6const mongoose = require('mongoose') 8const mongoose = require('mongoose')
7const request = require('request') 9const request = require('request')
10const waterfall = require('async/waterfall')
8 11
9const constants = require('../initializers/constants') 12const constants = require('../initializers/constants')
10const logger = require('../helpers/logger') 13const logger = require('../helpers/logger')
@@ -57,7 +60,7 @@ function makeFriends (callback) {
57 60
58 const urls = config.get('network.friends') 61 const urls = config.get('network.friends')
59 62
60 async.eachSeries(urls, function (url, callbackEach) { 63 eachSeries(urls, function (url, callbackEach) {
61 computeForeignPodsList(url, podsScore, callbackEach) 64 computeForeignPodsList(url, podsScore, callbackEach)
62 }, function (err) { 65 }, function (err) {
63 if (err) return callback(err) 66 if (err) return callback(err)
@@ -77,7 +80,7 @@ function quitFriends (callback) {
77 // Flush pool requests 80 // Flush pool requests
78 Request.flush() 81 Request.flush()
79 82
80 async.waterfall([ 83 waterfall([
81 function getPodsList (callbackAsync) { 84 function getPodsList (callbackAsync) {
82 return Pod.list(callbackAsync) 85 return Pod.list(callbackAsync)
83 }, 86 },
@@ -92,7 +95,7 @@ function quitFriends (callback) {
92 // Announce we quit them 95 // Announce we quit them
93 // We don't care if the request fails 96 // We don't care if the request fails
94 // The other pod will exclude us automatically after a while 97 // The other pod will exclude us automatically after a while
95 async.eachLimit(pods, constants.REQUESTS_IN_PARALLEL, function (pod, callbackEach) { 98 eachLimit(pods, constants.REQUESTS_IN_PARALLEL, function (pod, callbackEach) {
96 requestParams.toPod = pod 99 requestParams.toPod = pod
97 requests.makeSecureRequest(requestParams, callbackEach) 100 requests.makeSecureRequest(requestParams, callbackEach)
98 }, function (err) { 101 }, function (err) {
@@ -118,7 +121,7 @@ function quitFriends (callback) {
118 }, 121 },
119 122
120 function removeTheRemoteVideos (videosList, callbackAsync) { 123 function removeTheRemoteVideos (videosList, callbackAsync) {
121 async.each(videosList, function (video, callbackEach) { 124 each(videosList, function (video, callbackEach) {
122 video.remove(callbackEach) 125 video.remove(callbackEach)
123 }, callbackAsync) 126 }, callbackAsync)
124 } 127 }
@@ -212,7 +215,7 @@ function makeRequestsToWinningPods (cert, podsList, callback) {
212 // Flush pool requests 215 // Flush pool requests
213 Request.forceSend() 216 Request.forceSend()
214 217
215 async.eachLimit(podsList, constants.REQUESTS_IN_PARALLEL, function (pod, callbackEach) { 218 eachLimit(podsList, constants.REQUESTS_IN_PARALLEL, function (pod, callbackEach) {
216 const params = { 219 const params = {
217 url: pod.url + '/api/' + constants.API_VERSION + '/pods/', 220 url: pod.url + '/api/' + constants.API_VERSION + '/pods/',
218 method: 'POST', 221 method: 'POST',
diff --git a/server/models/request.js b/server/models/request.js
index 248ab3303..4d521919a 100644
--- a/server/models/request.js
+++ b/server/models/request.js
@@ -1,8 +1,10 @@
1'use strict' 1'use strict'
2 2
3const async = require('async') 3const each = require('async/each')
4const eachLimit = require('async/eachLimit')
4const map = require('lodash/map') 5const map = require('lodash/map')
5const mongoose = require('mongoose') 6const mongoose = require('mongoose')
7const waterfall = require('async/waterfall')
6 8
7const constants = require('../initializers/constants') 9const constants = require('../initializers/constants')
8const logger = require('../helpers/logger') 10const logger = require('../helpers/logger')
@@ -136,7 +138,7 @@ function makeRequests () {
136 const goodPods = [] 138 const goodPods = []
137 const badPods = [] 139 const badPods = []
138 140
139 async.eachLimit(Object.keys(requestsToMake), constants.REQUESTS_IN_PARALLEL, function (toPodId, callbackEach) { 141 eachLimit(Object.keys(requestsToMake), constants.REQUESTS_IN_PARALLEL, function (toPodId, callbackEach) {
140 const requestToMake = requestsToMake[toPodId] 142 const requestToMake = requestsToMake[toPodId]
141 143
142 // FIXME: mongodb request inside a loop :/ 144 // FIXME: mongodb request inside a loop :/
@@ -183,7 +185,7 @@ function makeRequests () {
183 185
184// Remove pods with a score of 0 (too many requests where they were unreachable) 186// Remove pods with a score of 0 (too many requests where they were unreachable)
185function removeBadPods () { 187function removeBadPods () {
186 async.waterfall([ 188 waterfall([
187 function findBadPods (callback) { 189 function findBadPods (callback) {
188 Pod.listBadPods(function (err, pods) { 190 Pod.listBadPods(function (err, pods) {
189 if (err) { 191 if (err) {
@@ -217,7 +219,7 @@ function removeBadPods () {
217 return callback(null) 219 return callback(null)
218 } 220 }
219 221
220 async.each(videosList, function (video, callbackEach) { 222 each(videosList, function (video, callbackEach) {
221 video.remove(callbackEach) 223 video.remove(callbackEach)
222 }, function (err) { 224 }, function (err) {
223 if (err) { 225 if (err) {
@@ -237,7 +239,7 @@ function removeBadPods () {
237 return callback(null) 239 return callback(null)
238 } 240 }
239 241
240 async.each(pods, function (pod, callbackEach) { 242 each(pods, function (pod, callbackEach) {
241 pod.remove(callbackEach) 243 pod.remove(callbackEach)
242 }, function (err) { 244 }, function (err) {
243 if (err) return callback(err) 245 if (err) return callback(err)
diff --git a/server/models/video.js b/server/models/video.js
index 8054caa77..98f43a06d 100644
--- a/server/models/video.js
+++ b/server/models/video.js
@@ -1,9 +1,10 @@
1'use strict' 1'use strict'
2 2
3const async = require('async')
4const config = require('config') 3const config = require('config')
4const each = require('async/each')
5const ffmpeg = require('fluent-ffmpeg') 5const ffmpeg = require('fluent-ffmpeg')
6const fs = require('fs') 6const fs = require('fs')
7const parallel = require('async/parallel')
7const pathUtils = require('path') 8const pathUtils = require('path')
8const mongoose = require('mongoose') 9const mongoose = require('mongoose')
9 10
@@ -90,7 +91,7 @@ VideoSchema.pre('remove', function (next) {
90 ) 91 )
91 } 92 }
92 93
93 async.parallel(tasks, next) 94 parallel(tasks, next)
94}) 95})
95 96
96VideoSchema.pre('save', function (next) { 97VideoSchema.pre('save', function (next) {
@@ -110,7 +111,7 @@ VideoSchema.pre('save', function (next) {
110 } 111 }
111 ) 112 )
112 113
113 async.parallel(tasks, function (err, results) { 114 parallel(tasks, function (err, results) {
114 if (err) return next(err) 115 if (err) return next(err)
115 116
116 video.magnetUri = results[0].magnetURI 117 video.magnetUri = results[0].magnetURI
@@ -234,7 +235,7 @@ function seedAllExisting (callback) {
234 listOwned.call(this, function (err, videos) { 235 listOwned.call(this, function (err, videos) {
235 if (err) return callback(err) 236 if (err) return callback(err)
236 237
237 async.each(videos, function (video, callbackEach) { 238 each(videos, function (video, callbackEach) {
238 const videoPath = pathUtils.join(uploadsDir, video.filename) 239 const videoPath = pathUtils.join(uploadsDir, video.filename)
239 seed(videoPath, callbackEach) 240 seed(videoPath, callbackEach)
240 }, callback) 241 }, callback)
@@ -246,7 +247,7 @@ function seedAllExisting (callback) {
246function findWithCount (query, start, count, sort, callback) { 247function findWithCount (query, start, count, sort, callback) {
247 const self = this 248 const self = this
248 249
249 async.parallel([ 250 parallel([
250 function (asyncCallback) { 251 function (asyncCallback) {
251 self.find(query).skip(start).limit(count).sort(sort).exec(asyncCallback) 252 self.find(query).skip(start).limit(count).sort(sort).exec(asyncCallback)
252 }, 253 },
diff --git a/server/tests/api/checkParams.js b/server/tests/api/checkParams.js
index 7f22a37cc..c1ba9c2c0 100644
--- a/server/tests/api/checkParams.js
+++ b/server/tests/api/checkParams.js
@@ -1,10 +1,10 @@
1'use strict' 1'use strict'
2 2
3const async = require('async')
4const chai = require('chai') 3const chai = require('chai')
5const expect = chai.expect 4const expect = chai.expect
6const pathUtils = require('path') 5const pathUtils = require('path')
7const request = require('supertest') 6const request = require('supertest')
7const series = require('async/series')
8 8
9const utils = require('./utils') 9const utils = require('./utils')
10 10
@@ -57,7 +57,7 @@ describe('Test parameters validator', function () {
57 before(function (done) { 57 before(function (done) {
58 this.timeout(20000) 58 this.timeout(20000)
59 59
60 async.series([ 60 series([
61 function (next) { 61 function (next) {
62 utils.flushTests(next) 62 utils.flushTests(next)
63 }, 63 },
diff --git a/server/tests/api/friendsAdvanced.js b/server/tests/api/friendsAdvanced.js
index b082270ff..603fbc16b 100644
--- a/server/tests/api/friendsAdvanced.js
+++ b/server/tests/api/friendsAdvanced.js
@@ -1,8 +1,9 @@
1'use strict' 1'use strict'
2 2
3const async = require('async')
4const chai = require('chai') 3const chai = require('chai')
4const each = require('async/each')
5const expect = chai.expect 5const expect = chai.expect
6const series = require('async/series')
6 7
7const utils = require('./utils') 8const utils = require('./utils')
8 9
@@ -45,7 +46,7 @@ describe('Test advanced friends', function () {
45 utils.flushAndRunMultipleServers(6, function (serversRun, urlsRun) { 46 utils.flushAndRunMultipleServers(6, function (serversRun, urlsRun) {
46 servers = serversRun 47 servers = serversRun
47 48
48 async.each(servers, function (server, callbackEach) { 49 each(servers, function (server, callbackEach) {
49 utils.loginAndGetAccessToken(server, function (err, accessToken) { 50 utils.loginAndGetAccessToken(server, function (err, accessToken) {
50 if (err) return callbackEach(err) 51 if (err) return callbackEach(err)
51 52
@@ -59,7 +60,7 @@ describe('Test advanced friends', function () {
59 it('Should make friends with two pod each in a different group', function (done) { 60 it('Should make friends with two pod each in a different group', function (done) {
60 this.timeout(20000) 61 this.timeout(20000)
61 62
62 async.series([ 63 series([
63 // Pod 3 makes friend with the first one 64 // Pod 3 makes friend with the first one
64 function (next) { 65 function (next) {
65 makeFriends(3, next) 66 makeFriends(3, next)
@@ -93,7 +94,7 @@ describe('Test advanced friends', function () {
93 it('Should quit all friends', function (done) { 94 it('Should quit all friends', function (done) {
94 this.timeout(10000) 95 this.timeout(10000)
95 96
96 async.series([ 97 series([
97 function (next) { 98 function (next) {
98 quitFriends(1, next) 99 quitFriends(1, next)
99 }, 100 },
@@ -103,7 +104,7 @@ describe('Test advanced friends', function () {
103 function (err) { 104 function (err) {
104 if (err) throw err 105 if (err) throw err
105 106
106 async.each([ 1, 2, 3, 4, 5, 6 ], function (i, callback) { 107 each([ 1, 2, 3, 4, 5, 6 ], function (i, callback) {
107 getFriendsList(i, function (err, res) { 108 getFriendsList(i, function (err, res) {
108 if (err) throw err 109 if (err) throw err
109 110
@@ -119,7 +120,7 @@ describe('Test advanced friends', function () {
119 it('Should make friends with the pods 1, 2, 3', function (done) { 120 it('Should make friends with the pods 1, 2, 3', function (done) {
120 this.timeout(150000) 121 this.timeout(150000)
121 122
122 async.series([ 123 series([
123 // Pods 1, 2, 3 and 4 become friends 124 // Pods 1, 2, 3 and 4 become friends
124 function (next) { 125 function (next) {
125 makeFriends(2, next) 126 makeFriends(2, next)
@@ -132,7 +133,7 @@ describe('Test advanced friends', function () {
132 }, 133 },
133 // Check the pods 1, 2, 3 and 4 are friends 134 // Check the pods 1, 2, 3 and 4 are friends
134 function (next) { 135 function (next) {
135 async.each([ 1, 2, 3, 4 ], function (i, callback) { 136 each([ 1, 2, 3, 4 ], function (i, callback) {
136 getFriendsList(i, function (err, res) { 137 getFriendsList(i, function (err, res) {
137 if (err) throw err 138 if (err) throw err
138 139
@@ -211,7 +212,7 @@ describe('Test advanced friends', function () {
211 it('Should pod 1 quit friends', function (done) { 212 it('Should pod 1 quit friends', function (done) {
212 this.timeout(25000) 213 this.timeout(25000)
213 214
214 async.series([ 215 series([
215 // Upload a video on server 3 for aditionnal tests 216 // Upload a video on server 3 for aditionnal tests
216 function (next) { 217 function (next) {
217 uploadVideo(3, next) 218 uploadVideo(3, next)
diff --git a/server/tests/api/friendsBasic.js b/server/tests/api/friendsBasic.js
index 5b738ad39..c74a7f224 100644
--- a/server/tests/api/friendsBasic.js
+++ b/server/tests/api/friendsBasic.js
@@ -1,8 +1,9 @@
1'use strict' 1'use strict'
2 2
3const async = require('async')
4const chai = require('chai') 3const chai = require('chai')
4const each = require('async/each')
5const expect = chai.expect 5const expect = chai.expect
6const series = require('async/series')
6 7
7const utils = require('./utils') 8const utils = require('./utils')
8 9
@@ -45,7 +46,7 @@ describe('Test basic friends', function () {
45 utils.flushAndRunMultipleServers(3, function (serversRun, urlsRun) { 46 utils.flushAndRunMultipleServers(3, function (serversRun, urlsRun) {
46 servers = serversRun 47 servers = serversRun
47 48
48 async.each(servers, function (server, callbackEach) { 49 each(servers, function (server, callbackEach) {
49 utils.loginAndGetAccessToken(server, function (err, accessToken) { 50 utils.loginAndGetAccessToken(server, function (err, accessToken) {
50 if (err) return callbackEach(err) 51 if (err) return callbackEach(err)
51 52
@@ -57,7 +58,7 @@ describe('Test basic friends', function () {
57 }) 58 })
58 59
59 it('Should not have friends', function (done) { 60 it('Should not have friends', function (done) {
60 async.each(servers, function (server, callback) { 61 each(servers, function (server, callback) {
61 utils.getFriendsList(server.url, function (err, res) { 62 utils.getFriendsList(server.url, function (err, res) {
62 if (err) throw err 63 if (err) throw err
63 64
@@ -72,7 +73,7 @@ describe('Test basic friends', function () {
72 it('Should make friends', function (done) { 73 it('Should make friends', function (done) {
73 this.timeout(10000) 74 this.timeout(10000)
74 75
75 async.series([ 76 series([
76 // The second pod make friend with the third 77 // The second pod make friend with the third
77 function (next) { 78 function (next) {
78 makeFriends(2, next) 79 makeFriends(2, next)
@@ -119,7 +120,7 @@ describe('Test basic friends', function () {
119 // Now each pod should be friend with the other ones 120 // Now each pod should be friend with the other ones
120 function (err) { 121 function (err) {
121 if (err) throw err 122 if (err) throw err
122 async.each(servers, function (server, callback) { 123 each(servers, function (server, callback) {
123 testMadeFriends(servers, server, callback) 124 testMadeFriends(servers, server, callback)
124 }, done) 125 }, done)
125 }) 126 })
@@ -131,7 +132,7 @@ describe('Test basic friends', function () {
131 }) 132 })
132 133
133 it('Should quit friends of pod 2', function (done) { 134 it('Should quit friends of pod 2', function (done) {
134 async.series([ 135 series([
135 // Pod 1 quit friends 136 // Pod 1 quit friends
136 function (next) { 137 function (next) {
137 const server = servers[1] 138 const server = servers[1]
@@ -151,7 +152,7 @@ describe('Test basic friends', function () {
151 }, 152 },
152 // Other pods shouldn't have pod 1 too 153 // Other pods shouldn't have pod 1 too
153 function (next) { 154 function (next) {
154 async.each([ servers[0].url, servers[2].url ], function (url, callback) { 155 each([ servers[0].url, servers[2].url ], function (url, callback) {
155 utils.getFriendsList(url, function (err, res) { 156 utils.getFriendsList(url, function (err, res) {
156 if (err) throw err 157 if (err) throw err
157 158
@@ -169,7 +170,7 @@ describe('Test basic friends', function () {
169 it('Should allow pod 2 to make friend again', function (done) { 170 it('Should allow pod 2 to make friend again', function (done) {
170 const server = servers[1] 171 const server = servers[1]
171 utils.makeFriends(server.url, server.accessToken, function () { 172 utils.makeFriends(server.url, server.accessToken, function () {
172 async.each(servers, function (server, callback) { 173 each(servers, function (server, callback) {
173 testMadeFriends(servers, server, callback) 174 testMadeFriends(servers, server, callback)
174 }, done) 175 }, done)
175 }) 176 })
diff --git a/server/tests/api/multiplePods.js b/server/tests/api/multiplePods.js
index 2a1bc64e6..ac140f6bb 100644
--- a/server/tests/api/multiplePods.js
+++ b/server/tests/api/multiplePods.js
@@ -1,9 +1,10 @@
1'use strict' 1'use strict'
2 2
3const async = require('async')
4const chai = require('chai') 3const chai = require('chai')
4const each = require('async/each')
5const expect = chai.expect 5const expect = chai.expect
6const pathUtils = require('path') 6const pathUtils = require('path')
7const series = require('async/series')
7 8
8const utils = require('./utils') 9const utils = require('./utils')
9const webtorrent = require(pathUtils.join(__dirname, '../../lib/webtorrent')) 10const webtorrent = require(pathUtils.join(__dirname, '../../lib/webtorrent'))
@@ -16,7 +17,7 @@ describe('Test multiple pods', function () {
16 before(function (done) { 17 before(function (done) {
17 this.timeout(30000) 18 this.timeout(30000)
18 19
19 async.series([ 20 series([
20 // Run servers 21 // Run servers
21 function (next) { 22 function (next) {
22 utils.flushAndRunMultipleServers(3, function (serversRun) { 23 utils.flushAndRunMultipleServers(3, function (serversRun) {
@@ -26,7 +27,7 @@ describe('Test multiple pods', function () {
26 }, 27 },
27 // Get the access tokens 28 // Get the access tokens
28 function (next) { 29 function (next) {
29 async.each(servers, function (server, callbackEach) { 30 each(servers, function (server, callbackEach) {
30 utils.loginAndGetAccessToken(server, function (err, accessToken) { 31 utils.loginAndGetAccessToken(server, function (err, accessToken) {
31 if (err) return callbackEach(err) 32 if (err) return callbackEach(err)
32 33
@@ -56,7 +57,7 @@ describe('Test multiple pods', function () {
56 }) 57 })
57 58
58 it('Should not have videos for all pods', function (done) { 59 it('Should not have videos for all pods', function (done) {
59 async.each(servers, function (server, callback) { 60 each(servers, function (server, callback) {
60 utils.getVideosList(server.url, function (err, res) { 61 utils.getVideosList(server.url, function (err, res) {
61 if (err) throw err 62 if (err) throw err
62 63
@@ -73,7 +74,7 @@ describe('Test multiple pods', function () {
73 it('Should upload the video on pod 1 and propagate on each pod', function (done) { 74 it('Should upload the video on pod 1 and propagate on each pod', function (done) {
74 this.timeout(15000) 75 this.timeout(15000)
75 76
76 async.series([ 77 series([
77 function (next) { 78 function (next) {
78 const name = 'my super name for pod 1' 79 const name = 'my super name for pod 1'
79 const description = 'my super description for pod 1' 80 const description = 'my super description for pod 1'
@@ -88,7 +89,7 @@ describe('Test multiple pods', function () {
88 function (err) { 89 function (err) {
89 if (err) throw err 90 if (err) throw err
90 91
91 async.each(servers, function (server, callback) { 92 each(servers, function (server, callback) {
92 let baseMagnet = null 93 let baseMagnet = null
93 94
94 utils.getVideosList(server.url, function (err, res) { 95 utils.getVideosList(server.url, function (err, res) {
@@ -135,7 +136,7 @@ describe('Test multiple pods', function () {
135 it('Should upload the video on pod 2 and propagate on each pod', function (done) { 136 it('Should upload the video on pod 2 and propagate on each pod', function (done) {
136 this.timeout(15000) 137 this.timeout(15000)
137 138
138 async.series([ 139 series([
139 function (next) { 140 function (next) {
140 const name = 'my super name for pod 2' 141 const name = 'my super name for pod 2'
141 const description = 'my super description for pod 2' 142 const description = 'my super description for pod 2'
@@ -150,7 +151,7 @@ describe('Test multiple pods', function () {
150 function (err) { 151 function (err) {
151 if (err) throw err 152 if (err) throw err
152 153
153 async.each(servers, function (server, callback) { 154 each(servers, function (server, callback) {
154 let baseMagnet = null 155 let baseMagnet = null
155 156
156 utils.getVideosList(server.url, function (err, res) { 157 utils.getVideosList(server.url, function (err, res) {
@@ -197,7 +198,7 @@ describe('Test multiple pods', function () {
197 it('Should upload two videos on pod 3 and propagate on each pod', function (done) { 198 it('Should upload two videos on pod 3 and propagate on each pod', function (done) {
198 this.timeout(30000) 199 this.timeout(30000)
199 200
200 async.series([ 201 series([
201 function (next) { 202 function (next) {
202 const name = 'my super name for pod 3' 203 const name = 'my super name for pod 3'
203 const description = 'my super description for pod 3' 204 const description = 'my super description for pod 3'
@@ -220,7 +221,7 @@ describe('Test multiple pods', function () {
220 221
221 let baseMagnet = null 222 let baseMagnet = null
222 // All pods should have this video 223 // All pods should have this video
223 async.each(servers, function (server, callback) { 224 each(servers, function (server, callback) {
224 utils.getVideosList(server.url, function (err, res) { 225 utils.getVideosList(server.url, function (err, res) {
225 if (err) throw err 226 if (err) throw err
226 227
@@ -372,7 +373,7 @@ describe('Test multiple pods', function () {
372 it('Should remove the file 3 and 3-2 by asking pod 3', function (done) { 373 it('Should remove the file 3 and 3-2 by asking pod 3', function (done) {
373 this.timeout(15000) 374 this.timeout(15000)
374 375
375 async.series([ 376 series([
376 function (next) { 377 function (next) {
377 utils.removeVideo(servers[2].url, servers[2].accessToken, toRemove[0], next) 378 utils.removeVideo(servers[2].url, servers[2].accessToken, toRemove[0], next)
378 }, 379 },
@@ -387,7 +388,7 @@ describe('Test multiple pods', function () {
387 }) 388 })
388 389
389 it('Should have videos 1 and 3 on each pod', function (done) { 390 it('Should have videos 1 and 3 on each pod', function (done) {
390 async.each(servers, function (server, callback) { 391 each(servers, function (server, callback) {
391 utils.getVideosList(server.url, function (err, res) { 392 utils.getVideosList(server.url, function (err, res) {
392 if (err) throw err 393 if (err) throw err
393 394
diff --git a/server/tests/api/singlePod.js b/server/tests/api/singlePod.js
index 465a86b13..6ed719f87 100644
--- a/server/tests/api/singlePod.js
+++ b/server/tests/api/singlePod.js
@@ -1,11 +1,12 @@
1'use strict' 1'use strict'
2 2
3const async = require('async')
4const chai = require('chai') 3const chai = require('chai')
4const each = require('async/each')
5const expect = chai.expect 5const expect = chai.expect
6const fs = require('fs') 6const fs = require('fs')
7const keyBy = require('lodash/keyBy') 7const keyBy = require('lodash/keyBy')
8const pathUtils = require('path') 8const pathUtils = require('path')
9const series = require('async/series')
9 10
10const webtorrent = require(pathUtils.join(__dirname, '../../lib/webtorrent')) 11const webtorrent = require(pathUtils.join(__dirname, '../../lib/webtorrent'))
11webtorrent.silent = true 12webtorrent.silent = true
@@ -20,7 +21,7 @@ describe('Test a single pod', function () {
20 before(function (done) { 21 before(function (done) {
21 this.timeout(20000) 22 this.timeout(20000)
22 23
23 async.series([ 24 series([
24 function (next) { 25 function (next) {
25 utils.flushTests(next) 26 utils.flushTests(next)
26 }, 27 },
@@ -280,7 +281,7 @@ describe('Test a single pod', function () {
280 'video_short.mp4', 'video_short.ogv', 'video_short.webm', 281 'video_short.mp4', 'video_short.ogv', 'video_short.webm',
281 'video_short1.webm', 'video_short2.webm', 'video_short3.webm' 282 'video_short1.webm', 'video_short2.webm', 'video_short3.webm'
282 ] 283 ]
283 async.each(videos, function (video, callbackEach) { 284 each(videos, function (video, callbackEach) {
284 const name = video + ' name' 285 const name = video + ' name'
285 const description = video + ' description' 286 const description = video + ' description'
286 const tags = [ 'tag1', 'tag2', 'tag3' ] 287 const tags = [ 'tag1', 'tag2', 'tag3' ]
@@ -318,7 +319,7 @@ describe('Test a single pod', function () {
318 // For the next test 319 // For the next test
319 videosListBase = videos 320 videosListBase = videos
320 321
321 async.each(videos, function (video, callbackEach) { 322 each(videos, function (video, callbackEach) {
322 if (err) throw err 323 if (err) throw err
323 const videoName = video.name.replace(' name', '') 324 const videoName = video.name.replace(' name', '')
324 325
diff --git a/server/tests/api/users.js b/server/tests/api/users.js
index 7ab426d85..749aa8af8 100644
--- a/server/tests/api/users.js
+++ b/server/tests/api/users.js
@@ -1,9 +1,9 @@
1'use strict' 1'use strict'
2 2
3const async = require('async')
4const chai = require('chai') 3const chai = require('chai')
5const expect = chai.expect 4const expect = chai.expect
6const pathUtils = require('path') 5const pathUtils = require('path')
6const series = require('async/series')
7 7
8const webtorrent = require(pathUtils.join(__dirname, '../../lib/webtorrent')) 8const webtorrent = require(pathUtils.join(__dirname, '../../lib/webtorrent'))
9webtorrent.silent = true 9webtorrent.silent = true
@@ -18,7 +18,7 @@ describe('Test users', function () {
18 before(function (done) { 18 before(function (done) {
19 this.timeout(20000) 19 this.timeout(20000)
20 20
21 async.series([ 21 series([
22 function (next) { 22 function (next) {
23 utils.flushTests(next) 23 utils.flushTests(next)
24 }, 24 },
diff --git a/server/tests/real-world/real-world.js b/server/tests/real-world/real-world.js
index bc6ea859b..b28796852 100644
--- a/server/tests/real-world/real-world.js
+++ b/server/tests/real-world/real-world.js
@@ -1,8 +1,9 @@
1'use strict' 1'use strict'
2 2
3const async = require('async') 3const each = require('each')
4const program = require('commander')
5const isEqual = require('lodash/isEqual') 4const isEqual = require('lodash/isEqual')
5const program = require('commander')
6const series = require('async/series')
6 7
7process.env.NODE_ENV = 'test' 8process.env.NODE_ENV = 'test'
8const constants = require('../../initializers/constants') 9const constants = require('../../initializers/constants')
@@ -93,7 +94,7 @@ function getRandomNumServer (servers) {
93function runServers (numberOfPods, callback) { 94function runServers (numberOfPods, callback) {
94 let servers = null 95 let servers = null
95 96
96 async.series([ 97 series([
97 // Run servers 98 // Run servers
98 function (next) { 99 function (next) {
99 utils.flushAndRunMultipleServers(numberOfPods, function (serversRun) { 100 utils.flushAndRunMultipleServers(numberOfPods, function (serversRun) {
@@ -103,7 +104,7 @@ function runServers (numberOfPods, callback) {
103 }, 104 },
104 // Get the access tokens 105 // Get the access tokens
105 function (next) { 106 function (next) {
106 async.each(servers, function (server, callbackEach) { 107 each(servers, function (server, callbackEach) {
107 utils.loginAndGetAccessToken(server, function (err, accessToken) { 108 utils.loginAndGetAccessToken(server, function (err, accessToken) {
108 if (err) return callbackEach(err) 109 if (err) return callbackEach(err)
109 110
@@ -184,7 +185,7 @@ function remove (servers, numServer, callback) {
184 185
185function checkIntegrity (servers, callback) { 186function checkIntegrity (servers, callback) {
186 const videos = [] 187 const videos = []
187 async.each(servers, function (server, callback) { 188 each(servers, function (server, callback) {
188 utils.getAllVideosListBy(server.url, function (err, res) { 189 utils.getAllVideosListBy(server.url, function (err, res) {
189 if (err) throw err 190 if (err) throw err
190 const serverVideos = res.body.data 191 const serverVideos = res.body.data