]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/tests/api/redundancy/redundancy.ts
Shorter server command names
[github/Chocobozzz/PeerTube.git] / server / tests / api / redundancy / redundancy.ts
CommitLineData
a1587156 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
26370ce4 2
26370ce4 3import 'mocha'
6949a1a1
C
4import * as chai from 'chai'
5import { readdir } from 'fs-extra'
6import * as magnetUtil from 'magnet-uri'
7import { join } from 'path'
dab04709 8import { HttpStatusCode } from '@shared/core-utils'
26370ce4 9import {
07b1a18a 10 checkSegmentHash,
b764380a
C
11 checkVideoFilesWereRemoved,
12 cleanupTests,
26370ce4
C
13 doubleFollow,
14 flushAndRunMultipleServers,
07b1a18a
C
15 killallServers,
16 makeGetRequest,
07b1a18a 17 reRunServer,
26370ce4
C
18 root,
19 ServerInfo,
07b1a18a 20 setAccessTokensToServers,
26370ce4 21 wait,
6c5065a0 22 waitJobs
dab04709 23} from '@shared/extra-utils'
d23dd9fb 24import { VideoPrivacy, VideoRedundancyStrategy, VideoRedundancyStrategyWithManual } from '@shared/models'
26370ce4
C
25
26const expect = chai.expect
27
28let servers: ServerInfo[] = []
29let video1Server2UUID: string
b764380a 30let video1Server2Id: number
26370ce4
C
31
32function checkMagnetWebseeds (file: { magnetUri: string, resolution: { id: number } }, baseWebseeds: string[], server: ServerInfo) {
33 const parsed = magnetUtil.decode(file.magnetUri)
34
35 for (const ws of baseWebseeds) {
36 const found = parsed.urlList.find(url => url === `${ws}-${file.resolution.id}.mp4`)
37 expect(found, `Webseed ${ws} not found in ${file.magnetUri} on server ${server.url}`).to.not.be.undefined
38 }
39
40 expect(parsed.urlList).to.have.lengthOf(baseWebseeds.length)
41}
42
7448551f 43async function flushAndRunServers (strategy: VideoRedundancyStrategy | null, additionalParams: any = {}, withWebtorrent = true) {
b764380a
C
44 const strategies: any[] = []
45
46 if (strategy !== null) {
47 strategies.push(
6c5065a0 48 {
b764380a
C
49 min_lifetime: '1 hour',
50 strategy: strategy,
6c5065a0
C
51 size: '400KB',
52
53 ...additionalParams
54 }
b764380a
C
55 )
56 }
57
26370ce4 58 const config = {
09209296 59 transcoding: {
7448551f
C
60 webtorrent: {
61 enabled: withWebtorrent
62 },
09209296
C
63 hls: {
64 enabled: true
65 }
66 },
26370ce4
C
67 redundancy: {
68 videos: {
69 check_interval: '5 seconds',
b764380a 70 strategies
26370ce4
C
71 }
72 }
73 }
b764380a 74
26370ce4
C
75 servers = await flushAndRunMultipleServers(3, config)
76
77 // Get the access tokens
78 await setAccessTokensToServers(servers)
79
80 {
89d241a7 81 const { uuid, id } = await servers[1].videos.upload({ attributes: { name: 'video 1 server 2' } })
d23dd9fb
C
82 video1Server2UUID = uuid
83 video1Server2Id = id
26370ce4 84
89d241a7 85 await servers[1].videos.view({ id: video1Server2UUID })
26370ce4
C
86 }
87
88 await waitJobs(servers)
89
90 // Server 1 and server 2 follow each other
a1587156 91 await doubleFollow(servers[0], servers[1])
26370ce4 92 // Server 1 and server 3 follow each other
a1587156 93 await doubleFollow(servers[0], servers[2])
26370ce4 94 // Server 2 and server 3 follow each other
a1587156 95 await doubleFollow(servers[1], servers[2])
26370ce4
C
96
97 await waitJobs(servers)
98}
99
09209296 100async function check1WebSeed (videoUUID?: string) {
26370ce4
C
101 if (!videoUUID) videoUUID = video1Server2UUID
102
103 const webseeds = [
a1587156 104 `http://localhost:${servers[1].port}/static/webseed/${videoUUID}`
26370ce4
C
105 ]
106
107 for (const server of servers) {
09209296 108 // With token to avoid issues with video follow constraints
89d241a7 109 const video = await server.videos.getWithToken({ id: videoUUID })
26370ce4 110
09209296
C
111 for (const f of video.files) {
112 checkMagnetWebseeds(f, webseeds, server)
26370ce4
C
113 }
114 }
115}
116
09209296 117async function check2Webseeds (videoUUID?: string) {
26370ce4
C
118 if (!videoUUID) videoUUID = video1Server2UUID
119
120 const webseeds = [
a1587156
C
121 `http://localhost:${servers[0].port}/static/redundancy/${videoUUID}`,
122 `http://localhost:${servers[1].port}/static/webseed/${videoUUID}`
26370ce4
C
123 ]
124
125 for (const server of servers) {
89d241a7 126 const video = await server.videos.get({ id: videoUUID })
26370ce4
C
127
128 for (const file of video.files) {
129 checkMagnetWebseeds(file, webseeds, server)
130
b9fffa29
C
131 await makeGetRequest({
132 url: servers[0].url,
2d53be02 133 statusCodeExpected: HttpStatusCode.OK_200,
b9fffa29
C
134 path: '/static/redundancy/' + `${videoUUID}-${file.resolution.id}.mp4`,
135 contentType: null
136 })
137 await makeGetRequest({
138 url: servers[1].url,
2d53be02 139 statusCodeExpected: HttpStatusCode.OK_200,
09209296 140 path: `/static/webseed/${videoUUID}-${file.resolution.id}.mp4`,
b9fffa29
C
141 contentType: null
142 })
26370ce4
C
143 }
144 }
145
7243f84d
C
146 const directories = [
147 'test' + servers[0].internalServerNumber + '/redundancy',
148 'test' + servers[1].internalServerNumber + '/videos'
149 ]
150
151 for (const directory of directories) {
b9fffa29 152 const files = await readdir(join(root(), directory))
26370ce4
C
153 expect(files).to.have.length.at.least(4)
154
155 for (const resolution of [ 240, 360, 480, 720 ]) {
156 expect(files.find(f => f === `${videoUUID}-${resolution}.mp4`)).to.not.be.undefined
157 }
158 }
159}
160
09209296
C
161async function check0PlaylistRedundancies (videoUUID?: string) {
162 if (!videoUUID) videoUUID = video1Server2UUID
163
164 for (const server of servers) {
165 // With token to avoid issues with video follow constraints
89d241a7 166 const video = await server.videos.getWithToken({ id: videoUUID })
09209296
C
167
168 expect(video.streamingPlaylists).to.be.an('array')
169 expect(video.streamingPlaylists).to.have.lengthOf(1)
170 expect(video.streamingPlaylists[0].redundancies).to.have.lengthOf(0)
171 }
172}
173
174async function check1PlaylistRedundancies (videoUUID?: string) {
175 if (!videoUUID) videoUUID = video1Server2UUID
176
177 for (const server of servers) {
89d241a7 178 const video = await server.videos.get({ id: videoUUID })
09209296
C
179
180 expect(video.streamingPlaylists).to.have.lengthOf(1)
181 expect(video.streamingPlaylists[0].redundancies).to.have.lengthOf(1)
182
183 const redundancy = video.streamingPlaylists[0].redundancies[0]
184
185 expect(redundancy.baseUrl).to.equal(servers[0].url + '/static/redundancy/hls/' + videoUUID)
186 }
187
0b16f5f2 188 const baseUrlPlaylist = servers[1].url + '/static/streaming-playlists/hls'
4c280004
C
189 const baseUrlSegment = servers[0].url + '/static/redundancy/hls'
190
89d241a7 191 const video = await servers[0].videos.get({ id: videoUUID })
d23dd9fb 192 const hlsPlaylist = video.streamingPlaylists[0]
4c280004
C
193
194 for (const resolution of [ 240, 360, 480, 720 ]) {
57f879a5 195 await checkSegmentHash({ server: servers[1], baseUrlPlaylist, baseUrlSegment, videoUUID, resolution, hlsPlaylist })
4c280004 196 }
09209296 197
7243f84d
C
198 const directories = [
199 'test' + servers[0].internalServerNumber + '/redundancy/hls',
200 'test' + servers[1].internalServerNumber + '/streaming-playlists/hls'
201 ]
202
203 for (const directory of directories) {
09209296
C
204 const files = await readdir(join(root(), directory, videoUUID))
205 expect(files).to.have.length.at.least(4)
206
207 for (const resolution of [ 240, 360, 480, 720 ]) {
4c280004
C
208 const filename = `${videoUUID}-${resolution}-fragmented.mp4`
209
210 expect(files.find(f => f === filename)).to.not.be.undefined
09209296
C
211 }
212 }
213}
214
b764380a
C
215async function checkStatsGlobal (strategy: VideoRedundancyStrategyWithManual) {
216 let totalSize: number = null
217 let statsLength = 1
218
219 if (strategy !== 'manual') {
220 totalSize = 409600
221 statsLength = 2
222 }
223
89d241a7 224 const data = await servers[0].stats.get()
b764380a 225 expect(data.videosRedundancy).to.have.lengthOf(statsLength)
09209296 226
b764380a 227 const stat = data.videosRedundancy[0]
09209296 228 expect(stat.strategy).to.equal(strategy)
b764380a
C
229 expect(stat.totalSize).to.equal(totalSize)
230
231 return stat
232}
233
6949a1a1 234async function checkStatsWith1Redundancy (strategy: VideoRedundancyStrategyWithManual, onlyHls = false) {
b764380a
C
235 const stat = await checkStatsGlobal(strategy)
236
9e3e3617 237 expect(stat.totalUsed).to.be.at.least(1).and.below(409601)
6949a1a1 238 expect(stat.totalVideoFiles).to.equal(onlyHls ? 4 : 8)
09209296
C
239 expect(stat.totalVideos).to.equal(1)
240}
241
7448551f 242async function checkStatsWithoutRedundancy (strategy: VideoRedundancyStrategyWithManual) {
b764380a 243 const stat = await checkStatsGlobal(strategy)
09209296 244
09209296
C
245 expect(stat.totalUsed).to.equal(0)
246 expect(stat.totalVideoFiles).to.equal(0)
247 expect(stat.totalVideos).to.equal(0)
248}
249
c3d29f69 250async function findServerFollows () {
89d241a7 251 const body = await servers[0].follows.getFollowings({ start: 0, count: 5, sort: '-createdAt' })
c3d29f69
C
252 const follows = body.data
253 const server2 = follows.find(f => f.following.host === `localhost:${servers[1].port}`)
254 const server3 = follows.find(f => f.following.host === `localhost:${servers[2].port}`)
255
256 return { server2, server3 }
257}
258
26370ce4 259async function enableRedundancyOnServer1 () {
89d241a7 260 await servers[0].redundancy.updateRedundancy({ host: servers[1].host, redundancyAllowed: true })
26370ce4 261
c3d29f69 262 const { server2, server3 } = await findServerFollows()
26370ce4
C
263
264 expect(server3).to.not.be.undefined
265 expect(server3.following.hostRedundancyAllowed).to.be.false
266
267 expect(server2).to.not.be.undefined
268 expect(server2.following.hostRedundancyAllowed).to.be.true
269}
270
271async function disableRedundancyOnServer1 () {
89d241a7 272 await servers[0].redundancy.updateRedundancy({ host: servers[1].host, redundancyAllowed: false })
26370ce4 273
c3d29f69 274 const { server2, server3 } = await findServerFollows()
26370ce4
C
275
276 expect(server3).to.not.be.undefined
277 expect(server3.following.hostRedundancyAllowed).to.be.false
278
279 expect(server2).to.not.be.undefined
280 expect(server2.following.hostRedundancyAllowed).to.be.false
281}
282
26370ce4
C
283describe('Test videos redundancy', function () {
284
285 describe('With most-views strategy', function () {
286 const strategy = 'most-views'
287
288 before(function () {
289 this.timeout(120000)
290
7c3b7976 291 return flushAndRunServers(strategy)
26370ce4
C
292 })
293
294 it('Should have 1 webseed on the first video', async function () {
09209296
C
295 await check1WebSeed()
296 await check0PlaylistRedundancies()
7448551f 297 await checkStatsWithoutRedundancy(strategy)
26370ce4
C
298 })
299
300 it('Should enable redundancy on server 1', function () {
301 return enableRedundancyOnServer1()
302 })
303
6cb3482c 304 it('Should have 2 webseeds on the first video', async function () {
09209296 305 this.timeout(80000)
26370ce4
C
306
307 await waitJobs(servers)
89d241a7 308 await servers[0].servers.waitUntilLog('Duplicated ', 5)
26370ce4
C
309 await waitJobs(servers)
310
09209296
C
311 await check2Webseeds()
312 await check1PlaylistRedundancies()
7448551f 313 await checkStatsWith1Redundancy(strategy)
26370ce4
C
314 })
315
316 it('Should undo redundancy on server 1 and remove duplicated videos', async function () {
09209296 317 this.timeout(80000)
26370ce4
C
318
319 await disableRedundancyOnServer1()
320
321 await waitJobs(servers)
322 await wait(5000)
323
09209296
C
324 await check1WebSeed()
325 await check0PlaylistRedundancies()
26370ce4 326
6c5065a0 327 await checkVideoFilesWereRemoved(video1Server2UUID, servers[0], [ 'videos', join('playlists', 'hls') ])
26370ce4
C
328 })
329
7c3b7976
C
330 after(async function () {
331 return cleanupTests(servers)
26370ce4
C
332 })
333 })
334
335 describe('With trending strategy', function () {
336 const strategy = 'trending'
337
338 before(function () {
339 this.timeout(120000)
340
7c3b7976 341 return flushAndRunServers(strategy)
26370ce4
C
342 })
343
344 it('Should have 1 webseed on the first video', async function () {
09209296
C
345 await check1WebSeed()
346 await check0PlaylistRedundancies()
7448551f 347 await checkStatsWithoutRedundancy(strategy)
26370ce4
C
348 })
349
350 it('Should enable redundancy on server 1', function () {
351 return enableRedundancyOnServer1()
352 })
353
6cb3482c 354 it('Should have 2 webseeds on the first video', async function () {
09209296 355 this.timeout(80000)
26370ce4
C
356
357 await waitJobs(servers)
89d241a7 358 await servers[0].servers.waitUntilLog('Duplicated ', 5)
26370ce4
C
359 await waitJobs(servers)
360
09209296
C
361 await check2Webseeds()
362 await check1PlaylistRedundancies()
7448551f 363 await checkStatsWith1Redundancy(strategy)
26370ce4
C
364 })
365
366 it('Should unfollow on server 1 and remove duplicated videos', async function () {
09209296 367 this.timeout(80000)
26370ce4 368
89d241a7 369 await servers[0].follows.unfollow({ target: servers[1] })
26370ce4
C
370
371 await waitJobs(servers)
372 await wait(5000)
373
09209296
C
374 await check1WebSeed()
375 await check0PlaylistRedundancies()
26370ce4 376
6c5065a0 377 await checkVideoFilesWereRemoved(video1Server2UUID, servers[0], [ 'videos' ])
26370ce4
C
378 })
379
7c3b7976
C
380 after(async function () {
381 await cleanupTests(servers)
26370ce4
C
382 })
383 })
384
385 describe('With recently added strategy', function () {
386 const strategy = 'recently-added'
387
388 before(function () {
389 this.timeout(120000)
390
7c3b7976 391 return flushAndRunServers(strategy, { min_views: 3 })
26370ce4
C
392 })
393
394 it('Should have 1 webseed on the first video', async function () {
09209296
C
395 await check1WebSeed()
396 await check0PlaylistRedundancies()
7448551f 397 await checkStatsWithoutRedundancy(strategy)
26370ce4
C
398 })
399
400 it('Should enable redundancy on server 1', function () {
401 return enableRedundancyOnServer1()
402 })
403
404 it('Should still have 1 webseed on the first video', async function () {
09209296 405 this.timeout(80000)
26370ce4
C
406
407 await waitJobs(servers)
408 await wait(15000)
409 await waitJobs(servers)
410
09209296
C
411 await check1WebSeed()
412 await check0PlaylistRedundancies()
7448551f 413 await checkStatsWithoutRedundancy(strategy)
26370ce4
C
414 })
415
416 it('Should view 2 times the first video to have > min_views config', async function () {
09209296 417 this.timeout(80000)
26370ce4 418
89d241a7
C
419 await servers[0].videos.view({ id: video1Server2UUID })
420 await servers[2].videos.view({ id: video1Server2UUID })
26370ce4
C
421
422 await wait(10000)
423 await waitJobs(servers)
424 })
425
6cb3482c 426 it('Should have 2 webseeds on the first video', async function () {
09209296 427 this.timeout(80000)
26370ce4
C
428
429 await waitJobs(servers)
89d241a7 430 await servers[0].servers.waitUntilLog('Duplicated ', 5)
26370ce4
C
431 await waitJobs(servers)
432
09209296
C
433 await check2Webseeds()
434 await check1PlaylistRedundancies()
7448551f 435 await checkStatsWith1Redundancy(strategy)
26370ce4
C
436 })
437
438 it('Should remove the video and the redundancy files', async function () {
439 this.timeout(20000)
440
89d241a7 441 await servers[1].videos.remove({ id: video1Server2UUID })
26370ce4
C
442
443 await waitJobs(servers)
444
445 for (const server of servers) {
6c5065a0 446 await checkVideoFilesWereRemoved(video1Server2UUID, server)
26370ce4
C
447 }
448 })
449
7c3b7976
C
450 after(async function () {
451 await cleanupTests(servers)
26370ce4
C
452 })
453 })
454
7448551f
C
455 describe('With only HLS files', function () {
456 const strategy = 'recently-added'
457
458 before(async function () {
459 this.timeout(120000)
460
461 await flushAndRunServers(strategy, { min_views: 3 }, false)
462 })
463
464 it('Should have 0 playlist redundancy on the first video', async function () {
465 await check1WebSeed()
466 await check0PlaylistRedundancies()
467 })
468
469 it('Should enable redundancy on server 1', function () {
470 return enableRedundancyOnServer1()
471 })
472
473 it('Should still have 0 redundancy on the first video', async function () {
474 this.timeout(80000)
475
476 await waitJobs(servers)
477 await wait(15000)
478 await waitJobs(servers)
479
480 await check0PlaylistRedundancies()
481 await checkStatsWithoutRedundancy(strategy)
482 })
483
484 it('Should have 1 redundancy on the first video', async function () {
485 this.timeout(160000)
486
89d241a7
C
487 await servers[0].videos.view({ id: video1Server2UUID })
488 await servers[2].videos.view({ id: video1Server2UUID })
7448551f
C
489
490 await wait(10000)
491 await waitJobs(servers)
492
493 await waitJobs(servers)
89d241a7 494 await servers[0].servers.waitUntilLog('Duplicated ', 1)
7448551f
C
495 await waitJobs(servers)
496
497 await check1PlaylistRedundancies()
6949a1a1 498 await checkStatsWith1Redundancy(strategy, true)
7448551f
C
499 })
500
501 it('Should remove the video and the redundancy files', async function () {
502 this.timeout(20000)
503
89d241a7 504 await servers[1].videos.remove({ id: video1Server2UUID })
7448551f
C
505
506 await waitJobs(servers)
507
508 for (const server of servers) {
6c5065a0 509 await checkVideoFilesWereRemoved(video1Server2UUID, server)
7448551f
C
510 }
511 })
6949a1a1
C
512
513 after(async function () {
514 await cleanupTests(servers)
515 })
7448551f
C
516 })
517
b764380a
C
518 describe('With manual strategy', function () {
519 before(function () {
520 this.timeout(120000)
521
522 return flushAndRunServers(null)
523 })
524
525 it('Should have 1 webseed on the first video', async function () {
526 await check1WebSeed()
527 await check0PlaylistRedundancies()
7448551f 528 await checkStatsWithoutRedundancy('manual')
b764380a
C
529 })
530
531 it('Should create a redundancy on first video', async function () {
89d241a7 532 await servers[0].redundancy.addVideo({ videoId: video1Server2Id })
b764380a
C
533 })
534
535 it('Should have 2 webseeds on the first video', async function () {
536 this.timeout(80000)
537
538 await waitJobs(servers)
89d241a7 539 await servers[0].servers.waitUntilLog('Duplicated ', 5)
b764380a
C
540 await waitJobs(servers)
541
542 await check2Webseeds()
543 await check1PlaylistRedundancies()
7448551f 544 await checkStatsWith1Redundancy('manual')
b764380a
C
545 })
546
547 it('Should manually remove redundancies on server 1 and remove duplicated videos', async function () {
548 this.timeout(80000)
549
89d241a7 550 const body = await servers[0].redundancy.listVideos({ target: 'remote-videos' })
b764380a 551
dab04709 552 const videos = body.data
b764380a
C
553 expect(videos).to.have.lengthOf(1)
554
555 const video = videos[0]
dab04709 556
b764380a 557 for (const r of video.redundancies.files.concat(video.redundancies.streamingPlaylists)) {
89d241a7 558 await servers[0].redundancy.removeVideo({ redundancyId: r.id })
b764380a
C
559 }
560
561 await waitJobs(servers)
562 await wait(5000)
563
564 await check1WebSeed()
565 await check0PlaylistRedundancies()
566
6c5065a0 567 await checkVideoFilesWereRemoved(video1Server2UUID, servers[0], [ 'videos' ])
b764380a
C
568 })
569
570 after(async function () {
571 await cleanupTests(servers)
572 })
573 })
574
26370ce4
C
575 describe('Test expiration', function () {
576 const strategy = 'recently-added'
577
578 async function checkContains (servers: ServerInfo[], str: string) {
579 for (const server of servers) {
89d241a7 580 const video = await server.videos.get({ id: video1Server2UUID })
26370ce4
C
581
582 for (const f of video.files) {
583 expect(f.magnetUri).to.contain(str)
584 }
585 }
586 }
587
588 async function checkNotContains (servers: ServerInfo[], str: string) {
589 for (const server of servers) {
89d241a7 590 const video = await server.videos.get({ id: video1Server2UUID })
26370ce4
C
591
592 for (const f of video.files) {
593 expect(f.magnetUri).to.not.contain(str)
594 }
595 }
596 }
597
598 before(async function () {
599 this.timeout(120000)
600
7c3b7976 601 await flushAndRunServers(strategy, { min_lifetime: '7 seconds', min_views: 0 })
26370ce4
C
602
603 await enableRedundancyOnServer1()
604 })
605
606 it('Should still have 2 webseeds after 10 seconds', async function () {
09209296 607 this.timeout(80000)
26370ce4
C
608
609 await wait(10000)
610
611 try {
7243f84d 612 await checkContains(servers, 'http%3A%2F%2Flocalhost%3A' + servers[0].port)
26370ce4
C
613 } catch {
614 // Maybe a server deleted a redundancy in the scheduler
615 await wait(2000)
616
7243f84d 617 await checkContains(servers, 'http%3A%2F%2Flocalhost%3A' + servers[0].port)
26370ce4
C
618 }
619 })
620
621 it('Should stop server 1 and expire video redundancy', async function () {
09209296 622 this.timeout(80000)
26370ce4 623
9293139f 624 await killallServers([ servers[0] ])
26370ce4 625
6cb3482c 626 await wait(15000)
26370ce4 627
7243f84d 628 await checkNotContains([ servers[1], servers[2] ], 'http%3A%2F%2Flocalhost%3A' + servers[0].port)
26370ce4
C
629 })
630
7c3b7976
C
631 after(async function () {
632 await cleanupTests(servers)
26370ce4
C
633 })
634 })
635
636 describe('Test file replacement', function () {
637 let video2Server2UUID: string
638 const strategy = 'recently-added'
639
640 before(async function () {
641 this.timeout(120000)
642
7c3b7976 643 await flushAndRunServers(strategy, { min_lifetime: '7 seconds', min_views: 0 })
26370ce4
C
644
645 await enableRedundancyOnServer1()
646
647 await waitJobs(servers)
89d241a7 648 await servers[0].servers.waitUntilLog('Duplicated ', 5)
26370ce4
C
649 await waitJobs(servers)
650
5e8dd6e0
C
651 await check2Webseeds(video1Server2UUID)
652 await check1PlaylistRedundancies(video1Server2UUID)
7448551f 653 await checkStatsWith1Redundancy(strategy)
26370ce4 654
89d241a7 655 const { uuid } = await servers[1].videos.upload({ attributes: { name: 'video 2 server 2', privacy: VideoPrivacy.PRIVATE } })
d23dd9fb 656 video2Server2UUID = uuid
5e8dd6e0
C
657
658 // Wait transcoding before federation
659 await waitJobs(servers)
660
89d241a7 661 await servers[1].videos.update({ id: video2Server2UUID, attributes: { privacy: VideoPrivacy.PUBLIC } })
26370ce4
C
662 })
663
6cb3482c
C
664 it('Should cache video 2 webseeds on the first video', async function () {
665 this.timeout(120000)
26370ce4
C
666
667 await waitJobs(servers)
668
6cb3482c 669 let checked = false
26370ce4 670
6cb3482c
C
671 while (checked === false) {
672 await wait(1000)
26370ce4
C
673
674 try {
09209296
C
675 await check1WebSeed(video1Server2UUID)
676 await check0PlaylistRedundancies(video1Server2UUID)
5e8dd6e0 677
09209296
C
678 await check2Webseeds(video2Server2UUID)
679 await check1PlaylistRedundancies(video2Server2UUID)
26370ce4 680
6cb3482c
C
681 checked = true
682 } catch {
683 checked = false
26370ce4
C
684 }
685 }
686 })
687
09209296
C
688 it('Should disable strategy and remove redundancies', async function () {
689 this.timeout(80000)
690
691 await waitJobs(servers)
692
9293139f 693 await killallServers([ servers[0] ])
a1587156 694 await reRunServer(servers[0], {
09209296
C
695 redundancy: {
696 videos: {
697 check_interval: '1 second',
698 strategies: []
699 }
700 }
701 })
702
703 await waitJobs(servers)
704
6c5065a0 705 await checkVideoFilesWereRemoved(video1Server2UUID, servers[0], [ join('redundancy', 'hls') ])
09209296
C
706 })
707
7c3b7976
C
708 after(async function () {
709 await cleanupTests(servers)
26370ce4
C
710 })
711 })
712})