From 4c280004ce62bf11ddb091854c28f1e1d54a54d6 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 7 Feb 2019 15:08:19 +0100 Subject: Use a single file instead of segments for HLS --- server/tests/api/redundancy/redundancy.ts | 22 +++++++++++++--------- server/tests/api/videos/video-hls.ts | 16 +++++----------- 2 files changed, 18 insertions(+), 20 deletions(-) (limited to 'server/tests') diff --git a/server/tests/api/redundancy/redundancy.ts b/server/tests/api/redundancy/redundancy.ts index 5b99309fb..778611fff 100644 --- a/server/tests/api/redundancy/redundancy.ts +++ b/server/tests/api/redundancy/redundancy.ts @@ -17,7 +17,7 @@ import { viewVideo, wait, waitUntilLog, - checkVideoFilesWereRemoved, removeVideo, getVideoWithToken, reRunServer + checkVideoFilesWereRemoved, removeVideo, getVideoWithToken, reRunServer, checkSegmentHash } from '../../../../shared/utils' import { waitJobs } from '../../../../shared/utils/server/jobs' @@ -178,20 +178,24 @@ async function check1PlaylistRedundancies (videoUUID?: string) { 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 - }) + const baseUrlPlaylist = servers[1].url + '/static/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) + } 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 + const filename = `${videoUUID}-${resolution}-fragmented.mp4` + + expect(files.find(f => f === filename)).to.not.be.undefined } } } diff --git a/server/tests/api/videos/video-hls.ts b/server/tests/api/videos/video-hls.ts index 71d863b12..a1214bad1 100644 --- a/server/tests/api/videos/video-hls.ts +++ b/server/tests/api/videos/video-hls.ts @@ -4,13 +4,12 @@ import * as chai from 'chai' import 'mocha' import { checkDirectoryIsEmpty, + checkSegmentHash, checkTmpIsEmpty, doubleFollow, flushAndRunMultipleServers, flushTests, getPlaylist, - getSegment, - getSegmentSha256, getVideo, killallServers, removeVideo, @@ -22,7 +21,6 @@ import { } from '../../../../shared/utils' import { VideoDetails } from '../../../../shared/models/videos' import { VideoStreamingPlaylistType } from '../../../../shared/models/videos/video-streaming-playlist.type' -import { sha256 } from '../../../helpers/core-utils' import { join } from 'path' const expect = chai.expect @@ -56,19 +54,15 @@ async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string) { const res2 = await getPlaylist(`http://localhost:9001/static/playlists/hls/${videoUUID}/${resolution}.m3u8`) const subPlaylist = res2.text - expect(subPlaylist).to.contain(resolution + '_000.ts') + expect(subPlaylist).to.contain(`${videoUUID}-${resolution}-fragmented.mp4`) } } { - for (const resolution of resolutions) { - - const res2 = await getSegment(`http://localhost:9001/static/playlists/hls/${videoUUID}/${resolution}_000.ts`) + const baseUrl = 'http://localhost:9001/static/playlists/hls' - const resSha = await getSegmentSha256(hlsPlaylist.segmentsSha256Url) - - const sha256Server = resSha.body[ resolution + '_000.ts' ] - expect(sha256(res2.body)).to.equal(sha256Server) + for (const resolution of resolutions) { + await checkSegmentHash(baseUrl, baseUrl, videoUUID, resolution, hlsPlaylist) } } } -- cgit v1.2.3