diff options
Diffstat (limited to 'server/tests/api')
-rw-r--r-- | server/tests/api/videos/video-create-transcoding.ts | 85 |
1 files changed, 80 insertions, 5 deletions
diff --git a/server/tests/api/videos/video-create-transcoding.ts b/server/tests/api/videos/video-create-transcoding.ts index dcdbd9c6e..445866a16 100644 --- a/server/tests/api/videos/video-create-transcoding.ts +++ b/server/tests/api/videos/video-create-transcoding.ts | |||
@@ -2,11 +2,12 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { expectStartWith } from '@server/tests/shared' | 5 | import { checkResolutionsInMasterPlaylist, expectStartWith } from '@server/tests/shared' |
6 | import { areObjectStorageTestsDisabled } from '@shared/core-utils' | 6 | import { areObjectStorageTestsDisabled } from '@shared/core-utils' |
7 | import { HttpStatusCode, VideoDetails } from '@shared/models' | 7 | import { HttpStatusCode, VideoDetails } from '@shared/models' |
8 | import { | 8 | import { |
9 | cleanupTests, | 9 | cleanupTests, |
10 | ConfigCommand, | ||
10 | createMultipleServers, | 11 | createMultipleServers, |
11 | doubleFollow, | 12 | doubleFollow, |
12 | expectNoFailedTranscodingJob, | 13 | expectNoFailedTranscodingJob, |
@@ -25,14 +26,19 @@ async function checkFilesInObjectStorage (video: VideoDetails) { | |||
25 | await makeRawRequest(file.fileUrl, HttpStatusCode.OK_200) | 26 | await makeRawRequest(file.fileUrl, HttpStatusCode.OK_200) |
26 | } | 27 | } |
27 | 28 | ||
28 | const streamingPlaylistFiles = video.streamingPlaylists.length === 0 | 29 | if (video.streamingPlaylists.length === 0) return |
29 | ? [] | ||
30 | : video.streamingPlaylists[0].files | ||
31 | 30 | ||
32 | for (const file of streamingPlaylistFiles) { | 31 | const hlsPlaylist = video.streamingPlaylists[0] |
32 | for (const file of hlsPlaylist.files) { | ||
33 | expectStartWith(file.fileUrl, ObjectStorageCommand.getPlaylistBaseUrl()) | 33 | expectStartWith(file.fileUrl, ObjectStorageCommand.getPlaylistBaseUrl()) |
34 | await makeRawRequest(file.fileUrl, HttpStatusCode.OK_200) | 34 | await makeRawRequest(file.fileUrl, HttpStatusCode.OK_200) |
35 | } | 35 | } |
36 | |||
37 | expectStartWith(hlsPlaylist.playlistUrl, ObjectStorageCommand.getPlaylistBaseUrl()) | ||
38 | await makeRawRequest(hlsPlaylist.playlistUrl, HttpStatusCode.OK_200) | ||
39 | |||
40 | expectStartWith(hlsPlaylist.segmentsSha256Url, ObjectStorageCommand.getPlaylistBaseUrl()) | ||
41 | await makeRawRequest(hlsPlaylist.segmentsSha256Url, HttpStatusCode.OK_200) | ||
36 | } | 42 | } |
37 | 43 | ||
38 | function runTests (objectStorage: boolean) { | 44 | function runTests (objectStorage: boolean) { |
@@ -150,6 +156,75 @@ function runTests (objectStorage: boolean) { | |||
150 | } | 156 | } |
151 | }) | 157 | }) |
152 | 158 | ||
159 | it('Should correctly update HLS playlist on resolution change', async function () { | ||
160 | await servers[0].config.updateExistingSubConfig({ | ||
161 | newConfig: { | ||
162 | transcoding: { | ||
163 | enabled: true, | ||
164 | resolutions: ConfigCommand.getCustomConfigResolutions(false), | ||
165 | |||
166 | webtorrent: { | ||
167 | enabled: true | ||
168 | }, | ||
169 | hls: { | ||
170 | enabled: true | ||
171 | } | ||
172 | } | ||
173 | } | ||
174 | }) | ||
175 | |||
176 | const { uuid } = await servers[0].videos.quickUpload({ name: 'quick' }) | ||
177 | |||
178 | await waitJobs(servers) | ||
179 | |||
180 | for (const server of servers) { | ||
181 | const videoDetails = await server.videos.get({ id: uuid }) | ||
182 | |||
183 | expect(videoDetails.files).to.have.lengthOf(1) | ||
184 | expect(videoDetails.streamingPlaylists).to.have.lengthOf(1) | ||
185 | expect(videoDetails.streamingPlaylists[0].files).to.have.lengthOf(1) | ||
186 | |||
187 | if (objectStorage) await checkFilesInObjectStorage(videoDetails) | ||
188 | } | ||
189 | |||
190 | await servers[0].config.updateExistingSubConfig({ | ||
191 | newConfig: { | ||
192 | transcoding: { | ||
193 | enabled: true, | ||
194 | resolutions: ConfigCommand.getCustomConfigResolutions(true), | ||
195 | |||
196 | webtorrent: { | ||
197 | enabled: true | ||
198 | }, | ||
199 | hls: { | ||
200 | enabled: true | ||
201 | } | ||
202 | } | ||
203 | } | ||
204 | }) | ||
205 | |||
206 | await servers[0].videos.runTranscoding({ videoId: uuid, transcodingType: 'hls' }) | ||
207 | await waitJobs(servers) | ||
208 | |||
209 | for (const server of servers) { | ||
210 | const videoDetails = await server.videos.get({ id: uuid }) | ||
211 | |||
212 | expect(videoDetails.streamingPlaylists).to.have.lengthOf(1) | ||
213 | expect(videoDetails.streamingPlaylists[0].files).to.have.lengthOf(5) | ||
214 | |||
215 | if (objectStorage) { | ||
216 | await checkFilesInObjectStorage(videoDetails) | ||
217 | |||
218 | const hlsPlaylist = videoDetails.streamingPlaylists[0] | ||
219 | const resolutions = hlsPlaylist.files.map(f => f.resolution.id) | ||
220 | await checkResolutionsInMasterPlaylist({ server: servers[0], playlistUrl: hlsPlaylist.playlistUrl, resolutions }) | ||
221 | |||
222 | const shaBody = await servers[0].streamingPlaylists.getSegmentSha256({ url: hlsPlaylist.segmentsSha256Url }) | ||
223 | expect(Object.keys(shaBody)).to.have.lengthOf(5) | ||
224 | } | ||
225 | } | ||
226 | }) | ||
227 | |||
153 | it('Should not have updated published at attributes', async function () { | 228 | it('Should not have updated published at attributes', async function () { |
154 | const video = await servers[0].videos.get({ id: videoUUID }) | 229 | const video = await servers[0].videos.get({ id: videoUUID }) |
155 | 230 | ||