diff options
author | Chocobozzz <me@florianbigard.com> | 2018-09-28 10:07:05 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-09-28 10:07:05 +0200 |
commit | 161b061d4e51eb1e2b2b7e9482d5299489ef7c45 (patch) | |
tree | 5b9524625b7d8dbde765eaf9799d4f272829e449 /server/tests | |
parent | d0b52b5285d0797b30bca6510b7a8f840fab4697 (diff) | |
download | PeerTube-161b061d4e51eb1e2b2b7e9482d5299489ef7c45.tar.gz PeerTube-161b061d4e51eb1e2b2b7e9482d5299489ef7c45.tar.zst PeerTube-161b061d4e51eb1e2b2b7e9482d5299489ef7c45.zip |
Remove duplicated videos on unfollow/delete redundancy
Diffstat (limited to 'server/tests')
-rw-r--r-- | server/tests/api/server/redundancy.ts | 69 |
1 files changed, 53 insertions, 16 deletions
diff --git a/server/tests/api/server/redundancy.ts b/server/tests/api/server/redundancy.ts index 9b3b1b4ad..e1709891d 100644 --- a/server/tests/api/server/redundancy.ts +++ b/server/tests/api/server/redundancy.ts | |||
@@ -12,7 +12,7 @@ import { | |||
12 | killallServers, makeGetRequest, | 12 | killallServers, makeGetRequest, |
13 | root, | 13 | root, |
14 | ServerInfo, | 14 | ServerInfo, |
15 | setAccessTokensToServers, | 15 | setAccessTokensToServers, unfollow, |
16 | uploadVideo, | 16 | uploadVideo, |
17 | viewVideo, | 17 | viewVideo, |
18 | wait | 18 | wait |
@@ -39,6 +39,8 @@ function checkMagnetWebseeds (file: { magnetUri: string, resolution: { id: numbe | |||
39 | const found = parsed.urlList.find(url => url === `${ws}-${file.resolution.id}.mp4`) | 39 | const found = parsed.urlList.find(url => url === `${ws}-${file.resolution.id}.mp4`) |
40 | expect(found, `Webseed ${ws} not found in ${file.magnetUri} on server ${server.url}`).to.not.be.undefined | 40 | expect(found, `Webseed ${ws} not found in ${file.magnetUri} on server ${server.url}`).to.not.be.undefined |
41 | } | 41 | } |
42 | |||
43 | expect(parsed.urlList).to.have.lengthOf(baseWebseeds.length) | ||
42 | } | 44 | } |
43 | 45 | ||
44 | async function runServers (strategy: VideoRedundancyStrategy, additionalParams: any = {}) { | 46 | async function runServers (strategy: VideoRedundancyStrategy, additionalParams: any = {}) { |
@@ -136,23 +138,21 @@ async function check2Webseeds (strategy: VideoRedundancyStrategy, videoUUID?: st | |||
136 | ] | 138 | ] |
137 | 139 | ||
138 | for (const server of servers) { | 140 | for (const server of servers) { |
139 | { | 141 | const res = await getVideo(server.url, videoUUID) |
140 | const res = await getVideo(server.url, videoUUID) | ||
141 | 142 | ||
142 | const video: VideoDetails = res.body | 143 | const video: VideoDetails = res.body |
143 | 144 | ||
144 | for (const file of video.files) { | 145 | for (const file of video.files) { |
145 | checkMagnetWebseeds(file, webseeds, server) | 146 | checkMagnetWebseeds(file, webseeds, server) |
146 | 147 | ||
147 | // Only servers 1 and 2 have the video | 148 | // Only servers 1 and 2 have the video |
148 | if (server.serverNumber !== 3) { | 149 | if (server.serverNumber !== 3) { |
149 | await makeGetRequest({ | 150 | await makeGetRequest({ |
150 | url: server.url, | 151 | url: server.url, |
151 | statusCodeExpected: 200, | 152 | statusCodeExpected: 200, |
152 | path: '/static/webseed/' + `${videoUUID}-${file.resolution.id}.mp4`, | 153 | path: '/static/webseed/' + `${videoUUID}-${file.resolution.id}.mp4`, |
153 | contentType: null | 154 | contentType: null |
154 | }) | 155 | }) |
155 | } | ||
156 | } | 156 | } |
157 | } | 157 | } |
158 | } | 158 | } |
@@ -182,6 +182,21 @@ async function enableRedundancyOnServer1 () { | |||
182 | expect(server2.following.hostRedundancyAllowed).to.be.true | 182 | expect(server2.following.hostRedundancyAllowed).to.be.true |
183 | } | 183 | } |
184 | 184 | ||
185 | async function disableRedundancyOnServer1 () { | ||
186 | await updateRedundancy(servers[ 0 ].url, servers[ 0 ].accessToken, servers[ 1 ].host, false) | ||
187 | |||
188 | const res = await getFollowingListPaginationAndSort(servers[ 0 ].url, 0, 5, '-createdAt') | ||
189 | const follows: ActorFollow[] = res.body.data | ||
190 | const server2 = follows.find(f => f.following.host === 'localhost:9002') | ||
191 | const server3 = follows.find(f => f.following.host === 'localhost:9003') | ||
192 | |||
193 | expect(server3).to.not.be.undefined | ||
194 | expect(server3.following.hostRedundancyAllowed).to.be.false | ||
195 | |||
196 | expect(server2).to.not.be.undefined | ||
197 | expect(server2.following.hostRedundancyAllowed).to.be.false | ||
198 | } | ||
199 | |||
185 | async function cleanServers () { | 200 | async function cleanServers () { |
186 | killallServers(servers) | 201 | killallServers(servers) |
187 | } | 202 | } |
@@ -217,6 +232,17 @@ describe('Test videos redundancy', function () { | |||
217 | await checkStatsWith2Webseed(strategy) | 232 | await checkStatsWith2Webseed(strategy) |
218 | }) | 233 | }) |
219 | 234 | ||
235 | it('Should undo redundancy on server 1 and remove duplicated videos', async function () { | ||
236 | this.timeout(40000) | ||
237 | |||
238 | await disableRedundancyOnServer1() | ||
239 | |||
240 | await waitJobs(servers) | ||
241 | await wait(5000) | ||
242 | |||
243 | await check1WebSeed(strategy) | ||
244 | }) | ||
245 | |||
220 | after(function () { | 246 | after(function () { |
221 | return cleanServers() | 247 | return cleanServers() |
222 | }) | 248 | }) |
@@ -251,6 +277,17 @@ describe('Test videos redundancy', function () { | |||
251 | await checkStatsWith2Webseed(strategy) | 277 | await checkStatsWith2Webseed(strategy) |
252 | }) | 278 | }) |
253 | 279 | ||
280 | it('Should unfollow on server 1 and remove duplicated videos', async function () { | ||
281 | this.timeout(40000) | ||
282 | |||
283 | await unfollow(servers[0].url, servers[0].accessToken, servers[1]) | ||
284 | |||
285 | await waitJobs(servers) | ||
286 | await wait(5000) | ||
287 | |||
288 | await check1WebSeed(strategy) | ||
289 | }) | ||
290 | |||
254 | after(function () { | 291 | after(function () { |
255 | return cleanServers() | 292 | return cleanServers() |
256 | }) | 293 | }) |