From 792e5b8e5b731e15228dd5938bc2f99bb2e1070a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 2 Oct 2018 09:04:19 +0200 Subject: Try to improve redundancy tests --- server/tests/utils/server/servers.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'server/tests/utils') 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 @@ import { ChildProcess, exec, fork } from 'child_process' import { join } from 'path' +import { root, wait } from '../miscs/miscs' +import { readFile } from 'fs-extra' interface ServerInfo { app: ChildProcess, @@ -157,6 +159,19 @@ function killallServers (servers: ServerInfo[]) { } } +async function waitUntilLog (server: ServerInfo, str: string, count = 1) { + const logfile = join(root(), 'test' + server.serverNumber, 'logs/peertube.log') + + while (true) { + const buf = await readFile(logfile) + + const matches = buf.toString().match(new RegExp(str, 'g')) + if (matches && matches.length === count) return + + await wait(1000) + } +} + // --------------------------------------------------------------------------- export { @@ -165,5 +180,6 @@ export { flushTests, runServer, killallServers, - reRunServer + reRunServer, + waitUntilLog } -- cgit v1.2.3