diff options
Diffstat (limited to 'server/tests/api/redundancy/redundancy.ts')
-rw-r--r-- | server/tests/api/redundancy/redundancy.ts | 38 |
1 files changed, 17 insertions, 21 deletions
diff --git a/server/tests/api/redundancy/redundancy.ts b/server/tests/api/redundancy/redundancy.ts index 280a4c64b..e31329c25 100644 --- a/server/tests/api/redundancy/redundancy.ts +++ b/server/tests/api/redundancy/redundancy.ts | |||
@@ -5,7 +5,7 @@ import 'mocha' | |||
5 | import { VideoDetails } from '../../../../shared/models/videos' | 5 | import { VideoDetails } from '../../../../shared/models/videos' |
6 | import { | 6 | import { |
7 | checkSegmentHash, | 7 | checkSegmentHash, |
8 | checkVideoFilesWereRemoved, | 8 | checkVideoFilesWereRemoved, cleanupTests, |
9 | doubleFollow, | 9 | doubleFollow, |
10 | flushAndRunMultipleServers, | 10 | flushAndRunMultipleServers, |
11 | getFollowingListPaginationAndSort, | 11 | getFollowingListPaginationAndSort, |
@@ -52,7 +52,7 @@ function checkMagnetWebseeds (file: { magnetUri: string, resolution: { id: numbe | |||
52 | expect(parsed.urlList).to.have.lengthOf(baseWebseeds.length) | 52 | expect(parsed.urlList).to.have.lengthOf(baseWebseeds.length) |
53 | } | 53 | } |
54 | 54 | ||
55 | async function runServers (strategy: VideoRedundancyStrategy, additionalParams: any = {}) { | 55 | async function flushAndRunServers (strategy: VideoRedundancyStrategy, additionalParams: any = {}) { |
56 | const config = { | 56 | const config = { |
57 | transcoding: { | 57 | transcoding: { |
58 | hls: { | 58 | hls: { |
@@ -264,10 +264,6 @@ async function disableRedundancyOnServer1 () { | |||
264 | expect(server2.following.hostRedundancyAllowed).to.be.false | 264 | expect(server2.following.hostRedundancyAllowed).to.be.false |
265 | } | 265 | } |
266 | 266 | ||
267 | async function cleanServers () { | ||
268 | killallServers(servers) | ||
269 | } | ||
270 | |||
271 | describe('Test videos redundancy', function () { | 267 | describe('Test videos redundancy', function () { |
272 | 268 | ||
273 | describe('With most-views strategy', function () { | 269 | describe('With most-views strategy', function () { |
@@ -276,7 +272,7 @@ describe('Test videos redundancy', function () { | |||
276 | before(function () { | 272 | before(function () { |
277 | this.timeout(120000) | 273 | this.timeout(120000) |
278 | 274 | ||
279 | return runServers(strategy) | 275 | return flushAndRunServers(strategy) |
280 | }) | 276 | }) |
281 | 277 | ||
282 | it('Should have 1 webseed on the first video', async function () { | 278 | it('Should have 1 webseed on the first video', async function () { |
@@ -315,8 +311,8 @@ describe('Test videos redundancy', function () { | |||
315 | await checkVideoFilesWereRemoved(video1Server2UUID, servers[0].serverNumber, [ 'videos', join('playlists', 'hls') ]) | 311 | await checkVideoFilesWereRemoved(video1Server2UUID, servers[0].serverNumber, [ 'videos', join('playlists', 'hls') ]) |
316 | }) | 312 | }) |
317 | 313 | ||
318 | after(function () { | 314 | after(async function () { |
319 | return cleanServers() | 315 | return cleanupTests(servers) |
320 | }) | 316 | }) |
321 | }) | 317 | }) |
322 | 318 | ||
@@ -326,7 +322,7 @@ describe('Test videos redundancy', function () { | |||
326 | before(function () { | 322 | before(function () { |
327 | this.timeout(120000) | 323 | this.timeout(120000) |
328 | 324 | ||
329 | return runServers(strategy) | 325 | return flushAndRunServers(strategy) |
330 | }) | 326 | }) |
331 | 327 | ||
332 | it('Should have 1 webseed on the first video', async function () { | 328 | it('Should have 1 webseed on the first video', async function () { |
@@ -365,8 +361,8 @@ describe('Test videos redundancy', function () { | |||
365 | await checkVideoFilesWereRemoved(video1Server2UUID, servers[0].serverNumber, [ 'videos' ]) | 361 | await checkVideoFilesWereRemoved(video1Server2UUID, servers[0].serverNumber, [ 'videos' ]) |
366 | }) | 362 | }) |
367 | 363 | ||
368 | after(function () { | 364 | after(async function () { |
369 | return cleanServers() | 365 | await cleanupTests(servers) |
370 | }) | 366 | }) |
371 | }) | 367 | }) |
372 | 368 | ||
@@ -376,7 +372,7 @@ describe('Test videos redundancy', function () { | |||
376 | before(function () { | 372 | before(function () { |
377 | this.timeout(120000) | 373 | this.timeout(120000) |
378 | 374 | ||
379 | return runServers(strategy, { min_views: 3 }) | 375 | return flushAndRunServers(strategy, { min_views: 3 }) |
380 | }) | 376 | }) |
381 | 377 | ||
382 | it('Should have 1 webseed on the first video', async function () { | 378 | it('Should have 1 webseed on the first video', async function () { |
@@ -435,8 +431,8 @@ describe('Test videos redundancy', function () { | |||
435 | } | 431 | } |
436 | }) | 432 | }) |
437 | 433 | ||
438 | after(function () { | 434 | after(async function () { |
439 | return cleanServers() | 435 | await cleanupTests(servers) |
440 | }) | 436 | }) |
441 | }) | 437 | }) |
442 | 438 | ||
@@ -468,7 +464,7 @@ describe('Test videos redundancy', function () { | |||
468 | before(async function () { | 464 | before(async function () { |
469 | this.timeout(120000) | 465 | this.timeout(120000) |
470 | 466 | ||
471 | await runServers(strategy, { min_lifetime: '7 seconds', min_views: 0 }) | 467 | await flushAndRunServers(strategy, { min_lifetime: '7 seconds', min_views: 0 }) |
472 | 468 | ||
473 | await enableRedundancyOnServer1() | 469 | await enableRedundancyOnServer1() |
474 | }) | 470 | }) |
@@ -498,8 +494,8 @@ describe('Test videos redundancy', function () { | |||
498 | await checkNotContains([ servers[1], servers[2] ], 'http%3A%2F%2Flocalhost%3A9001') | 494 | await checkNotContains([ servers[1], servers[2] ], 'http%3A%2F%2Flocalhost%3A9001') |
499 | }) | 495 | }) |
500 | 496 | ||
501 | after(function () { | 497 | after(async function () { |
502 | return killallServers([ servers[1], servers[2] ]) | 498 | await cleanupTests(servers) |
503 | }) | 499 | }) |
504 | }) | 500 | }) |
505 | 501 | ||
@@ -510,7 +506,7 @@ describe('Test videos redundancy', function () { | |||
510 | before(async function () { | 506 | before(async function () { |
511 | this.timeout(120000) | 507 | this.timeout(120000) |
512 | 508 | ||
513 | await runServers(strategy, { min_lifetime: '7 seconds', min_views: 0 }) | 509 | await flushAndRunServers(strategy, { min_lifetime: '7 seconds', min_views: 0 }) |
514 | 510 | ||
515 | await enableRedundancyOnServer1() | 511 | await enableRedundancyOnServer1() |
516 | 512 | ||
@@ -569,8 +565,8 @@ describe('Test videos redundancy', function () { | |||
569 | await checkVideoFilesWereRemoved(video1Server2UUID, servers[0].serverNumber, [ join('redundancy', 'hls') ]) | 565 | await checkVideoFilesWereRemoved(video1Server2UUID, servers[0].serverNumber, [ join('redundancy', 'hls') ]) |
570 | }) | 566 | }) |
571 | 567 | ||
572 | after(function () { | 568 | after(async function () { |
573 | return cleanServers() | 569 | await cleanupTests(servers) |
574 | }) | 570 | }) |
575 | }) | 571 | }) |
576 | }) | 572 | }) |