aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/multiplePods.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/multiplePods.js')
-rw-r--r--server/tests/api/multiplePods.js67
1 files changed, 38 insertions, 29 deletions
diff --git a/server/tests/api/multiplePods.js b/server/tests/api/multiplePods.js
index 0e2355a55..b6545ca60 100644
--- a/server/tests/api/multiplePods.js
+++ b/server/tests/api/multiplePods.js
@@ -10,8 +10,7 @@ const webtorrent = require(pathUtils.join(__dirname, '../../lib/webtorrent'))
10webtorrent.silent = true 10webtorrent.silent = true
11 11
12describe('Test multiple pods', function () { 12describe('Test multiple pods', function () {
13 let apps = [] 13 let servers = []
14 let urls = []
15 const to_remove = [] 14 const to_remove = []
16 15
17 before(function (done) { 16 before(function (done) {
@@ -20,15 +19,25 @@ describe('Test multiple pods', function () {
20 async.series([ 19 async.series([
21 // Run servers 20 // Run servers
22 function (next) { 21 function (next) {
23 utils.flushAndRunMultipleServers(3, function (apps_run, urls_run) { 22 utils.flushAndRunMultipleServers(3, function (servers_run) {
24 apps = apps_run 23 servers = servers_run
25 urls = urls_run
26 next() 24 next()
27 }) 25 })
28 }, 26 },
27 // Get the access tokens
28 function (next) {
29 async.each(servers, function (server, callback_each) {
30 utils.loginAndGetAccessToken(server, function (err, access_token) {
31 if (err) return callback_each(err)
32
33 server.access_token = access_token
34 callback_each()
35 })
36 }, next)
37 },
29 // The second pod make friend with the third 38 // The second pod make friend with the third
30 function (next) { 39 function (next) {
31 utils.makeFriends(urls[1], next) 40 utils.makeFriends(servers[1].url, next)
32 }, 41 },
33 // Wait for the request between pods 42 // Wait for the request between pods
34 function (next) { 43 function (next) {
@@ -36,7 +45,7 @@ describe('Test multiple pods', function () {
36 }, 45 },
37 // Pod 1 make friends too 46 // Pod 1 make friends too
38 function (next) { 47 function (next) {
39 utils.makeFriends(urls[0], next) 48 utils.makeFriends(servers[0].url, next)
40 }, 49 },
41 function (next) { 50 function (next) {
42 webtorrent.create({ host: 'client', port: '1' }, next) 51 webtorrent.create({ host: 'client', port: '1' }, next)
@@ -45,8 +54,8 @@ describe('Test multiple pods', function () {
45 }) 54 })
46 55
47 it('Should not have videos for all pods', function (done) { 56 it('Should not have videos for all pods', function (done) {
48 async.each(urls, function (url, callback) { 57 async.each(servers, function (server, callback) {
49 utils.getVideosList(url, function (err, res) { 58 utils.getVideosList(server.url, function (err, res) {
50 if (err) throw err 59 if (err) throw err
51 60
52 expect(res.body).to.be.an('array') 61 expect(res.body).to.be.an('array')
@@ -63,7 +72,7 @@ describe('Test multiple pods', function () {
63 72
64 async.series([ 73 async.series([
65 function (next) { 74 function (next) {
66 utils.uploadVideo(urls[0], 'my super name for pod 1', 'my super description for pod 1', 'video_short1.webm', next) 75 utils.uploadVideo(servers[0].url, servers[0].access_token, 'my super name for pod 1', 'my super description for pod 1', 'video_short1.webm', next)
67 }, 76 },
68 function (next) { 77 function (next) {
69 setTimeout(next, 11000) 78 setTimeout(next, 11000)
@@ -72,10 +81,10 @@ describe('Test multiple pods', function () {
72 function (err) { 81 function (err) {
73 if (err) throw err 82 if (err) throw err
74 83
75 async.each(urls, function (url, callback) { 84 async.each(servers, function (server, callback) {
76 let base_magnet = null 85 let base_magnet = null
77 86
78 utils.getVideosList(url, function (err, res) { 87 utils.getVideosList(server.url, function (err, res) {
79 if (err) throw err 88 if (err) throw err
80 89
81 const videos = res.body 90 const videos = res.body
@@ -106,7 +115,7 @@ describe('Test multiple pods', function () {
106 115
107 async.series([ 116 async.series([
108 function (next) { 117 function (next) {
109 utils.uploadVideo(urls[1], 'my super name for pod 2', 'my super description for pod 2', 'video_short2.webm', next) 118 utils.uploadVideo(servers[1].url, servers[1].access_token, 'my super name for pod 2', 'my super description for pod 2', 'video_short2.webm', next)
110 }, 119 },
111 function (next) { 120 function (next) {
112 setTimeout(next, 11000) 121 setTimeout(next, 11000)
@@ -115,10 +124,10 @@ describe('Test multiple pods', function () {
115 function (err) { 124 function (err) {
116 if (err) throw err 125 if (err) throw err
117 126
118 async.each(urls, function (url, callback) { 127 async.each(servers, function (server, callback) {
119 let base_magnet = null 128 let base_magnet = null
120 129
121 utils.getVideosList(url, function (err, res) { 130 utils.getVideosList(server.url, function (err, res) {
122 if (err) throw err 131 if (err) throw err
123 132
124 const videos = res.body 133 const videos = res.body
@@ -149,10 +158,10 @@ describe('Test multiple pods', function () {
149 158
150 async.series([ 159 async.series([
151 function (next) { 160 function (next) {
152 utils.uploadVideo(urls[2], 'my super name for pod 3', 'my super description for pod 3', 'video_short3.webm', next) 161 utils.uploadVideo(servers[2].url, servers[2].access_token, 'my super name for pod 3', 'my super description for pod 3', 'video_short3.webm', next)
153 }, 162 },
154 function (next) { 163 function (next) {
155 utils.uploadVideo(urls[2], 'my super name for pod 3-2', 'my super description for pod 3-2', 'video_short.webm', next) 164 utils.uploadVideo(servers[2].url, servers[2].access_token, 'my super name for pod 3-2', 'my super description for pod 3-2', 'video_short.webm', next)
156 }, 165 },
157 function (next) { 166 function (next) {
158 setTimeout(next, 22000) 167 setTimeout(next, 22000)
@@ -162,8 +171,8 @@ describe('Test multiple pods', function () {
162 171
163 let base_magnet = null 172 let base_magnet = null
164 // All pods should have this video 173 // All pods should have this video
165 async.each(urls, function (url, callback) { 174 async.each(servers, function (server, callback) {
166 utils.getVideosList(url, function (err, res) { 175 utils.getVideosList(server.url, function (err, res) {
167 if (err) throw err 176 if (err) throw err
168 177
169 const videos = res.body 178 const videos = res.body
@@ -201,7 +210,7 @@ describe('Test multiple pods', function () {
201 // Yes, this could be long 210 // Yes, this could be long
202 this.timeout(200000) 211 this.timeout(200000)
203 212
204 utils.getVideosList(urls[2], function (err, res) { 213 utils.getVideosList(servers[2].url, function (err, res) {
205 if (err) throw err 214 if (err) throw err
206 215
207 const video = res.body[0] 216 const video = res.body[0]
@@ -222,7 +231,7 @@ describe('Test multiple pods', function () {
222 // Yes, this could be long 231 // Yes, this could be long
223 this.timeout(200000) 232 this.timeout(200000)
224 233
225 utils.getVideosList(urls[0], function (err, res) { 234 utils.getVideosList(servers[0].url, function (err, res) {
226 if (err) throw err 235 if (err) throw err
227 236
228 const video = res.body[1] 237 const video = res.body[1]
@@ -241,7 +250,7 @@ describe('Test multiple pods', function () {
241 // Yes, this could be long 250 // Yes, this could be long
242 this.timeout(200000) 251 this.timeout(200000)
243 252
244 utils.getVideosList(urls[1], function (err, res) { 253 utils.getVideosList(servers[1].url, function (err, res) {
245 if (err) throw err 254 if (err) throw err
246 255
247 const video = res.body[2] 256 const video = res.body[2]
@@ -260,7 +269,7 @@ describe('Test multiple pods', function () {
260 // Yes, this could be long 269 // Yes, this could be long
261 this.timeout(200000) 270 this.timeout(200000)
262 271
263 utils.getVideosList(urls[0], function (err, res) { 272 utils.getVideosList(servers[0].url, function (err, res) {
264 if (err) throw err 273 if (err) throw err
265 274
266 const video = res.body[3] 275 const video = res.body[3]
@@ -280,10 +289,10 @@ describe('Test multiple pods', function () {
280 289
281 async.series([ 290 async.series([
282 function (next) { 291 function (next) {
283 utils.removeVideo(urls[2], to_remove[0], next) 292 utils.removeVideo(servers[2].url, servers[2].access_token, to_remove[0], next)
284 }, 293 },
285 function (next) { 294 function (next) {
286 utils.removeVideo(urls[2], to_remove[1], next) 295 utils.removeVideo(servers[2].url, servers[2].access_token, to_remove[1], next)
287 }], 296 }],
288 function (err) { 297 function (err) {
289 if (err) throw err 298 if (err) throw err
@@ -293,8 +302,8 @@ describe('Test multiple pods', function () {
293 }) 302 })
294 303
295 it('Should have videos 1 and 3 on each pod', function (done) { 304 it('Should have videos 1 and 3 on each pod', function (done) {
296 async.each(urls, function (url, callback) { 305 async.each(servers, function (server, callback) {
297 utils.getVideosList(url, function (err, res) { 306 utils.getVideosList(server.url, function (err, res) {
298 if (err) throw err 307 if (err) throw err
299 308
300 const videos = res.body 309 const videos = res.body
@@ -313,8 +322,8 @@ describe('Test multiple pods', function () {
313 }) 322 })
314 323
315 after(function (done) { 324 after(function (done) {
316 apps.forEach(function (app) { 325 servers.forEach(function (server) {
317 process.kill(-app.pid) 326 process.kill(-server.app.pid)
318 }) 327 })
319 process.kill(-webtorrent.app.pid) 328 process.kill(-webtorrent.app.pid)
320 329