diff options
Diffstat (limited to 'server/tests')
-rw-r--r-- | server/tests/api/redundancy/redundancy.ts | 22 | ||||
-rw-r--r-- | server/tests/api/videos/video-hls.ts | 16 |
2 files changed, 18 insertions, 20 deletions
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 { | |||
17 | viewVideo, | 17 | viewVideo, |
18 | wait, | 18 | wait, |
19 | waitUntilLog, | 19 | waitUntilLog, |
20 | checkVideoFilesWereRemoved, removeVideo, getVideoWithToken, reRunServer | 20 | checkVideoFilesWereRemoved, removeVideo, getVideoWithToken, reRunServer, checkSegmentHash |
21 | } from '../../../../shared/utils' | 21 | } from '../../../../shared/utils' |
22 | import { waitJobs } from '../../../../shared/utils/server/jobs' | 22 | import { waitJobs } from '../../../../shared/utils/server/jobs' |
23 | 23 | ||
@@ -178,20 +178,24 @@ async function check1PlaylistRedundancies (videoUUID?: string) { | |||
178 | expect(redundancy.baseUrl).to.equal(servers[0].url + '/static/redundancy/hls/' + videoUUID) | 178 | expect(redundancy.baseUrl).to.equal(servers[0].url + '/static/redundancy/hls/' + videoUUID) |
179 | } | 179 | } |
180 | 180 | ||
181 | await makeGetRequest({ | 181 | const baseUrlPlaylist = servers[1].url + '/static/playlists/hls' |
182 | url: servers[0].url, | 182 | const baseUrlSegment = servers[0].url + '/static/redundancy/hls' |
183 | statusCodeExpected: 200, | 183 | |
184 | path: `/static/redundancy/hls/${videoUUID}/360_000.ts`, | 184 | const res = await getVideo(servers[0].url, videoUUID) |
185 | contentType: null | 185 | const hlsPlaylist = (res.body as VideoDetails).streamingPlaylists[0] |
186 | }) | 186 | |
187 | for (const resolution of [ 240, 360, 480, 720 ]) { | ||
188 | await checkSegmentHash(baseUrlPlaylist, baseUrlSegment, videoUUID, resolution, hlsPlaylist) | ||
189 | } | ||
187 | 190 | ||
188 | for (const directory of [ 'test1/redundancy/hls', 'test2/playlists/hls' ]) { | 191 | for (const directory of [ 'test1/redundancy/hls', 'test2/playlists/hls' ]) { |
189 | const files = await readdir(join(root(), directory, videoUUID)) | 192 | const files = await readdir(join(root(), directory, videoUUID)) |
190 | expect(files).to.have.length.at.least(4) | 193 | expect(files).to.have.length.at.least(4) |
191 | 194 | ||
192 | for (const resolution of [ 240, 360, 480, 720 ]) { | 195 | for (const resolution of [ 240, 360, 480, 720 ]) { |
193 | expect(files.find(f => f === `${resolution}_000.ts`)).to.not.be.undefined | 196 | const filename = `${videoUUID}-${resolution}-fragmented.mp4` |
194 | expect(files.find(f => f === `${resolution}_001.ts`)).to.not.be.undefined | 197 | |
198 | expect(files.find(f => f === filename)).to.not.be.undefined | ||
195 | } | 199 | } |
196 | } | 200 | } |
197 | } | 201 | } |
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' | |||
4 | import 'mocha' | 4 | import 'mocha' |
5 | import { | 5 | import { |
6 | checkDirectoryIsEmpty, | 6 | checkDirectoryIsEmpty, |
7 | checkSegmentHash, | ||
7 | checkTmpIsEmpty, | 8 | checkTmpIsEmpty, |
8 | doubleFollow, | 9 | doubleFollow, |
9 | flushAndRunMultipleServers, | 10 | flushAndRunMultipleServers, |
10 | flushTests, | 11 | flushTests, |
11 | getPlaylist, | 12 | getPlaylist, |
12 | getSegment, | ||
13 | getSegmentSha256, | ||
14 | getVideo, | 13 | getVideo, |
15 | killallServers, | 14 | killallServers, |
16 | removeVideo, | 15 | removeVideo, |
@@ -22,7 +21,6 @@ import { | |||
22 | } from '../../../../shared/utils' | 21 | } from '../../../../shared/utils' |
23 | import { VideoDetails } from '../../../../shared/models/videos' | 22 | import { VideoDetails } from '../../../../shared/models/videos' |
24 | import { VideoStreamingPlaylistType } from '../../../../shared/models/videos/video-streaming-playlist.type' | 23 | import { VideoStreamingPlaylistType } from '../../../../shared/models/videos/video-streaming-playlist.type' |
25 | import { sha256 } from '../../../helpers/core-utils' | ||
26 | import { join } from 'path' | 24 | import { join } from 'path' |
27 | 25 | ||
28 | const expect = chai.expect | 26 | const expect = chai.expect |
@@ -56,19 +54,15 @@ async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string) { | |||
56 | const res2 = await getPlaylist(`http://localhost:9001/static/playlists/hls/${videoUUID}/${resolution}.m3u8`) | 54 | const res2 = await getPlaylist(`http://localhost:9001/static/playlists/hls/${videoUUID}/${resolution}.m3u8`) |
57 | 55 | ||
58 | const subPlaylist = res2.text | 56 | const subPlaylist = res2.text |
59 | expect(subPlaylist).to.contain(resolution + '_000.ts') | 57 | expect(subPlaylist).to.contain(`${videoUUID}-${resolution}-fragmented.mp4`) |
60 | } | 58 | } |
61 | } | 59 | } |
62 | 60 | ||
63 | { | 61 | { |
64 | for (const resolution of resolutions) { | 62 | const baseUrl = 'http://localhost:9001/static/playlists/hls' |
65 | |||
66 | const res2 = await getSegment(`http://localhost:9001/static/playlists/hls/${videoUUID}/${resolution}_000.ts`) | ||
67 | 63 | ||
68 | const resSha = await getSegmentSha256(hlsPlaylist.segmentsSha256Url) | 64 | for (const resolution of resolutions) { |
69 | 65 | await checkSegmentHash(baseUrl, baseUrl, videoUUID, resolution, hlsPlaylist) | |
70 | const sha256Server = resSha.body[ resolution + '_000.ts' ] | ||
71 | expect(sha256(res2.body)).to.equal(sha256Server) | ||
72 | } | 66 | } |
73 | } | 67 | } |
74 | } | 68 | } |