diff options
author | Chocobozzz <me@florianbigard.com> | 2023-01-27 08:30:56 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2023-01-27 08:30:56 +0100 |
commit | 8059e050ef4e800c95851ac97abbb2330fe17882 (patch) | |
tree | 6cd6cc94cea7d5234e95ddb86aed5be206c4f81c /server/tests/shared | |
parent | 2e5dd0bef8797dad82e5a908c30bc126cb924033 (diff) | |
download | PeerTube-8059e050ef4e800c95851ac97abbb2330fe17882.tar.gz PeerTube-8059e050ef4e800c95851ac97abbb2330fe17882.tar.zst PeerTube-8059e050ef4e800c95851ac97abbb2330fe17882.zip |
Fix live with base url object storage
Diffstat (limited to 'server/tests/shared')
-rw-r--r-- | server/tests/shared/live.ts | 23 | ||||
-rw-r--r-- | server/tests/shared/mock-servers/mock-object-storage.ts | 2 |
2 files changed, 18 insertions, 7 deletions
diff --git a/server/tests/shared/live.ts b/server/tests/shared/live.ts index 1c868eb5b..ff0b2f226 100644 --- a/server/tests/shared/live.ts +++ b/server/tests/shared/live.ts | |||
@@ -3,10 +3,10 @@ | |||
3 | import { expect } from 'chai' | 3 | import { expect } from 'chai' |
4 | import { pathExists, readdir } from 'fs-extra' | 4 | import { pathExists, readdir } from 'fs-extra' |
5 | import { join } from 'path' | 5 | import { join } from 'path' |
6 | import { sha1 } from '@shared/extra-utils' | ||
6 | import { LiveVideo, VideoStreamingPlaylistType } from '@shared/models' | 7 | import { LiveVideo, VideoStreamingPlaylistType } from '@shared/models' |
7 | import { ObjectStorageCommand, PeerTubeServer } from '@shared/server-commands' | 8 | import { ObjectStorageCommand, PeerTubeServer } from '@shared/server-commands' |
8 | import { checkLiveSegmentHash, checkResolutionsInMasterPlaylist } from './streaming-playlists' | 9 | import { checkLiveSegmentHash, checkResolutionsInMasterPlaylist } from './streaming-playlists' |
9 | import { sha1 } from '@shared/extra-utils' | ||
10 | 10 | ||
11 | async function checkLiveCleanup (options: { | 11 | async function checkLiveCleanup (options: { |
12 | server: PeerTubeServer | 12 | server: PeerTubeServer |
@@ -42,9 +42,19 @@ async function testVideoResolutions (options: { | |||
42 | liveVideoId: string | 42 | liveVideoId: string |
43 | resolutions: number[] | 43 | resolutions: number[] |
44 | transcoded: boolean | 44 | transcoded: boolean |
45 | |||
45 | objectStorage: boolean | 46 | objectStorage: boolean |
47 | objectStorageBaseUrl?: string | ||
46 | }) { | 48 | }) { |
47 | const { originServer, servers, liveVideoId, resolutions, transcoded, objectStorage } = options | 49 | const { |
50 | originServer, | ||
51 | servers, | ||
52 | liveVideoId, | ||
53 | resolutions, | ||
54 | transcoded, | ||
55 | objectStorage, | ||
56 | objectStorageBaseUrl = ObjectStorageCommand.getMockPlaylistBaseUrl() | ||
57 | } = options | ||
48 | 58 | ||
49 | for (const server of servers) { | 59 | for (const server of servers) { |
50 | const { data } = await server.videos.list() | 60 | const { data } = await server.videos.list() |
@@ -66,7 +76,7 @@ async function testVideoResolutions (options: { | |||
66 | }) | 76 | }) |
67 | 77 | ||
68 | if (objectStorage) { | 78 | if (objectStorage) { |
69 | expect(hlsPlaylist.playlistUrl).to.contain(ObjectStorageCommand.getMockPlaylistBaseUrl()) | 79 | expect(hlsPlaylist.playlistUrl).to.contain(objectStorageBaseUrl) |
70 | } | 80 | } |
71 | 81 | ||
72 | for (let i = 0; i < resolutions.length; i++) { | 82 | for (let i = 0; i < resolutions.length; i++) { |
@@ -77,15 +87,16 @@ async function testVideoResolutions (options: { | |||
77 | videoUUID: video.uuid, | 87 | videoUUID: video.uuid, |
78 | playlistNumber: i, | 88 | playlistNumber: i, |
79 | segment: segmentNum, | 89 | segment: segmentNum, |
80 | objectStorage | 90 | objectStorage, |
91 | objectStorageBaseUrl | ||
81 | }) | 92 | }) |
82 | 93 | ||
83 | const baseUrl = objectStorage | 94 | const baseUrl = objectStorage |
84 | ? ObjectStorageCommand.getMockPlaylistBaseUrl() + 'hls' | 95 | ? join(objectStorageBaseUrl, 'hls') |
85 | : originServer.url + '/static/streaming-playlists/hls' | 96 | : originServer.url + '/static/streaming-playlists/hls' |
86 | 97 | ||
87 | if (objectStorage) { | 98 | if (objectStorage) { |
88 | expect(hlsPlaylist.segmentsSha256Url).to.contain(ObjectStorageCommand.getMockPlaylistBaseUrl()) | 99 | expect(hlsPlaylist.segmentsSha256Url).to.contain(objectStorageBaseUrl) |
89 | } | 100 | } |
90 | 101 | ||
91 | const subPlaylist = await originServer.streamingPlaylists.get({ | 102 | const subPlaylist = await originServer.streamingPlaylists.get({ |
diff --git a/server/tests/shared/mock-servers/mock-object-storage.ts b/server/tests/shared/mock-servers/mock-object-storage.ts index 8c325bf11..ae76c4f3f 100644 --- a/server/tests/shared/mock-servers/mock-object-storage.ts +++ b/server/tests/shared/mock-servers/mock-object-storage.ts | |||
@@ -5,7 +5,7 @@ import { pipeline } from 'stream' | |||
5 | import { ObjectStorageCommand } from '@shared/server-commands' | 5 | import { ObjectStorageCommand } from '@shared/server-commands' |
6 | import { getPort, randomListen, terminateServer } from './shared' | 6 | import { getPort, randomListen, terminateServer } from './shared' |
7 | 7 | ||
8 | export class MockObjectStorage { | 8 | export class MockObjectStorageProxy { |
9 | private server: Server | 9 | private server: Server |
10 | 10 | ||
11 | async initialize () { | 11 | async initialize () { |