aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/redundancy
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-15 10:02:54 +0200
committerChocobozzz <me@florianbigard.com>2021-07-20 15:27:18 +0200
commitd23dd9fbfc4d26026352c10f81d2795ceaf2908a (patch)
treeda82286d423c5e834a1ee2dcd5970076b8263cf1 /server/tests/api/redundancy
parent7926c5f9b3ffcabb1ffb0dcfa5e48b8e0b88fbc0 (diff)
downloadPeerTube-d23dd9fbfc4d26026352c10f81d2795ceaf2908a.tar.gz
PeerTube-d23dd9fbfc4d26026352c10f81d2795ceaf2908a.tar.zst
PeerTube-d23dd9fbfc4d26026352c10f81d2795ceaf2908a.zip
Introduce videos command
Diffstat (limited to 'server/tests/api/redundancy')
-rw-r--r--server/tests/api/redundancy/manage-redundancy.ts15
-rw-r--r--server/tests/api/redundancy/redundancy-constraints.ts8
-rw-r--r--server/tests/api/redundancy/redundancy.ts57
3 files changed, 31 insertions, 49 deletions
diff --git a/server/tests/api/redundancy/manage-redundancy.ts b/server/tests/api/redundancy/manage-redundancy.ts
index 03857f512..efb60dc56 100644
--- a/server/tests/api/redundancy/manage-redundancy.ts
+++ b/server/tests/api/redundancy/manage-redundancy.ts
@@ -6,12 +6,9 @@ import {
6 cleanupTests, 6 cleanupTests,
7 doubleFollow, 7 doubleFollow,
8 flushAndRunMultipleServers, 8 flushAndRunMultipleServers,
9 getLocalIdByUUID,
10 RedundancyCommand, 9 RedundancyCommand,
11 ServerInfo, 10 ServerInfo,
12 setAccessTokensToServers, 11 setAccessTokensToServers,
13 uploadVideo,
14 uploadVideoAndGetId,
15 waitJobs 12 waitJobs
16} from '@shared/extra-utils' 13} from '@shared/extra-utils'
17import { VideoPrivacy, VideoRedundanciesTarget } from '@shared/models' 14import { VideoPrivacy, VideoRedundanciesTarget } from '@shared/models'
@@ -59,13 +56,13 @@ describe('Test manage videos redundancy', function () {
59 commands = servers.map(s => s.redundancyCommand) 56 commands = servers.map(s => s.redundancyCommand)
60 57
61 { 58 {
62 const res = await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video 1 server 2' }) 59 const { uuid } = await servers[1].videosCommand.upload({ attributes: { name: 'video 1 server 2' } })
63 video1Server2UUID = res.body.video.uuid 60 video1Server2UUID = uuid
64 } 61 }
65 62
66 { 63 {
67 const res = await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video 2 server 2' }) 64 const { uuid } = await servers[1].videosCommand.upload({ attributes: { name: 'video 2 server 2' } })
68 video2Server2UUID = res.body.video.uuid 65 video2Server2UUID = uuid
69 } 66 }
70 67
71 await waitJobs(servers) 68 await waitJobs(servers)
@@ -206,9 +203,9 @@ describe('Test manage videos redundancy', function () {
206 it('Should manually add a redundancy and list it', async function () { 203 it('Should manually add a redundancy and list it', async function () {
207 this.timeout(120000) 204 this.timeout(120000)
208 205
209 const uuid = (await uploadVideoAndGetId({ server: servers[1], videoName: 'video 3 server 2', privacy: VideoPrivacy.UNLISTED })).uuid 206 const uuid = (await servers[1].videosCommand.quickUpload({ name: 'video 3 server 2', privacy: VideoPrivacy.UNLISTED })).uuid
210 await waitJobs(servers) 207 await waitJobs(servers)
211 const videoId = await getLocalIdByUUID(servers[0].url, uuid) 208 const videoId = await servers[0].videosCommand.getId({ uuid })
212 209
213 await commands[0].addVideo({ videoId }) 210 await commands[0].addVideo({ videoId })
214 211
diff --git a/server/tests/api/redundancy/redundancy-constraints.ts b/server/tests/api/redundancy/redundancy-constraints.ts
index a31278de7..b3f6ed160 100644
--- a/server/tests/api/redundancy/redundancy-constraints.ts
+++ b/server/tests/api/redundancy/redundancy-constraints.ts
@@ -9,8 +9,6 @@ import {
9 reRunServer, 9 reRunServer,
10 ServerInfo, 10 ServerInfo,
11 setAccessTokensToServers, 11 setAccessTokensToServers,
12 updateVideo,
13 uploadVideo,
14 waitJobs 12 waitJobs
15} from '@shared/extra-utils' 13} from '@shared/extra-utils'
16import { VideoPrivacy } from '@shared/models' 14import { VideoPrivacy } from '@shared/models'
@@ -38,11 +36,11 @@ describe('Test redundancy constraints', function () {
38 36
39 async function uploadWrapper (videoName: string) { 37 async function uploadWrapper (videoName: string) {
40 // Wait for transcoding 38 // Wait for transcoding
41 const res = await uploadVideo(localServer.url, localServer.accessToken, { name: 'to transcode', privacy: VideoPrivacy.PRIVATE }) 39 const { id } = await localServer.videosCommand.upload({ attributes: { name: 'to transcode', privacy: VideoPrivacy.PRIVATE } })
42 await waitJobs([ localServer ]) 40 await waitJobs([ localServer ])
43 41
44 // Update video to schedule a federation 42 // Update video to schedule a federation
45 await updateVideo(localServer.url, localServer.accessToken, res.body.video.id, { name: videoName, privacy: VideoPrivacy.PUBLIC }) 43 await localServer.videosCommand.update({ id, attributes: { name: videoName, privacy: VideoPrivacy.PUBLIC } })
46 } 44 }
47 45
48 async function getTotalRedundanciesLocalServer () { 46 async function getTotalRedundanciesLocalServer () {
@@ -80,7 +78,7 @@ describe('Test redundancy constraints', function () {
80 // Get the access tokens 78 // Get the access tokens
81 await setAccessTokensToServers(servers) 79 await setAccessTokensToServers(servers)
82 80
83 await uploadVideo(localServer.url, localServer.accessToken, { name: 'video 1 server 2' }) 81 await localServer.videosCommand.upload({ attributes: { name: 'video 1 server 2' } })
84 82
85 await waitJobs(servers) 83 await waitJobs(servers)
86 84
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'
30import { VideoDetails, VideoPrivacy, VideoRedundancyStrategy, VideoRedundancyStrategyWithManual } from '@shared/models' 24import { VideoPrivacy, VideoRedundancyStrategy, VideoRedundancyStrategyWithManual } from '@shared/models'
31 25
32const expect = chai.expect 26const 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 () {