+ await wait(10000)
+
+ try {
+ await checkContains(servers, 'http%3A%2F%2Flocalhost%3A9001')
+ } catch {
+ // Maybe a server deleted a redundancy in the scheduler
+ await wait(2000)
+
+ await checkContains(servers, 'http%3A%2F%2Flocalhost%3A9001')
+ }
+ })
+
+ it('Should stop server 1 and expire video redundancy', async function () {
+ this.timeout(40000)
+
+ killallServers([ servers[0] ])
+
+ await wait(10000)
+
+ await checkNotContains([ servers[1], servers[2] ], 'http%3A%2F%2Flocalhost%3A9001')
+ })
+
+ after(function () {
+ return killallServers([ servers[1], servers[2] ])
+ })
+ })
+
+ describe('Test file replacement', function () {
+ let video2Server2UUID: string
+ const strategy = 'recently-added'
+
+ before(async function () {
+ this.timeout(120000)
+
+ await runServers(strategy, { min_lifetime: '7 seconds', min_views: 0 })
+
+ await enableRedundancyOnServer1()
+
+ await waitJobs(servers)
+ await waitUntilLog(servers[0], 'Duplicated ', 4)
+ await waitJobs(servers)
+
+ await check2Webseeds(strategy)
+ await checkStatsWith2Webseed(strategy)
+
+ const res = await uploadVideo(servers[ 1 ].url, servers[ 1 ].accessToken, { name: 'video 2 server 2' })
+ video2Server2UUID = res.body.video.uuid
+ })
+
+ it('Should cache video 2 webseed on the first video', async function () {
+ this.timeout(50000)
+
+ await waitJobs(servers)
+
+ await wait(7000)
+
+ try {
+ await check1WebSeed(strategy, video1Server2UUID)
+ await check2Webseeds(strategy, video2Server2UUID)
+ } catch {
+ await wait(7000)
+
+ await check1WebSeed(strategy, video1Server2UUID)
+ await check2Webseeds(strategy, video2Server2UUID)
+ }