From 8059e050ef4e800c95851ac97abbb2330fe17882 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 27 Jan 2023 08:30:56 +0100 Subject: Fix live with base url object storage --- server/tests/api/object-storage/live.ts | 62 +++++++++++++++++++++++++++++-- server/tests/api/object-storage/videos.ts | 12 +++--- 2 files changed, 66 insertions(+), 8 deletions(-) (limited to 'server/tests/api/object-storage') diff --git a/server/tests/api/object-storage/live.ts b/server/tests/api/object-storage/live.ts index ad2b554b7..2a3fc4779 100644 --- a/server/tests/api/object-storage/live.ts +++ b/server/tests/api/object-storage/live.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { expectStartWith, testVideoResolutions } from '@server/tests/shared' +import { expectStartWith, MockObjectStorageProxy, testVideoResolutions } from '@server/tests/shared' import { areMockObjectStorageTestsDisabled } from '@shared/core-utils' import { HttpStatusCode, LiveVideoCreate, VideoPrivacy } from '@shared/models' import { @@ -93,7 +93,7 @@ describe('Object storage for lives', function () { await servers[0].config.enableTranscoding() }) - describe('Without live transcoding', async function () { + describe('Without live transcoding', function () { let videoUUID: string before(async function () { @@ -134,7 +134,7 @@ describe('Object storage for lives', function () { }) }) - describe('With live transcoding', async function () { + describe('With live transcoding', function () { const resolutions = [ 720, 480, 360, 240, 144 ] before(async function () { @@ -223,6 +223,62 @@ describe('Object storage for lives', function () { }) }) + describe('With object storage base url', function () { + const mockObjectStorageProxy = new MockObjectStorageProxy() + let baseMockUrl: string + + before(async function () { + this.timeout(120000) + + const port = await mockObjectStorageProxy.initialize() + baseMockUrl = `http://127.0.0.1:${port}/streaming-playlists` + + await ObjectStorageCommand.createMockBucket('streaming-playlists') + + const config = { + object_storage: { + enabled: true, + endpoint: 'http://' + ObjectStorageCommand.getMockEndpointHost(), + region: ObjectStorageCommand.getMockRegion(), + + credentials: ObjectStorageCommand.getMockCredentialsConfig(), + + streaming_playlists: { + bucket_name: 'streaming-playlists', + prefix: '', + base_url: baseMockUrl + } + } + } + + await servers[0].kill() + await servers[0].run(config) + + await servers[0].config.enableLive({ transcoding: true, resolutions: 'min' }) + }) + + it('Should publish a live and replace the base url', async function () { + this.timeout(240000) + + const videoUUIDPermanent = await createLive(servers[0], true) + + const ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: videoUUIDPermanent }) + await waitUntilLivePublishedOnAllServers(servers, videoUUIDPermanent) + + await testVideoResolutions({ + originServer: servers[0], + servers, + liveVideoId: videoUUIDPermanent, + resolutions: [ 720 ], + transcoded: true, + objectStorage: true, + objectStorageBaseUrl: baseMockUrl + }) + + await stopFfmpeg(ffmpegCommand) + }) + }) + after(async function () { await killallServers(servers) }) diff --git a/server/tests/api/object-storage/videos.ts b/server/tests/api/object-storage/videos.ts index 1b3c389d7..6862658cc 100644 --- a/server/tests/api/object-storage/videos.ts +++ b/server/tests/api/object-storage/videos.ts @@ -9,7 +9,7 @@ import { expectLogDoesNotContain, expectStartWith, generateHighBitrateVideo, - MockObjectStorage + MockObjectStorageProxy } from '@server/tests/shared' import { areMockObjectStorageTestsDisabled } from '@shared/core-utils' import { HttpStatusCode, VideoDetails } from '@shared/models' @@ -124,7 +124,7 @@ function runTestSuite (options: { useMockBaseUrl?: boolean }) { - const mockObjectStorage = new MockObjectStorage() + const mockObjectStorageProxy = new MockObjectStorageProxy() const { fixture } = options let baseMockUrl: string @@ -138,8 +138,10 @@ function runTestSuite (options: { before(async function () { this.timeout(120000) - const port = await mockObjectStorage.initialize() - baseMockUrl = options.useMockBaseUrl ? `http://127.0.0.1:${port}` : undefined + const port = await mockObjectStorageProxy.initialize() + baseMockUrl = options.useMockBaseUrl + ? `http://127.0.0.1:${port}` + : undefined await ObjectStorageCommand.createMockBucket(options.playlistBucket) await ObjectStorageCommand.createMockBucket(options.webtorrentBucket) @@ -254,7 +256,7 @@ function runTestSuite (options: { }) after(async function () { - await mockObjectStorage.terminate() + await mockObjectStorageProxy.terminate() await cleanupTests(servers) }) -- cgit v1.2.3