diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-07 09:16:40 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-07-20 15:27:17 +0200 |
commit | c3d29f694bf8c910f917be655626d0f80871124f (patch) | |
tree | c90dfdc1245c8a9aca49e9ea9c71ed8e6b9dd35f /server/tests/api/redundancy/redundancy.ts | |
parent | 883a9019085ff9013079d6b1539b86f2f519175a (diff) | |
download | PeerTube-c3d29f694bf8c910f917be655626d0f80871124f.tar.gz PeerTube-c3d29f694bf8c910f917be655626d0f80871124f.tar.zst PeerTube-c3d29f694bf8c910f917be655626d0f80871124f.zip |
Introduce follows command
Diffstat (limited to 'server/tests/api/redundancy/redundancy.ts')
-rw-r--r-- | server/tests/api/redundancy/redundancy.ts | 24 |
1 files changed, 12 insertions, 12 deletions
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' |
40 | import { getStats } from '../../../../shared/extra-utils/server/stats' | 38 | import { getStats } from '../../../../shared/extra-utils/server/stats' |
41 | import { ActorFollow } from '../../../../shared/models/actors' | ||
42 | import { VideoRedundancy, VideoRedundancyStrategy, VideoRedundancyStrategyWithManual } from '../../../../shared/models/redundancy' | 39 | import { VideoRedundancy, VideoRedundancyStrategy, VideoRedundancyStrategyWithManual } from '../../../../shared/models/redundancy' |
43 | import { ServerStats } from '../../../../shared/models/server/server-stats.model' | 40 | import { ServerStats } from '../../../../shared/models/server/server-stats.model' |
44 | import { VideoDetails, VideoPrivacy } from '../../../../shared/models/videos' | 41 | import { 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 | ||
272 | async 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 | |||
275 | async function enableRedundancyOnServer1 () { | 281 | async 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 () { | |||
290 | async function disableRedundancyOnServer1 () { | 293 | async 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) |