+ const video: VideoDetails = res.body
+ for (const f of video.files) {
+ checkMagnetWebseeds(f, webseeds, server)
+ }
+ }
+}
+
+async function check2Webseeds (videoUUID?: string) {
+ if (!videoUUID) videoUUID = video1Server2UUID
+
+ const webseeds = [
+ `http://localhost:${servers[ 0 ].port}/static/redundancy/${videoUUID}`,
+ `http://localhost:${servers[ 1 ].port}/static/webseed/${videoUUID}`
+ ]
+
+ for (const server of servers) {
+ const res = await getVideo(server.url, videoUUID)
+
+ const video: VideoDetails = res.body
+
+ for (const file of video.files) {
+ checkMagnetWebseeds(file, webseeds, server)
+
+ await makeGetRequest({
+ url: servers[0].url,
+ statusCodeExpected: 200,
+ path: '/static/redundancy/' + `${videoUUID}-${file.resolution.id}.mp4`,
+ contentType: null
+ })
+ await makeGetRequest({
+ url: servers[1].url,
+ statusCodeExpected: 200,
+ path: `/static/webseed/${videoUUID}-${file.resolution.id}.mp4`,
+ contentType: null
+ })
+ }
+ }
+
+ const directories = [
+ 'test' + servers[0].internalServerNumber + '/redundancy',
+ 'test' + servers[1].internalServerNumber + '/videos'
+ ]
+
+ for (const directory of directories) {
+ const files = await readdir(join(root(), directory))
+ expect(files).to.have.length.at.least(4)
+
+ for (const resolution of [ 240, 360, 480, 720 ]) {
+ expect(files.find(f => f === `${videoUUID}-${resolution}.mp4`)).to.not.be.undefined
+ }
+ }
+}
+
+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)
+ }
+
+ const baseUrlPlaylist = servers[1].url + '/static/streaming-playlists/hls'
+ const baseUrlSegment = servers[0].url + '/static/redundancy/hls'
+
+ const res = await getVideo(servers[0].url, videoUUID)
+ const hlsPlaylist = (res.body as VideoDetails).streamingPlaylists[0]
+
+ for (const resolution of [ 240, 360, 480, 720 ]) {
+ await checkSegmentHash(baseUrlPlaylist, baseUrlSegment, videoUUID, resolution, hlsPlaylist)
+ }
+
+ const directories = [
+ 'test' + servers[0].internalServerNumber + '/redundancy/hls',
+ 'test' + servers[1].internalServerNumber + '/streaming-playlists/hls'
+ ]
+
+ for (const directory of directories) {
+ const files = await readdir(join(root(), directory, videoUUID))
+ expect(files).to.have.length.at.least(4)
+
+ for (const resolution of [ 240, 360, 480, 720 ]) {
+ const filename = `${videoUUID}-${resolution}-fragmented.mp4`
+
+ expect(files.find(f => f === filename)).to.not.be.undefined