diff options
Diffstat (limited to 'server/tests')
-rw-r--r-- | server/tests/api/server/redundancy.ts | 25 | ||||
-rw-r--r-- | server/tests/utils/server/servers.ts | 18 |
2 files changed, 33 insertions, 10 deletions
diff --git a/server/tests/api/server/redundancy.ts b/server/tests/api/server/redundancy.ts index e1709891d..fcf1eacd3 100644 --- a/server/tests/api/server/redundancy.ts +++ b/server/tests/api/server/redundancy.ts | |||
@@ -15,7 +15,8 @@ import { | |||
15 | setAccessTokensToServers, unfollow, | 15 | setAccessTokensToServers, unfollow, |
16 | uploadVideo, | 16 | uploadVideo, |
17 | viewVideo, | 17 | viewVideo, |
18 | wait | 18 | wait, |
19 | waitUntilLog | ||
19 | } from '../../utils' | 20 | } from '../../utils' |
20 | import { waitJobs } from '../../utils/server/jobs' | 21 | import { waitJobs } from '../../utils/server/jobs' |
21 | import * as magnetUtil from 'magnet-uri' | 22 | import * as magnetUtil from 'magnet-uri' |
@@ -225,7 +226,7 @@ describe('Test videos redundancy', function () { | |||
225 | this.timeout(40000) | 226 | this.timeout(40000) |
226 | 227 | ||
227 | await waitJobs(servers) | 228 | await waitJobs(servers) |
228 | await wait(15000) | 229 | await waitUntilLog(servers[0], 'Duplicated ', 4) |
229 | await waitJobs(servers) | 230 | await waitJobs(servers) |
230 | 231 | ||
231 | await check2Webseeds(strategy) | 232 | await check2Webseeds(strategy) |
@@ -270,7 +271,7 @@ describe('Test videos redundancy', function () { | |||
270 | this.timeout(40000) | 271 | this.timeout(40000) |
271 | 272 | ||
272 | await waitJobs(servers) | 273 | await waitJobs(servers) |
273 | await wait(15000) | 274 | await waitUntilLog(servers[0], 'Duplicated ', 4) |
274 | await waitJobs(servers) | 275 | await waitJobs(servers) |
275 | 276 | ||
276 | await check2Webseeds(strategy) | 277 | await check2Webseeds(strategy) |
@@ -336,7 +337,7 @@ describe('Test videos redundancy', function () { | |||
336 | this.timeout(40000) | 337 | this.timeout(40000) |
337 | 338 | ||
338 | await waitJobs(servers) | 339 | await waitJobs(servers) |
339 | await wait(15000) | 340 | await waitUntilLog(servers[0], 'Duplicated ', 4) |
340 | await waitJobs(servers) | 341 | await waitJobs(servers) |
341 | 342 | ||
342 | await check2Webseeds(strategy) | 343 | await check2Webseeds(strategy) |
@@ -423,7 +424,7 @@ describe('Test videos redundancy', function () { | |||
423 | await enableRedundancyOnServer1() | 424 | await enableRedundancyOnServer1() |
424 | 425 | ||
425 | await waitJobs(servers) | 426 | await waitJobs(servers) |
426 | await wait(5000) | 427 | await waitUntilLog(servers[0], 'Duplicated ', 4) |
427 | await waitJobs(servers) | 428 | await waitJobs(servers) |
428 | 429 | ||
429 | await check2Webseeds(strategy) | 430 | await check2Webseeds(strategy) |
@@ -434,15 +435,21 @@ describe('Test videos redundancy', function () { | |||
434 | }) | 435 | }) |
435 | 436 | ||
436 | it('Should cache video 2 webseed on the first video', async function () { | 437 | it('Should cache video 2 webseed on the first video', async function () { |
437 | this.timeout(40000) | 438 | this.timeout(50000) |
438 | this.retries(3) | ||
439 | 439 | ||
440 | await waitJobs(servers) | 440 | await waitJobs(servers) |
441 | 441 | ||
442 | await wait(7000) | 442 | await wait(7000) |
443 | 443 | ||
444 | await check1WebSeed(strategy, video1Server2UUID) | 444 | try { |
445 | await check2Webseeds(strategy, video2Server2UUID) | 445 | await check1WebSeed(strategy, video1Server2UUID) |
446 | await check2Webseeds(strategy, video2Server2UUID) | ||
447 | } catch { | ||
448 | await wait(7000) | ||
449 | |||
450 | await check1WebSeed(strategy, video1Server2UUID) | ||
451 | await check2Webseeds(strategy, video2Server2UUID) | ||
452 | } | ||
446 | }) | 453 | }) |
447 | 454 | ||
448 | after(function () { | 455 | after(function () { |
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 | } |