diff options
Diffstat (limited to 'server/tests/api/redundancy')
-rw-r--r-- | server/tests/api/redundancy/manage-redundancy.ts | 8 | ||||
-rw-r--r-- | server/tests/api/redundancy/redundancy-constraints.ts | 19 | ||||
-rw-r--r-- | server/tests/api/redundancy/redundancy.ts | 33 |
3 files changed, 29 insertions, 31 deletions
diff --git a/server/tests/api/redundancy/manage-redundancy.ts b/server/tests/api/redundancy/manage-redundancy.ts index e193b968e..aff64e2eb 100644 --- a/server/tests/api/redundancy/manage-redundancy.ts +++ b/server/tests/api/redundancy/manage-redundancy.ts | |||
@@ -5,9 +5,9 @@ import * as chai from 'chai' | |||
5 | import { | 5 | import { |
6 | cleanupTests, | 6 | cleanupTests, |
7 | doubleFollow, | 7 | doubleFollow, |
8 | flushAndRunMultipleServers, | 8 | createMultipleServers, |
9 | RedundancyCommand, | 9 | RedundancyCommand, |
10 | ServerInfo, | 10 | PeerTubeServer, |
11 | setAccessTokensToServers, | 11 | setAccessTokensToServers, |
12 | waitJobs | 12 | waitJobs |
13 | } from '@shared/extra-utils' | 13 | } from '@shared/extra-utils' |
@@ -18,7 +18,7 @@ const expect = chai.expect | |||
18 | describe('Test manage videos redundancy', function () { | 18 | describe('Test manage videos redundancy', function () { |
19 | const targets: VideoRedundanciesTarget[] = [ 'my-videos', 'remote-videos' ] | 19 | const targets: VideoRedundanciesTarget[] = [ 'my-videos', 'remote-videos' ] |
20 | 20 | ||
21 | let servers: ServerInfo[] | 21 | let servers: PeerTubeServer[] |
22 | let video1Server2UUID: string | 22 | let video1Server2UUID: string |
23 | let video2Server2UUID: string | 23 | let video2Server2UUID: string |
24 | let redundanciesToRemove: number[] = [] | 24 | let redundanciesToRemove: number[] = [] |
@@ -48,7 +48,7 @@ describe('Test manage videos redundancy', function () { | |||
48 | } | 48 | } |
49 | } | 49 | } |
50 | } | 50 | } |
51 | servers = await flushAndRunMultipleServers(3, config) | 51 | servers = await createMultipleServers(3, config) |
52 | 52 | ||
53 | // Get the access tokens | 53 | // Get the access tokens |
54 | await setAccessTokensToServers(servers) | 54 | await setAccessTokensToServers(servers) |
diff --git a/server/tests/api/redundancy/redundancy-constraints.ts b/server/tests/api/redundancy/redundancy-constraints.ts index 0378cc122..217691fb6 100644 --- a/server/tests/api/redundancy/redundancy-constraints.ts +++ b/server/tests/api/redundancy/redundancy-constraints.ts | |||
@@ -4,19 +4,18 @@ import 'mocha' | |||
4 | import { expect } from 'chai' | 4 | import { expect } from 'chai' |
5 | import { | 5 | import { |
6 | cleanupTests, | 6 | cleanupTests, |
7 | flushAndRunServer, | 7 | createSingleServer, |
8 | killallServers, | 8 | killallServers, |
9 | reRunServer, | 9 | PeerTubeServer, |
10 | ServerInfo, | ||
11 | setAccessTokensToServers, | 10 | setAccessTokensToServers, |
12 | waitJobs | 11 | waitJobs |
13 | } from '@shared/extra-utils' | 12 | } from '@shared/extra-utils' |
14 | import { VideoPrivacy } from '@shared/models' | 13 | import { VideoPrivacy } from '@shared/models' |
15 | 14 | ||
16 | describe('Test redundancy constraints', function () { | 15 | describe('Test redundancy constraints', function () { |
17 | let remoteServer: ServerInfo | 16 | let remoteServer: PeerTubeServer |
18 | let localServer: ServerInfo | 17 | let localServer: PeerTubeServer |
19 | let servers: ServerInfo[] | 18 | let servers: PeerTubeServer[] |
20 | 19 | ||
21 | const remoteServerConfig = { | 20 | const remoteServerConfig = { |
22 | redundancy: { | 21 | redundancy: { |
@@ -59,7 +58,7 @@ describe('Test redundancy constraints', function () { | |||
59 | this.timeout(120000) | 58 | this.timeout(120000) |
60 | 59 | ||
61 | { | 60 | { |
62 | remoteServer = await flushAndRunServer(1, remoteServerConfig) | 61 | remoteServer = await createSingleServer(1, remoteServerConfig) |
63 | } | 62 | } |
64 | 63 | ||
65 | { | 64 | { |
@@ -70,7 +69,7 @@ describe('Test redundancy constraints', function () { | |||
70 | } | 69 | } |
71 | } | 70 | } |
72 | } | 71 | } |
73 | localServer = await flushAndRunServer(2, config) | 72 | localServer = await createSingleServer(2, config) |
74 | } | 73 | } |
75 | 74 | ||
76 | servers = [ remoteServer, localServer ] | 75 | servers = [ remoteServer, localServer ] |
@@ -119,7 +118,7 @@ describe('Test redundancy constraints', function () { | |||
119 | } | 118 | } |
120 | } | 119 | } |
121 | await await killallServers([ localServer ]) | 120 | await await killallServers([ localServer ]) |
122 | await reRunServer(localServer, config) | 121 | await localServer.run(config) |
123 | 122 | ||
124 | await uploadWrapper('video 2 server 2') | 123 | await uploadWrapper('video 2 server 2') |
125 | 124 | ||
@@ -148,7 +147,7 @@ describe('Test redundancy constraints', function () { | |||
148 | } | 147 | } |
149 | } | 148 | } |
150 | await killallServers([ localServer ]) | 149 | await killallServers([ localServer ]) |
151 | await reRunServer(localServer, config) | 150 | await localServer.run(config) |
152 | 151 | ||
153 | await uploadWrapper('video 3 server 2') | 152 | await uploadWrapper('video 3 server 2') |
154 | 153 | ||
diff --git a/server/tests/api/redundancy/redundancy.ts b/server/tests/api/redundancy/redundancy.ts index 77ea2278e..9d5d96efd 100644 --- a/server/tests/api/redundancy/redundancy.ts +++ b/server/tests/api/redundancy/redundancy.ts | |||
@@ -11,12 +11,11 @@ import { | |||
11 | checkVideoFilesWereRemoved, | 11 | checkVideoFilesWereRemoved, |
12 | cleanupTests, | 12 | cleanupTests, |
13 | doubleFollow, | 13 | doubleFollow, |
14 | flushAndRunMultipleServers, | 14 | createMultipleServers, |
15 | killallServers, | 15 | killallServers, |
16 | makeGetRequest, | 16 | makeGetRequest, |
17 | reRunServer, | ||
18 | root, | 17 | root, |
19 | ServerInfo, | 18 | PeerTubeServer, |
20 | setAccessTokensToServers, | 19 | setAccessTokensToServers, |
21 | wait, | 20 | wait, |
22 | waitJobs | 21 | waitJobs |
@@ -25,11 +24,11 @@ import { VideoPrivacy, VideoRedundancyStrategy, VideoRedundancyStrategyWithManua | |||
25 | 24 | ||
26 | const expect = chai.expect | 25 | const expect = chai.expect |
27 | 26 | ||
28 | let servers: ServerInfo[] = [] | 27 | let servers: PeerTubeServer[] = [] |
29 | let video1Server2UUID: string | 28 | let video1Server2UUID: string |
30 | let video1Server2Id: number | 29 | let video1Server2Id: number |
31 | 30 | ||
32 | function checkMagnetWebseeds (file: { magnetUri: string, resolution: { id: number } }, baseWebseeds: string[], server: ServerInfo) { | 31 | function checkMagnetWebseeds (file: { magnetUri: string, resolution: { id: number } }, baseWebseeds: string[], server: PeerTubeServer) { |
33 | const parsed = magnetUtil.decode(file.magnetUri) | 32 | const parsed = magnetUtil.decode(file.magnetUri) |
34 | 33 | ||
35 | for (const ws of baseWebseeds) { | 34 | for (const ws of baseWebseeds) { |
@@ -40,7 +39,7 @@ function checkMagnetWebseeds (file: { magnetUri: string, resolution: { id: numbe | |||
40 | expect(parsed.urlList).to.have.lengthOf(baseWebseeds.length) | 39 | expect(parsed.urlList).to.have.lengthOf(baseWebseeds.length) |
41 | } | 40 | } |
42 | 41 | ||
43 | async function flushAndRunServers (strategy: VideoRedundancyStrategy | null, additionalParams: any = {}, withWebtorrent = true) { | 42 | async function createSingleServers (strategy: VideoRedundancyStrategy | null, additionalParams: any = {}, withWebtorrent = true) { |
44 | const strategies: any[] = [] | 43 | const strategies: any[] = [] |
45 | 44 | ||
46 | if (strategy !== null) { | 45 | if (strategy !== null) { |
@@ -72,7 +71,7 @@ async function flushAndRunServers (strategy: VideoRedundancyStrategy | null, add | |||
72 | } | 71 | } |
73 | } | 72 | } |
74 | 73 | ||
75 | servers = await flushAndRunMultipleServers(3, config) | 74 | servers = await createMultipleServers(3, config) |
76 | 75 | ||
77 | // Get the access tokens | 76 | // Get the access tokens |
78 | await setAccessTokensToServers(servers) | 77 | await setAccessTokensToServers(servers) |
@@ -288,7 +287,7 @@ describe('Test videos redundancy', function () { | |||
288 | before(function () { | 287 | before(function () { |
289 | this.timeout(120000) | 288 | this.timeout(120000) |
290 | 289 | ||
291 | return flushAndRunServers(strategy) | 290 | return createSingleServers(strategy) |
292 | }) | 291 | }) |
293 | 292 | ||
294 | it('Should have 1 webseed on the first video', async function () { | 293 | it('Should have 1 webseed on the first video', async function () { |
@@ -338,7 +337,7 @@ describe('Test videos redundancy', function () { | |||
338 | before(function () { | 337 | before(function () { |
339 | this.timeout(120000) | 338 | this.timeout(120000) |
340 | 339 | ||
341 | return flushAndRunServers(strategy) | 340 | return createSingleServers(strategy) |
342 | }) | 341 | }) |
343 | 342 | ||
344 | it('Should have 1 webseed on the first video', async function () { | 343 | it('Should have 1 webseed on the first video', async function () { |
@@ -388,7 +387,7 @@ describe('Test videos redundancy', function () { | |||
388 | before(function () { | 387 | before(function () { |
389 | this.timeout(120000) | 388 | this.timeout(120000) |
390 | 389 | ||
391 | return flushAndRunServers(strategy, { min_views: 3 }) | 390 | return createSingleServers(strategy, { min_views: 3 }) |
392 | }) | 391 | }) |
393 | 392 | ||
394 | it('Should have 1 webseed on the first video', async function () { | 393 | it('Should have 1 webseed on the first video', async function () { |
@@ -458,7 +457,7 @@ describe('Test videos redundancy', function () { | |||
458 | before(async function () { | 457 | before(async function () { |
459 | this.timeout(120000) | 458 | this.timeout(120000) |
460 | 459 | ||
461 | await flushAndRunServers(strategy, { min_views: 3 }, false) | 460 | await createSingleServers(strategy, { min_views: 3 }, false) |
462 | }) | 461 | }) |
463 | 462 | ||
464 | it('Should have 0 playlist redundancy on the first video', async function () { | 463 | it('Should have 0 playlist redundancy on the first video', async function () { |
@@ -519,7 +518,7 @@ describe('Test videos redundancy', function () { | |||
519 | before(function () { | 518 | before(function () { |
520 | this.timeout(120000) | 519 | this.timeout(120000) |
521 | 520 | ||
522 | return flushAndRunServers(null) | 521 | return createSingleServers(null) |
523 | }) | 522 | }) |
524 | 523 | ||
525 | it('Should have 1 webseed on the first video', async function () { | 524 | it('Should have 1 webseed on the first video', async function () { |
@@ -575,7 +574,7 @@ describe('Test videos redundancy', function () { | |||
575 | describe('Test expiration', function () { | 574 | describe('Test expiration', function () { |
576 | const strategy = 'recently-added' | 575 | const strategy = 'recently-added' |
577 | 576 | ||
578 | async function checkContains (servers: ServerInfo[], str: string) { | 577 | async function checkContains (servers: PeerTubeServer[], str: string) { |
579 | for (const server of servers) { | 578 | for (const server of servers) { |
580 | const video = await server.videos.get({ id: video1Server2UUID }) | 579 | const video = await server.videos.get({ id: video1Server2UUID }) |
581 | 580 | ||
@@ -585,7 +584,7 @@ describe('Test videos redundancy', function () { | |||
585 | } | 584 | } |
586 | } | 585 | } |
587 | 586 | ||
588 | async function checkNotContains (servers: ServerInfo[], str: string) { | 587 | async function checkNotContains (servers: PeerTubeServer[], str: string) { |
589 | for (const server of servers) { | 588 | for (const server of servers) { |
590 | const video = await server.videos.get({ id: video1Server2UUID }) | 589 | const video = await server.videos.get({ id: video1Server2UUID }) |
591 | 590 | ||
@@ -598,7 +597,7 @@ describe('Test videos redundancy', function () { | |||
598 | before(async function () { | 597 | before(async function () { |
599 | this.timeout(120000) | 598 | this.timeout(120000) |
600 | 599 | ||
601 | await flushAndRunServers(strategy, { min_lifetime: '7 seconds', min_views: 0 }) | 600 | await createSingleServers(strategy, { min_lifetime: '7 seconds', min_views: 0 }) |
602 | 601 | ||
603 | await enableRedundancyOnServer1() | 602 | await enableRedundancyOnServer1() |
604 | }) | 603 | }) |
@@ -640,7 +639,7 @@ describe('Test videos redundancy', function () { | |||
640 | before(async function () { | 639 | before(async function () { |
641 | this.timeout(120000) | 640 | this.timeout(120000) |
642 | 641 | ||
643 | await flushAndRunServers(strategy, { min_lifetime: '7 seconds', min_views: 0 }) | 642 | await createSingleServers(strategy, { min_lifetime: '7 seconds', min_views: 0 }) |
644 | 643 | ||
645 | await enableRedundancyOnServer1() | 644 | await enableRedundancyOnServer1() |
646 | 645 | ||
@@ -691,7 +690,7 @@ describe('Test videos redundancy', function () { | |||
691 | await waitJobs(servers) | 690 | await waitJobs(servers) |
692 | 691 | ||
693 | await killallServers([ servers[0] ]) | 692 | await killallServers([ servers[0] ]) |
694 | await reRunServer(servers[0], { | 693 | await servers[0].run({ |
695 | redundancy: { | 694 | redundancy: { |
696 | videos: { | 695 | videos: { |
697 | check_interval: '1 second', | 696 | check_interval: '1 second', |