aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/api/object-storage/live.ts62
-rw-r--r--server/tests/api/object-storage/videos.ts12
-rw-r--r--server/tests/shared/live.ts23
-rw-r--r--server/tests/shared/mock-servers/mock-object-storage.ts2
4 files changed, 84 insertions, 15 deletions
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 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import { expect } from 'chai' 3import { expect } from 'chai'
4import { expectStartWith, testVideoResolutions } from '@server/tests/shared' 4import { expectStartWith, MockObjectStorageProxy, testVideoResolutions } from '@server/tests/shared'
5import { areMockObjectStorageTestsDisabled } from '@shared/core-utils' 5import { areMockObjectStorageTestsDisabled } from '@shared/core-utils'
6import { HttpStatusCode, LiveVideoCreate, VideoPrivacy } from '@shared/models' 6import { HttpStatusCode, LiveVideoCreate, VideoPrivacy } from '@shared/models'
7import { 7import {
@@ -93,7 +93,7 @@ describe('Object storage for lives', function () {
93 await servers[0].config.enableTranscoding() 93 await servers[0].config.enableTranscoding()
94 }) 94 })
95 95
96 describe('Without live transcoding', async function () { 96 describe('Without live transcoding', function () {
97 let videoUUID: string 97 let videoUUID: string
98 98
99 before(async function () { 99 before(async function () {
@@ -134,7 +134,7 @@ describe('Object storage for lives', function () {
134 }) 134 })
135 }) 135 })
136 136
137 describe('With live transcoding', async function () { 137 describe('With live transcoding', function () {
138 const resolutions = [ 720, 480, 360, 240, 144 ] 138 const resolutions = [ 720, 480, 360, 240, 144 ]
139 139
140 before(async function () { 140 before(async function () {
@@ -223,6 +223,62 @@ describe('Object storage for lives', function () {
223 }) 223 })
224 }) 224 })
225 225
226 describe('With object storage base url', function () {
227 const mockObjectStorageProxy = new MockObjectStorageProxy()
228 let baseMockUrl: string
229
230 before(async function () {
231 this.timeout(120000)
232
233 const port = await mockObjectStorageProxy.initialize()
234 baseMockUrl = `http://127.0.0.1:${port}/streaming-playlists`
235
236 await ObjectStorageCommand.createMockBucket('streaming-playlists')
237
238 const config = {
239 object_storage: {
240 enabled: true,
241 endpoint: 'http://' + ObjectStorageCommand.getMockEndpointHost(),
242 region: ObjectStorageCommand.getMockRegion(),
243
244 credentials: ObjectStorageCommand.getMockCredentialsConfig(),
245
246 streaming_playlists: {
247 bucket_name: 'streaming-playlists',
248 prefix: '',
249 base_url: baseMockUrl
250 }
251 }
252 }
253
254 await servers[0].kill()
255 await servers[0].run(config)
256
257 await servers[0].config.enableLive({ transcoding: true, resolutions: 'min' })
258 })
259
260 it('Should publish a live and replace the base url', async function () {
261 this.timeout(240000)
262
263 const videoUUIDPermanent = await createLive(servers[0], true)
264
265 const ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: videoUUIDPermanent })
266 await waitUntilLivePublishedOnAllServers(servers, videoUUIDPermanent)
267
268 await testVideoResolutions({
269 originServer: servers[0],
270 servers,
271 liveVideoId: videoUUIDPermanent,
272 resolutions: [ 720 ],
273 transcoded: true,
274 objectStorage: true,
275 objectStorageBaseUrl: baseMockUrl
276 })
277
278 await stopFfmpeg(ffmpegCommand)
279 })
280 })
281
226 after(async function () { 282 after(async function () {
227 await killallServers(servers) 283 await killallServers(servers)
228 }) 284 })
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 {
9 expectLogDoesNotContain, 9 expectLogDoesNotContain,
10 expectStartWith, 10 expectStartWith,
11 generateHighBitrateVideo, 11 generateHighBitrateVideo,
12 MockObjectStorage 12 MockObjectStorageProxy
13} from '@server/tests/shared' 13} from '@server/tests/shared'
14import { areMockObjectStorageTestsDisabled } from '@shared/core-utils' 14import { areMockObjectStorageTestsDisabled } from '@shared/core-utils'
15import { HttpStatusCode, VideoDetails } from '@shared/models' 15import { HttpStatusCode, VideoDetails } from '@shared/models'
@@ -124,7 +124,7 @@ function runTestSuite (options: {
124 124
125 useMockBaseUrl?: boolean 125 useMockBaseUrl?: boolean
126}) { 126}) {
127 const mockObjectStorage = new MockObjectStorage() 127 const mockObjectStorageProxy = new MockObjectStorageProxy()
128 const { fixture } = options 128 const { fixture } = options
129 let baseMockUrl: string 129 let baseMockUrl: string
130 130
@@ -138,8 +138,10 @@ function runTestSuite (options: {
138 before(async function () { 138 before(async function () {
139 this.timeout(120000) 139 this.timeout(120000)
140 140
141 const port = await mockObjectStorage.initialize() 141 const port = await mockObjectStorageProxy.initialize()
142 baseMockUrl = options.useMockBaseUrl ? `http://127.0.0.1:${port}` : undefined 142 baseMockUrl = options.useMockBaseUrl
143 ? `http://127.0.0.1:${port}`
144 : undefined
143 145
144 await ObjectStorageCommand.createMockBucket(options.playlistBucket) 146 await ObjectStorageCommand.createMockBucket(options.playlistBucket)
145 await ObjectStorageCommand.createMockBucket(options.webtorrentBucket) 147 await ObjectStorageCommand.createMockBucket(options.webtorrentBucket)
@@ -254,7 +256,7 @@ function runTestSuite (options: {
254 }) 256 })
255 257
256 after(async function () { 258 after(async function () {
257 await mockObjectStorage.terminate() 259 await mockObjectStorageProxy.terminate()
258 260
259 await cleanupTests(servers) 261 await cleanupTests(servers)
260 }) 262 })
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 @@
3import { expect } from 'chai' 3import { expect } from 'chai'
4import { pathExists, readdir } from 'fs-extra' 4import { pathExists, readdir } from 'fs-extra'
5import { join } from 'path' 5import { join } from 'path'
6import { sha1 } from '@shared/extra-utils'
6import { LiveVideo, VideoStreamingPlaylistType } from '@shared/models' 7import { LiveVideo, VideoStreamingPlaylistType } from '@shared/models'
7import { ObjectStorageCommand, PeerTubeServer } from '@shared/server-commands' 8import { ObjectStorageCommand, PeerTubeServer } from '@shared/server-commands'
8import { checkLiveSegmentHash, checkResolutionsInMasterPlaylist } from './streaming-playlists' 9import { checkLiveSegmentHash, checkResolutionsInMasterPlaylist } from './streaming-playlists'
9import { sha1 } from '@shared/extra-utils'
10 10
11async function checkLiveCleanup (options: { 11async 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'
5import { ObjectStorageCommand } from '@shared/server-commands' 5import { ObjectStorageCommand } from '@shared/server-commands'
6import { getPort, randomListen, terminateServer } from './shared' 6import { getPort, randomListen, terminateServer } from './shared'
7 7
8export class MockObjectStorage { 8export class MockObjectStorageProxy {
9 private server: Server 9 private server: Server
10 10
11 async initialize () { 11 async initialize () {