diff options
Diffstat (limited to 'server/tests/peertube-runner/vod-transcoding.ts')
-rw-r--r-- | server/tests/peertube-runner/vod-transcoding.ts | 350 |
1 files changed, 0 insertions, 350 deletions
diff --git a/server/tests/peertube-runner/vod-transcoding.ts b/server/tests/peertube-runner/vod-transcoding.ts deleted file mode 100644 index b3b62e5e0..000000000 --- a/server/tests/peertube-runner/vod-transcoding.ts +++ /dev/null | |||
@@ -1,350 +0,0 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | ||
2 | import { expect } from 'chai' | ||
3 | import { | ||
4 | checkPeerTubeRunnerCacheIsEmpty, | ||
5 | completeCheckHlsPlaylist, | ||
6 | completeWebVideoFilesCheck, | ||
7 | PeerTubeRunnerProcess | ||
8 | } from '@server/tests/shared' | ||
9 | import { areMockObjectStorageTestsDisabled, getAllFiles, wait } from '@shared/core-utils' | ||
10 | import { VideoPrivacy } from '@shared/models' | ||
11 | import { | ||
12 | cleanupTests, | ||
13 | createMultipleServers, | ||
14 | doubleFollow, | ||
15 | ObjectStorageCommand, | ||
16 | PeerTubeServer, | ||
17 | setAccessTokensToServers, | ||
18 | setDefaultVideoChannel, | ||
19 | waitJobs | ||
20 | } from '@shared/server-commands' | ||
21 | |||
22 | describe('Test VOD transcoding in peertube-runner program', function () { | ||
23 | let servers: PeerTubeServer[] = [] | ||
24 | let peertubeRunner: PeerTubeRunnerProcess | ||
25 | |||
26 | function runSuite (options: { | ||
27 | webVideoEnabled: boolean | ||
28 | hlsEnabled: boolean | ||
29 | objectStorage?: ObjectStorageCommand | ||
30 | }) { | ||
31 | const { webVideoEnabled, hlsEnabled, objectStorage } = options | ||
32 | |||
33 | const objectStorageBaseUrlWebVideo = objectStorage | ||
34 | ? objectStorage.getMockWebVideosBaseUrl() | ||
35 | : undefined | ||
36 | |||
37 | const objectStorageBaseUrlHLS = objectStorage | ||
38 | ? objectStorage.getMockPlaylistBaseUrl() | ||
39 | : undefined | ||
40 | |||
41 | it('Should upload a classic video mp4 and transcode it', async function () { | ||
42 | this.timeout(120000) | ||
43 | |||
44 | const { uuid } = await servers[0].videos.quickUpload({ name: 'mp4', fixture: 'video_short.mp4' }) | ||
45 | |||
46 | await waitJobs(servers, { runnerJobs: true }) | ||
47 | |||
48 | for (const server of servers) { | ||
49 | if (webVideoEnabled) { | ||
50 | await completeWebVideoFilesCheck({ | ||
51 | server, | ||
52 | originServer: servers[0], | ||
53 | fixture: 'video_short.mp4', | ||
54 | videoUUID: uuid, | ||
55 | objectStorageBaseUrl: objectStorageBaseUrlWebVideo, | ||
56 | files: [ | ||
57 | { resolution: 0 }, | ||
58 | { resolution: 144 }, | ||
59 | { resolution: 240 }, | ||
60 | { resolution: 360 }, | ||
61 | { resolution: 480 }, | ||
62 | { resolution: 720 } | ||
63 | ] | ||
64 | }) | ||
65 | } | ||
66 | |||
67 | if (hlsEnabled) { | ||
68 | await completeCheckHlsPlaylist({ | ||
69 | hlsOnly: !webVideoEnabled, | ||
70 | servers, | ||
71 | videoUUID: uuid, | ||
72 | objectStorageBaseUrl: objectStorageBaseUrlHLS, | ||
73 | resolutions: [ 720, 480, 360, 240, 144, 0 ] | ||
74 | }) | ||
75 | } | ||
76 | } | ||
77 | }) | ||
78 | |||
79 | it('Should upload a webm video and transcode it', async function () { | ||
80 | this.timeout(120000) | ||
81 | |||
82 | const { uuid } = await servers[0].videos.quickUpload({ name: 'mp4', fixture: 'video_short.webm' }) | ||
83 | |||
84 | await waitJobs(servers, { runnerJobs: true }) | ||
85 | |||
86 | for (const server of servers) { | ||
87 | if (webVideoEnabled) { | ||
88 | await completeWebVideoFilesCheck({ | ||
89 | server, | ||
90 | originServer: servers[0], | ||
91 | fixture: 'video_short.webm', | ||
92 | videoUUID: uuid, | ||
93 | objectStorageBaseUrl: objectStorageBaseUrlWebVideo, | ||
94 | files: [ | ||
95 | { resolution: 0 }, | ||
96 | { resolution: 144 }, | ||
97 | { resolution: 240 }, | ||
98 | { resolution: 360 }, | ||
99 | { resolution: 480 }, | ||
100 | { resolution: 720 } | ||
101 | ] | ||
102 | }) | ||
103 | } | ||
104 | |||
105 | if (hlsEnabled) { | ||
106 | await completeCheckHlsPlaylist({ | ||
107 | hlsOnly: !webVideoEnabled, | ||
108 | servers, | ||
109 | videoUUID: uuid, | ||
110 | objectStorageBaseUrl: objectStorageBaseUrlHLS, | ||
111 | resolutions: [ 720, 480, 360, 240, 144, 0 ] | ||
112 | }) | ||
113 | } | ||
114 | } | ||
115 | }) | ||
116 | |||
117 | it('Should upload an audio only video and transcode it', async function () { | ||
118 | this.timeout(120000) | ||
119 | |||
120 | const attributes = { name: 'audio_without_preview', fixture: 'sample.ogg' } | ||
121 | const { uuid } = await servers[0].videos.upload({ attributes, mode: 'resumable' }) | ||
122 | |||
123 | await waitJobs(servers, { runnerJobs: true }) | ||
124 | |||
125 | for (const server of servers) { | ||
126 | if (webVideoEnabled) { | ||
127 | await completeWebVideoFilesCheck({ | ||
128 | server, | ||
129 | originServer: servers[0], | ||
130 | fixture: 'sample.ogg', | ||
131 | videoUUID: uuid, | ||
132 | objectStorageBaseUrl: objectStorageBaseUrlWebVideo, | ||
133 | files: [ | ||
134 | { resolution: 0 }, | ||
135 | { resolution: 144 }, | ||
136 | { resolution: 240 }, | ||
137 | { resolution: 360 }, | ||
138 | { resolution: 480 } | ||
139 | ] | ||
140 | }) | ||
141 | } | ||
142 | |||
143 | if (hlsEnabled) { | ||
144 | await completeCheckHlsPlaylist({ | ||
145 | hlsOnly: !webVideoEnabled, | ||
146 | servers, | ||
147 | videoUUID: uuid, | ||
148 | objectStorageBaseUrl: objectStorageBaseUrlHLS, | ||
149 | resolutions: [ 480, 360, 240, 144, 0 ] | ||
150 | }) | ||
151 | } | ||
152 | } | ||
153 | }) | ||
154 | |||
155 | it('Should upload a private video and transcode it', async function () { | ||
156 | this.timeout(120000) | ||
157 | |||
158 | const { uuid } = await servers[0].videos.quickUpload({ name: 'mp4', fixture: 'video_short.mp4', privacy: VideoPrivacy.PRIVATE }) | ||
159 | |||
160 | await waitJobs(servers, { runnerJobs: true }) | ||
161 | |||
162 | if (webVideoEnabled) { | ||
163 | await completeWebVideoFilesCheck({ | ||
164 | server: servers[0], | ||
165 | originServer: servers[0], | ||
166 | fixture: 'video_short.mp4', | ||
167 | videoUUID: uuid, | ||
168 | objectStorageBaseUrl: objectStorageBaseUrlWebVideo, | ||
169 | files: [ | ||
170 | { resolution: 0 }, | ||
171 | { resolution: 144 }, | ||
172 | { resolution: 240 }, | ||
173 | { resolution: 360 }, | ||
174 | { resolution: 480 }, | ||
175 | { resolution: 720 } | ||
176 | ] | ||
177 | }) | ||
178 | } | ||
179 | |||
180 | if (hlsEnabled) { | ||
181 | await completeCheckHlsPlaylist({ | ||
182 | hlsOnly: !webVideoEnabled, | ||
183 | servers: [ servers[0] ], | ||
184 | videoUUID: uuid, | ||
185 | objectStorageBaseUrl: objectStorageBaseUrlHLS, | ||
186 | resolutions: [ 720, 480, 360, 240, 144, 0 ] | ||
187 | }) | ||
188 | } | ||
189 | }) | ||
190 | |||
191 | it('Should transcode videos on manual run', async function () { | ||
192 | this.timeout(120000) | ||
193 | |||
194 | await servers[0].config.disableTranscoding() | ||
195 | |||
196 | const { uuid } = await servers[0].videos.quickUpload({ name: 'manual transcoding', fixture: 'video_short.mp4' }) | ||
197 | await waitJobs(servers, { runnerJobs: true }) | ||
198 | |||
199 | { | ||
200 | const video = await servers[0].videos.get({ id: uuid }) | ||
201 | expect(getAllFiles(video)).to.have.lengthOf(1) | ||
202 | } | ||
203 | |||
204 | await servers[0].config.enableTranscoding({ hls: true, webVideo: true, with0p: true }) | ||
205 | |||
206 | await servers[0].videos.runTranscoding({ transcodingType: 'web-video', videoId: uuid }) | ||
207 | await waitJobs(servers, { runnerJobs: true }) | ||
208 | |||
209 | await completeWebVideoFilesCheck({ | ||
210 | server: servers[0], | ||
211 | originServer: servers[0], | ||
212 | fixture: 'video_short.mp4', | ||
213 | videoUUID: uuid, | ||
214 | objectStorageBaseUrl: objectStorageBaseUrlWebVideo, | ||
215 | files: [ | ||
216 | { resolution: 0 }, | ||
217 | { resolution: 144 }, | ||
218 | { resolution: 240 }, | ||
219 | { resolution: 360 }, | ||
220 | { resolution: 480 }, | ||
221 | { resolution: 720 } | ||
222 | ] | ||
223 | }) | ||
224 | |||
225 | await servers[0].videos.runTranscoding({ transcodingType: 'hls', videoId: uuid }) | ||
226 | await waitJobs(servers, { runnerJobs: true }) | ||
227 | |||
228 | await completeCheckHlsPlaylist({ | ||
229 | hlsOnly: false, | ||
230 | servers: [ servers[0] ], | ||
231 | videoUUID: uuid, | ||
232 | objectStorageBaseUrl: objectStorageBaseUrlHLS, | ||
233 | resolutions: [ 720, 480, 360, 240, 144, 0 ] | ||
234 | }) | ||
235 | }) | ||
236 | } | ||
237 | |||
238 | before(async function () { | ||
239 | this.timeout(120_000) | ||
240 | |||
241 | servers = await createMultipleServers(2) | ||
242 | |||
243 | await setAccessTokensToServers(servers) | ||
244 | await setDefaultVideoChannel(servers) | ||
245 | |||
246 | await doubleFollow(servers[0], servers[1]) | ||
247 | |||
248 | await servers[0].config.enableRemoteTranscoding() | ||
249 | |||
250 | const registrationToken = await servers[0].runnerRegistrationTokens.getFirstRegistrationToken() | ||
251 | |||
252 | peertubeRunner = new PeerTubeRunnerProcess(servers[0]) | ||
253 | await peertubeRunner.runServer() | ||
254 | await peertubeRunner.registerPeerTubeInstance({ registrationToken, runnerName: 'runner' }) | ||
255 | }) | ||
256 | |||
257 | describe('With videos on local filesystem storage', function () { | ||
258 | |||
259 | describe('Web video only enabled', function () { | ||
260 | |||
261 | before(async function () { | ||
262 | await servers[0].config.enableTranscoding({ webVideo: true, hls: false, with0p: true }) | ||
263 | }) | ||
264 | |||
265 | runSuite({ webVideoEnabled: true, hlsEnabled: false }) | ||
266 | }) | ||
267 | |||
268 | describe('HLS videos only enabled', function () { | ||
269 | |||
270 | before(async function () { | ||
271 | await servers[0].config.enableTranscoding({ webVideo: false, hls: true, with0p: true }) | ||
272 | }) | ||
273 | |||
274 | runSuite({ webVideoEnabled: false, hlsEnabled: true }) | ||
275 | }) | ||
276 | |||
277 | describe('Web video & HLS enabled', function () { | ||
278 | |||
279 | before(async function () { | ||
280 | await servers[0].config.enableTranscoding({ hls: true, webVideo: true, with0p: true }) | ||
281 | }) | ||
282 | |||
283 | runSuite({ webVideoEnabled: true, hlsEnabled: true }) | ||
284 | }) | ||
285 | }) | ||
286 | |||
287 | describe('With videos on object storage', function () { | ||
288 | if (areMockObjectStorageTestsDisabled()) return | ||
289 | |||
290 | const objectStorage = new ObjectStorageCommand() | ||
291 | |||
292 | before(async function () { | ||
293 | await objectStorage.prepareDefaultMockBuckets() | ||
294 | |||
295 | await servers[0].kill() | ||
296 | |||
297 | await servers[0].run(objectStorage.getDefaultMockConfig()) | ||
298 | |||
299 | // Wait for peertube runner socket reconnection | ||
300 | await wait(1500) | ||
301 | }) | ||
302 | |||
303 | describe('Web video only enabled', function () { | ||
304 | |||
305 | before(async function () { | ||
306 | await servers[0].config.enableTranscoding({ webVideo: true, hls: false, with0p: true }) | ||
307 | }) | ||
308 | |||
309 | runSuite({ webVideoEnabled: true, hlsEnabled: false, objectStorage }) | ||
310 | }) | ||
311 | |||
312 | describe('HLS videos only enabled', function () { | ||
313 | |||
314 | before(async function () { | ||
315 | await servers[0].config.enableTranscoding({ webVideo: false, hls: true, with0p: true }) | ||
316 | }) | ||
317 | |||
318 | runSuite({ webVideoEnabled: false, hlsEnabled: true, objectStorage }) | ||
319 | }) | ||
320 | |||
321 | describe('Web video & HLS enabled', function () { | ||
322 | |||
323 | before(async function () { | ||
324 | await servers[0].config.enableTranscoding({ hls: true, webVideo: true, with0p: true }) | ||
325 | }) | ||
326 | |||
327 | runSuite({ webVideoEnabled: true, hlsEnabled: true, objectStorage }) | ||
328 | }) | ||
329 | |||
330 | after(async function () { | ||
331 | await objectStorage.cleanupMock() | ||
332 | }) | ||
333 | }) | ||
334 | |||
335 | describe('Check cleanup', function () { | ||
336 | |||
337 | it('Should have an empty cache directory', async function () { | ||
338 | await checkPeerTubeRunnerCacheIsEmpty(peertubeRunner) | ||
339 | }) | ||
340 | }) | ||
341 | |||
342 | after(async function () { | ||
343 | if (peertubeRunner) { | ||
344 | await peertubeRunner.unregisterPeerTubeInstance({ runnerName: 'runner' }) | ||
345 | peertubeRunner.kill() | ||
346 | } | ||
347 | |||
348 | await cleanupTests(servers) | ||
349 | }) | ||
350 | }) | ||