diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-11-17 15:20:42 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-11-27 19:40:52 +0100 |
commit | 9a27cdc27c900feaae5f6db4315c4ccdfc0c4493 (patch) | |
tree | f91fcfa0fa1a2e45aae1c5333ef2f7ec60e56ef0 /server/tests/real-world | |
parent | 975e6e0e44e2f2b25f804cd48a62e2a8d9e8117a (diff) | |
download | PeerTube-9a27cdc27c900feaae5f6db4315c4ccdfc0c4493.tar.gz PeerTube-9a27cdc27c900feaae5f6db4315c4ccdfc0c4493.tar.zst PeerTube-9a27cdc27c900feaae5f6db4315c4ccdfc0c4493.zip |
Optimize signature verification
Diffstat (limited to 'server/tests/real-world')
-rw-r--r-- | server/tests/real-world/real-world.ts | 51 |
1 files changed, 24 insertions, 27 deletions
diff --git a/server/tests/real-world/real-world.ts b/server/tests/real-world/real-world.ts index c79ad38ff..ac83d64a6 100644 --- a/server/tests/real-world/real-world.ts +++ b/server/tests/real-world/real-world.ts | |||
@@ -1,25 +1,24 @@ | |||
1 | import * as program from 'commander' | ||
2 | |||
3 | // /!\ Before imports /!\ | 1 | // /!\ Before imports /!\ |
4 | process.env.NODE_ENV = 'test' | 2 | process.env.NODE_ENV = 'test' |
5 | 3 | ||
6 | import { Video, VideoRateType, VideoFile } from '../../../shared' | 4 | import * as program from 'commander' |
5 | import { Video, VideoFile, VideoRateType } from '../../../shared' | ||
7 | import { | 6 | import { |
8 | ServerInfo as DefaultServerInfo, | ||
9 | flushAndRunMultipleServers, | 7 | flushAndRunMultipleServers, |
10 | setAccessTokensToServers, | ||
11 | makeFriends, | ||
12 | wait, | ||
13 | killallServers, | ||
14 | flushTests, | 8 | flushTests, |
15 | uploadVideo, | 9 | getAllVideosListBy, |
10 | getRequestsStats, | ||
11 | getVideo, | ||
16 | getVideosList, | 12 | getVideosList, |
17 | updateVideo, | 13 | killallServers, |
18 | removeVideo, | 14 | removeVideo, |
19 | getVideo, | 15 | ServerInfo as DefaultServerInfo, |
20 | getAllVideosListBy, | 16 | setAccessTokensToServers, |
21 | getRequestsStats | 17 | updateVideo, |
18 | uploadVideo, | ||
19 | wait | ||
22 | } from '../utils' | 20 | } from '../utils' |
21 | import { follow } from '../utils/follows' | ||
23 | 22 | ||
24 | interface ServerInfo extends DefaultServerInfo { | 23 | interface ServerInfo extends DefaultServerInfo { |
25 | requestsNumber: number | 24 | requestsNumber: number |
@@ -32,7 +31,7 @@ program | |||
32 | .option('-v, --view [weight]', 'Weight for viewing videos') | 31 | .option('-v, --view [weight]', 'Weight for viewing videos') |
33 | .option('-l, --like [weight]', 'Weight for liking videos') | 32 | .option('-l, --like [weight]', 'Weight for liking videos') |
34 | .option('-s, --dislike [weight]', 'Weight for disliking videos') | 33 | .option('-s, --dislike [weight]', 'Weight for disliking videos') |
35 | .option('-p, --pods [n]', 'Number of pods to run (3 or 6)', /^3|6$/, 3) | 34 | .option('-p, --servers [n]', 'Number of servers to run (3 or 6)', /^3|6$/, 3) |
36 | .option('-i, --interval-action [interval]', 'Interval in ms for an action') | 35 | .option('-i, --interval-action [interval]', 'Interval in ms for an action') |
37 | .option('-I, --interval-integrity [interval]', 'Interval in ms for an integrity check') | 36 | .option('-I, --interval-integrity [interval]', 'Interval in ms for an integrity check') |
38 | .option('-f, --flush', 'Flush datas on exit') | 37 | .option('-f, --flush', 'Flush datas on exit') |
@@ -50,7 +49,7 @@ const actionInterval = program['intervalAction'] !== undefined ? parseInt(progra | |||
50 | const integrityInterval = program['intervalIntegrity'] !== undefined ? parseInt(program['intervalIntegrity'], 10) : 60000 | 49 | const integrityInterval = program['intervalIntegrity'] !== undefined ? parseInt(program['intervalIntegrity'], 10) : 60000 |
51 | const displayDiffOnFail = program['difference'] || false | 50 | const displayDiffOnFail = program['difference'] || false |
52 | 51 | ||
53 | const numberOfPods = 6 | 52 | const numberOfServers = 6 |
54 | 53 | ||
55 | console.log( | 54 | console.log( |
56 | 'Create weight: %d, update weight: %d, remove weight: %d, view weight: %d, like weight: %d, dislike weight: %d.', | 55 | 'Create weight: %d, update weight: %d, remove weight: %d, view weight: %d, like weight: %d, dislike weight: %d.', |
@@ -77,7 +76,7 @@ start() | |||
77 | // ---------------------------------------------------------------------------- | 76 | // ---------------------------------------------------------------------------- |
78 | 77 | ||
79 | async function start () { | 78 | async function start () { |
80 | const servers = await runServers(numberOfPods) | 79 | const servers = await runServers(numberOfServers) |
81 | 80 | ||
82 | process.on('exit', async () => { | 81 | process.on('exit', async () => { |
83 | await exitServers(servers, flushAtExit) | 82 | await exitServers(servers, flushAtExit) |
@@ -152,22 +151,20 @@ function getRandomNumServer (servers) { | |||
152 | return getRandomInt(0, servers.length) | 151 | return getRandomInt(0, servers.length) |
153 | } | 152 | } |
154 | 153 | ||
155 | async function runServers (numberOfPods: number) { | 154 | async function runServers (numberOfServers: number) { |
156 | const servers: ServerInfo[] = (await flushAndRunMultipleServers(numberOfPods)) | 155 | const servers: ServerInfo[] = (await flushAndRunMultipleServers(numberOfServers)) |
157 | .map(s => Object.assign({ requestsNumber: 0 }, s)) | 156 | .map(s => Object.assign({ requestsNumber: 0 }, s)) |
158 | 157 | ||
159 | // Get the access tokens | 158 | // Get the access tokens |
160 | await setAccessTokensToServers(servers) | 159 | await setAccessTokensToServers(servers) |
161 | 160 | ||
162 | await makeFriends(servers[1].url, servers[1].accessToken) | 161 | for (let i = 0; i < numberOfServers; i++) { |
163 | await makeFriends(servers[0].url, servers[0].accessToken) | 162 | for (let j = 0; j < numberOfServers; j++) { |
164 | await wait(1000) | 163 | if (i === j) continue |
165 | |||
166 | await makeFriends(servers[3].url, servers[3].accessToken) | ||
167 | await makeFriends(servers[5].url, servers[5].accessToken) | ||
168 | await makeFriends(servers[4].url, servers[4].accessToken) | ||
169 | 164 | ||
170 | await wait(1000) | 165 | await follow(servers[i].url, [ servers[j].url ], servers[i].accessToken) |
166 | } | ||
167 | } | ||
171 | 168 | ||
172 | return servers | 169 | return servers |
173 | } | 170 | } |
@@ -259,7 +256,7 @@ async function checkIntegrity (servers: ServerInfo[]) { | |||
259 | const videos: Video[][] = [] | 256 | const videos: Video[][] = [] |
260 | const tasks: Promise<any>[] = [] | 257 | const tasks: Promise<any>[] = [] |
261 | 258 | ||
262 | // Fetch all videos and remove some fields that can differ between pods | 259 | // Fetch all videos and remove some fields that can differ between servers |
263 | for (const server of servers) { | 260 | for (const server of servers) { |
264 | const p = getAllVideosListBy(server.url).then(res => videos.push(res.body.data)) | 261 | const p = getAllVideosListBy(server.url).then(res => videos.push(res.body.data)) |
265 | tasks.push(p) | 262 | tasks.push(p) |