+async function check0PlaylistRedundancies (videoUUID?: string) {
+ if (!videoUUID) videoUUID = video1Server2UUID
+
+ for (const server of servers) {
+ // With token to avoid issues with video follow constraints
+ const res = await getVideoWithToken(server.url, server.accessToken, videoUUID)
+ const video: VideoDetails = res.body
+
+ expect(video.streamingPlaylists).to.be.an('array')
+ expect(video.streamingPlaylists).to.have.lengthOf(1)
+ expect(video.streamingPlaylists[0].redundancies).to.have.lengthOf(0)
+ }
+}
+
+async function check1PlaylistRedundancies (videoUUID?: string) {
+ if (!videoUUID) videoUUID = video1Server2UUID
+
+ for (const server of servers) {
+ const res = await getVideo(server.url, videoUUID)
+ const video: VideoDetails = res.body
+
+ expect(video.streamingPlaylists).to.have.lengthOf(1)
+ expect(video.streamingPlaylists[0].redundancies).to.have.lengthOf(1)
+
+ const redundancy = video.streamingPlaylists[0].redundancies[0]
+
+ expect(redundancy.baseUrl).to.equal(servers[0].url + '/static/redundancy/hls/' + videoUUID)
+ }
+
+ await makeGetRequest({
+ url: servers[0].url,
+ statusCodeExpected: 200,
+ path: `/static/redundancy/hls/${videoUUID}/360_000.ts`,
+ contentType: null
+ })
+
+ for (const directory of [ 'test1/redundancy/hls', 'test2/playlists/hls' ]) {
+ const files = await readdir(join(root(), directory, videoUUID))
+ expect(files).to.have.length.at.least(4)
+
+ for (const resolution of [ 240, 360, 480, 720 ]) {
+ expect(files.find(f => f === `${resolution}_000.ts`)).to.not.be.undefined
+ expect(files.find(f => f === `${resolution}_001.ts`)).to.not.be.undefined
+ }
+ }
+}
+
+async function checkStatsWith2Webseed (strategy: VideoRedundancyStrategy) {
+ const res = await getStats(servers[0].url)
+ const data: ServerStats = res.body
+
+ expect(data.videosRedundancy).to.have.lengthOf(1)
+ const stat = data.videosRedundancy[0]
+
+ expect(stat.strategy).to.equal(strategy)
+ expect(stat.totalSize).to.equal(204800)
+ expect(stat.totalUsed).to.be.at.least(1).and.below(204801)
+ expect(stat.totalVideoFiles).to.equal(4)
+ expect(stat.totalVideos).to.equal(1)
+}
+
+async function checkStatsWith1Webseed (strategy: VideoRedundancyStrategy) {
+ const res = await getStats(servers[0].url)
+ const data: ServerStats = res.body
+
+ expect(data.videosRedundancy).to.have.lengthOf(1)
+
+ const stat = data.videosRedundancy[0]
+ expect(stat.strategy).to.equal(strategy)
+ expect(stat.totalSize).to.equal(204800)
+ expect(stat.totalUsed).to.equal(0)
+ expect(stat.totalVideoFiles).to.equal(0)
+ expect(stat.totalVideos).to.equal(0)
+}
+