aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/redundancy/redundancy-constraints.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/redundancy/redundancy-constraints.ts')
-rw-r--r--server/tests/api/redundancy/redundancy-constraints.ts58
1 files changed, 33 insertions, 25 deletions
diff --git a/server/tests/api/redundancy/redundancy-constraints.ts b/server/tests/api/redundancy/redundancy-constraints.ts
index 4fd8f065c..1cb1603bc 100644
--- a/server/tests/api/redundancy/redundancy-constraints.ts
+++ b/server/tests/api/redundancy/redundancy-constraints.ts
@@ -1,7 +1,9 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import * as chai from 'chai'
4import 'mocha' 3import 'mocha'
4import * as chai from 'chai'
5import { listVideoRedundancies, updateRedundancy } from '@shared/extra-utils/server/redundancy'
6import { VideoPrivacy } from '@shared/models'
5import { 7import {
6 cleanupTests, 8 cleanupTests,
7 flushAndRunServer, 9 flushAndRunServer,
@@ -10,11 +12,11 @@ import {
10 reRunServer, 12 reRunServer,
11 ServerInfo, 13 ServerInfo,
12 setAccessTokensToServers, 14 setAccessTokensToServers,
15 updateVideo,
13 uploadVideo, 16 uploadVideo,
14 waitUntilLog 17 waitUntilLog
15} from '../../../../shared/extra-utils' 18} from '../../../../shared/extra-utils'
16import { waitJobs } from '../../../../shared/extra-utils/server/jobs' 19import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
17import { listVideoRedundancies, updateRedundancy } from '@shared/extra-utils/server/redundancy'
18 20
19const expect = chai.expect 21const expect = chai.expect
20 22
@@ -23,6 +25,31 @@ describe('Test redundancy constraints', function () {
23 let localServer: ServerInfo 25 let localServer: ServerInfo
24 let servers: ServerInfo[] 26 let servers: ServerInfo[]
25 27
28 const remoteServerConfig = {
29 redundancy: {
30 videos: {
31 check_interval: '1 second',
32 strategies: [
33 {
34 strategy: 'recently-added',
35 min_lifetime: '1 hour',
36 size: '100MB',
37 min_views: 0
38 }
39 ]
40 }
41 }
42 }
43
44 async function uploadWrapper (videoName: string) {
45 // Wait for transcoding
46 const res = await uploadVideo(localServer.url, localServer.accessToken, { name: 'to transcode', privacy: VideoPrivacy.PRIVATE })
47 await waitJobs([ localServer ])
48
49 // Update video to schedule a federation
50 await updateVideo(localServer.url, localServer.accessToken, res.body.video.id, { name: videoName, privacy: VideoPrivacy.PUBLIC })
51 }
52
26 async function getTotalRedundanciesLocalServer () { 53 async function getTotalRedundanciesLocalServer () {
27 const res = await listVideoRedundancies({ 54 const res = await listVideoRedundancies({
28 url: localServer.url, 55 url: localServer.url,
@@ -47,22 +74,7 @@ describe('Test redundancy constraints', function () {
47 this.timeout(120000) 74 this.timeout(120000)
48 75
49 { 76 {
50 const config = { 77 remoteServer = await flushAndRunServer(1, remoteServerConfig)
51 redundancy: {
52 videos: {
53 check_interval: '1 second',
54 strategies: [
55 {
56 strategy: 'recently-added',
57 min_lifetime: '1 hour',
58 size: '100MB',
59 min_views: 0
60 }
61 ]
62 }
63 }
64 }
65 remoteServer = await flushAndRunServer(1, config)
66 } 78 }
67 79
68 { 80 {
@@ -124,9 +136,8 @@ describe('Test redundancy constraints', function () {
124 await killallServers([ localServer ]) 136 await killallServers([ localServer ])
125 await reRunServer(localServer, config) 137 await reRunServer(localServer, config)
126 138
127 await uploadVideo(localServer.url, localServer.accessToken, { name: 'video 2 server 2' }) 139 await uploadWrapper('video 2 server 2')
128 140
129 await waitJobs(servers)
130 await waitUntilLog(remoteServer, 'Duplicated ', 10) 141 await waitUntilLog(remoteServer, 'Duplicated ', 10)
131 await waitJobs(servers) 142 await waitJobs(servers)
132 143
@@ -154,9 +165,8 @@ describe('Test redundancy constraints', function () {
154 await killallServers([ localServer ]) 165 await killallServers([ localServer ])
155 await reRunServer(localServer, config) 166 await reRunServer(localServer, config)
156 167
157 await uploadVideo(localServer.url, localServer.accessToken, { name: 'video 3 server 2' }) 168 await uploadWrapper('video 3 server 2')
158 169
159 await waitJobs(servers)
160 await waitUntilLog(remoteServer, 'Duplicated ', 15) 170 await waitUntilLog(remoteServer, 'Duplicated ', 15)
161 await waitJobs(servers) 171 await waitJobs(servers)
162 172
@@ -177,9 +187,7 @@ describe('Test redundancy constraints', function () {
177 await follow(localServer.url, [ remoteServer.url ], localServer.accessToken) 187 await follow(localServer.url, [ remoteServer.url ], localServer.accessToken)
178 await waitJobs(servers) 188 await waitJobs(servers)
179 189
180 await uploadVideo(localServer.url, localServer.accessToken, { name: 'video 4 server 2' }) 190 await uploadWrapper('video 4 server 2')
181
182 await waitJobs(servers)
183 await waitUntilLog(remoteServer, 'Duplicated ', 20) 191 await waitUntilLog(remoteServer, 'Duplicated ', 20)
184 await waitJobs(servers) 192 await waitJobs(servers)
185 193