aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-08-20 17:19:27 +0200
committerChocobozzz <florian.bigard@gmail.com>2016-08-20 17:19:27 +0200
commit4613274479968f58f62c63178c92c1391de84297 (patch)
treef7b14ff8c71aade804c022393f9a4d0decaaa5e3
parent1e2564d3927ce4ca4ca9a09930da6da7ebb4e9a1 (diff)
downloadPeerTube-4613274479968f58f62c63178c92c1391de84297.tar.gz
PeerTube-4613274479968f58f62c63178c92c1391de84297.tar.zst
PeerTube-4613274479968f58f62c63178c92c1391de84297.zip
Server: fix real world simulation script
-rw-r--r--server/tests/real-world/real-world.js31
1 files changed, 17 insertions, 14 deletions
diff --git a/server/tests/real-world/real-world.js b/server/tests/real-world/real-world.js
index b28796852..dba1970c5 100644
--- a/server/tests/real-world/real-world.js
+++ b/server/tests/real-world/real-world.js
@@ -1,6 +1,6 @@
1'use strict' 1'use strict'
2 2
3const each = require('each') 3const each = require('async/each')
4const isEqual = require('lodash/isEqual') 4const isEqual = require('lodash/isEqual')
5const program = require('commander') 5const program = require('commander')
6const series = require('async/series') 6const series = require('async/series')
@@ -8,7 +8,10 @@ const series = require('async/series')
8process.env.NODE_ENV = 'test' 8process.env.NODE_ENV = 'test'
9const constants = require('../../initializers/constants') 9const constants = require('../../initializers/constants')
10 10
11const utils = require('../api/utils') 11const loginUtils = require('../utils/login')
12const podsUtils = require('../utils/pods')
13const serversUtils = require('../utils/servers')
14const videosUtils = require('../utils/videos')
12 15
13program 16program
14 .option('-c, --create [weight]', 'Weight for creating videos') 17 .option('-c, --create [weight]', 'Weight for creating videos')
@@ -97,7 +100,7 @@ function runServers (numberOfPods, callback) {
97 series([ 100 series([
98 // Run servers 101 // Run servers
99 function (next) { 102 function (next) {
100 utils.flushAndRunMultipleServers(numberOfPods, function (serversRun) { 103 serversUtils.flushAndRunMultipleServers(numberOfPods, function (serversRun) {
101 servers = serversRun 104 servers = serversRun
102 next() 105 next()
103 }) 106 })
@@ -105,7 +108,7 @@ function runServers (numberOfPods, callback) {
105 // Get the access tokens 108 // Get the access tokens
106 function (next) { 109 function (next) {
107 each(servers, function (server, callbackEach) { 110 each(servers, function (server, callbackEach) {
108 utils.loginAndGetAccessToken(server, function (err, accessToken) { 111 loginUtils.loginAndGetAccessToken(server, function (err, accessToken) {
109 if (err) return callbackEach(err) 112 if (err) return callbackEach(err)
110 113
111 server.accessToken = accessToken 114 server.accessToken = accessToken
@@ -115,26 +118,26 @@ function runServers (numberOfPods, callback) {
115 }, 118 },
116 function (next) { 119 function (next) {
117 const server = servers[1] 120 const server = servers[1]
118 utils.makeFriends(server.url, server.accessToken, next) 121 podsUtils.makeFriends(server.url, server.accessToken, next)
119 }, 122 },
120 function (next) { 123 function (next) {
121 const server = servers[0] 124 const server = servers[0]
122 utils.makeFriends(server.url, server.accessToken, next) 125 podsUtils.makeFriends(server.url, server.accessToken, next)
123 }, 126 },
124 function (next) { 127 function (next) {
125 setTimeout(next, 1000) 128 setTimeout(next, 1000)
126 }, 129 },
127 function (next) { 130 function (next) {
128 const server = servers[3] 131 const server = servers[3]
129 utils.makeFriends(server.url, server.accessToken, next) 132 podsUtils.makeFriends(server.url, server.accessToken, next)
130 }, 133 },
131 function (next) { 134 function (next) {
132 const server = servers[5] 135 const server = servers[5]
133 utils.makeFriends(server.url, server.accessToken, next) 136 podsUtils.makeFriends(server.url, server.accessToken, next)
134 }, 137 },
135 function (next) { 138 function (next) {
136 const server = servers[4] 139 const server = servers[4]
137 utils.makeFriends(server.url, server.accessToken, next) 140 podsUtils.makeFriends(server.url, server.accessToken, next)
138 }, 141 },
139 function (next) { 142 function (next) {
140 setTimeout(next, 1000) 143 setTimeout(next, 1000)
@@ -151,7 +154,7 @@ function exitServers (servers, callback) {
151 if (server.app) process.kill(-server.app.pid) 154 if (server.app) process.kill(-server.app.pid)
152 }) 155 })
153 156
154 if (flushAtExit) utils.flushTests(callback) 157 if (flushAtExit) serversUtils.flushTests(callback)
155} 158}
156 159
157function upload (servers, numServer, callback) { 160function upload (servers, numServer, callback) {
@@ -164,13 +167,13 @@ function upload (servers, numServer, callback) {
164 167
165 console.log('Upload video to server ' + numServer) 168 console.log('Upload video to server ' + numServer)
166 169
167 utils.uploadVideo(servers[numServer].url, servers[numServer].accessToken, name, description, tags, file, callback) 170 videosUtils.uploadVideo(servers[numServer].url, servers[numServer].accessToken, name, description, tags, file, callback)
168} 171}
169 172
170function remove (servers, numServer, callback) { 173function remove (servers, numServer, callback) {
171 if (!callback) callback = function () {} 174 if (!callback) callback = function () {}
172 175
173 utils.getVideosList(servers[numServer].url, function (err, res) { 176 videosUtils.getVideosList(servers[numServer].url, function (err, res) {
174 if (err) throw err 177 if (err) throw err
175 178
176 const videos = res.body.data 179 const videos = res.body.data
@@ -179,14 +182,14 @@ function remove (servers, numServer, callback) {
179 const toRemove = videos[getRandomInt(0, videos.length)].id 182 const toRemove = videos[getRandomInt(0, videos.length)].id
180 183
181 console.log('Removing video from server ' + numServer) 184 console.log('Removing video from server ' + numServer)
182 utils.removeVideo(servers[numServer].url, servers[numServer].accessToken, toRemove, callback) 185 videosUtils.removeVideo(servers[numServer].url, servers[numServer].accessToken, toRemove, callback)
183 }) 186 })
184} 187}
185 188
186function checkIntegrity (servers, callback) { 189function checkIntegrity (servers, callback) {
187 const videos = [] 190 const videos = []
188 each(servers, function (server, callback) { 191 each(servers, function (server, callback) {
189 utils.getAllVideosListBy(server.url, function (err, res) { 192 videosUtils.getAllVideosListBy(server.url, function (err, res) {
190 if (err) throw err 193 if (err) throw err
191 const serverVideos = res.body.data 194 const serverVideos = res.body.data
192 for (const serverVideo of serverVideos) { 195 for (const serverVideo of serverVideos) {