diff options
author | Chocobozzz <me@florianbigard.com> | 2018-10-02 09:04:19 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-10-02 09:04:19 +0200 |
commit | 792e5b8e5b731e15228dd5938bc2f99bb2e1070a (patch) | |
tree | d9290b11aea35934f653cb38fb1b3bf948b8a575 /server/tests/utils | |
parent | 913f08f2bd5b03c121ee65751e938e4faa27e7f1 (diff) | |
download | PeerTube-792e5b8e5b731e15228dd5938bc2f99bb2e1070a.tar.gz PeerTube-792e5b8e5b731e15228dd5938bc2f99bb2e1070a.tar.zst PeerTube-792e5b8e5b731e15228dd5938bc2f99bb2e1070a.zip |
Try to improve redundancy tests
Diffstat (limited to 'server/tests/utils')
-rw-r--r-- | server/tests/utils/server/servers.ts | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/server/tests/utils/server/servers.ts b/server/tests/utils/server/servers.ts index fbfc83ca1..3c946db27 100644 --- a/server/tests/utils/server/servers.ts +++ b/server/tests/utils/server/servers.ts | |||
@@ -1,5 +1,7 @@ | |||
1 | import { ChildProcess, exec, fork } from 'child_process' | 1 | import { ChildProcess, exec, fork } from 'child_process' |
2 | import { join } from 'path' | 2 | import { join } from 'path' |
3 | import { root, wait } from '../miscs/miscs' | ||
4 | import { readFile } from 'fs-extra' | ||
3 | 5 | ||
4 | interface ServerInfo { | 6 | interface ServerInfo { |
5 | app: ChildProcess, | 7 | app: ChildProcess, |
@@ -157,6 +159,19 @@ function killallServers (servers: ServerInfo[]) { | |||
157 | } | 159 | } |
158 | } | 160 | } |
159 | 161 | ||
162 | async function waitUntilLog (server: ServerInfo, str: string, count = 1) { | ||
163 | const logfile = join(root(), 'test' + server.serverNumber, 'logs/peertube.log') | ||
164 | |||
165 | while (true) { | ||
166 | const buf = await readFile(logfile) | ||
167 | |||
168 | const matches = buf.toString().match(new RegExp(str, 'g')) | ||
169 | if (matches && matches.length === count) return | ||
170 | |||
171 | await wait(1000) | ||
172 | } | ||
173 | } | ||
174 | |||
160 | // --------------------------------------------------------------------------- | 175 | // --------------------------------------------------------------------------- |
161 | 176 | ||
162 | export { | 177 | export { |
@@ -165,5 +180,6 @@ export { | |||
165 | flushTests, | 180 | flushTests, |
166 | runServer, | 181 | runServer, |
167 | killallServers, | 182 | killallServers, |
168 | reRunServer | 183 | reRunServer, |
184 | waitUntilLog | ||
169 | } | 185 | } |