diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-15 10:02:54 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-07-20 15:27:18 +0200 |
commit | d23dd9fbfc4d26026352c10f81d2795ceaf2908a (patch) | |
tree | da82286d423c5e834a1ee2dcd5970076b8263cf1 /server/tests/api/redundancy/redundancy.ts | |
parent | 7926c5f9b3ffcabb1ffb0dcfa5e48b8e0b88fbc0 (diff) | |
download | PeerTube-d23dd9fbfc4d26026352c10f81d2795ceaf2908a.tar.gz PeerTube-d23dd9fbfc4d26026352c10f81d2795ceaf2908a.tar.zst PeerTube-d23dd9fbfc4d26026352c10f81d2795ceaf2908a.zip |
Introduce videos command
Diffstat (limited to 'server/tests/api/redundancy/redundancy.ts')
-rw-r--r-- | server/tests/api/redundancy/redundancy.ts | 57 |
1 files changed, 22 insertions, 35 deletions
diff --git a/server/tests/api/redundancy/redundancy.ts b/server/tests/api/redundancy/redundancy.ts index 00a5e86cc..6ca9c9303 100644 --- a/server/tests/api/redundancy/redundancy.ts +++ b/server/tests/api/redundancy/redundancy.ts | |||
@@ -12,22 +12,16 @@ import { | |||
12 | cleanupTests, | 12 | cleanupTests, |
13 | doubleFollow, | 13 | doubleFollow, |
14 | flushAndRunMultipleServers, | 14 | flushAndRunMultipleServers, |
15 | getVideo, | ||
16 | getVideoWithToken, | ||
17 | killallServers, | 15 | killallServers, |
18 | makeGetRequest, | 16 | makeGetRequest, |
19 | removeVideo, | ||
20 | reRunServer, | 17 | reRunServer, |
21 | root, | 18 | root, |
22 | ServerInfo, | 19 | ServerInfo, |
23 | setAccessTokensToServers, | 20 | setAccessTokensToServers, |
24 | updateVideo, | ||
25 | uploadVideo, | ||
26 | viewVideo, | ||
27 | wait, | 21 | wait, |
28 | waitJobs | 22 | waitJobs |
29 | } from '@shared/extra-utils' | 23 | } from '@shared/extra-utils' |
30 | import { VideoDetails, VideoPrivacy, VideoRedundancyStrategy, VideoRedundancyStrategyWithManual } from '@shared/models' | 24 | import { VideoPrivacy, VideoRedundancyStrategy, VideoRedundancyStrategyWithManual } from '@shared/models' |
31 | 25 | ||
32 | const expect = chai.expect | 26 | const expect = chai.expect |
33 | 27 | ||
@@ -84,11 +78,11 @@ async function flushAndRunServers (strategy: VideoRedundancyStrategy | null, add | |||
84 | await setAccessTokensToServers(servers) | 78 | await setAccessTokensToServers(servers) |
85 | 79 | ||
86 | { | 80 | { |
87 | const res = await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video 1 server 2' }) | 81 | const { uuid, id } = await servers[1].videosCommand.upload({ attributes: { name: 'video 1 server 2' } }) |
88 | video1Server2UUID = res.body.video.uuid | 82 | video1Server2UUID = uuid |
89 | video1Server2Id = res.body.video.id | 83 | video1Server2Id = id |
90 | 84 | ||
91 | await viewVideo(servers[1].url, video1Server2UUID) | 85 | await servers[1].videosCommand.view({ id: video1Server2UUID }) |
92 | } | 86 | } |
93 | 87 | ||
94 | await waitJobs(servers) | 88 | await waitJobs(servers) |
@@ -112,9 +106,8 @@ async function check1WebSeed (videoUUID?: string) { | |||
112 | 106 | ||
113 | for (const server of servers) { | 107 | for (const server of servers) { |
114 | // With token to avoid issues with video follow constraints | 108 | // With token to avoid issues with video follow constraints |
115 | const res = await getVideoWithToken(server.url, server.accessToken, videoUUID) | 109 | const video = await server.videosCommand.getWithToken({ id: videoUUID }) |
116 | 110 | ||
117 | const video: VideoDetails = res.body | ||
118 | for (const f of video.files) { | 111 | for (const f of video.files) { |
119 | checkMagnetWebseeds(f, webseeds, server) | 112 | checkMagnetWebseeds(f, webseeds, server) |
120 | } | 113 | } |
@@ -130,9 +123,7 @@ async function check2Webseeds (videoUUID?: string) { | |||
130 | ] | 123 | ] |
131 | 124 | ||
132 | for (const server of servers) { | 125 | for (const server of servers) { |
133 | const res = await getVideo(server.url, videoUUID) | 126 | const video = await server.videosCommand.get({ id: videoUUID }) |
134 | |||
135 | const video: VideoDetails = res.body | ||
136 | 127 | ||
137 | for (const file of video.files) { | 128 | for (const file of video.files) { |
138 | checkMagnetWebseeds(file, webseeds, server) | 129 | checkMagnetWebseeds(file, webseeds, server) |
@@ -172,8 +163,7 @@ async function check0PlaylistRedundancies (videoUUID?: string) { | |||
172 | 163 | ||
173 | for (const server of servers) { | 164 | for (const server of servers) { |
174 | // With token to avoid issues with video follow constraints | 165 | // With token to avoid issues with video follow constraints |
175 | const res = await getVideoWithToken(server.url, server.accessToken, videoUUID) | 166 | const video = await server.videosCommand.getWithToken({ id: videoUUID }) |
176 | const video: VideoDetails = res.body | ||
177 | 167 | ||
178 | expect(video.streamingPlaylists).to.be.an('array') | 168 | expect(video.streamingPlaylists).to.be.an('array') |
179 | expect(video.streamingPlaylists).to.have.lengthOf(1) | 169 | expect(video.streamingPlaylists).to.have.lengthOf(1) |
@@ -185,8 +175,7 @@ async function check1PlaylistRedundancies (videoUUID?: string) { | |||
185 | if (!videoUUID) videoUUID = video1Server2UUID | 175 | if (!videoUUID) videoUUID = video1Server2UUID |
186 | 176 | ||
187 | for (const server of servers) { | 177 | for (const server of servers) { |
188 | const res = await getVideo(server.url, videoUUID) | 178 | const video = await server.videosCommand.get({ id: videoUUID }) |
189 | const video: VideoDetails = res.body | ||
190 | 179 | ||
191 | expect(video.streamingPlaylists).to.have.lengthOf(1) | 180 | expect(video.streamingPlaylists).to.have.lengthOf(1) |
192 | expect(video.streamingPlaylists[0].redundancies).to.have.lengthOf(1) | 181 | expect(video.streamingPlaylists[0].redundancies).to.have.lengthOf(1) |
@@ -199,8 +188,8 @@ async function check1PlaylistRedundancies (videoUUID?: string) { | |||
199 | const baseUrlPlaylist = servers[1].url + '/static/streaming-playlists/hls' | 188 | const baseUrlPlaylist = servers[1].url + '/static/streaming-playlists/hls' |
200 | const baseUrlSegment = servers[0].url + '/static/redundancy/hls' | 189 | const baseUrlSegment = servers[0].url + '/static/redundancy/hls' |
201 | 190 | ||
202 | const res = await getVideo(servers[0].url, videoUUID) | 191 | const video = await servers[0].videosCommand.get({ id: videoUUID }) |
203 | const hlsPlaylist = (res.body as VideoDetails).streamingPlaylists[0] | 192 | const hlsPlaylist = video.streamingPlaylists[0] |
204 | 193 | ||
205 | for (const resolution of [ 240, 360, 480, 720 ]) { | 194 | for (const resolution of [ 240, 360, 480, 720 ]) { |
206 | await checkSegmentHash({ server: servers[1], baseUrlPlaylist, baseUrlSegment, videoUUID, resolution, hlsPlaylist }) | 195 | await checkSegmentHash({ server: servers[1], baseUrlPlaylist, baseUrlSegment, videoUUID, resolution, hlsPlaylist }) |
@@ -427,8 +416,8 @@ describe('Test videos redundancy', function () { | |||
427 | 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 () { |
428 | this.timeout(80000) | 417 | this.timeout(80000) |
429 | 418 | ||
430 | await viewVideo(servers[0].url, video1Server2UUID) | 419 | await servers[0].videosCommand.view({ id: video1Server2UUID }) |
431 | await viewVideo(servers[2].url, video1Server2UUID) | 420 | await servers[2].videosCommand.view({ id: video1Server2UUID }) |
432 | 421 | ||
433 | await wait(10000) | 422 | await wait(10000) |
434 | await waitJobs(servers) | 423 | await waitJobs(servers) |
@@ -449,7 +438,7 @@ describe('Test videos redundancy', function () { | |||
449 | it('Should remove the video and the redundancy files', async function () { | 438 | it('Should remove the video and the redundancy files', async function () { |
450 | this.timeout(20000) | 439 | this.timeout(20000) |
451 | 440 | ||
452 | await removeVideo(servers[1].url, servers[1].accessToken, video1Server2UUID) | 441 | await servers[1].videosCommand.remove({ id: video1Server2UUID }) |
453 | 442 | ||
454 | await waitJobs(servers) | 443 | await waitJobs(servers) |
455 | 444 | ||
@@ -495,8 +484,8 @@ describe('Test videos redundancy', function () { | |||
495 | it('Should have 1 redundancy on the first video', async function () { | 484 | it('Should have 1 redundancy on the first video', async function () { |
496 | this.timeout(160000) | 485 | this.timeout(160000) |
497 | 486 | ||
498 | await viewVideo(servers[0].url, video1Server2UUID) | 487 | await servers[0].videosCommand.view({ id: video1Server2UUID }) |
499 | await viewVideo(servers[2].url, video1Server2UUID) | 488 | await servers[2].videosCommand.view({ id: video1Server2UUID }) |
500 | 489 | ||
501 | await wait(10000) | 490 | await wait(10000) |
502 | await waitJobs(servers) | 491 | await waitJobs(servers) |
@@ -512,7 +501,7 @@ describe('Test videos redundancy', function () { | |||
512 | it('Should remove the video and the redundancy files', async function () { | 501 | it('Should remove the video and the redundancy files', async function () { |
513 | this.timeout(20000) | 502 | this.timeout(20000) |
514 | 503 | ||
515 | await removeVideo(servers[1].url, servers[1].accessToken, video1Server2UUID) | 504 | await servers[1].videosCommand.remove({ id: video1Server2UUID }) |
516 | 505 | ||
517 | await waitJobs(servers) | 506 | await waitJobs(servers) |
518 | 507 | ||
@@ -588,8 +577,7 @@ describe('Test videos redundancy', function () { | |||
588 | 577 | ||
589 | async function checkContains (servers: ServerInfo[], str: string) { | 578 | async function checkContains (servers: ServerInfo[], str: string) { |
590 | for (const server of servers) { | 579 | for (const server of servers) { |
591 | const res = await getVideo(server.url, video1Server2UUID) | 580 | const video = await server.videosCommand.get({ id: video1Server2UUID }) |
592 | const video: VideoDetails = res.body | ||
593 | 581 | ||
594 | for (const f of video.files) { | 582 | for (const f of video.files) { |
595 | expect(f.magnetUri).to.contain(str) | 583 | expect(f.magnetUri).to.contain(str) |
@@ -599,8 +587,7 @@ describe('Test videos redundancy', function () { | |||
599 | 587 | ||
600 | async function checkNotContains (servers: ServerInfo[], str: string) { | 588 | async function checkNotContains (servers: ServerInfo[], str: string) { |
601 | for (const server of servers) { | 589 | for (const server of servers) { |
602 | const res = await getVideo(server.url, video1Server2UUID) | 590 | const video = await server.videosCommand.get({ id: video1Server2UUID }) |
603 | const video: VideoDetails = res.body | ||
604 | 591 | ||
605 | for (const f of video.files) { | 592 | for (const f of video.files) { |
606 | expect(f.magnetUri).to.not.contain(str) | 593 | expect(f.magnetUri).to.not.contain(str) |
@@ -665,13 +652,13 @@ describe('Test videos redundancy', function () { | |||
665 | await check1PlaylistRedundancies(video1Server2UUID) | 652 | await check1PlaylistRedundancies(video1Server2UUID) |
666 | await checkStatsWith1Redundancy(strategy) | 653 | await checkStatsWith1Redundancy(strategy) |
667 | 654 | ||
668 | const res = await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video 2 server 2', privacy: VideoPrivacy.PRIVATE }) | 655 | const { uuid } = await servers[1].videosCommand.upload({ attributes: { name: 'video 2 server 2', privacy: VideoPrivacy.PRIVATE } }) |
669 | video2Server2UUID = res.body.video.uuid | 656 | video2Server2UUID = uuid |
670 | 657 | ||
671 | // Wait transcoding before federation | 658 | // Wait transcoding before federation |
672 | await waitJobs(servers) | 659 | await waitJobs(servers) |
673 | 660 | ||
674 | await updateVideo(servers[1].url, servers[1].accessToken, video2Server2UUID, { privacy: VideoPrivacy.PUBLIC }) | 661 | await servers[1].videosCommand.update({ id: video2Server2UUID, attributes: { privacy: VideoPrivacy.PUBLIC } }) |
675 | }) | 662 | }) |
676 | 663 | ||
677 | 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 () { |