aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/multiplePods.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-08-07 22:09:59 +0200
committerChocobozzz <florian.bigard@gmail.com>2016-08-07 22:09:59 +0200
commit8d30905858245f12a42fc327d2d57cbfe062d548 (patch)
tree9bd590872fbb753782f2ebbb9516db0414022d70 /server/tests/api/multiplePods.js
parent58b2ba55a90f05f24661e664b1fb0a3486f037e8 (diff)
downloadPeerTube-8d30905858245f12a42fc327d2d57cbfe062d548.tar.gz
PeerTube-8d30905858245f12a42fc327d2d57cbfe062d548.tar.zst
PeerTube-8d30905858245f12a42fc327d2d57cbfe062d548.zip
Server: split tests utils in multiple files
Diffstat (limited to 'server/tests/api/multiplePods.js')
-rw-r--r--server/tests/api/multiplePods.js62
1 files changed, 33 insertions, 29 deletions
diff --git a/server/tests/api/multiplePods.js b/server/tests/api/multiplePods.js
index ac140f6bb..b86f88c22 100644
--- a/server/tests/api/multiplePods.js
+++ b/server/tests/api/multiplePods.js
@@ -6,7 +6,11 @@ const expect = chai.expect
6const pathUtils = require('path') 6const pathUtils = require('path')
7const series = require('async/series') 7const series = require('async/series')
8 8
9const utils = require('./utils') 9const loginUtils = require('../utils/login')
10const miscsUtils = require('../utils/miscs')
11const podsUtils = require('../utils/pods')
12const serversUtils = require('../utils/servers')
13const videosUtils = require('../utils/videos')
10const webtorrent = require(pathUtils.join(__dirname, '../../lib/webtorrent')) 14const webtorrent = require(pathUtils.join(__dirname, '../../lib/webtorrent'))
11webtorrent.silent = true 15webtorrent.silent = true
12 16
@@ -20,7 +24,7 @@ describe('Test multiple pods', function () {
20 series([ 24 series([
21 // Run servers 25 // Run servers
22 function (next) { 26 function (next) {
23 utils.flushAndRunMultipleServers(3, function (serversRun) { 27 serversUtils.flushAndRunMultipleServers(3, function (serversRun) {
24 servers = serversRun 28 servers = serversRun
25 next() 29 next()
26 }) 30 })
@@ -28,7 +32,7 @@ describe('Test multiple pods', function () {
28 // Get the access tokens 32 // Get the access tokens
29 function (next) { 33 function (next) {
30 each(servers, function (server, callbackEach) { 34 each(servers, function (server, callbackEach) {
31 utils.loginAndGetAccessToken(server, function (err, accessToken) { 35 loginUtils.loginAndGetAccessToken(server, function (err, accessToken) {
32 if (err) return callbackEach(err) 36 if (err) return callbackEach(err)
33 37
34 server.accessToken = accessToken 38 server.accessToken = accessToken
@@ -39,7 +43,7 @@ describe('Test multiple pods', function () {
39 // The second pod make friend with the third 43 // The second pod make friend with the third
40 function (next) { 44 function (next) {
41 const server = servers[1] 45 const server = servers[1]
42 utils.makeFriends(server.url, server.accessToken, next) 46 podsUtils.makeFriends(server.url, server.accessToken, next)
43 }, 47 },
44 // Wait for the request between pods 48 // Wait for the request between pods
45 function (next) { 49 function (next) {
@@ -48,7 +52,7 @@ describe('Test multiple pods', function () {
48 // Pod 1 make friends too 52 // Pod 1 make friends too
49 function (next) { 53 function (next) {
50 const server = servers[0] 54 const server = servers[0]
51 utils.makeFriends(server.url, server.accessToken, next) 55 podsUtils.makeFriends(server.url, server.accessToken, next)
52 }, 56 },
53 function (next) { 57 function (next) {
54 webtorrent.create({ host: 'client', port: '1' }, next) 58 webtorrent.create({ host: 'client', port: '1' }, next)
@@ -58,7 +62,7 @@ describe('Test multiple pods', function () {
58 62
59 it('Should not have videos for all pods', function (done) { 63 it('Should not have videos for all pods', function (done) {
60 each(servers, function (server, callback) { 64 each(servers, function (server, callback) {
61 utils.getVideosList(server.url, function (err, res) { 65 videosUtils.getVideosList(server.url, function (err, res) {
62 if (err) throw err 66 if (err) throw err
63 67
64 const videos = res.body.data 68 const videos = res.body.data
@@ -80,7 +84,7 @@ describe('Test multiple pods', function () {
80 const description = 'my super description for pod 1' 84 const description = 'my super description for pod 1'
81 const tags = [ 'tag1p1', 'tag2p1' ] 85 const tags = [ 'tag1p1', 'tag2p1' ]
82 const file = 'video_short1.webm' 86 const file = 'video_short1.webm'
83 utils.uploadVideo(servers[0].url, servers[0].accessToken, name, description, tags, file, next) 87 videosUtils.uploadVideo(servers[0].url, servers[0].accessToken, name, description, tags, file, next)
84 }, 88 },
85 function (next) { 89 function (next) {
86 setTimeout(next, 11000) 90 setTimeout(next, 11000)
@@ -92,7 +96,7 @@ describe('Test multiple pods', function () {
92 each(servers, function (server, callback) { 96 each(servers, function (server, callback) {
93 let baseMagnet = null 97 let baseMagnet = null
94 98
95 utils.getVideosList(server.url, function (err, res) { 99 videosUtils.getVideosList(server.url, function (err, res) {
96 if (err) throw err 100 if (err) throw err
97 101
98 const videos = res.body.data 102 const videos = res.body.data
@@ -105,7 +109,7 @@ describe('Test multiple pods', function () {
105 expect(video.magnetUri).to.exist 109 expect(video.magnetUri).to.exist
106 expect(video.duration).to.equal(10) 110 expect(video.duration).to.equal(10)
107 expect(video.tags).to.deep.equal([ 'tag1p1', 'tag2p1' ]) 111 expect(video.tags).to.deep.equal([ 'tag1p1', 'tag2p1' ])
108 expect(utils.dateIsValid(video.createdDate)).to.be.true 112 expect(miscsUtils.dateIsValid(video.createdDate)).to.be.true
109 expect(video.author).to.equal('root') 113 expect(video.author).to.equal('root')
110 114
111 if (server.url !== 'http://localhost:9001') { 115 if (server.url !== 'http://localhost:9001') {
@@ -121,7 +125,7 @@ describe('Test multiple pods', function () {
121 expect(video.magnetUri).to.equal.magnetUri 125 expect(video.magnetUri).to.equal.magnetUri
122 } 126 }
123 127
124 utils.testImage(server.url, 'video_short1.webm', video.thumbnailPath, function (err, test) { 128 videosUtils.testVideoImage(server.url, 'video_short1.webm', video.thumbnailPath, function (err, test) {
125 if (err) throw err 129 if (err) throw err
126 expect(test).to.equal(true) 130 expect(test).to.equal(true)
127 131
@@ -142,7 +146,7 @@ describe('Test multiple pods', function () {
142 const description = 'my super description for pod 2' 146 const description = 'my super description for pod 2'
143 const tags = [ 'tag1p2', 'tag2p2', 'tag3p2' ] 147 const tags = [ 'tag1p2', 'tag2p2', 'tag3p2' ]
144 const file = 'video_short2.webm' 148 const file = 'video_short2.webm'
145 utils.uploadVideo(servers[1].url, servers[1].accessToken, name, description, tags, file, next) 149 videosUtils.uploadVideo(servers[1].url, servers[1].accessToken, name, description, tags, file, next)
146 }, 150 },
147 function (next) { 151 function (next) {
148 setTimeout(next, 11000) 152 setTimeout(next, 11000)
@@ -154,7 +158,7 @@ describe('Test multiple pods', function () {
154 each(servers, function (server, callback) { 158 each(servers, function (server, callback) {
155 let baseMagnet = null 159 let baseMagnet = null
156 160
157 utils.getVideosList(server.url, function (err, res) { 161 videosUtils.getVideosList(server.url, function (err, res) {
158 if (err) throw err 162 if (err) throw err
159 163
160 const videos = res.body.data 164 const videos = res.body.data
@@ -167,7 +171,7 @@ describe('Test multiple pods', function () {
167 expect(video.magnetUri).to.exist 171 expect(video.magnetUri).to.exist
168 expect(video.duration).to.equal(5) 172 expect(video.duration).to.equal(5)
169 expect(video.tags).to.deep.equal([ 'tag1p2', 'tag2p2', 'tag3p2' ]) 173 expect(video.tags).to.deep.equal([ 'tag1p2', 'tag2p2', 'tag3p2' ])
170 expect(utils.dateIsValid(video.createdDate)).to.be.true 174 expect(miscsUtils.dateIsValid(video.createdDate)).to.be.true
171 expect(video.author).to.equal('root') 175 expect(video.author).to.equal('root')
172 176
173 if (server.url !== 'http://localhost:9002') { 177 if (server.url !== 'http://localhost:9002') {
@@ -183,7 +187,7 @@ describe('Test multiple pods', function () {
183 expect(video.magnetUri).to.equal.magnetUri 187 expect(video.magnetUri).to.equal.magnetUri
184 } 188 }
185 189
186 utils.testImage(server.url, 'video_short2.webm', video.thumbnailPath, function (err, test) { 190 videosUtils.testVideoImage(server.url, 'video_short2.webm', video.thumbnailPath, function (err, test) {
187 if (err) throw err 191 if (err) throw err
188 expect(test).to.equal(true) 192 expect(test).to.equal(true)
189 193
@@ -204,14 +208,14 @@ describe('Test multiple pods', function () {
204 const description = 'my super description for pod 3' 208 const description = 'my super description for pod 3'
205 const tags = [ 'tag1p3' ] 209 const tags = [ 'tag1p3' ]
206 const file = 'video_short3.webm' 210 const file = 'video_short3.webm'
207 utils.uploadVideo(servers[2].url, servers[2].accessToken, name, description, tags, file, next) 211 videosUtils.uploadVideo(servers[2].url, servers[2].accessToken, name, description, tags, file, next)
208 }, 212 },
209 function (next) { 213 function (next) {
210 const name = 'my super name for pod 3-2' 214 const name = 'my super name for pod 3-2'
211 const description = 'my super description for pod 3-2' 215 const description = 'my super description for pod 3-2'
212 const tags = [ 'tag2p3', 'tag3p3', 'tag4p3' ] 216 const tags = [ 'tag2p3', 'tag3p3', 'tag4p3' ]
213 const file = 'video_short.webm' 217 const file = 'video_short.webm'
214 utils.uploadVideo(servers[2].url, servers[2].accessToken, name, description, tags, file, next) 218 videosUtils.uploadVideo(servers[2].url, servers[2].accessToken, name, description, tags, file, next)
215 }, 219 },
216 function (next) { 220 function (next) {
217 setTimeout(next, 22000) 221 setTimeout(next, 22000)
@@ -222,7 +226,7 @@ describe('Test multiple pods', function () {
222 let baseMagnet = null 226 let baseMagnet = null
223 // All pods should have this video 227 // All pods should have this video
224 each(servers, function (server, callback) { 228 each(servers, function (server, callback) {
225 utils.getVideosList(server.url, function (err, res) { 229 videosUtils.getVideosList(server.url, function (err, res) {
226 if (err) throw err 230 if (err) throw err
227 231
228 const videos = res.body.data 232 const videos = res.body.data
@@ -247,7 +251,7 @@ describe('Test multiple pods', function () {
247 expect(video1.duration).to.equal(5) 251 expect(video1.duration).to.equal(5)
248 expect(video1.tags).to.deep.equal([ 'tag1p3' ]) 252 expect(video1.tags).to.deep.equal([ 'tag1p3' ])
249 expect(video1.author).to.equal('root') 253 expect(video1.author).to.equal('root')
250 expect(utils.dateIsValid(video1.createdDate)).to.be.true 254 expect(miscsUtils.dateIsValid(video1.createdDate)).to.be.true
251 255
252 expect(video2.name).to.equal('my super name for pod 3-2') 256 expect(video2.name).to.equal('my super name for pod 3-2')
253 expect(video2.description).to.equal('my super description for pod 3-2') 257 expect(video2.description).to.equal('my super description for pod 3-2')
@@ -256,7 +260,7 @@ describe('Test multiple pods', function () {
256 expect(video2.duration).to.equal(5) 260 expect(video2.duration).to.equal(5)
257 expect(video2.tags).to.deep.equal([ 'tag2p3', 'tag3p3', 'tag4p3' ]) 261 expect(video2.tags).to.deep.equal([ 'tag2p3', 'tag3p3', 'tag4p3' ])
258 expect(video2.author).to.equal('root') 262 expect(video2.author).to.equal('root')
259 expect(utils.dateIsValid(video2.createdDate)).to.be.true 263 expect(miscsUtils.dateIsValid(video2.createdDate)).to.be.true
260 264
261 if (server.url !== 'http://localhost:9003') { 265 if (server.url !== 'http://localhost:9003') {
262 expect(video1.isLocal).to.be.false 266 expect(video1.isLocal).to.be.false
@@ -273,11 +277,11 @@ describe('Test multiple pods', function () {
273 expect(video2.magnetUri).to.equal.magnetUri 277 expect(video2.magnetUri).to.equal.magnetUri
274 } 278 }
275 279
276 utils.testImage(server.url, 'video_short3.webm', video1.thumbnailPath, function (err, test) { 280 videosUtils.testVideoImage(server.url, 'video_short3.webm', video1.thumbnailPath, function (err, test) {
277 if (err) throw err 281 if (err) throw err
278 expect(test).to.equal(true) 282 expect(test).to.equal(true)
279 283
280 utils.testImage(server.url, 'video_short.webm', video2.thumbnailPath, function (err, test) { 284 videosUtils.testVideoImage(server.url, 'video_short.webm', video2.thumbnailPath, function (err, test) {
281 if (err) throw err 285 if (err) throw err
282 expect(test).to.equal(true) 286 expect(test).to.equal(true)
283 287
@@ -296,7 +300,7 @@ describe('Test multiple pods', function () {
296 // Yes, this could be long 300 // Yes, this could be long
297 this.timeout(200000) 301 this.timeout(200000)
298 302
299 utils.getVideosList(servers[2].url, function (err, res) { 303 videosUtils.getVideosList(servers[2].url, function (err, res) {
300 if (err) throw err 304 if (err) throw err
301 305
302 const video = res.body.data[0] 306 const video = res.body.data[0]
@@ -317,7 +321,7 @@ describe('Test multiple pods', function () {
317 // Yes, this could be long 321 // Yes, this could be long
318 this.timeout(200000) 322 this.timeout(200000)
319 323
320 utils.getVideosList(servers[0].url, function (err, res) { 324 videosUtils.getVideosList(servers[0].url, function (err, res) {
321 if (err) throw err 325 if (err) throw err
322 326
323 const video = res.body.data[1] 327 const video = res.body.data[1]
@@ -336,7 +340,7 @@ describe('Test multiple pods', function () {
336 // Yes, this could be long 340 // Yes, this could be long
337 this.timeout(200000) 341 this.timeout(200000)
338 342
339 utils.getVideosList(servers[1].url, function (err, res) { 343 videosUtils.getVideosList(servers[1].url, function (err, res) {
340 if (err) throw err 344 if (err) throw err
341 345
342 const video = res.body.data[2] 346 const video = res.body.data[2]
@@ -355,7 +359,7 @@ describe('Test multiple pods', function () {
355 // Yes, this could be long 359 // Yes, this could be long
356 this.timeout(200000) 360 this.timeout(200000)
357 361
358 utils.getVideosList(servers[0].url, function (err, res) { 362 videosUtils.getVideosList(servers[0].url, function (err, res) {
359 if (err) throw err 363 if (err) throw err
360 364
361 const video = res.body.data[3] 365 const video = res.body.data[3]
@@ -375,10 +379,10 @@ describe('Test multiple pods', function () {
375 379
376 series([ 380 series([
377 function (next) { 381 function (next) {
378 utils.removeVideo(servers[2].url, servers[2].accessToken, toRemove[0], next) 382 videosUtils.removeVideo(servers[2].url, servers[2].accessToken, toRemove[0], next)
379 }, 383 },
380 function (next) { 384 function (next) {
381 utils.removeVideo(servers[2].url, servers[2].accessToken, toRemove[1], next) 385 videosUtils.removeVideo(servers[2].url, servers[2].accessToken, toRemove[1], next)
382 }], 386 }],
383 function (err) { 387 function (err) {
384 if (err) throw err 388 if (err) throw err
@@ -389,7 +393,7 @@ describe('Test multiple pods', function () {
389 393
390 it('Should have videos 1 and 3 on each pod', function (done) { 394 it('Should have videos 1 and 3 on each pod', function (done) {
391 each(servers, function (server, callback) { 395 each(servers, function (server, callback) {
392 utils.getVideosList(server.url, function (err, res) { 396 videosUtils.getVideosList(server.url, function (err, res) {
393 if (err) throw err 397 if (err) throw err
394 398
395 const videos = res.body.data 399 const videos = res.body.data
@@ -415,7 +419,7 @@ describe('Test multiple pods', function () {
415 419
416 // Keep the logs if the test failed 420 // Keep the logs if the test failed
417 if (this.ok) { 421 if (this.ok) {
418 utils.flushTests(done) 422 serversUtils.flushTests(done)
419 } else { 423 } else {
420 done() 424 done()
421 } 425 }