aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/real-world/real-world.js29
1 files changed, 22 insertions, 7 deletions
diff --git a/server/tests/real-world/real-world.js b/server/tests/real-world/real-world.js
index 2ae3dc15b..751d3923f 100644
--- a/server/tests/real-world/real-world.js
+++ b/server/tests/real-world/real-world.js
@@ -2,6 +2,7 @@
2 2
3const each = require('async/each') 3const each = require('async/each')
4const isEqual = require('lodash/isEqual') 4const isEqual = require('lodash/isEqual')
5const differenceWith = require('lodash/differenceWith')
5const program = require('commander') 6const program = require('commander')
6const series = require('async/series') 7const series = require('async/series')
7 8
@@ -20,28 +21,35 @@ program
20 .option('-a, --action [interval]', 'Interval in ms for an action') 21 .option('-a, --action [interval]', 'Interval in ms for an action')
21 .option('-i, --integrity [interval]', 'Interval in ms for an integrity check') 22 .option('-i, --integrity [interval]', 'Interval in ms for an integrity check')
22 .option('-f, --flush', 'Flush datas on exit') 23 .option('-f, --flush', 'Flush datas on exit')
24 .option('-d, --difference', 'Display difference if integrity is not okay')
23 .parse(process.argv) 25 .parse(process.argv)
24 26
25const createWeight = parseInt(program.create) || 5 27const createWeight = program.create !== undefined ? parseInt(program.create) : 5
26const removeWeight = parseInt(program.remove) || 4 28const removeWeight = program.remove !== undefined ? parseInt(program.remove) : 4
27const flushAtExit = program.flush || false 29const flushAtExit = program.flush || false
28const actionInterval = parseInt(program.action) || 500 30const actionInterval = program.action !== undefined ? parseInt(program.action) : 500
29let integrityInterval = parseInt(program.integrity) || 60000 31let integrityInterval = program.integrity !== undefined ? parseInt(program.integrity) : 60000
32const displayDiffOnFail = program.integrity || false
30 33
31const numberOfPods = 6 34const numberOfPods = 6
35
32// Wait requests between pods 36// Wait requests between pods
33const requestsMaxPerInterval = constants.REQUESTS_INTERVAL / actionInterval 37const baseRequestInterval = integrityInterval < constants.REQUESTS_INTERVAL ? integrityInterval : constants.REQUESTS_INTERVAL
38const requestsMaxPerInterval = baseRequestInterval / actionInterval
34const intervalsToMakeAllRequests = Math.ceil(requestsMaxPerInterval / constants.REQUESTS_LIMIT) 39const intervalsToMakeAllRequests = Math.ceil(requestsMaxPerInterval / constants.REQUESTS_LIMIT)
35const waitForBeforeIntegrityCheck = (intervalsToMakeAllRequests * constants.REQUESTS_INTERVAL) + 1000 40const waitForBeforeIntegrityCheck = (intervalsToMakeAllRequests * constants.REQUESTS_INTERVAL) + 1000
36 41
37integrityInterval += waitForBeforeIntegrityCheck
38
39console.log('Create weight: %d, remove weight: %d.', createWeight, removeWeight) 42console.log('Create weight: %d, remove weight: %d.', createWeight, removeWeight)
40if (flushAtExit) { 43if (flushAtExit) {
41 console.log('Program will flush data on exit.') 44 console.log('Program will flush data on exit.')
42} else { 45} else {
43 console.log('Program will not flush data on exit.') 46 console.log('Program will not flush data on exit.')
44} 47}
48if (displayDiffOnFail) {
49 console.log('Program will display diff on failure.')
50} else {
51 console.log('Program will not display diff on failure')
52}
45console.log('Interval in ms for each action: %d.', actionInterval) 53console.log('Interval in ms for each action: %d.', actionInterval)
46console.log('Interval in ms for each integrity check: %d.', integrityInterval) 54console.log('Interval in ms for each integrity check: %d.', integrityInterval)
47console.log('Will wait %d ms before an integrity check.', waitForBeforeIntegrityCheck) 55console.log('Will wait %d ms before an integrity check.', waitForBeforeIntegrityCheck)
@@ -73,6 +81,8 @@ runServers(numberOfPods, function (err, servers) {
73 }, actionInterval) 81 }, actionInterval)
74 82
75 setInterval(function () { 83 setInterval(function () {
84 if (checking === true) return
85
76 console.log('Checking integrity...') 86 console.log('Checking integrity...')
77 checking = true 87 checking = true
78 88
@@ -196,6 +206,7 @@ function checkIntegrity (servers, callback) {
196 delete serverVideo.id 206 delete serverVideo.id
197 delete serverVideo.isLocal 207 delete serverVideo.isLocal
198 delete serverVideo.thumbnailPath 208 delete serverVideo.thumbnailPath
209 delete serverVideo.updatedAt
199 } 210 }
200 211
201 videos.push(serverVideos) 212 videos.push(serverVideos)
@@ -206,6 +217,10 @@ function checkIntegrity (servers, callback) {
206 if (!isEqual(video, videos[0])) { 217 if (!isEqual(video, videos[0])) {
207 console.error('Integrity not ok!') 218 console.error('Integrity not ok!')
208 219
220 if (displayDiffOnFail) {
221 console.log(differenceWith(videos[0], video, isEqual))
222 }
223
209 process.exit(-1) 224 process.exit(-1)
210 } 225 }
211 } 226 }