aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/redundancy/redundancy.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-16 09:47:51 +0200
committerChocobozzz <me@florianbigard.com>2021-07-20 15:27:18 +0200
commit254d3579f5338f5fd775c17d15cdfc37078bcfb4 (patch)
treeeaeb13fda16c16e98cd6991d202b0ca6a4cbdb63 /server/tests/api/redundancy/redundancy.ts
parent89d241a79c262b9775c233b73cff080043ebb5e6 (diff)
downloadPeerTube-254d3579f5338f5fd775c17d15cdfc37078bcfb4.tar.gz
PeerTube-254d3579f5338f5fd775c17d15cdfc37078bcfb4.tar.zst
PeerTube-254d3579f5338f5fd775c17d15cdfc37078bcfb4.zip
Use an object to represent a server
Diffstat (limited to 'server/tests/api/redundancy/redundancy.ts')
-rw-r--r--server/tests/api/redundancy/redundancy.ts33
1 files changed, 16 insertions, 17 deletions
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
26const expect = chai.expect 25const expect = chai.expect
27 26
28let servers: ServerInfo[] = [] 27let servers: PeerTubeServer[] = []
29let video1Server2UUID: string 28let video1Server2UUID: string
30let video1Server2Id: number 29let video1Server2Id: number
31 30
32function checkMagnetWebseeds (file: { magnetUri: string, resolution: { id: number } }, baseWebseeds: string[], server: ServerInfo) { 31function 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
43async function flushAndRunServers (strategy: VideoRedundancyStrategy | null, additionalParams: any = {}, withWebtorrent = true) { 42async 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',