aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/redundancy
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-07 09:16:40 +0200
committerChocobozzz <me@florianbigard.com>2021-07-20 15:27:17 +0200
commitc3d29f694bf8c910f917be655626d0f80871124f (patch)
treec90dfdc1245c8a9aca49e9ea9c71ed8e6b9dd35f /server/tests/api/redundancy
parent883a9019085ff9013079d6b1539b86f2f519175a (diff)
downloadPeerTube-c3d29f694bf8c910f917be655626d0f80871124f.tar.gz
PeerTube-c3d29f694bf8c910f917be655626d0f80871124f.tar.zst
PeerTube-c3d29f694bf8c910f917be655626d0f80871124f.zip
Introduce follows command
Diffstat (limited to 'server/tests/api/redundancy')
-rw-r--r--server/tests/api/redundancy/redundancy-constraints.ts5
-rw-r--r--server/tests/api/redundancy/redundancy.ts24
2 files changed, 14 insertions, 15 deletions
diff --git a/server/tests/api/redundancy/redundancy-constraints.ts b/server/tests/api/redundancy/redundancy-constraints.ts
index 1cb1603bc..602f4bc1b 100644
--- a/server/tests/api/redundancy/redundancy-constraints.ts
+++ b/server/tests/api/redundancy/redundancy-constraints.ts
@@ -7,7 +7,6 @@ import { VideoPrivacy } from '@shared/models'
7import { 7import {
8 cleanupTests, 8 cleanupTests,
9 flushAndRunServer, 9 flushAndRunServer,
10 follow,
11 killallServers, 10 killallServers,
12 reRunServer, 11 reRunServer,
13 ServerInfo, 12 ServerInfo,
@@ -98,7 +97,7 @@ describe('Test redundancy constraints', function () {
98 await waitJobs(servers) 97 await waitJobs(servers)
99 98
100 // Server 1 and server 2 follow each other 99 // Server 1 and server 2 follow each other
101 await follow(remoteServer.url, [ localServer.url ], remoteServer.accessToken) 100 await remoteServer.followsCommand.follow({ targets: [ localServer.url ] })
102 await waitJobs(servers) 101 await waitJobs(servers)
103 await updateRedundancy(remoteServer.url, remoteServer.accessToken, localServer.host, true) 102 await updateRedundancy(remoteServer.url, remoteServer.accessToken, localServer.host, true)
104 103
@@ -184,7 +183,7 @@ describe('Test redundancy constraints', function () {
184 it('Should have redundancy on server 1 and on server 2 with followings filter now server 2 follows server 1', async function () { 183 it('Should have redundancy on server 1 and on server 2 with followings filter now server 2 follows server 1', async function () {
185 this.timeout(120000) 184 this.timeout(120000)
186 185
187 await follow(localServer.url, [ remoteServer.url ], localServer.accessToken) 186 await localServer.followsCommand.follow({ targets: [ remoteServer.url ] })
188 await waitJobs(servers) 187 await waitJobs(servers)
189 188
190 await uploadWrapper('video 4 server 2') 189 await uploadWrapper('video 4 server 2')
diff --git a/server/tests/api/redundancy/redundancy.ts b/server/tests/api/redundancy/redundancy.ts
index 0e0a73b9d..dfe8099ed 100644
--- a/server/tests/api/redundancy/redundancy.ts
+++ b/server/tests/api/redundancy/redundancy.ts
@@ -12,7 +12,6 @@ import {
12 cleanupTests, 12 cleanupTests,
13 doubleFollow, 13 doubleFollow,
14 flushAndRunMultipleServers, 14 flushAndRunMultipleServers,
15 getFollowingListPaginationAndSort,
16 getVideo, 15 getVideo,
17 getVideoWithToken, 16 getVideoWithToken,
18 immutableAssign, 17 immutableAssign,
@@ -23,7 +22,6 @@ import {
23 root, 22 root,
24 ServerInfo, 23 ServerInfo,
25 setAccessTokensToServers, 24 setAccessTokensToServers,
26 unfollow,
27 updateVideo, 25 updateVideo,
28 uploadVideo, 26 uploadVideo,
29 viewVideo, 27 viewVideo,
@@ -38,7 +36,6 @@ import {
38 updateRedundancy 36 updateRedundancy
39} from '../../../../shared/extra-utils/server/redundancy' 37} from '../../../../shared/extra-utils/server/redundancy'
40import { getStats } from '../../../../shared/extra-utils/server/stats' 38import { getStats } from '../../../../shared/extra-utils/server/stats'
41import { ActorFollow } from '../../../../shared/models/actors'
42import { VideoRedundancy, VideoRedundancyStrategy, VideoRedundancyStrategyWithManual } from '../../../../shared/models/redundancy' 39import { VideoRedundancy, VideoRedundancyStrategy, VideoRedundancyStrategyWithManual } from '../../../../shared/models/redundancy'
43import { ServerStats } from '../../../../shared/models/server/server-stats.model' 40import { ServerStats } from '../../../../shared/models/server/server-stats.model'
44import { VideoDetails, VideoPrivacy } from '../../../../shared/models/videos' 41import { VideoDetails, VideoPrivacy } from '../../../../shared/models/videos'
@@ -272,13 +269,19 @@ async function checkStatsWithoutRedundancy (strategy: VideoRedundancyStrategyWit
272 expect(stat.totalVideos).to.equal(0) 269 expect(stat.totalVideos).to.equal(0)
273} 270}
274 271
272async function findServerFollows () {
273 const body = await servers[0].followsCommand.getFollowings({ start: 0, count: 5, sort: '-createdAt' })
274 const follows = body.data
275 const server2 = follows.find(f => f.following.host === `localhost:${servers[1].port}`)
276 const server3 = follows.find(f => f.following.host === `localhost:${servers[2].port}`)
277
278 return { server2, server3 }
279}
280
275async function enableRedundancyOnServer1 () { 281async function enableRedundancyOnServer1 () {
276 await updateRedundancy(servers[0].url, servers[0].accessToken, servers[1].host, true) 282 await updateRedundancy(servers[0].url, servers[0].accessToken, servers[1].host, true)
277 283
278 const res = await getFollowingListPaginationAndSort({ url: servers[0].url, start: 0, count: 5, sort: '-createdAt' }) 284 const { server2, server3 } = await findServerFollows()
279 const follows: ActorFollow[] = res.body.data
280 const server2 = follows.find(f => f.following.host === `localhost:${servers[1].port}`)
281 const server3 = follows.find(f => f.following.host === `localhost:${servers[2].port}`)
282 285
283 expect(server3).to.not.be.undefined 286 expect(server3).to.not.be.undefined
284 expect(server3.following.hostRedundancyAllowed).to.be.false 287 expect(server3.following.hostRedundancyAllowed).to.be.false
@@ -290,10 +293,7 @@ async function enableRedundancyOnServer1 () {
290async function disableRedundancyOnServer1 () { 293async function disableRedundancyOnServer1 () {
291 await updateRedundancy(servers[0].url, servers[0].accessToken, servers[1].host, false) 294 await updateRedundancy(servers[0].url, servers[0].accessToken, servers[1].host, false)
292 295
293 const res = await getFollowingListPaginationAndSort({ url: servers[0].url, start: 0, count: 5, sort: '-createdAt' }) 296 const { server2, server3 } = await findServerFollows()
294 const follows: ActorFollow[] = res.body.data
295 const server2 = follows.find(f => f.following.host === `localhost:${servers[1].port}`)
296 const server3 = follows.find(f => f.following.host === `localhost:${servers[2].port}`)
297 297
298 expect(server3).to.not.be.undefined 298 expect(server3).to.not.be.undefined
299 expect(server3.following.hostRedundancyAllowed).to.be.false 299 expect(server3.following.hostRedundancyAllowed).to.be.false
@@ -388,7 +388,7 @@ describe('Test videos redundancy', function () {
388 it('Should unfollow on server 1 and remove duplicated videos', async function () { 388 it('Should unfollow on server 1 and remove duplicated videos', async function () {
389 this.timeout(80000) 389 this.timeout(80000)
390 390
391 await unfollow(servers[0].url, servers[0].accessToken, servers[1]) 391 await servers[0].followsCommand.unfollow({ target: servers[1] })
392 392
393 await waitJobs(servers) 393 await waitJobs(servers)
394 await wait(5000) 394 await wait(5000)