diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-16 09:04:35 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-07-20 15:27:18 +0200 |
commit | 89d241a79c262b9775c233b73cff080043ebb5e6 (patch) | |
tree | cb3b6cb431d25d891ef4e02f66c61d252d17048f /server/tests/api/redundancy/redundancy.ts | |
parent | d23dd9fbfc4d26026352c10f81d2795ceaf2908a (diff) | |
download | PeerTube-89d241a79c262b9775c233b73cff080043ebb5e6.tar.gz PeerTube-89d241a79c262b9775c233b73cff080043ebb5e6.tar.zst PeerTube-89d241a79c262b9775c233b73cff080043ebb5e6.zip |
Shorter server command names
Diffstat (limited to 'server/tests/api/redundancy/redundancy.ts')
-rw-r--r-- | server/tests/api/redundancy/redundancy.ts | 62 |
1 files changed, 31 insertions, 31 deletions
diff --git a/server/tests/api/redundancy/redundancy.ts b/server/tests/api/redundancy/redundancy.ts index 6ca9c9303..77ea2278e 100644 --- a/server/tests/api/redundancy/redundancy.ts +++ b/server/tests/api/redundancy/redundancy.ts | |||
@@ -78,11 +78,11 @@ async function flushAndRunServers (strategy: VideoRedundancyStrategy | null, add | |||
78 | await setAccessTokensToServers(servers) | 78 | await setAccessTokensToServers(servers) |
79 | 79 | ||
80 | { | 80 | { |
81 | const { uuid, id } = await servers[1].videosCommand.upload({ attributes: { name: 'video 1 server 2' } }) | 81 | const { uuid, id } = await servers[1].videos.upload({ attributes: { name: 'video 1 server 2' } }) |
82 | video1Server2UUID = uuid | 82 | video1Server2UUID = uuid |
83 | video1Server2Id = id | 83 | video1Server2Id = id |
84 | 84 | ||
85 | await servers[1].videosCommand.view({ id: video1Server2UUID }) | 85 | await servers[1].videos.view({ id: video1Server2UUID }) |
86 | } | 86 | } |
87 | 87 | ||
88 | await waitJobs(servers) | 88 | await waitJobs(servers) |
@@ -106,7 +106,7 @@ async function check1WebSeed (videoUUID?: string) { | |||
106 | 106 | ||
107 | for (const server of servers) { | 107 | for (const server of servers) { |
108 | // With token to avoid issues with video follow constraints | 108 | // With token to avoid issues with video follow constraints |
109 | const video = await server.videosCommand.getWithToken({ id: videoUUID }) | 109 | const video = await server.videos.getWithToken({ id: videoUUID }) |
110 | 110 | ||
111 | for (const f of video.files) { | 111 | for (const f of video.files) { |
112 | checkMagnetWebseeds(f, webseeds, server) | 112 | checkMagnetWebseeds(f, webseeds, server) |
@@ -123,7 +123,7 @@ async function check2Webseeds (videoUUID?: string) { | |||
123 | ] | 123 | ] |
124 | 124 | ||
125 | for (const server of servers) { | 125 | for (const server of servers) { |
126 | const video = await server.videosCommand.get({ id: videoUUID }) | 126 | const video = await server.videos.get({ id: videoUUID }) |
127 | 127 | ||
128 | for (const file of video.files) { | 128 | for (const file of video.files) { |
129 | checkMagnetWebseeds(file, webseeds, server) | 129 | checkMagnetWebseeds(file, webseeds, server) |
@@ -163,7 +163,7 @@ async function check0PlaylistRedundancies (videoUUID?: string) { | |||
163 | 163 | ||
164 | for (const server of servers) { | 164 | for (const server of servers) { |
165 | // With token to avoid issues with video follow constraints | 165 | // With token to avoid issues with video follow constraints |
166 | const video = await server.videosCommand.getWithToken({ id: videoUUID }) | 166 | const video = await server.videos.getWithToken({ id: videoUUID }) |
167 | 167 | ||
168 | expect(video.streamingPlaylists).to.be.an('array') | 168 | expect(video.streamingPlaylists).to.be.an('array') |
169 | expect(video.streamingPlaylists).to.have.lengthOf(1) | 169 | expect(video.streamingPlaylists).to.have.lengthOf(1) |
@@ -175,7 +175,7 @@ async function check1PlaylistRedundancies (videoUUID?: string) { | |||
175 | if (!videoUUID) videoUUID = video1Server2UUID | 175 | if (!videoUUID) videoUUID = video1Server2UUID |
176 | 176 | ||
177 | for (const server of servers) { | 177 | for (const server of servers) { |
178 | const video = await server.videosCommand.get({ id: videoUUID }) | 178 | const video = await server.videos.get({ id: videoUUID }) |
179 | 179 | ||
180 | expect(video.streamingPlaylists).to.have.lengthOf(1) | 180 | expect(video.streamingPlaylists).to.have.lengthOf(1) |
181 | expect(video.streamingPlaylists[0].redundancies).to.have.lengthOf(1) | 181 | expect(video.streamingPlaylists[0].redundancies).to.have.lengthOf(1) |
@@ -188,7 +188,7 @@ async function check1PlaylistRedundancies (videoUUID?: string) { | |||
188 | const baseUrlPlaylist = servers[1].url + '/static/streaming-playlists/hls' | 188 | const baseUrlPlaylist = servers[1].url + '/static/streaming-playlists/hls' |
189 | const baseUrlSegment = servers[0].url + '/static/redundancy/hls' | 189 | const baseUrlSegment = servers[0].url + '/static/redundancy/hls' |
190 | 190 | ||
191 | const video = await servers[0].videosCommand.get({ id: videoUUID }) | 191 | const video = await servers[0].videos.get({ id: videoUUID }) |
192 | const hlsPlaylist = video.streamingPlaylists[0] | 192 | const hlsPlaylist = video.streamingPlaylists[0] |
193 | 193 | ||
194 | for (const resolution of [ 240, 360, 480, 720 ]) { | 194 | for (const resolution of [ 240, 360, 480, 720 ]) { |
@@ -221,7 +221,7 @@ async function checkStatsGlobal (strategy: VideoRedundancyStrategyWithManual) { | |||
221 | statsLength = 2 | 221 | statsLength = 2 |
222 | } | 222 | } |
223 | 223 | ||
224 | const data = await servers[0].statsCommand.get() | 224 | const data = await servers[0].stats.get() |
225 | expect(data.videosRedundancy).to.have.lengthOf(statsLength) | 225 | expect(data.videosRedundancy).to.have.lengthOf(statsLength) |
226 | 226 | ||
227 | const stat = data.videosRedundancy[0] | 227 | const stat = data.videosRedundancy[0] |
@@ -248,7 +248,7 @@ async function checkStatsWithoutRedundancy (strategy: VideoRedundancyStrategyWit | |||
248 | } | 248 | } |
249 | 249 | ||
250 | async function findServerFollows () { | 250 | async function findServerFollows () { |
251 | const body = await servers[0].followsCommand.getFollowings({ start: 0, count: 5, sort: '-createdAt' }) | 251 | const body = await servers[0].follows.getFollowings({ start: 0, count: 5, sort: '-createdAt' }) |
252 | const follows = body.data | 252 | const follows = body.data |
253 | const server2 = follows.find(f => f.following.host === `localhost:${servers[1].port}`) | 253 | const server2 = follows.find(f => f.following.host === `localhost:${servers[1].port}`) |
254 | const server3 = follows.find(f => f.following.host === `localhost:${servers[2].port}`) | 254 | const server3 = follows.find(f => f.following.host === `localhost:${servers[2].port}`) |
@@ -257,7 +257,7 @@ async function findServerFollows () { | |||
257 | } | 257 | } |
258 | 258 | ||
259 | async function enableRedundancyOnServer1 () { | 259 | async function enableRedundancyOnServer1 () { |
260 | await servers[0].redundancyCommand.updateRedundancy({ host: servers[1].host, redundancyAllowed: true }) | 260 | await servers[0].redundancy.updateRedundancy({ host: servers[1].host, redundancyAllowed: true }) |
261 | 261 | ||
262 | const { server2, server3 } = await findServerFollows() | 262 | const { server2, server3 } = await findServerFollows() |
263 | 263 | ||
@@ -269,7 +269,7 @@ async function enableRedundancyOnServer1 () { | |||
269 | } | 269 | } |
270 | 270 | ||
271 | async function disableRedundancyOnServer1 () { | 271 | async function disableRedundancyOnServer1 () { |
272 | await servers[0].redundancyCommand.updateRedundancy({ host: servers[1].host, redundancyAllowed: false }) | 272 | await servers[0].redundancy.updateRedundancy({ host: servers[1].host, redundancyAllowed: false }) |
273 | 273 | ||
274 | const { server2, server3 } = await findServerFollows() | 274 | const { server2, server3 } = await findServerFollows() |
275 | 275 | ||
@@ -305,7 +305,7 @@ describe('Test videos redundancy', function () { | |||
305 | this.timeout(80000) | 305 | this.timeout(80000) |
306 | 306 | ||
307 | await waitJobs(servers) | 307 | await waitJobs(servers) |
308 | await servers[0].serversCommand.waitUntilLog('Duplicated ', 5) | 308 | await servers[0].servers.waitUntilLog('Duplicated ', 5) |
309 | await waitJobs(servers) | 309 | await waitJobs(servers) |
310 | 310 | ||
311 | await check2Webseeds() | 311 | await check2Webseeds() |
@@ -355,7 +355,7 @@ describe('Test videos redundancy', function () { | |||
355 | this.timeout(80000) | 355 | this.timeout(80000) |
356 | 356 | ||
357 | await waitJobs(servers) | 357 | await waitJobs(servers) |
358 | await servers[0].serversCommand.waitUntilLog('Duplicated ', 5) | 358 | await servers[0].servers.waitUntilLog('Duplicated ', 5) |
359 | await waitJobs(servers) | 359 | await waitJobs(servers) |
360 | 360 | ||
361 | await check2Webseeds() | 361 | await check2Webseeds() |
@@ -366,7 +366,7 @@ describe('Test videos redundancy', function () { | |||
366 | it('Should unfollow on server 1 and remove duplicated videos', async function () { | 366 | it('Should unfollow on server 1 and remove duplicated videos', async function () { |
367 | this.timeout(80000) | 367 | this.timeout(80000) |
368 | 368 | ||
369 | await servers[0].followsCommand.unfollow({ target: servers[1] }) | 369 | await servers[0].follows.unfollow({ target: servers[1] }) |
370 | 370 | ||
371 | await waitJobs(servers) | 371 | await waitJobs(servers) |
372 | await wait(5000) | 372 | await wait(5000) |
@@ -416,8 +416,8 @@ describe('Test videos redundancy', function () { | |||
416 | it('Should view 2 times the first video to have > min_views config', async function () { | 416 | it('Should view 2 times the first video to have > min_views config', async function () { |
417 | this.timeout(80000) | 417 | this.timeout(80000) |
418 | 418 | ||
419 | await servers[0].videosCommand.view({ id: video1Server2UUID }) | 419 | await servers[0].videos.view({ id: video1Server2UUID }) |
420 | await servers[2].videosCommand.view({ id: video1Server2UUID }) | 420 | await servers[2].videos.view({ id: video1Server2UUID }) |
421 | 421 | ||
422 | await wait(10000) | 422 | await wait(10000) |
423 | await waitJobs(servers) | 423 | await waitJobs(servers) |
@@ -427,7 +427,7 @@ describe('Test videos redundancy', function () { | |||
427 | this.timeout(80000) | 427 | this.timeout(80000) |
428 | 428 | ||
429 | await waitJobs(servers) | 429 | await waitJobs(servers) |
430 | await servers[0].serversCommand.waitUntilLog('Duplicated ', 5) | 430 | await servers[0].servers.waitUntilLog('Duplicated ', 5) |
431 | await waitJobs(servers) | 431 | await waitJobs(servers) |
432 | 432 | ||
433 | await check2Webseeds() | 433 | await check2Webseeds() |
@@ -438,7 +438,7 @@ describe('Test videos redundancy', function () { | |||
438 | it('Should remove the video and the redundancy files', async function () { | 438 | it('Should remove the video and the redundancy files', async function () { |
439 | this.timeout(20000) | 439 | this.timeout(20000) |
440 | 440 | ||
441 | await servers[1].videosCommand.remove({ id: video1Server2UUID }) | 441 | await servers[1].videos.remove({ id: video1Server2UUID }) |
442 | 442 | ||
443 | await waitJobs(servers) | 443 | await waitJobs(servers) |
444 | 444 | ||
@@ -484,14 +484,14 @@ describe('Test videos redundancy', function () { | |||
484 | it('Should have 1 redundancy on the first video', async function () { | 484 | it('Should have 1 redundancy on the first video', async function () { |
485 | this.timeout(160000) | 485 | this.timeout(160000) |
486 | 486 | ||
487 | await servers[0].videosCommand.view({ id: video1Server2UUID }) | 487 | await servers[0].videos.view({ id: video1Server2UUID }) |
488 | await servers[2].videosCommand.view({ id: video1Server2UUID }) | 488 | await servers[2].videos.view({ id: video1Server2UUID }) |
489 | 489 | ||
490 | await wait(10000) | 490 | await wait(10000) |
491 | await waitJobs(servers) | 491 | await waitJobs(servers) |
492 | 492 | ||
493 | await waitJobs(servers) | 493 | await waitJobs(servers) |
494 | await servers[0].serversCommand.waitUntilLog('Duplicated ', 1) | 494 | await servers[0].servers.waitUntilLog('Duplicated ', 1) |
495 | await waitJobs(servers) | 495 | await waitJobs(servers) |
496 | 496 | ||
497 | await check1PlaylistRedundancies() | 497 | await check1PlaylistRedundancies() |
@@ -501,7 +501,7 @@ describe('Test videos redundancy', function () { | |||
501 | it('Should remove the video and the redundancy files', async function () { | 501 | it('Should remove the video and the redundancy files', async function () { |
502 | this.timeout(20000) | 502 | this.timeout(20000) |
503 | 503 | ||
504 | await servers[1].videosCommand.remove({ id: video1Server2UUID }) | 504 | await servers[1].videos.remove({ id: video1Server2UUID }) |
505 | 505 | ||
506 | await waitJobs(servers) | 506 | await waitJobs(servers) |
507 | 507 | ||
@@ -529,14 +529,14 @@ describe('Test videos redundancy', function () { | |||
529 | }) | 529 | }) |
530 | 530 | ||
531 | it('Should create a redundancy on first video', async function () { | 531 | it('Should create a redundancy on first video', async function () { |
532 | await servers[0].redundancyCommand.addVideo({ videoId: video1Server2Id }) | 532 | await servers[0].redundancy.addVideo({ videoId: video1Server2Id }) |
533 | }) | 533 | }) |
534 | 534 | ||
535 | it('Should have 2 webseeds on the first video', async function () { | 535 | it('Should have 2 webseeds on the first video', async function () { |
536 | this.timeout(80000) | 536 | this.timeout(80000) |
537 | 537 | ||
538 | await waitJobs(servers) | 538 | await waitJobs(servers) |
539 | await servers[0].serversCommand.waitUntilLog('Duplicated ', 5) | 539 | await servers[0].servers.waitUntilLog('Duplicated ', 5) |
540 | await waitJobs(servers) | 540 | await waitJobs(servers) |
541 | 541 | ||
542 | await check2Webseeds() | 542 | await check2Webseeds() |
@@ -547,7 +547,7 @@ describe('Test videos redundancy', function () { | |||
547 | it('Should manually remove redundancies on server 1 and remove duplicated videos', async function () { | 547 | it('Should manually remove redundancies on server 1 and remove duplicated videos', async function () { |
548 | this.timeout(80000) | 548 | this.timeout(80000) |
549 | 549 | ||
550 | const body = await servers[0].redundancyCommand.listVideos({ target: 'remote-videos' }) | 550 | const body = await servers[0].redundancy.listVideos({ target: 'remote-videos' }) |
551 | 551 | ||
552 | const videos = body.data | 552 | const videos = body.data |
553 | expect(videos).to.have.lengthOf(1) | 553 | expect(videos).to.have.lengthOf(1) |
@@ -555,7 +555,7 @@ describe('Test videos redundancy', function () { | |||
555 | const video = videos[0] | 555 | const video = videos[0] |
556 | 556 | ||
557 | for (const r of video.redundancies.files.concat(video.redundancies.streamingPlaylists)) { | 557 | for (const r of video.redundancies.files.concat(video.redundancies.streamingPlaylists)) { |
558 | await servers[0].redundancyCommand.removeVideo({ redundancyId: r.id }) | 558 | await servers[0].redundancy.removeVideo({ redundancyId: r.id }) |
559 | } | 559 | } |
560 | 560 | ||
561 | await waitJobs(servers) | 561 | await waitJobs(servers) |
@@ -577,7 +577,7 @@ describe('Test videos redundancy', function () { | |||
577 | 577 | ||
578 | async function checkContains (servers: ServerInfo[], str: string) { | 578 | async function checkContains (servers: ServerInfo[], str: string) { |
579 | for (const server of servers) { | 579 | for (const server of servers) { |
580 | const video = await server.videosCommand.get({ id: video1Server2UUID }) | 580 | const video = await server.videos.get({ id: video1Server2UUID }) |
581 | 581 | ||
582 | for (const f of video.files) { | 582 | for (const f of video.files) { |
583 | expect(f.magnetUri).to.contain(str) | 583 | expect(f.magnetUri).to.contain(str) |
@@ -587,7 +587,7 @@ describe('Test videos redundancy', function () { | |||
587 | 587 | ||
588 | async function checkNotContains (servers: ServerInfo[], str: string) { | 588 | async function checkNotContains (servers: ServerInfo[], str: string) { |
589 | for (const server of servers) { | 589 | for (const server of servers) { |
590 | const video = await server.videosCommand.get({ id: video1Server2UUID }) | 590 | const video = await server.videos.get({ id: video1Server2UUID }) |
591 | 591 | ||
592 | for (const f of video.files) { | 592 | for (const f of video.files) { |
593 | expect(f.magnetUri).to.not.contain(str) | 593 | expect(f.magnetUri).to.not.contain(str) |
@@ -645,20 +645,20 @@ describe('Test videos redundancy', function () { | |||
645 | await enableRedundancyOnServer1() | 645 | await enableRedundancyOnServer1() |
646 | 646 | ||
647 | await waitJobs(servers) | 647 | await waitJobs(servers) |
648 | await servers[0].serversCommand.waitUntilLog('Duplicated ', 5) | 648 | await servers[0].servers.waitUntilLog('Duplicated ', 5) |
649 | await waitJobs(servers) | 649 | await waitJobs(servers) |
650 | 650 | ||
651 | await check2Webseeds(video1Server2UUID) | 651 | await check2Webseeds(video1Server2UUID) |
652 | await check1PlaylistRedundancies(video1Server2UUID) | 652 | await check1PlaylistRedundancies(video1Server2UUID) |
653 | await checkStatsWith1Redundancy(strategy) | 653 | await checkStatsWith1Redundancy(strategy) |
654 | 654 | ||
655 | const { uuid } = await servers[1].videosCommand.upload({ attributes: { name: 'video 2 server 2', privacy: VideoPrivacy.PRIVATE } }) | 655 | const { uuid } = await servers[1].videos.upload({ attributes: { name: 'video 2 server 2', privacy: VideoPrivacy.PRIVATE } }) |
656 | video2Server2UUID = uuid | 656 | video2Server2UUID = uuid |
657 | 657 | ||
658 | // Wait transcoding before federation | 658 | // Wait transcoding before federation |
659 | await waitJobs(servers) | 659 | await waitJobs(servers) |
660 | 660 | ||
661 | await servers[1].videosCommand.update({ id: video2Server2UUID, attributes: { privacy: VideoPrivacy.PUBLIC } }) | 661 | await servers[1].videos.update({ id: video2Server2UUID, attributes: { privacy: VideoPrivacy.PUBLIC } }) |
662 | }) | 662 | }) |
663 | 663 | ||
664 | it('Should cache video 2 webseeds on the first video', async function () { | 664 | it('Should cache video 2 webseeds on the first video', async function () { |