aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/redundancy
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-01-31 16:56:52 +0100
committerChocobozzz <me@florianbigard.com>2020-02-03 08:31:02 +0100
commita15871560f80e07386c1dabb8370cd2664ecfd1f (patch)
tree44440e140c9e43b0d7f97ade777a76e649e0553d /server/tests/api/redundancy
parenta22046d166805222ca76060e471b6cb3d419a32d (diff)
downloadPeerTube-a15871560f80e07386c1dabb8370cd2664ecfd1f.tar.gz
PeerTube-a15871560f80e07386c1dabb8370cd2664ecfd1f.tar.zst
PeerTube-a15871560f80e07386c1dabb8370cd2664ecfd1f.zip
Move to eslintcontain
Diffstat (limited to 'server/tests/api/redundancy')
-rw-r--r--server/tests/api/redundancy/manage-redundancy.ts44
-rw-r--r--server/tests/api/redundancy/redundancy.ts44
2 files changed, 44 insertions, 44 deletions
diff --git a/server/tests/api/redundancy/manage-redundancy.ts b/server/tests/api/redundancy/manage-redundancy.ts
index 6a8937f24..4253124c8 100644
--- a/server/tests/api/redundancy/manage-redundancy.ts
+++ b/server/tests/api/redundancy/manage-redundancy.ts
@@ -1,4 +1,4 @@
1/* tslint:disable:no-unused-expression */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import * as chai from 'chai' 3import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
@@ -56,20 +56,20 @@ describe('Test manage videos redundancy', function () {
56 await setAccessTokensToServers(servers) 56 await setAccessTokensToServers(servers)
57 57
58 { 58 {
59 const res = await uploadVideo(servers[ 1 ].url, servers[ 1 ].accessToken, { name: 'video 1 server 2' }) 59 const res = await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video 1 server 2' })
60 video1Server2UUID = res.body.video.uuid 60 video1Server2UUID = res.body.video.uuid
61 } 61 }
62 62
63 { 63 {
64 const res = await uploadVideo(servers[ 1 ].url, servers[ 1 ].accessToken, { name: 'video 2 server 2' }) 64 const res = await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video 2 server 2' })
65 video2Server2UUID = res.body.video.uuid 65 video2Server2UUID = res.body.video.uuid
66 } 66 }
67 67
68 await waitJobs(servers) 68 await waitJobs(servers)
69 69
70 // Server 1 and server 2 follow each other 70 // Server 1 and server 2 follow each other
71 await doubleFollow(servers[ 0 ], servers[ 1 ]) 71 await doubleFollow(servers[0], servers[1])
72 await updateRedundancy(servers[ 0 ].url, servers[ 0 ].accessToken, servers[ 1 ].host, true) 72 await updateRedundancy(servers[0].url, servers[0].accessToken, servers[1].host, true)
73 73
74 await waitJobs(servers) 74 await waitJobs(servers)
75 }) 75 })
@@ -195,8 +195,8 @@ describe('Test manage videos redundancy', function () {
195 }) 195 })
196 196
197 const videos = res.body.data 197 const videos = res.body.data
198 expect(videos[ 0 ].name).to.equal('video 1 server 2') 198 expect(videos[0].name).to.equal('video 1 server 2')
199 expect(videos[ 1 ].name).to.equal('video 2 server 2') 199 expect(videos[1].name).to.equal('video 2 server 2')
200 } 200 }
201 201
202 { 202 {
@@ -210,8 +210,8 @@ describe('Test manage videos redundancy', function () {
210 }) 210 })
211 211
212 const videos = res.body.data 212 const videos = res.body.data
213 expect(videos[ 0 ].name).to.equal('video 2 server 2') 213 expect(videos[0].name).to.equal('video 2 server 2')
214 expect(videos[ 1 ].name).to.equal('video 1 server 2') 214 expect(videos[1].name).to.equal('video 1 server 2')
215 } 215 }
216 216
217 { 217 {
@@ -225,14 +225,14 @@ describe('Test manage videos redundancy', function () {
225 }) 225 })
226 226
227 const videos = res.body.data 227 const videos = res.body.data
228 expect(videos[ 0 ].name).to.equal('video 1 server 2') 228 expect(videos[0].name).to.equal('video 1 server 2')
229 } 229 }
230 }) 230 })
231 231
232 it('Should manually add a redundancy and list it', async function () { 232 it('Should manually add a redundancy and list it', async function () {
233 this.timeout(120000) 233 this.timeout(120000)
234 234
235 const uuid = (await uploadVideoAndGetId({ server: servers[ 1 ], videoName: 'video 3 server 2', privacy: VideoPrivacy.UNLISTED })).uuid 235 const uuid = (await uploadVideoAndGetId({ server: servers[1], videoName: 'video 3 server 2', privacy: VideoPrivacy.UNLISTED })).uuid
236 await waitJobs(servers) 236 await waitJobs(servers)
237 const videoId = await getLocalIdByUUID(servers[0].url, uuid) 237 const videoId = await getLocalIdByUUID(servers[0].url, uuid)
238 238
@@ -257,9 +257,9 @@ describe('Test manage videos redundancy', function () {
257 }) 257 })
258 258
259 const videos = res.body.data 259 const videos = res.body.data
260 expect(videos[ 0 ].name).to.equal('video 3 server 2') 260 expect(videos[0].name).to.equal('video 3 server 2')
261 261
262 const video = videos[ 0 ] 262 const video = videos[0]
263 expect(video.redundancies.files).to.have.lengthOf(4) 263 expect(video.redundancies.files).to.have.lengthOf(4)
264 expect(video.redundancies.streamingPlaylists).to.have.lengthOf(1) 264 expect(video.redundancies.streamingPlaylists).to.have.lengthOf(1)
265 265
@@ -286,9 +286,9 @@ describe('Test manage videos redundancy', function () {
286 }) 286 })
287 287
288 const videos = res.body.data 288 const videos = res.body.data
289 expect(videos[ 0 ].name).to.equal('video 3 server 2') 289 expect(videos[0].name).to.equal('video 3 server 2')
290 290
291 const video = videos[ 0 ] 291 const video = videos[0]
292 expect(video.redundancies.files).to.have.lengthOf(4) 292 expect(video.redundancies.files).to.have.lengthOf(4)
293 expect(video.redundancies.streamingPlaylists).to.have.lengthOf(1) 293 expect(video.redundancies.streamingPlaylists).to.have.lengthOf(1)
294 294
@@ -308,8 +308,8 @@ describe('Test manage videos redundancy', function () {
308 308
309 for (const redundancyId of redundanciesToRemove) { 309 for (const redundancyId of redundanciesToRemove) {
310 await removeVideoRedundancy({ 310 await removeVideoRedundancy({
311 url: servers[ 0 ].url, 311 url: servers[0].url,
312 accessToken: servers[ 0 ].accessToken, 312 accessToken: servers[0].accessToken,
313 redundancyId 313 redundancyId
314 }) 314 })
315 } 315 }
@@ -327,10 +327,10 @@ describe('Test manage videos redundancy', function () {
327 const videos = res.body.data 327 const videos = res.body.data
328 expect(videos).to.have.lengthOf(2) 328 expect(videos).to.have.lengthOf(2)
329 329
330 expect(videos[ 0 ].name).to.equal('video 2 server 2') 330 expect(videos[0].name).to.equal('video 2 server 2')
331 331
332 redundanciesToRemove = [] 332 redundanciesToRemove = []
333 const video = videos[ 0 ] 333 const video = videos[0]
334 expect(video.redundancies.files).to.have.lengthOf(4) 334 expect(video.redundancies.files).to.have.lengthOf(4)
335 expect(video.redundancies.streamingPlaylists).to.have.lengthOf(1) 335 expect(video.redundancies.streamingPlaylists).to.have.lengthOf(1)
336 336
@@ -346,8 +346,8 @@ describe('Test manage videos redundancy', function () {
346 { 346 {
347 for (const redundancyId of redundanciesToRemove) { 347 for (const redundancyId of redundanciesToRemove) {
348 await removeVideoRedundancy({ 348 await removeVideoRedundancy({
349 url: servers[ 0 ].url, 349 url: servers[0].url,
350 accessToken: servers[ 0 ].accessToken, 350 accessToken: servers[0].accessToken,
351 redundancyId 351 redundancyId
352 }) 352 })
353 } 353 }
@@ -362,7 +362,7 @@ describe('Test manage videos redundancy', function () {
362 }) 362 })
363 363
364 const videos = res.body.data 364 const videos = res.body.data
365 expect(videos[ 0 ].name).to.equal('video 1 server 2') 365 expect(videos[0].name).to.equal('video 1 server 2')
366 expect(videos).to.have.lengthOf(1) 366 expect(videos).to.have.lengthOf(1)
367 } 367 }
368 }) 368 })
diff --git a/server/tests/api/redundancy/redundancy.ts b/server/tests/api/redundancy/redundancy.ts
index f5bf130d5..c5037a541 100644
--- a/server/tests/api/redundancy/redundancy.ts
+++ b/server/tests/api/redundancy/redundancy.ts
@@ -1,4 +1,4 @@
1/* tslint:disable:no-unused-expression */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import * as chai from 'chai' 3import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
@@ -92,21 +92,21 @@ async function flushAndRunServers (strategy: VideoRedundancyStrategy | null, add
92 await setAccessTokensToServers(servers) 92 await setAccessTokensToServers(servers)
93 93
94 { 94 {
95 const res = await uploadVideo(servers[ 1 ].url, servers[ 1 ].accessToken, { name: 'video 1 server 2' }) 95 const res = await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video 1 server 2' })
96 video1Server2UUID = res.body.video.uuid 96 video1Server2UUID = res.body.video.uuid
97 video1Server2Id = res.body.video.id 97 video1Server2Id = res.body.video.id
98 98
99 await viewVideo(servers[ 1 ].url, video1Server2UUID) 99 await viewVideo(servers[1].url, video1Server2UUID)
100 } 100 }
101 101
102 await waitJobs(servers) 102 await waitJobs(servers)
103 103
104 // Server 1 and server 2 follow each other 104 // Server 1 and server 2 follow each other
105 await doubleFollow(servers[ 0 ], servers[ 1 ]) 105 await doubleFollow(servers[0], servers[1])
106 // Server 1 and server 3 follow each other 106 // Server 1 and server 3 follow each other
107 await doubleFollow(servers[ 0 ], servers[ 2 ]) 107 await doubleFollow(servers[0], servers[2])
108 // Server 2 and server 3 follow each other 108 // Server 2 and server 3 follow each other
109 await doubleFollow(servers[ 1 ], servers[ 2 ]) 109 await doubleFollow(servers[1], servers[2])
110 110
111 await waitJobs(servers) 111 await waitJobs(servers)
112} 112}
@@ -115,7 +115,7 @@ async function check1WebSeed (videoUUID?: string) {
115 if (!videoUUID) videoUUID = video1Server2UUID 115 if (!videoUUID) videoUUID = video1Server2UUID
116 116
117 const webseeds = [ 117 const webseeds = [
118 `http://localhost:${servers[ 1 ].port}/static/webseed/${videoUUID}` 118 `http://localhost:${servers[1].port}/static/webseed/${videoUUID}`
119 ] 119 ]
120 120
121 for (const server of servers) { 121 for (const server of servers) {
@@ -133,8 +133,8 @@ async function check2Webseeds (videoUUID?: string) {
133 if (!videoUUID) videoUUID = video1Server2UUID 133 if (!videoUUID) videoUUID = video1Server2UUID
134 134
135 const webseeds = [ 135 const webseeds = [
136 `http://localhost:${servers[ 0 ].port}/static/redundancy/${videoUUID}`, 136 `http://localhost:${servers[0].port}/static/redundancy/${videoUUID}`,
137 `http://localhost:${servers[ 1 ].port}/static/webseed/${videoUUID}` 137 `http://localhost:${servers[1].port}/static/webseed/${videoUUID}`
138 ] 138 ]
139 139
140 for (const server of servers) { 140 for (const server of servers) {
@@ -269,12 +269,12 @@ async function checkStatsWith1Webseed (strategy: VideoRedundancyStrategyWithManu
269} 269}
270 270
271async function enableRedundancyOnServer1 () { 271async function enableRedundancyOnServer1 () {
272 await updateRedundancy(servers[ 0 ].url, servers[ 0 ].accessToken, servers[ 1 ].host, true) 272 await updateRedundancy(servers[0].url, servers[0].accessToken, servers[1].host, true)
273 273
274 const res = await getFollowingListPaginationAndSort({ url: servers[ 0 ].url, start: 0, count: 5, sort: '-createdAt' }) 274 const res = await getFollowingListPaginationAndSort({ url: servers[0].url, start: 0, count: 5, sort: '-createdAt' })
275 const follows: ActorFollow[] = res.body.data 275 const follows: ActorFollow[] = res.body.data
276 const server2 = follows.find(f => f.following.host === `localhost:${servers[ 1 ].port}`) 276 const server2 = follows.find(f => f.following.host === `localhost:${servers[1].port}`)
277 const server3 = follows.find(f => f.following.host === `localhost:${servers[ 2 ].port}`) 277 const server3 = follows.find(f => f.following.host === `localhost:${servers[2].port}`)
278 278
279 expect(server3).to.not.be.undefined 279 expect(server3).to.not.be.undefined
280 expect(server3.following.hostRedundancyAllowed).to.be.false 280 expect(server3.following.hostRedundancyAllowed).to.be.false
@@ -284,12 +284,12 @@ async function enableRedundancyOnServer1 () {
284} 284}
285 285
286async function disableRedundancyOnServer1 () { 286async function disableRedundancyOnServer1 () {
287 await updateRedundancy(servers[ 0 ].url, servers[ 0 ].accessToken, servers[ 1 ].host, false) 287 await updateRedundancy(servers[0].url, servers[0].accessToken, servers[1].host, false)
288 288
289 const res = await getFollowingListPaginationAndSort({ url: servers[ 0 ].url, start: 0, count: 5, sort: '-createdAt' }) 289 const res = await getFollowingListPaginationAndSort({ url: servers[0].url, start: 0, count: 5, sort: '-createdAt' })
290 const follows: ActorFollow[] = res.body.data 290 const follows: ActorFollow[] = res.body.data
291 const server2 = follows.find(f => f.following.host === `localhost:${servers[ 1 ].port}`) 291 const server2 = follows.find(f => f.following.host === `localhost:${servers[1].port}`)
292 const server3 = follows.find(f => f.following.host === `localhost:${servers[ 2 ].port}`) 292 const server3 = follows.find(f => f.following.host === `localhost:${servers[2].port}`)
293 293
294 expect(server3).to.not.be.undefined 294 expect(server3).to.not.be.undefined
295 expect(server3.following.hostRedundancyAllowed).to.be.false 295 expect(server3.following.hostRedundancyAllowed).to.be.false
@@ -434,8 +434,8 @@ describe('Test videos redundancy', function () {
434 it('Should view 2 times the first video to have > min_views config', async function () { 434 it('Should view 2 times the first video to have > min_views config', async function () {
435 this.timeout(80000) 435 this.timeout(80000)
436 436
437 await viewVideo(servers[ 0 ].url, video1Server2UUID) 437 await viewVideo(servers[0].url, video1Server2UUID)
438 await viewVideo(servers[ 2 ].url, video1Server2UUID) 438 await viewVideo(servers[2].url, video1Server2UUID)
439 439
440 await wait(10000) 440 await wait(10000)
441 await waitJobs(servers) 441 await waitJobs(servers)
@@ -620,7 +620,7 @@ describe('Test videos redundancy', function () {
620 await check1PlaylistRedundancies() 620 await check1PlaylistRedundancies()
621 await checkStatsWith2Webseed(strategy) 621 await checkStatsWith2Webseed(strategy)
622 622
623 const res = await uploadVideo(servers[ 1 ].url, servers[ 1 ].accessToken, { name: 'video 2 server 2' }) 623 const res = await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video 2 server 2' })
624 video2Server2UUID = res.body.video.uuid 624 video2Server2UUID = res.body.video.uuid
625 }) 625 })
626 626
@@ -652,8 +652,8 @@ describe('Test videos redundancy', function () {
652 652
653 await waitJobs(servers) 653 await waitJobs(servers)
654 654
655 killallServers([ servers[ 0 ] ]) 655 killallServers([ servers[0] ])
656 await reRunServer(servers[ 0 ], { 656 await reRunServer(servers[0], {
657 redundancy: { 657 redundancy: {
658 videos: { 658 videos: {
659 check_interval: '1 second', 659 check_interval: '1 second',