diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/lib/activitypub/videos.ts | 2 | ||||
-rw-r--r-- | server/lib/schedulers/videos-redundancy-scheduler.ts | 2 | ||||
-rw-r--r-- | server/tests/api/server/redundancy.ts | 25 | ||||
-rw-r--r-- | server/tests/utils/server/servers.ts | 18 |
4 files changed, 37 insertions, 10 deletions
diff --git a/server/lib/activitypub/videos.ts b/server/lib/activitypub/videos.ts index cd1bc4e06..54cea542f 100644 --- a/server/lib/activitypub/videos.ts +++ b/server/lib/activitypub/videos.ts | |||
@@ -396,6 +396,8 @@ async function refreshVideoIfNeeded (options: { | |||
396 | } | 396 | } |
397 | await retryTransactionWrapper(updateVideoFromAP, updateOptions) | 397 | await retryTransactionWrapper(updateVideoFromAP, updateOptions) |
398 | await syncVideoExternalAttributes(video, videoObject, options.syncParam) | 398 | await syncVideoExternalAttributes(video, videoObject, options.syncParam) |
399 | |||
400 | return video | ||
399 | } catch (err) { | 401 | } catch (err) { |
400 | logger.warn('Cannot refresh video %s.', options.video.url, { err }) | 402 | logger.warn('Cannot refresh video %s.', options.video.url, { err }) |
401 | return video | 403 | return video |
diff --git a/server/lib/schedulers/videos-redundancy-scheduler.ts b/server/lib/schedulers/videos-redundancy-scheduler.ts index 0b1ae76ff..607bdf67c 100644 --- a/server/lib/schedulers/videos-redundancy-scheduler.ts +++ b/server/lib/schedulers/videos-redundancy-scheduler.ts | |||
@@ -157,6 +157,8 @@ export class VideosRedundancyScheduler extends AbstractScheduler { | |||
157 | createdModel.VideoFile = file | 157 | createdModel.VideoFile = file |
158 | 158 | ||
159 | await sendCreateCacheFile(serverActor, createdModel) | 159 | await sendCreateCacheFile(serverActor, createdModel) |
160 | |||
161 | logger.info('Duplicated %s - %d -> %s.', video.url, file.resolution, createdModel.url) | ||
160 | } | 162 | } |
161 | } | 163 | } |
162 | 164 | ||
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 | } |