aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-08-06 17:19:53 +0200
committerChocobozzz <me@florianbigard.com>2019-08-06 17:26:51 +0200
commit6b9c966f6428c9e47bead3410a0401e8ebd744bf (patch)
tree282218ec56725b0e2e878b0471cd08a54fd91998 /server/tests/api
parent466e3f20a537f1eff4b4fd03297df11ba371d049 (diff)
downloadPeerTube-6b9c966f6428c9e47bead3410a0401e8ebd744bf.tar.gz
PeerTube-6b9c966f6428c9e47bead3410a0401e8ebd744bf.tar.zst
PeerTube-6b9c966f6428c9e47bead3410a0401e8ebd744bf.zip
Automatically remove bad followings
Diffstat (limited to 'server/tests/api')
-rw-r--r--server/tests/api/server/handle-down.ts54
1 files changed, 52 insertions, 2 deletions
diff --git a/server/tests/api/server/handle-down.ts b/server/tests/api/server/handle-down.ts
index a225443c5..420289bf4 100644
--- a/server/tests/api/server/handle-down.ts
+++ b/server/tests/api/server/handle-down.ts
@@ -19,8 +19,9 @@ import {
19 setAccessTokensToServers, 19 setAccessTokensToServers,
20 unfollow, 20 unfollow,
21 updateVideo, 21 updateVideo,
22 uploadVideo, 22 uploadVideo, uploadVideoAndGetId,
23 wait 23 wait,
24 setActorFollowScores, closeAllSequelize
24} from '../../../../shared/extra-utils' 25} from '../../../../shared/extra-utils'
25import { follow, getFollowersListPaginationAndSort } from '../../../../shared/extra-utils/server/follows' 26import { follow, getFollowersListPaginationAndSort } from '../../../../shared/extra-utils/server/follows'
26import { getJobsListPaginationAndSort, waitJobs } from '../../../../shared/extra-utils/server/jobs' 27import { getJobsListPaginationAndSort, waitJobs } from '../../../../shared/extra-utils/server/jobs'
@@ -43,6 +44,8 @@ describe('Test handle downs', function () {
43 let missedVideo2: Video 44 let missedVideo2: Video
44 let unlistedVideo: Video 45 let unlistedVideo: Video
45 46
47 let videoIdsServer1: number[] = []
48
46 const videoAttributes = { 49 const videoAttributes = {
47 name: 'my super name for server 1', 50 name: 'my super name for server 1',
48 category: 5, 51 category: 5,
@@ -299,7 +302,54 @@ describe('Test handle downs', function () {
299 } 302 }
300 }) 303 })
301 304
305 it('Should upload many videos on server 1', async function () {
306 this.timeout(120000)
307
308 for (let i = 0; i < 10; i++) {
309 const uuid = (await uploadVideoAndGetId({ server: servers[ 0 ], videoName: 'video ' + i })).uuid
310 videoIdsServer1.push(uuid)
311 }
312
313 await waitJobs(servers)
314
315 for (const id of videoIdsServer1) {
316 await getVideo(servers[ 1 ].url, id)
317 }
318
319 await waitJobs(servers)
320 await setActorFollowScores(servers[1].internalServerNumber, 20)
321
322 // Wait video expiration
323 await wait(11000)
324
325 // Refresh video -> score + 10 = 30
326 await getVideo(servers[1].url, videoIdsServer1[0])
327
328 await waitJobs(servers)
329 })
330
331 it('Should remove followings that are down', async function () {
332 this.timeout(120000)
333
334 killallServers([ servers[0] ])
335
336 // Wait video expiration
337 await wait(11000)
338
339 for (let i = 0; i < 3; i++) {
340 await getVideo(servers[1].url, videoIdsServer1[i])
341 await wait(1000)
342 await waitJobs([ servers[1] ])
343 }
344
345 for (const id of videoIdsServer1) {
346 await getVideo(servers[1].url, id, 403)
347 }
348 })
349
302 after(async function () { 350 after(async function () {
351 await closeAllSequelize([ servers[1] ])
352
303 await cleanupTests(servers) 353 await cleanupTests(servers)
304 }) 354 })
305}) 355})