aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/live/live.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/live/live.ts')
-rw-r--r--server/tests/api/live/live.ts213
1 files changed, 42 insertions, 171 deletions
diff --git a/server/tests/api/live/live.ts b/server/tests/api/live/live.ts
index f351e9650..f7ccb453d 100644
--- a/server/tests/api/live/live.ts
+++ b/server/tests/api/live/live.ts
@@ -4,6 +4,7 @@ import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { LiveVideo, LiveVideoCreate, User, VideoDetails, VideoPrivacy } from '@shared/models' 5import { LiveVideo, LiveVideoCreate, User, VideoDetails, VideoPrivacy } from '@shared/models'
6import { 6import {
7 addVideoToBlacklist,
7 cleanupTests, 8 cleanupTests,
8 createLive, 9 createLive,
9 createUser, 10 createUser,
@@ -15,6 +16,7 @@ import {
15 getVideosList, 16 getVideosList,
16 makeRawRequest, 17 makeRawRequest,
17 removeVideo, 18 removeVideo,
19 sendRTMPStream,
18 ServerInfo, 20 ServerInfo,
19 setAccessTokensToServers, 21 setAccessTokensToServers,
20 setDefaultVideoChannel, 22 setDefaultVideoChannel,
@@ -22,9 +24,7 @@ import {
22 testImage, 24 testImage,
23 updateCustomSubConfig, 25 updateCustomSubConfig,
24 updateLive, 26 updateLive,
25 updateUser,
26 userLogin, 27 userLogin,
27 wait,
28 waitJobs 28 waitJobs
29} from '../../../../shared/extra-utils' 29} from '../../../../shared/extra-utils'
30 30
@@ -32,7 +32,6 @@ const expect = chai.expect
32 32
33describe('Test live', function () { 33describe('Test live', function () {
34 let servers: ServerInfo[] = [] 34 let servers: ServerInfo[] = []
35 let liveVideoUUID: string
36 let userId: number 35 let userId: number
37 let userAccessToken: string 36 let userAccessToken: string
38 let userChannelId: number 37 let userChannelId: number
@@ -49,7 +48,10 @@ describe('Test live', function () {
49 await updateCustomSubConfig(servers[0].url, servers[0].accessToken, { 48 await updateCustomSubConfig(servers[0].url, servers[0].accessToken, {
50 live: { 49 live: {
51 enabled: true, 50 enabled: true,
52 allowReplay: true 51 allowReplay: true,
52 transcoding: {
53 enabled: false
54 }
53 } 55 }
54 }) 56 })
55 57
@@ -74,6 +76,7 @@ describe('Test live', function () {
74 }) 76 })
75 77
76 describe('Live creation, update and delete', function () { 78 describe('Live creation, update and delete', function () {
79 let liveVideoUUID: string
77 80
78 it('Should create a live with the appropriate parameters', async function () { 81 it('Should create a live with the appropriate parameters', async function () {
79 this.timeout(20000) 82 this.timeout(20000)
@@ -220,206 +223,74 @@ describe('Test live', function () {
220 }) 223 })
221 }) 224 })
222 225
223 describe('Test live constraints', function () { 226 describe('Stream checks', function () {
227 let liveVideo: LiveVideo & VideoDetails
228 let rtmpUrl: string
229
230 before(function () {
231 rtmpUrl = 'rtmp://' + servers[0].hostname + ':1936'
232 })
224 233
225 async function createLiveWrapper (saveReplay: boolean) { 234 async function createLiveWrapper () {
226 const liveAttributes = { 235 const liveAttributes = {
227 name: 'user live', 236 name: 'user live',
228 channelId: userChannelId, 237 channelId: userChannelId,
229 privacy: VideoPrivacy.PUBLIC, 238 privacy: VideoPrivacy.PUBLIC,
230 saveReplay 239 saveReplay: false
231 } 240 }
232 241
233 const res = await createLive(servers[0].url, userAccessToken, liveAttributes) 242 const res = await createLive(servers[0].url, userAccessToken, liveAttributes)
234 return res.body.video.uuid as string 243 const uuid = res.body.video.uuid
235 }
236
237 before(async function () {
238 await updateCustomSubConfig(servers[0].url, servers[0].accessToken, {
239 live: {
240 enabled: true,
241 allowReplay: true
242 }
243 })
244
245 await updateUser({
246 url: servers[0].url,
247 userId,
248 accessToken: servers[0].accessToken,
249 videoQuota: 1,
250 videoQuotaDaily: -1
251 })
252 })
253 244
254 it('Should not have size limit if save replay is disabled', async function () { 245 const resLive = await getLive(servers[0].url, servers[0].accessToken, uuid)
255 this.timeout(30000) 246 const resVideo = await getVideo(servers[0].url, uuid)
256 247
257 const userVideoLiveoId = await createLiveWrapper(false) 248 return Object.assign(resVideo.body, resLive.body) as LiveVideo & VideoDetails
258 await testFfmpegStreamError(servers[0].url, userAccessToken, userVideoLiveoId, false) 249 }
259 })
260 250
261 it('Should have size limit depending on user global quota if save replay is enabled', async function () { 251 it('Should not allow a stream without the appropriate path', async function () {
262 this.timeout(30000) 252 this.timeout(30000)
263 253
264 const userVideoLiveoId = await createLiveWrapper(true) 254 liveVideo = await createLiveWrapper()
265 await testFfmpegStreamError(servers[0].url, userAccessToken, userVideoLiveoId, true)
266
267 await waitJobs(servers)
268
269 for (const server of servers) {
270 const res = await getVideo(server.url, userVideoLiveoId)
271 255
272 const video: VideoDetails = res.body 256 const command = sendRTMPStream(rtmpUrl + '/bad-live', liveVideo.streamKey)
273 expect(video.isLive).to.be.false 257 await testFfmpegStreamError(command, true)
274 expect(video.duration).to.be.greaterThan(0)
275 }
276
277 // TODO: check stream correctly saved + cleaned
278 }) 258 })
279 259
280 it('Should have size limit depending on user daily quota if save replay is enabled', async function () { 260 it('Should not allow a stream without the appropriate stream key', async function () {
281 this.timeout(30000) 261 this.timeout(30000)
282 262
283 await updateUser({ 263 const command = sendRTMPStream(rtmpUrl + '/live', 'bad-stream-key')
284 url: servers[0].url, 264 await testFfmpegStreamError(command, true)
285 userId,
286 accessToken: servers[0].accessToken,
287 videoQuota: -1,
288 videoQuotaDaily: 1
289 })
290
291 const userVideoLiveoId = await createLiveWrapper(true)
292 await testFfmpegStreamError(servers[0].url, userAccessToken, userVideoLiveoId, true)
293
294 // TODO: check stream correctly saved + cleaned
295 }) 265 })
296 266
297 it('Should succeed without quota limit', async function () { 267 it('Should succeed with the correct params', async function () {
298 this.timeout(30000) 268 this.timeout(30000)
299 269
300 // Wait for user quota memoize cache invalidation 270 const command = sendRTMPStream(rtmpUrl + '/live', liveVideo.streamKey)
301 await wait(5000) 271 await testFfmpegStreamError(command, false)
302
303 await updateUser({
304 url: servers[0].url,
305 userId,
306 accessToken: servers[0].accessToken,
307 videoQuota: 10 * 1000 * 1000,
308 videoQuotaDaily: -1
309 })
310
311 const userVideoLiveoId = await createLiveWrapper(true)
312 await testFfmpegStreamError(servers[0].url, userAccessToken, userVideoLiveoId, false)
313 }) 272 })
314 273
315 it('Should have max duration limit', async function () { 274 it('Should not allow a stream on a live that was blacklisted', async function () {
316 this.timeout(30000) 275 this.timeout(30000)
317 276
318 await updateCustomSubConfig(servers[0].url, servers[0].accessToken, { 277 liveVideo = await createLiveWrapper()
319 live: {
320 enabled: true,
321 allowReplay: true,
322 maxDuration: 1
323 }
324 })
325
326 const userVideoLiveoId = await createLiveWrapper(true)
327 await testFfmpegStreamError(servers[0].url, userAccessToken, userVideoLiveoId, true)
328
329 // TODO: check stream correctly saved + cleaned
330 })
331 })
332
333 describe('With save replay disabled', function () {
334 278
335 it('Should correctly create and federate the "waiting for stream" live', async function () { 279 await addVideoToBlacklist(servers[0].url, servers[0].accessToken, liveVideo.uuid)
336 280
281 const command = sendRTMPStream(rtmpUrl + '/live', liveVideo.streamKey)
282 await testFfmpegStreamError(command, true)
337 }) 283 })
338 284
339 it('Should correctly have updated the live and federated it when streaming in the live', async function () { 285 it('Should not allow a stream on a live that was deleted', async function () {
340 286 this.timeout(30000)
341 })
342
343 it('Should correctly delete the video and the live after the stream ended', async function () {
344 // Wait 10 seconds
345 // get video 404
346 // get video federation 404
347
348 // check cleanup
349 })
350
351 it('Should correctly terminate the stream on blacklist and delete the live', async function () {
352 // Wait 10 seconds
353 // get video 404
354 // get video federation 404
355
356 // check cleanup
357 })
358
359 it('Should correctly terminate the stream on delete and delete the video', async function () {
360 // Wait 10 seconds
361 // get video 404
362 // get video federation 404
363
364 // check cleanup
365 })
366 })
367
368 describe('With save replay enabled', function () {
369
370 it('Should correctly create and federate the "waiting for stream" live', async function () {
371
372 })
373
374 it('Should correctly have updated the live and federated it when streaming in the live', async function () {
375
376 })
377
378 it('Should correctly have saved the live and federated it after the streaming', async function () {
379
380 })
381
382 it('Should update the saved live and correctly federate the updated attributes', async function () {
383
384 })
385
386 it('Should have cleaned up the live files', async function () {
387
388 })
389
390 it('Should correctly terminate the stream on blacklist and blacklist the saved replay video', async function () {
391 // Wait 10 seconds
392 // get video -> blacklisted
393 // get video federation -> blacklisted
394
395 // check cleanup live files quand meme
396 })
397
398 it('Should correctly terminate the stream on delete and delete the video', async function () {
399 // Wait 10 seconds
400 // get video 404
401 // get video federation 404
402
403 // check cleanup
404 })
405 })
406
407 describe('Stream checks', function () {
408
409 it('Should not allow a stream without the appropriate path', async function () {
410
411 })
412
413 it('Should not allow a stream without the appropriate stream key', async function () {
414
415 })
416
417 it('Should not allow a stream on a live that was blacklisted', async function () {
418 287
419 }) 288 liveVideo = await createLiveWrapper()
420 289
421 it('Should not allow a stream on a live that was deleted', async function () { 290 await removeVideo(servers[0].url, servers[0].accessToken, liveVideo.uuid)
422 291
292 const command = sendRTMPStream(rtmpUrl + '/live', liveVideo.streamKey)
293 await testFfmpegStreamError(command, true)
423 }) 294 })
424 }) 295 })
425 296