mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2024-11-22 08:46:54 -06:00
Server: fix real world simulation script
This commit is contained in:
parent
1e2564d392
commit
4613274479
@ -1,6 +1,6 @@
|
|||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
const each = require('each')
|
const each = require('async/each')
|
||||||
const isEqual = require('lodash/isEqual')
|
const isEqual = require('lodash/isEqual')
|
||||||
const program = require('commander')
|
const program = require('commander')
|
||||||
const series = require('async/series')
|
const series = require('async/series')
|
||||||
@ -8,7 +8,10 @@ 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')
|
||||||
|
|
||||||
const utils = require('../api/utils')
|
const loginUtils = require('../utils/login')
|
||||||
|
const podsUtils = require('../utils/pods')
|
||||||
|
const serversUtils = require('../utils/servers')
|
||||||
|
const videosUtils = require('../utils/videos')
|
||||||
|
|
||||||
program
|
program
|
||||||
.option('-c, --create [weight]', 'Weight for creating videos')
|
.option('-c, --create [weight]', 'Weight for creating videos')
|
||||||
@ -97,7 +100,7 @@ function runServers (numberOfPods, callback) {
|
|||||||
series([
|
series([
|
||||||
// Run servers
|
// Run servers
|
||||||
function (next) {
|
function (next) {
|
||||||
utils.flushAndRunMultipleServers(numberOfPods, function (serversRun) {
|
serversUtils.flushAndRunMultipleServers(numberOfPods, function (serversRun) {
|
||||||
servers = serversRun
|
servers = serversRun
|
||||||
next()
|
next()
|
||||||
})
|
})
|
||||||
@ -105,7 +108,7 @@ function runServers (numberOfPods, callback) {
|
|||||||
// Get the access tokens
|
// Get the access tokens
|
||||||
function (next) {
|
function (next) {
|
||||||
each(servers, function (server, callbackEach) {
|
each(servers, function (server, callbackEach) {
|
||||||
utils.loginAndGetAccessToken(server, function (err, accessToken) {
|
loginUtils.loginAndGetAccessToken(server, function (err, accessToken) {
|
||||||
if (err) return callbackEach(err)
|
if (err) return callbackEach(err)
|
||||||
|
|
||||||
server.accessToken = accessToken
|
server.accessToken = accessToken
|
||||||
@ -115,26 +118,26 @@ function runServers (numberOfPods, callback) {
|
|||||||
},
|
},
|
||||||
function (next) {
|
function (next) {
|
||||||
const server = servers[1]
|
const server = servers[1]
|
||||||
utils.makeFriends(server.url, server.accessToken, next)
|
podsUtils.makeFriends(server.url, server.accessToken, next)
|
||||||
},
|
},
|
||||||
function (next) {
|
function (next) {
|
||||||
const server = servers[0]
|
const server = servers[0]
|
||||||
utils.makeFriends(server.url, server.accessToken, next)
|
podsUtils.makeFriends(server.url, server.accessToken, next)
|
||||||
},
|
},
|
||||||
function (next) {
|
function (next) {
|
||||||
setTimeout(next, 1000)
|
setTimeout(next, 1000)
|
||||||
},
|
},
|
||||||
function (next) {
|
function (next) {
|
||||||
const server = servers[3]
|
const server = servers[3]
|
||||||
utils.makeFriends(server.url, server.accessToken, next)
|
podsUtils.makeFriends(server.url, server.accessToken, next)
|
||||||
},
|
},
|
||||||
function (next) {
|
function (next) {
|
||||||
const server = servers[5]
|
const server = servers[5]
|
||||||
utils.makeFriends(server.url, server.accessToken, next)
|
podsUtils.makeFriends(server.url, server.accessToken, next)
|
||||||
},
|
},
|
||||||
function (next) {
|
function (next) {
|
||||||
const server = servers[4]
|
const server = servers[4]
|
||||||
utils.makeFriends(server.url, server.accessToken, next)
|
podsUtils.makeFriends(server.url, server.accessToken, next)
|
||||||
},
|
},
|
||||||
function (next) {
|
function (next) {
|
||||||
setTimeout(next, 1000)
|
setTimeout(next, 1000)
|
||||||
@ -151,7 +154,7 @@ function exitServers (servers, callback) {
|
|||||||
if (server.app) process.kill(-server.app.pid)
|
if (server.app) process.kill(-server.app.pid)
|
||||||
})
|
})
|
||||||
|
|
||||||
if (flushAtExit) utils.flushTests(callback)
|
if (flushAtExit) serversUtils.flushTests(callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
function upload (servers, numServer, callback) {
|
function upload (servers, numServer, callback) {
|
||||||
@ -164,13 +167,13 @@ function upload (servers, numServer, callback) {
|
|||||||
|
|
||||||
console.log('Upload video to server ' + numServer)
|
console.log('Upload video to server ' + numServer)
|
||||||
|
|
||||||
utils.uploadVideo(servers[numServer].url, servers[numServer].accessToken, name, description, tags, file, callback)
|
videosUtils.uploadVideo(servers[numServer].url, servers[numServer].accessToken, name, description, tags, file, callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
function remove (servers, numServer, callback) {
|
function remove (servers, numServer, callback) {
|
||||||
if (!callback) callback = function () {}
|
if (!callback) callback = function () {}
|
||||||
|
|
||||||
utils.getVideosList(servers[numServer].url, function (err, res) {
|
videosUtils.getVideosList(servers[numServer].url, function (err, res) {
|
||||||
if (err) throw err
|
if (err) throw err
|
||||||
|
|
||||||
const videos = res.body.data
|
const videos = res.body.data
|
||||||
@ -179,14 +182,14 @@ function remove (servers, numServer, callback) {
|
|||||||
const toRemove = videos[getRandomInt(0, videos.length)].id
|
const toRemove = videos[getRandomInt(0, videos.length)].id
|
||||||
|
|
||||||
console.log('Removing video from server ' + numServer)
|
console.log('Removing video from server ' + numServer)
|
||||||
utils.removeVideo(servers[numServer].url, servers[numServer].accessToken, toRemove, callback)
|
videosUtils.removeVideo(servers[numServer].url, servers[numServer].accessToken, toRemove, callback)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkIntegrity (servers, callback) {
|
function checkIntegrity (servers, callback) {
|
||||||
const videos = []
|
const videos = []
|
||||||
each(servers, function (server, callback) {
|
each(servers, function (server, callback) {
|
||||||
utils.getAllVideosListBy(server.url, function (err, res) {
|
videosUtils.getAllVideosListBy(server.url, function (err, res) {
|
||||||
if (err) throw err
|
if (err) throw err
|
||||||
const serverVideos = res.body.data
|
const serverVideos = res.body.data
|
||||||
for (const serverVideo of serverVideos) {
|
for (const serverVideo of serverVideos) {
|
||||||
|
Loading…
Reference in New Issue
Block a user