+ describe('With only HLS files', function () {
+ const strategy = 'recently-added'
+
+ before(async function () {
+ this.timeout(240000)
+
+ await createServers(strategy, { min_views: 3 }, false)
+ })
+
+ it('Should have 0 playlist redundancy on the first video', async function () {
+ await check1WebSeed()
+ await check0PlaylistRedundancies()
+ })
+
+ it('Should enable redundancy on server 1', function () {
+ return enableRedundancyOnServer1()
+ })
+
+ it('Should still have 0 redundancy on the first video', async function () {
+ this.timeout(80000)
+
+ await waitJobs(servers)
+ await wait(15000)
+ await waitJobs(servers)
+
+ await check0PlaylistRedundancies()
+ await checkStatsWithoutRedundancy(strategy)
+ })
+
+ it('Should have 1 redundancy on the first video', async function () {
+ this.timeout(160000)
+
+ await servers[0].views.simulateView({ id: video1Server2.uuid })
+ await servers[2].views.simulateView({ id: video1Server2.uuid })
+
+ await wait(10000)
+ await waitJobs(servers)
+
+ await waitJobs(servers)
+ await servers[0].servers.waitUntilLog('Duplicated ', 1)
+ await waitJobs(servers)
+
+ await check1PlaylistRedundancies()
+ await checkStatsWith1Redundancy(strategy, true)
+ })
+
+ it('Should remove the video and the redundancy files', async function () {
+ this.timeout(20000)
+
+ await saveVideoInServers(servers, video1Server2.uuid)
+ await servers[1].videos.remove({ id: video1Server2.uuid })
+
+ await waitJobs(servers)
+
+ for (const server of servers) {
+ await checkVideoFilesWereRemoved({ server, video: server.store.videoDetails })
+ }
+ })
+
+ after(async function () {
+ await cleanupTests(servers)
+ })
+ })
+
+ describe('With manual strategy', function () {
+ before(function () {
+ this.timeout(240000)
+
+ return createServers(null)
+ })
+
+ it('Should have 1 webseed on the first video', async function () {
+ await check1WebSeed()
+ await check0PlaylistRedundancies()
+ await checkStatsWithoutRedundancy('manual')
+ })
+
+ it('Should create a redundancy on first video', async function () {
+ await servers[0].redundancy.addVideo({ videoId: video1Server2.id })
+ })
+
+ it('Should have 2 webseeds on the first video', async function () {
+ this.timeout(80000)
+
+ await waitJobs(servers)
+ await servers[0].servers.waitUntilLog('Duplicated ', 5)
+ await waitJobs(servers)
+
+ await check2Webseeds()
+ await check1PlaylistRedundancies()
+ await checkStatsWith1Redundancy('manual')
+ })
+
+ it('Should manually remove redundancies on server 1 and remove duplicated videos', async function () {
+ this.timeout(80000)
+
+ const body = await servers[0].redundancy.listVideos({ target: 'remote-videos' })
+
+ const videos = body.data
+ expect(videos).to.have.lengthOf(1)
+
+ const video = videos[0]
+
+ for (const r of video.redundancies.files.concat(video.redundancies.streamingPlaylists)) {
+ await servers[0].redundancy.removeVideo({ redundancyId: r.id })
+ }
+
+ await waitJobs(servers)
+ await wait(5000)
+
+ await check1WebSeed()
+ await check0PlaylistRedundancies()
+
+ await checkVideoFilesWereRemoved({ server: servers[0], video: video1Server2, onlyVideoFiles: true })
+ })
+
+ after(async function () {
+ await cleanupTests(servers)
+ })
+ })
+