aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/utils
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-10-02 09:04:19 +0200
committerChocobozzz <me@florianbigard.com>2018-10-02 09:04:19 +0200
commit792e5b8e5b731e15228dd5938bc2f99bb2e1070a (patch)
treed9290b11aea35934f653cb38fb1b3bf948b8a575 /server/tests/utils
parent913f08f2bd5b03c121ee65751e938e4faa27e7f1 (diff)
downloadPeerTube-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.ts18
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 @@
1import { ChildProcess, exec, fork } from 'child_process' 1import { ChildProcess, exec, fork } from 'child_process'
2import { join } from 'path' 2import { join } from 'path'
3import { root, wait } from '../miscs/miscs'
4import { readFile } from 'fs-extra'
3 5
4interface ServerInfo { 6interface ServerInfo {
5 app: ChildProcess, 7 app: ChildProcess,
@@ -157,6 +159,19 @@ function killallServers (servers: ServerInfo[]) {
157 } 159 }
158} 160}
159 161
162async 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
162export { 177export {
@@ -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}