diff options
author | Chocobozzz <me@florianbigard.com> | 2022-10-04 10:03:17 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-10-04 10:03:17 +0200 |
commit | cfd57d2ca0bb058087f7dc90fcc3e8442b0288e1 (patch) | |
tree | dc899a1504ecac588e5580553e02571e0f5d7e4b /server/tests/api/live | |
parent | 9c0cdc5047918b959ebd5e075ddad81eb7fb93f0 (diff) | |
download | PeerTube-cfd57d2ca0bb058087f7dc90fcc3e8442b0288e1.tar.gz PeerTube-cfd57d2ca0bb058087f7dc90fcc3e8442b0288e1.tar.zst PeerTube-cfd57d2ca0bb058087f7dc90fcc3e8442b0288e1.zip |
Live supports object storage
* Sync live files (segments, master playlist, resolution playlist,
segment sha file) into object storage
* Automatically delete them when the live ends
* Segment sha file is now a file on disk, and not stored in memory
anymore
Diffstat (limited to 'server/tests/api/live')
-rw-r--r-- | server/tests/api/live/live-fast-restream.ts | 2 | ||||
-rw-r--r-- | server/tests/api/live/live.ts | 87 |
2 files changed, 42 insertions, 47 deletions
diff --git a/server/tests/api/live/live-fast-restream.ts b/server/tests/api/live/live-fast-restream.ts index 502959258..3ea6be9ff 100644 --- a/server/tests/api/live/live-fast-restream.ts +++ b/server/tests/api/live/live-fast-restream.ts | |||
@@ -59,7 +59,7 @@ describe('Fast restream in live', function () { | |||
59 | const video = await server.videos.get({ id: liveId }) | 59 | const video = await server.videos.get({ id: liveId }) |
60 | expect(video.streamingPlaylists).to.have.lengthOf(1) | 60 | expect(video.streamingPlaylists).to.have.lengthOf(1) |
61 | 61 | ||
62 | await server.live.getSegment({ videoUUID: liveId, segment: 0, playlistNumber: 0 }) | 62 | await server.live.getSegmentFile({ videoUUID: liveId, segment: 0, playlistNumber: 0 }) |
63 | await makeRawRequest(video.streamingPlaylists[0].playlistUrl, HttpStatusCode.OK_200) | 63 | await makeRawRequest(video.streamingPlaylists[0].playlistUrl, HttpStatusCode.OK_200) |
64 | await makeRawRequest(video.streamingPlaylists[0].segmentsSha256Url, HttpStatusCode.OK_200) | 64 | await makeRawRequest(video.streamingPlaylists[0].segmentsSha256Url, HttpStatusCode.OK_200) |
65 | 65 | ||
diff --git a/server/tests/api/live/live.ts b/server/tests/api/live/live.ts index 4e070832d..5dd2bd9ab 100644 --- a/server/tests/api/live/live.ts +++ b/server/tests/api/live/live.ts | |||
@@ -3,7 +3,7 @@ | |||
3 | import { expect } from 'chai' | 3 | import { expect } from 'chai' |
4 | import { basename, join } from 'path' | 4 | import { basename, join } from 'path' |
5 | import { ffprobePromise, getVideoStream } from '@server/helpers/ffmpeg' | 5 | import { ffprobePromise, getVideoStream } from '@server/helpers/ffmpeg' |
6 | import { checkLiveSegmentHash, checkResolutionsInMasterPlaylist, testImage } from '@server/tests/shared' | 6 | import { testImage, testVideoResolutions } from '@server/tests/shared' |
7 | import { getAllFiles, wait } from '@shared/core-utils' | 7 | import { getAllFiles, wait } from '@shared/core-utils' |
8 | import { | 8 | import { |
9 | HttpStatusCode, | 9 | HttpStatusCode, |
@@ -372,46 +372,6 @@ describe('Test live', function () { | |||
372 | return uuid | 372 | return uuid |
373 | } | 373 | } |
374 | 374 | ||
375 | async function testVideoResolutions (liveVideoId: string, resolutions: number[]) { | ||
376 | for (const server of servers) { | ||
377 | const { data } = await server.videos.list() | ||
378 | expect(data.find(v => v.uuid === liveVideoId)).to.exist | ||
379 | |||
380 | const video = await server.videos.get({ id: liveVideoId }) | ||
381 | |||
382 | expect(video.streamingPlaylists).to.have.lengthOf(1) | ||
383 | |||
384 | const hlsPlaylist = video.streamingPlaylists.find(s => s.type === VideoStreamingPlaylistType.HLS) | ||
385 | expect(hlsPlaylist).to.exist | ||
386 | |||
387 | // Only finite files are displayed | ||
388 | expect(hlsPlaylist.files).to.have.lengthOf(0) | ||
389 | |||
390 | await checkResolutionsInMasterPlaylist({ server, playlistUrl: hlsPlaylist.playlistUrl, resolutions }) | ||
391 | |||
392 | for (let i = 0; i < resolutions.length; i++) { | ||
393 | const segmentNum = 3 | ||
394 | const segmentName = `${i}-00000${segmentNum}.ts` | ||
395 | await commands[0].waitUntilSegmentGeneration({ videoUUID: video.uuid, playlistNumber: i, segment: segmentNum }) | ||
396 | |||
397 | const subPlaylist = await servers[0].streamingPlaylists.get({ | ||
398 | url: `${servers[0].url}/static/streaming-playlists/hls/${video.uuid}/${i}.m3u8` | ||
399 | }) | ||
400 | |||
401 | expect(subPlaylist).to.contain(segmentName) | ||
402 | |||
403 | const baseUrlAndPath = servers[0].url + '/static/streaming-playlists/hls' | ||
404 | await checkLiveSegmentHash({ | ||
405 | server, | ||
406 | baseUrlSegment: baseUrlAndPath, | ||
407 | videoUUID: video.uuid, | ||
408 | segmentName, | ||
409 | hlsPlaylist | ||
410 | }) | ||
411 | } | ||
412 | } | ||
413 | } | ||
414 | |||
415 | function updateConf (resolutions: number[]) { | 375 | function updateConf (resolutions: number[]) { |
416 | return servers[0].config.updateCustomSubConfig({ | 376 | return servers[0].config.updateCustomSubConfig({ |
417 | newConfig: { | 377 | newConfig: { |
@@ -449,7 +409,14 @@ describe('Test live', function () { | |||
449 | await waitUntilLivePublishedOnAllServers(servers, liveVideoId) | 409 | await waitUntilLivePublishedOnAllServers(servers, liveVideoId) |
450 | await waitJobs(servers) | 410 | await waitJobs(servers) |
451 | 411 | ||
452 | await testVideoResolutions(liveVideoId, [ 720 ]) | 412 | await testVideoResolutions({ |
413 | originServer: servers[0], | ||
414 | servers, | ||
415 | liveVideoId, | ||
416 | resolutions: [ 720 ], | ||
417 | objectStorage: false, | ||
418 | transcoded: true | ||
419 | }) | ||
453 | 420 | ||
454 | await stopFfmpeg(ffmpegCommand) | 421 | await stopFfmpeg(ffmpegCommand) |
455 | }) | 422 | }) |
@@ -477,7 +444,14 @@ describe('Test live', function () { | |||
477 | await waitUntilLivePublishedOnAllServers(servers, liveVideoId) | 444 | await waitUntilLivePublishedOnAllServers(servers, liveVideoId) |
478 | await waitJobs(servers) | 445 | await waitJobs(servers) |
479 | 446 | ||
480 | await testVideoResolutions(liveVideoId, resolutions.concat([ 720 ])) | 447 | await testVideoResolutions({ |
448 | originServer: servers[0], | ||
449 | servers, | ||
450 | liveVideoId, | ||
451 | resolutions: resolutions.concat([ 720 ]), | ||
452 | objectStorage: false, | ||
453 | transcoded: true | ||
454 | }) | ||
481 | 455 | ||
482 | await stopFfmpeg(ffmpegCommand) | 456 | await stopFfmpeg(ffmpegCommand) |
483 | }) | 457 | }) |
@@ -522,7 +496,14 @@ describe('Test live', function () { | |||
522 | await waitUntilLivePublishedOnAllServers(servers, liveVideoId) | 496 | await waitUntilLivePublishedOnAllServers(servers, liveVideoId) |
523 | await waitJobs(servers) | 497 | await waitJobs(servers) |
524 | 498 | ||
525 | await testVideoResolutions(liveVideoId, resolutions) | 499 | await testVideoResolutions({ |
500 | originServer: servers[0], | ||
501 | servers, | ||
502 | liveVideoId, | ||
503 | resolutions, | ||
504 | objectStorage: false, | ||
505 | transcoded: true | ||
506 | }) | ||
526 | 507 | ||
527 | await stopFfmpeg(ffmpegCommand) | 508 | await stopFfmpeg(ffmpegCommand) |
528 | await commands[0].waitUntilEnded({ videoId: liveVideoId }) | 509 | await commands[0].waitUntilEnded({ videoId: liveVideoId }) |
@@ -611,7 +592,14 @@ describe('Test live', function () { | |||
611 | await waitUntilLivePublishedOnAllServers(servers, liveVideoId) | 592 | await waitUntilLivePublishedOnAllServers(servers, liveVideoId) |
612 | await waitJobs(servers) | 593 | await waitJobs(servers) |
613 | 594 | ||
614 | await testVideoResolutions(liveVideoId, resolutions) | 595 | await testVideoResolutions({ |
596 | originServer: servers[0], | ||
597 | servers, | ||
598 | liveVideoId, | ||
599 | resolutions, | ||
600 | objectStorage: false, | ||
601 | transcoded: true | ||
602 | }) | ||
615 | 603 | ||
616 | await stopFfmpeg(ffmpegCommand) | 604 | await stopFfmpeg(ffmpegCommand) |
617 | await commands[0].waitUntilEnded({ videoId: liveVideoId }) | 605 | await commands[0].waitUntilEnded({ videoId: liveVideoId }) |
@@ -640,7 +628,14 @@ describe('Test live', function () { | |||
640 | await waitUntilLivePublishedOnAllServers(servers, liveVideoId) | 628 | await waitUntilLivePublishedOnAllServers(servers, liveVideoId) |
641 | await waitJobs(servers) | 629 | await waitJobs(servers) |
642 | 630 | ||
643 | await testVideoResolutions(liveVideoId, [ 720 ]) | 631 | await testVideoResolutions({ |
632 | originServer: servers[0], | ||
633 | servers, | ||
634 | liveVideoId, | ||
635 | resolutions: [ 720 ], | ||
636 | objectStorage: false, | ||
637 | transcoded: true | ||
638 | }) | ||
644 | 639 | ||
645 | await stopFfmpeg(ffmpegCommand) | 640 | await stopFfmpeg(ffmpegCommand) |
646 | await commands[0].waitUntilEnded({ videoId: liveVideoId }) | 641 | await commands[0].waitUntilEnded({ videoId: liveVideoId }) |