aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2023-05-23 10:49:45 +0200
committerChocobozzz <me@florianbigard.com>2023-05-23 10:49:45 +0200
commitf89189907bbdff6c4bc6d3460ed9ef4c49515f17 (patch)
treec55e50e3fc02ae9b3f2d1d19d95160af98cc7d7c
parent41cde76bbf5ac16a90b5f158672523069db74009 (diff)
downloadPeerTube-f89189907bbdff6c4bc6d3460ed9ef4c49515f17.tar.gz
PeerTube-f89189907bbdff6c4bc6d3460ed9ef4c49515f17.tar.zst
PeerTube-f89189907bbdff6c4bc6d3460ed9ef4c49515f17.zip
Prevent object storage mock conflicts
When running tests in parallel
-rw-r--r--server/tests/api/live/live-fast-restream.ts3
-rw-r--r--server/tests/api/live/live.ts8
-rw-r--r--server/tests/api/object-storage/live.ts58
-rw-r--r--server/tests/api/object-storage/video-imports.ts13
-rw-r--r--server/tests/api/object-storage/videos.ts50
-rw-r--r--server/tests/api/server/follows.ts2
-rw-r--r--server/tests/api/server/proxy.ts16
-rw-r--r--server/tests/api/transcoding/create-transcoding.ts35
-rw-r--r--server/tests/api/transcoding/hls.ts12
-rw-r--r--server/tests/api/transcoding/update-while-transcoding.ts12
-rw-r--r--server/tests/api/transcoding/video-studio.ts14
-rw-r--r--server/tests/cli/create-import-video-file-job.ts22
-rw-r--r--server/tests/cli/create-move-video-storage-job.ts25
-rw-r--r--server/tests/peertube-runner/live-transcoding.ts20
-rw-r--r--server/tests/peertube-runner/studio-transcoding.ts22
-rw-r--r--server/tests/peertube-runner/vod-transcoding.ts28
-rw-r--r--server/tests/shared/live.ts10
-rw-r--r--shared/server-commands/server/object-storage-command.ts103
-rw-r--r--shared/server-commands/server/server.ts3
-rw-r--r--shared/server-commands/videos/live-command.ts20
20 files changed, 276 insertions, 200 deletions
diff --git a/server/tests/api/live/live-fast-restream.ts b/server/tests/api/live/live-fast-restream.ts
index 2169393c2..d7085a957 100644
--- a/server/tests/api/live/live-fast-restream.ts
+++ b/server/tests/api/live/live-fast-restream.ts
@@ -65,8 +65,7 @@ describe('Fast restream in live', function () {
65 server, 65 server,
66 videoUUID: liveVideoUUID, 66 videoUUID: liveVideoUUID,
67 segment: 1, 67 segment: 1,
68 playlistNumber: 0, 68 playlistNumber: 0
69 objectStorage: false
70 }) 69 })
71 70
72 return { ffmpegCommand, liveVideoUUID } 71 return { ffmpegCommand, liveVideoUUID }
diff --git a/server/tests/api/live/live.ts b/server/tests/api/live/live.ts
index 65ebbc5f7..7ab67b126 100644
--- a/server/tests/api/live/live.ts
+++ b/server/tests/api/live/live.ts
@@ -423,7 +423,6 @@ describe('Test live', function () {
423 servers, 423 servers,
424 liveVideoId, 424 liveVideoId,
425 resolutions: [ 720 ], 425 resolutions: [ 720 ],
426 objectStorage: false,
427 transcoded: true 426 transcoded: true
428 }) 427 })
429 428
@@ -459,7 +458,6 @@ describe('Test live', function () {
459 servers, 458 servers,
460 liveVideoId, 459 liveVideoId,
461 resolutions: resolutions.concat([ 720 ]), 460 resolutions: resolutions.concat([ 720 ]),
462 objectStorage: false,
463 transcoded: true 461 transcoded: true
464 }) 462 })
465 463
@@ -512,7 +510,6 @@ describe('Test live', function () {
512 servers, 510 servers,
513 liveVideoId, 511 liveVideoId,
514 resolutions, 512 resolutions,
515 objectStorage: false,
516 transcoded: true 513 transcoded: true
517 }) 514 })
518 515
@@ -609,7 +606,6 @@ describe('Test live', function () {
609 servers, 606 servers,
610 liveVideoId, 607 liveVideoId,
611 resolutions, 608 resolutions,
612 objectStorage: false,
613 transcoded: true 609 transcoded: true
614 }) 610 })
615 611
@@ -646,7 +642,6 @@ describe('Test live', function () {
646 servers, 642 servers,
647 liveVideoId, 643 liveVideoId,
648 resolutions: [ 720 ], 644 resolutions: [ 720 ],
649 objectStorage: false,
650 transcoded: true 645 transcoded: true
651 }) 646 })
652 647
@@ -720,8 +715,7 @@ describe('Test live', function () {
720 server: servers[0], 715 server: servers[0],
721 videoUUID, 716 videoUUID,
722 playlistNumber: 0, 717 playlistNumber: 0,
723 segment: 2, 718 segment: 2
724 objectStorage: false
725 }) 719 })
726 } 720 }
727 721
diff --git a/server/tests/api/object-storage/live.ts b/server/tests/api/object-storage/live.ts
index 7f8db40e5..07ff4763b 100644
--- a/server/tests/api/object-storage/live.ts
+++ b/server/tests/api/object-storage/live.ts
@@ -36,7 +36,14 @@ async function createLive (server: PeerTubeServer, permanent: boolean) {
36 return uuid 36 return uuid
37} 37}
38 38
39async function checkFilesExist (servers: PeerTubeServer[], videoUUID: string, numberOfFiles: number) { 39async function checkFilesExist (options: {
40 servers: PeerTubeServer[]
41 videoUUID: string
42 numberOfFiles: number
43 objectStorage: ObjectStorageCommand
44}) {
45 const { servers, videoUUID, numberOfFiles, objectStorage } = options
46
40 for (const server of servers) { 47 for (const server of servers) {
41 const video = await server.videos.get({ id: videoUUID }) 48 const video = await server.videos.get({ id: videoUUID })
42 49
@@ -47,14 +54,21 @@ async function checkFilesExist (servers: PeerTubeServer[], videoUUID: string, nu
47 expect(files).to.have.lengthOf(numberOfFiles) 54 expect(files).to.have.lengthOf(numberOfFiles)
48 55
49 for (const file of files) { 56 for (const file of files) {
50 expectStartWith(file.fileUrl, ObjectStorageCommand.getMockPlaylistBaseUrl()) 57 expectStartWith(file.fileUrl, objectStorage.getMockPlaylistBaseUrl())
51 58
52 await makeRawRequest({ url: file.fileUrl, expectedStatus: HttpStatusCode.OK_200 }) 59 await makeRawRequest({ url: file.fileUrl, expectedStatus: HttpStatusCode.OK_200 })
53 } 60 }
54 } 61 }
55} 62}
56 63
57async function checkFilesCleanup (server: PeerTubeServer, videoUUID: string, resolutions: number[]) { 64async function checkFilesCleanup (options: {
65 server: PeerTubeServer
66 videoUUID: string
67 resolutions: number[]
68 objectStorage: ObjectStorageCommand
69}) {
70 const { server, videoUUID, resolutions, objectStorage } = options
71
58 const resolutionFiles = resolutions.map((_value, i) => `${i}.m3u8`) 72 const resolutionFiles = resolutions.map((_value, i) => `${i}.m3u8`)
59 73
60 for (const playlistName of [ 'master.m3u8' ].concat(resolutionFiles)) { 74 for (const playlistName of [ 'master.m3u8' ].concat(resolutionFiles)) {
@@ -62,7 +76,7 @@ async function checkFilesCleanup (server: PeerTubeServer, videoUUID: string, res
62 videoUUID, 76 videoUUID,
63 playlistName, 77 playlistName,
64 expectedStatus: HttpStatusCode.NOT_FOUND_404, 78 expectedStatus: HttpStatusCode.NOT_FOUND_404,
65 objectStorage: true 79 objectStorage
66 }) 80 })
67 } 81 }
68 82
@@ -70,7 +84,7 @@ async function checkFilesCleanup (server: PeerTubeServer, videoUUID: string, res
70 videoUUID, 84 videoUUID,
71 playlistNumber: 0, 85 playlistNumber: 0,
72 segment: 0, 86 segment: 0,
73 objectStorage: true, 87 objectStorage,
74 expectedStatus: HttpStatusCode.NOT_FOUND_404 88 expectedStatus: HttpStatusCode.NOT_FOUND_404
75 }) 89 })
76} 90}
@@ -80,13 +94,13 @@ describe('Object storage for lives', function () {
80 94
81 let servers: PeerTubeServer[] 95 let servers: PeerTubeServer[]
82 let sqlCommandServer1: SQLCommand 96 let sqlCommandServer1: SQLCommand
97 const objectStorage = new ObjectStorageCommand()
83 98
84 before(async function () { 99 before(async function () {
85 this.timeout(120000) 100 this.timeout(120000)
86 101
87 await ObjectStorageCommand.prepareDefaultMockBuckets() 102 await objectStorage.prepareDefaultMockBuckets()
88 103 servers = await createMultipleServers(2, objectStorage.getDefaultMockConfig())
89 servers = await createMultipleServers(2, ObjectStorageCommand.getDefaultMockConfig())
90 104
91 await setAccessTokensToServers(servers) 105 await setAccessTokensToServers(servers)
92 await setDefaultVideoChannel(servers) 106 await setDefaultVideoChannel(servers)
@@ -119,7 +133,7 @@ describe('Object storage for lives', function () {
119 liveVideoId: videoUUID, 133 liveVideoId: videoUUID,
120 resolutions: [ 720 ], 134 resolutions: [ 720 ],
121 transcoded: false, 135 transcoded: false,
122 objectStorage: true 136 objectStorage
123 }) 137 })
124 138
125 await stopFfmpeg(ffmpegCommand) 139 await stopFfmpeg(ffmpegCommand)
@@ -131,11 +145,11 @@ describe('Object storage for lives', function () {
131 await waitUntilLiveReplacedByReplayOnAllServers(servers, videoUUID) 145 await waitUntilLiveReplacedByReplayOnAllServers(servers, videoUUID)
132 await waitJobs(servers) 146 await waitJobs(servers)
133 147
134 await checkFilesExist(servers, videoUUID, 1) 148 await checkFilesExist({ servers, videoUUID, numberOfFiles: 1, objectStorage })
135 }) 149 })
136 150
137 it('Should have cleaned up live files from object storage', async function () { 151 it('Should have cleaned up live files from object storage', async function () {
138 await checkFilesCleanup(servers[0], videoUUID, [ 720 ]) 152 await checkFilesCleanup({ server: servers[0], videoUUID, resolutions: [ 720 ], objectStorage })
139 }) 153 })
140 }) 154 })
141 155
@@ -166,7 +180,7 @@ describe('Object storage for lives', function () {
166 liveVideoId: videoUUIDNonPermanent, 180 liveVideoId: videoUUIDNonPermanent,
167 resolutions, 181 resolutions,
168 transcoded: true, 182 transcoded: true,
169 objectStorage: true 183 objectStorage
170 }) 184 })
171 185
172 await stopFfmpeg(ffmpegCommand) 186 await stopFfmpeg(ffmpegCommand)
@@ -178,11 +192,11 @@ describe('Object storage for lives', function () {
178 await waitUntilLiveReplacedByReplayOnAllServers(servers, videoUUIDNonPermanent) 192 await waitUntilLiveReplacedByReplayOnAllServers(servers, videoUUIDNonPermanent)
179 await waitJobs(servers) 193 await waitJobs(servers)
180 194
181 await checkFilesExist(servers, videoUUIDNonPermanent, 5) 195 await checkFilesExist({ servers, videoUUID: videoUUIDNonPermanent, numberOfFiles: 5, objectStorage })
182 }) 196 })
183 197
184 it('Should have cleaned up live files from object storage', async function () { 198 it('Should have cleaned up live files from object storage', async function () {
185 await checkFilesCleanup(servers[0], videoUUIDNonPermanent, resolutions) 199 await checkFilesCleanup({ server: servers[0], videoUUID: videoUUIDNonPermanent, resolutions, objectStorage })
186 }) 200 })
187 }) 201 })
188 202
@@ -206,7 +220,7 @@ describe('Object storage for lives', function () {
206 liveVideoId: videoUUIDPermanent, 220 liveVideoId: videoUUIDPermanent,
207 resolutions, 221 resolutions,
208 transcoded: true, 222 transcoded: true,
209 objectStorage: true 223 objectStorage
210 }) 224 })
211 225
212 await stopFfmpeg(ffmpegCommand) 226 await stopFfmpeg(ffmpegCommand)
@@ -221,11 +235,11 @@ describe('Object storage for lives', function () {
221 const videoLiveDetails = await servers[0].videos.get({ id: videoUUIDPermanent }) 235 const videoLiveDetails = await servers[0].videos.get({ id: videoUUIDPermanent })
222 const replay = await findExternalSavedVideo(servers[0], videoLiveDetails) 236 const replay = await findExternalSavedVideo(servers[0], videoLiveDetails)
223 237
224 await checkFilesExist(servers, replay.uuid, 5) 238 await checkFilesExist({ servers, videoUUID: replay.uuid, numberOfFiles: 5, objectStorage })
225 }) 239 })
226 240
227 it('Should have cleaned up live files from object storage', async function () { 241 it('Should have cleaned up live files from object storage', async function () {
228 await checkFilesCleanup(servers[0], videoUUIDPermanent, resolutions) 242 await checkFilesCleanup({ server: servers[0], videoUUID: videoUUIDPermanent, resolutions, objectStorage })
229 }) 243 })
230 }) 244 })
231 }) 245 })
@@ -238,9 +252,10 @@ describe('Object storage for lives', function () {
238 this.timeout(120000) 252 this.timeout(120000)
239 253
240 const port = await mockObjectStorageProxy.initialize() 254 const port = await mockObjectStorageProxy.initialize()
241 baseMockUrl = `http://127.0.0.1:${port}/streaming-playlists` 255 const bucketName = objectStorage.getMockStreamingPlaylistsBucketName()
256 baseMockUrl = `http://127.0.0.1:${port}/${bucketName}`
242 257
243 await ObjectStorageCommand.createMockBucket('streaming-playlists') 258 await objectStorage.prepareDefaultMockBuckets()
244 259
245 const config = { 260 const config = {
246 object_storage: { 261 object_storage: {
@@ -251,7 +266,7 @@ describe('Object storage for lives', function () {
251 credentials: ObjectStorageCommand.getMockCredentialsConfig(), 266 credentials: ObjectStorageCommand.getMockCredentialsConfig(),
252 267
253 streaming_playlists: { 268 streaming_playlists: {
254 bucket_name: 'streaming-playlists', 269 bucket_name: bucketName,
255 prefix: '', 270 prefix: '',
256 base_url: baseMockUrl 271 base_url: baseMockUrl
257 } 272 }
@@ -279,7 +294,7 @@ describe('Object storage for lives', function () {
279 liveVideoId: videoUUIDPermanent, 294 liveVideoId: videoUUIDPermanent,
280 resolutions: [ 720 ], 295 resolutions: [ 720 ],
281 transcoded: true, 296 transcoded: true,
282 objectStorage: true, 297 objectStorage,
283 objectStorageBaseUrl: baseMockUrl 298 objectStorageBaseUrl: baseMockUrl
284 }) 299 })
285 300
@@ -289,6 +304,7 @@ describe('Object storage for lives', function () {
289 304
290 after(async function () { 305 after(async function () {
291 await sqlCommandServer1.cleanup() 306 await sqlCommandServer1.cleanup()
307 await objectStorage.cleanupMock()
292 308
293 await cleanupTests(servers) 309 await cleanupTests(servers)
294 }) 310 })
diff --git a/server/tests/api/object-storage/video-imports.ts b/server/tests/api/object-storage/video-imports.ts
index d5fd91b6a..57150e5a6 100644
--- a/server/tests/api/object-storage/video-imports.ts
+++ b/server/tests/api/object-storage/video-imports.ts
@@ -32,13 +32,14 @@ describe('Object storage for video import', function () {
32 if (areMockObjectStorageTestsDisabled()) return 32 if (areMockObjectStorageTestsDisabled()) return
33 33
34 let server: PeerTubeServer 34 let server: PeerTubeServer
35 const objectStorage = new ObjectStorageCommand()
35 36
36 before(async function () { 37 before(async function () {
37 this.timeout(120000) 38 this.timeout(120000)
38 39
39 await ObjectStorageCommand.prepareDefaultMockBuckets() 40 await objectStorage.prepareDefaultMockBuckets()
40 41
41 server = await createSingleServer(1, ObjectStorageCommand.getDefaultMockConfig()) 42 server = await createSingleServer(1, objectStorage.getDefaultMockConfig())
42 43
43 await setAccessTokensToServers([ server ]) 44 await setAccessTokensToServers([ server ])
44 await setDefaultVideoChannel([ server ]) 45 await setDefaultVideoChannel([ server ])
@@ -64,7 +65,7 @@ describe('Object storage for video import', function () {
64 expect(video.streamingPlaylists).to.have.lengthOf(0) 65 expect(video.streamingPlaylists).to.have.lengthOf(0)
65 66
66 const fileUrl = video.files[0].fileUrl 67 const fileUrl = video.files[0].fileUrl
67 expectStartWith(fileUrl, ObjectStorageCommand.getMockWebTorrentBaseUrl()) 68 expectStartWith(fileUrl, objectStorage.getMockWebVideosBaseUrl())
68 69
69 await makeRawRequest({ url: fileUrl, expectedStatus: HttpStatusCode.OK_200 }) 70 await makeRawRequest({ url: fileUrl, expectedStatus: HttpStatusCode.OK_200 })
70 }) 71 })
@@ -89,13 +90,13 @@ describe('Object storage for video import', function () {
89 expect(video.streamingPlaylists[0].files).to.have.lengthOf(5) 90 expect(video.streamingPlaylists[0].files).to.have.lengthOf(5)
90 91
91 for (const file of video.files) { 92 for (const file of video.files) {
92 expectStartWith(file.fileUrl, ObjectStorageCommand.getMockWebTorrentBaseUrl()) 93 expectStartWith(file.fileUrl, objectStorage.getMockWebVideosBaseUrl())
93 94
94 await makeRawRequest({ url: file.fileUrl, expectedStatus: HttpStatusCode.OK_200 }) 95 await makeRawRequest({ url: file.fileUrl, expectedStatus: HttpStatusCode.OK_200 })
95 } 96 }
96 97
97 for (const file of video.streamingPlaylists[0].files) { 98 for (const file of video.streamingPlaylists[0].files) {
98 expectStartWith(file.fileUrl, ObjectStorageCommand.getMockPlaylistBaseUrl()) 99 expectStartWith(file.fileUrl, objectStorage.getMockPlaylistBaseUrl())
99 100
100 await makeRawRequest({ url: file.fileUrl, expectedStatus: HttpStatusCode.OK_200 }) 101 await makeRawRequest({ url: file.fileUrl, expectedStatus: HttpStatusCode.OK_200 })
101 } 102 }
@@ -103,6 +104,8 @@ describe('Object storage for video import', function () {
103 }) 104 })
104 105
105 after(async function () { 106 after(async function () {
107 await objectStorage.cleanupMock()
108
106 await cleanupTests([ server ]) 109 await cleanupTests([ server ])
107 }) 110 })
108}) 111})
diff --git a/server/tests/api/object-storage/videos.ts b/server/tests/api/object-storage/videos.ts
index 77ed78ae1..f837d9966 100644
--- a/server/tests/api/object-storage/videos.ts
+++ b/server/tests/api/object-storage/videos.ts
@@ -145,6 +145,7 @@ function runTestSuite (options: {
145 145
146 let servers: PeerTubeServer[] 146 let servers: PeerTubeServer[]
147 let sqlCommands: SQLCommand[] = [] 147 let sqlCommands: SQLCommand[] = []
148 const objectStorage = new ObjectStorageCommand()
148 149
149 let keptUrls: string[] = [] 150 let keptUrls: string[] = []
150 151
@@ -159,8 +160,8 @@ function runTestSuite (options: {
159 ? `http://127.0.0.1:${port}` 160 ? `http://127.0.0.1:${port}`
160 : undefined 161 : undefined
161 162
162 await ObjectStorageCommand.createMockBucket(options.playlistBucket) 163 await objectStorage.createMockBucket(options.playlistBucket)
163 await ObjectStorageCommand.createMockBucket(options.webtorrentBucket) 164 await objectStorage.createMockBucket(options.webtorrentBucket)
164 165
165 const config = { 166 const config = {
166 object_storage: { 167 object_storage: {
@@ -275,6 +276,7 @@ function runTestSuite (options: {
275 276
276 after(async function () { 277 after(async function () {
277 await mockObjectStorageProxy.terminate() 278 await mockObjectStorageProxy.terminate()
279 await objectStorage.cleanupMock()
278 280
279 for (const sqlCommand of sqlCommands) { 281 for (const sqlCommand of sqlCommands) {
280 await sqlCommand.cleanup() 282 await sqlCommand.cleanup()
@@ -287,26 +289,12 @@ function runTestSuite (options: {
287describe('Object storage for videos', function () { 289describe('Object storage for videos', function () {
288 if (areMockObjectStorageTestsDisabled()) return 290 if (areMockObjectStorageTestsDisabled()) return
289 291
292 const objectStorage = new ObjectStorageCommand()
293
290 describe('Test config', function () { 294 describe('Test config', function () {
291 let server: PeerTubeServer 295 let server: PeerTubeServer
292 296
293 const baseConfig = { 297 const baseConfig = objectStorage.getDefaultMockConfig()
294 object_storage: {
295 enabled: true,
296 endpoint: 'http://' + ObjectStorageCommand.getMockEndpointHost(),
297 region: ObjectStorageCommand.getMockRegion(),
298
299 credentials: ObjectStorageCommand.getMockCredentialsConfig(),
300
301 streaming_playlists: {
302 bucket_name: ObjectStorageCommand.DEFAULT_PLAYLIST_MOCK_BUCKET
303 },
304
305 videos: {
306 bucket_name: ObjectStorageCommand.DEFAULT_WEBTORRENT_MOCK_BUCKET
307 }
308 }
309 }
310 298
311 const badCredentials = { 299 const badCredentials = {
312 access_key_id: 'AKIAIOSFODNN7EXAMPLE', 300 access_key_id: 'AKIAIOSFODNN7EXAMPLE',
@@ -334,7 +322,7 @@ describe('Object storage for videos', function () {
334 it('Should fail with bad credentials', async function () { 322 it('Should fail with bad credentials', async function () {
335 this.timeout(60000) 323 this.timeout(60000)
336 324
337 await ObjectStorageCommand.prepareDefaultMockBuckets() 325 await objectStorage.prepareDefaultMockBuckets()
338 326
339 const config = merge({}, baseConfig, { 327 const config = merge({}, baseConfig, {
340 object_storage: { 328 object_storage: {
@@ -358,7 +346,7 @@ describe('Object storage for videos', function () {
358 it('Should succeed with credentials from env', async function () { 346 it('Should succeed with credentials from env', async function () {
359 this.timeout(60000) 347 this.timeout(60000)
360 348
361 await ObjectStorageCommand.prepareDefaultMockBuckets() 349 await objectStorage.prepareDefaultMockBuckets()
362 350
363 const config = merge({}, baseConfig, { 351 const config = merge({}, baseConfig, {
364 object_storage: { 352 object_storage: {
@@ -385,25 +373,27 @@ describe('Object storage for videos', function () {
385 await waitJobs([ server ], { skipDelayed: true }) 373 await waitJobs([ server ], { skipDelayed: true })
386 const video = await server.videos.get({ id: uuid }) 374 const video = await server.videos.get({ id: uuid })
387 375
388 expectStartWith(video.files[0].fileUrl, ObjectStorageCommand.getMockWebTorrentBaseUrl()) 376 expectStartWith(video.files[0].fileUrl, objectStorage.getMockWebVideosBaseUrl())
389 }) 377 })
390 378
391 after(async function () { 379 after(async function () {
380 await objectStorage.cleanupMock()
381
392 await cleanupTests([ server ]) 382 await cleanupTests([ server ])
393 }) 383 })
394 }) 384 })
395 385
396 describe('Test simple object storage', function () { 386 describe('Test simple object storage', function () {
397 runTestSuite({ 387 runTestSuite({
398 playlistBucket: 'streaming-playlists', 388 playlistBucket: objectStorage.getMockBucketName('streaming-playlists'),
399 webtorrentBucket: 'videos' 389 webtorrentBucket: objectStorage.getMockBucketName('videos')
400 }) 390 })
401 }) 391 })
402 392
403 describe('Test object storage with prefix', function () { 393 describe('Test object storage with prefix', function () {
404 runTestSuite({ 394 runTestSuite({
405 playlistBucket: 'mybucket', 395 playlistBucket: objectStorage.getMockBucketName('mybucket'),
406 webtorrentBucket: 'mybucket', 396 webtorrentBucket: objectStorage.getMockBucketName('mybucket'),
407 397
408 playlistPrefix: 'streaming-playlists_', 398 playlistPrefix: 'streaming-playlists_',
409 webtorrentPrefix: 'webtorrent_' 399 webtorrentPrefix: 'webtorrent_'
@@ -412,8 +402,8 @@ describe('Object storage for videos', function () {
412 402
413 describe('Test object storage with prefix and base URL', function () { 403 describe('Test object storage with prefix and base URL', function () {
414 runTestSuite({ 404 runTestSuite({
415 playlistBucket: 'mybucket', 405 playlistBucket: objectStorage.getMockBucketName('mybucket'),
416 webtorrentBucket: 'mybucket', 406 webtorrentBucket: objectStorage.getMockBucketName('mybucket'),
417 407
418 playlistPrefix: 'streaming-playlists/', 408 playlistPrefix: 'streaming-playlists/',
419 webtorrentPrefix: 'webtorrent/', 409 webtorrentPrefix: 'webtorrent/',
@@ -440,8 +430,8 @@ describe('Object storage for videos', function () {
440 430
441 runTestSuite({ 431 runTestSuite({
442 maxUploadPart, 432 maxUploadPart,
443 playlistBucket: 'streaming-playlists', 433 playlistBucket: objectStorage.getMockBucketName('streaming-playlists'),
444 webtorrentBucket: 'videos', 434 webtorrentBucket: objectStorage.getMockBucketName('videos'),
445 fixture 435 fixture
446 }) 436 })
447 }) 437 })
diff --git a/server/tests/api/server/follows.ts b/server/tests/api/server/follows.ts
index dba9e107c..2a5fff82b 100644
--- a/server/tests/api/server/follows.ts
+++ b/server/tests/api/server/follows.ts
@@ -279,7 +279,7 @@ describe('Test follows', function () {
279 }) 279 })
280 280
281 it('Should upload a video on server 2 and 3 and propagate only the video of server 2', async function () { 281 it('Should upload a video on server 2 and 3 and propagate only the video of server 2', async function () {
282 this.timeout(120000) 282 this.timeout(160000)
283 283
284 await servers[1].videos.upload({ attributes: { name: 'server2' } }) 284 await servers[1].videos.upload({ attributes: { name: 'server2' } })
285 await servers[2].videos.upload({ attributes: { name: 'server3' } }) 285 await servers[2].videos.upload({ attributes: { name: 'server3' } })
diff --git a/server/tests/api/server/proxy.ts b/server/tests/api/server/proxy.ts
index 4bf89410e..9337468d5 100644
--- a/server/tests/api/server/proxy.ts
+++ b/server/tests/api/server/proxy.ts
@@ -122,38 +122,44 @@ describe('Test proxy', function () {
122 describe('Object storage', function () { 122 describe('Object storage', function () {
123 if (areMockObjectStorageTestsDisabled()) return 123 if (areMockObjectStorageTestsDisabled()) return
124 124
125 const objectStorage = new ObjectStorageCommand()
126
125 before(async function () { 127 before(async function () {
126 this.timeout(30000) 128 this.timeout(30000)
127 129
128 await ObjectStorageCommand.prepareDefaultMockBuckets() 130 await objectStorage.prepareDefaultMockBuckets()
129 }) 131 })
130 132
131 it('Should succeed to upload to object storage with the appropriate proxy config', async function () { 133 it('Should succeed to upload to object storage with the appropriate proxy config', async function () {
132 this.timeout(120000) 134 this.timeout(120000)
133 135
134 await servers[0].kill() 136 await servers[0].kill()
135 await servers[0].run(ObjectStorageCommand.getDefaultMockConfig(), { env: goodEnv }) 137 await servers[0].run(objectStorage.getDefaultMockConfig(), { env: goodEnv })
136 138
137 const { uuid } = await servers[0].videos.quickUpload({ name: 'video' }) 139 const { uuid } = await servers[0].videos.quickUpload({ name: 'video' })
138 await waitJobs(servers) 140 await waitJobs(servers)
139 141
140 const video = await servers[0].videos.get({ id: uuid }) 142 const video = await servers[0].videos.get({ id: uuid })
141 143
142 expectStartWith(video.files[0].fileUrl, ObjectStorageCommand.getMockWebTorrentBaseUrl()) 144 expectStartWith(video.files[0].fileUrl, objectStorage.getMockWebVideosBaseUrl())
143 }) 145 })
144 146
145 it('Should fail to upload to object storage with a wrong proxy config', async function () { 147 it('Should fail to upload to object storage with a wrong proxy config', async function () {
146 this.timeout(120000) 148 this.timeout(120000)
147 149
148 await servers[0].kill() 150 await servers[0].kill()
149 await servers[0].run(ObjectStorageCommand.getDefaultMockConfig(), { env: badEnv }) 151 await servers[0].run(objectStorage.getDefaultMockConfig(), { env: badEnv })
150 152
151 const { uuid } = await servers[0].videos.quickUpload({ name: 'video' }) 153 const { uuid } = await servers[0].videos.quickUpload({ name: 'video' })
152 await waitJobs(servers, { skipDelayed: true }) 154 await waitJobs(servers, { skipDelayed: true })
153 155
154 const video = await servers[0].videos.get({ id: uuid }) 156 const video = await servers[0].videos.get({ id: uuid })
155 157
156 expectNotStartWith(video.files[0].fileUrl, ObjectStorageCommand.getMockWebTorrentBaseUrl()) 158 expectNotStartWith(video.files[0].fileUrl, objectStorage.getMockWebVideosBaseUrl())
159 })
160
161 after(async function () {
162 await objectStorage.cleanupMock()
157 }) 163 })
158 }) 164 })
159 165
diff --git a/server/tests/api/transcoding/create-transcoding.ts b/server/tests/api/transcoding/create-transcoding.ts
index 5483c8dba..d6f5b01dc 100644
--- a/server/tests/api/transcoding/create-transcoding.ts
+++ b/server/tests/api/transcoding/create-transcoding.ts
@@ -17,9 +17,9 @@ import {
17 waitJobs 17 waitJobs
18} from '@shared/server-commands' 18} from '@shared/server-commands'
19 19
20async function checkFilesInObjectStorage (video: VideoDetails) { 20async function checkFilesInObjectStorage (objectStorage: ObjectStorageCommand, video: VideoDetails) {
21 for (const file of video.files) { 21 for (const file of video.files) {
22 expectStartWith(file.fileUrl, ObjectStorageCommand.getMockWebTorrentBaseUrl()) 22 expectStartWith(file.fileUrl, objectStorage.getMockWebVideosBaseUrl())
23 await makeRawRequest({ url: file.fileUrl, expectedStatus: HttpStatusCode.OK_200 }) 23 await makeRawRequest({ url: file.fileUrl, expectedStatus: HttpStatusCode.OK_200 })
24 } 24 }
25 25
@@ -27,29 +27,30 @@ async function checkFilesInObjectStorage (video: VideoDetails) {
27 27
28 const hlsPlaylist = video.streamingPlaylists[0] 28 const hlsPlaylist = video.streamingPlaylists[0]
29 for (const file of hlsPlaylist.files) { 29 for (const file of hlsPlaylist.files) {
30 expectStartWith(file.fileUrl, ObjectStorageCommand.getMockPlaylistBaseUrl()) 30 expectStartWith(file.fileUrl, objectStorage.getMockPlaylistBaseUrl())
31 await makeRawRequest({ url: file.fileUrl, expectedStatus: HttpStatusCode.OK_200 }) 31 await makeRawRequest({ url: file.fileUrl, expectedStatus: HttpStatusCode.OK_200 })
32 } 32 }
33 33
34 expectStartWith(hlsPlaylist.playlistUrl, ObjectStorageCommand.getMockPlaylistBaseUrl()) 34 expectStartWith(hlsPlaylist.playlistUrl, objectStorage.getMockPlaylistBaseUrl())
35 await makeRawRequest({ url: hlsPlaylist.playlistUrl, expectedStatus: HttpStatusCode.OK_200 }) 35 await makeRawRequest({ url: hlsPlaylist.playlistUrl, expectedStatus: HttpStatusCode.OK_200 })
36 36
37 expectStartWith(hlsPlaylist.segmentsSha256Url, ObjectStorageCommand.getMockPlaylistBaseUrl()) 37 expectStartWith(hlsPlaylist.segmentsSha256Url, objectStorage.getMockPlaylistBaseUrl())
38 await makeRawRequest({ url: hlsPlaylist.segmentsSha256Url, expectedStatus: HttpStatusCode.OK_200 }) 38 await makeRawRequest({ url: hlsPlaylist.segmentsSha256Url, expectedStatus: HttpStatusCode.OK_200 })
39} 39}
40 40
41function runTests (objectStorage: boolean) { 41function runTests (enableObjectStorage: boolean) {
42 let servers: PeerTubeServer[] = [] 42 let servers: PeerTubeServer[] = []
43 let videoUUID: string 43 let videoUUID: string
44 let publishedAt: string 44 let publishedAt: string
45 45
46 let shouldBeDeleted: string[] 46 let shouldBeDeleted: string[]
47 const objectStorage = new ObjectStorageCommand()
47 48
48 before(async function () { 49 before(async function () {
49 this.timeout(120000) 50 this.timeout(120000)
50 51
51 const config = objectStorage 52 const config = enableObjectStorage
52 ? ObjectStorageCommand.getDefaultMockConfig() 53 ? objectStorage.getDefaultMockConfig()
53 : {} 54 : {}
54 55
55 // Run server 2 to have transcoding enabled 56 // Run server 2 to have transcoding enabled
@@ -60,7 +61,7 @@ function runTests (objectStorage: boolean) {
60 61
61 await doubleFollow(servers[0], servers[1]) 62 await doubleFollow(servers[0], servers[1])
62 63
63 if (objectStorage) await ObjectStorageCommand.prepareDefaultMockBuckets() 64 if (enableObjectStorage) await objectStorage.prepareDefaultMockBuckets()
64 65
65 const { shortUUID } = await servers[0].videos.quickUpload({ name: 'video' }) 66 const { shortUUID } = await servers[0].videos.quickUpload({ name: 'video' })
66 videoUUID = shortUUID 67 videoUUID = shortUUID
@@ -91,7 +92,7 @@ function runTests (objectStorage: boolean) {
91 expect(videoDetails.streamingPlaylists).to.have.lengthOf(1) 92 expect(videoDetails.streamingPlaylists).to.have.lengthOf(1)
92 expect(videoDetails.streamingPlaylists[0].files).to.have.lengthOf(5) 93 expect(videoDetails.streamingPlaylists[0].files).to.have.lengthOf(5)
93 94
94 if (objectStorage) await checkFilesInObjectStorage(videoDetails) 95 if (enableObjectStorage) await checkFilesInObjectStorage(objectStorage, videoDetails)
95 } 96 }
96 }) 97 })
97 98
@@ -112,7 +113,7 @@ function runTests (objectStorage: boolean) {
112 expect(videoDetails.streamingPlaylists).to.have.lengthOf(1) 113 expect(videoDetails.streamingPlaylists).to.have.lengthOf(1)
113 expect(videoDetails.streamingPlaylists[0].files).to.have.lengthOf(5) 114 expect(videoDetails.streamingPlaylists[0].files).to.have.lengthOf(5)
114 115
115 if (objectStorage) await checkFilesInObjectStorage(videoDetails) 116 if (enableObjectStorage) await checkFilesInObjectStorage(objectStorage, videoDetails)
116 } 117 }
117 }) 118 })
118 119
@@ -132,7 +133,7 @@ function runTests (objectStorage: boolean) {
132 expect(videoDetails.streamingPlaylists).to.have.lengthOf(1) 133 expect(videoDetails.streamingPlaylists).to.have.lengthOf(1)
133 expect(videoDetails.streamingPlaylists[0].files).to.have.lengthOf(5) 134 expect(videoDetails.streamingPlaylists[0].files).to.have.lengthOf(5)
134 135
135 if (objectStorage) await checkFilesInObjectStorage(videoDetails) 136 if (enableObjectStorage) await checkFilesInObjectStorage(objectStorage, videoDetails)
136 } 137 }
137 }) 138 })
138 139
@@ -151,7 +152,7 @@ function runTests (objectStorage: boolean) {
151 expect(videoDetails.files).to.have.lengthOf(5) 152 expect(videoDetails.files).to.have.lengthOf(5)
152 expect(videoDetails.streamingPlaylists).to.have.lengthOf(0) 153 expect(videoDetails.streamingPlaylists).to.have.lengthOf(0)
153 154
154 if (objectStorage) await checkFilesInObjectStorage(videoDetails) 155 if (enableObjectStorage) await checkFilesInObjectStorage(objectStorage, videoDetails)
155 } 156 }
156 }) 157 })
157 158
@@ -185,7 +186,7 @@ function runTests (objectStorage: boolean) {
185 expect(videoDetails.streamingPlaylists).to.have.lengthOf(1) 186 expect(videoDetails.streamingPlaylists).to.have.lengthOf(1)
186 expect(videoDetails.streamingPlaylists[0].files).to.have.lengthOf(1) 187 expect(videoDetails.streamingPlaylists[0].files).to.have.lengthOf(1)
187 188
188 if (objectStorage) await checkFilesInObjectStorage(videoDetails) 189 if (enableObjectStorage) await checkFilesInObjectStorage(objectStorage, videoDetails)
189 190
190 shouldBeDeleted = [ 191 shouldBeDeleted = [
191 videoDetails.streamingPlaylists[0].files[0].fileUrl, 192 videoDetails.streamingPlaylists[0].files[0].fileUrl,
@@ -219,8 +220,8 @@ function runTests (objectStorage: boolean) {
219 expect(videoDetails.streamingPlaylists).to.have.lengthOf(1) 220 expect(videoDetails.streamingPlaylists).to.have.lengthOf(1)
220 expect(videoDetails.streamingPlaylists[0].files).to.have.lengthOf(5) 221 expect(videoDetails.streamingPlaylists[0].files).to.have.lengthOf(5)
221 222
222 if (objectStorage) { 223 if (enableObjectStorage) {
223 await checkFilesInObjectStorage(videoDetails) 224 await checkFilesInObjectStorage(objectStorage, videoDetails)
224 225
225 const hlsPlaylist = videoDetails.streamingPlaylists[0] 226 const hlsPlaylist = videoDetails.streamingPlaylists[0]
226 const resolutions = hlsPlaylist.files.map(f => f.resolution.id) 227 const resolutions = hlsPlaylist.files.map(f => f.resolution.id)
@@ -245,6 +246,8 @@ function runTests (objectStorage: boolean) {
245 }) 246 })
246 247
247 after(async function () { 248 after(async function () {
249 if (objectStorage) await objectStorage.cleanupMock()
250
248 await cleanupTests(servers) 251 await cleanupTests(servers)
249 }) 252 })
250} 253}
diff --git a/server/tests/api/transcoding/hls.ts b/server/tests/api/transcoding/hls.ts
index b6e4fe8e5..c668d7e0b 100644
--- a/server/tests/api/transcoding/hls.ts
+++ b/server/tests/api/transcoding/hls.ts
@@ -150,17 +150,23 @@ describe('Test HLS videos', function () {
150 describe('With object storage enabled', function () { 150 describe('With object storage enabled', function () {
151 if (areMockObjectStorageTestsDisabled()) return 151 if (areMockObjectStorageTestsDisabled()) return
152 152
153 const objectStorage = new ObjectStorageCommand()
154
153 before(async function () { 155 before(async function () {
154 this.timeout(120000) 156 this.timeout(120000)
155 157
156 const configOverride = ObjectStorageCommand.getDefaultMockConfig() 158 const configOverride = objectStorage.getDefaultMockConfig()
157 await ObjectStorageCommand.prepareDefaultMockBuckets() 159 await objectStorage.prepareDefaultMockBuckets()
158 160
159 await servers[0].kill() 161 await servers[0].kill()
160 await servers[0].run(configOverride) 162 await servers[0].run(configOverride)
161 }) 163 })
162 164
163 runTestSuite(true, ObjectStorageCommand.getMockPlaylistBaseUrl()) 165 runTestSuite(true, objectStorage.getMockPlaylistBaseUrl())
166
167 after(async function () {
168 await objectStorage.cleanupMock()
169 })
164 }) 170 })
165 171
166 after(async function () { 172 after(async function () {
diff --git a/server/tests/api/transcoding/update-while-transcoding.ts b/server/tests/api/transcoding/update-while-transcoding.ts
index f4d728118..61655f102 100644
--- a/server/tests/api/transcoding/update-while-transcoding.ts
+++ b/server/tests/api/transcoding/update-while-transcoding.ts
@@ -135,17 +135,23 @@ describe('Test update video privacy while transcoding', function () {
135 describe('With object storage enabled', function () { 135 describe('With object storage enabled', function () {
136 if (areMockObjectStorageTestsDisabled()) return 136 if (areMockObjectStorageTestsDisabled()) return
137 137
138 const objectStorage = new ObjectStorageCommand()
139
138 before(async function () { 140 before(async function () {
139 this.timeout(120000) 141 this.timeout(120000)
140 142
141 const configOverride = ObjectStorageCommand.getDefaultMockConfig() 143 const configOverride = objectStorage.getDefaultMockConfig()
142 await ObjectStorageCommand.prepareDefaultMockBuckets() 144 await objectStorage.prepareDefaultMockBuckets()
143 145
144 await servers[0].kill() 146 await servers[0].kill()
145 await servers[0].run(configOverride) 147 await servers[0].run(configOverride)
146 }) 148 })
147 149
148 runTestSuite(true, ObjectStorageCommand.getMockPlaylistBaseUrl()) 150 runTestSuite(true, objectStorage.getMockPlaylistBaseUrl())
151
152 after(async function () {
153 await objectStorage.cleanupMock()
154 })
149 }) 155 })
150 156
151 after(async function () { 157 after(async function () {
diff --git a/server/tests/api/transcoding/video-studio.ts b/server/tests/api/transcoding/video-studio.ts
index 35efc3d49..d1298caf7 100644
--- a/server/tests/api/transcoding/video-studio.ts
+++ b/server/tests/api/transcoding/video-studio.ts
@@ -326,11 +326,13 @@ describe('Test video studio', function () {
326 describe('Object storage studio edition', function () { 326 describe('Object storage studio edition', function () {
327 if (areMockObjectStorageTestsDisabled()) return 327 if (areMockObjectStorageTestsDisabled()) return
328 328
329 const objectStorage = new ObjectStorageCommand()
330
329 before(async function () { 331 before(async function () {
330 await ObjectStorageCommand.prepareDefaultMockBuckets() 332 await objectStorage.prepareDefaultMockBuckets()
331 333
332 await servers[0].kill() 334 await servers[0].kill()
333 await servers[0].run(ObjectStorageCommand.getDefaultMockConfig()) 335 await servers[0].run(objectStorage.getDefaultMockConfig())
334 336
335 await servers[0].config.enableMinimumTranscoding() 337 await servers[0].config.enableMinimumTranscoding()
336 }) 338 })
@@ -353,16 +355,20 @@ describe('Test video studio', function () {
353 } 355 }
354 356
355 for (const webtorrentFile of video.files) { 357 for (const webtorrentFile of video.files) {
356 expectStartWith(webtorrentFile.fileUrl, ObjectStorageCommand.getMockWebTorrentBaseUrl()) 358 expectStartWith(webtorrentFile.fileUrl, objectStorage.getMockWebVideosBaseUrl())
357 } 359 }
358 360
359 for (const hlsFile of video.streamingPlaylists[0].files) { 361 for (const hlsFile of video.streamingPlaylists[0].files) {
360 expectStartWith(hlsFile.fileUrl, ObjectStorageCommand.getMockPlaylistBaseUrl()) 362 expectStartWith(hlsFile.fileUrl, objectStorage.getMockPlaylistBaseUrl())
361 } 363 }
362 364
363 await checkVideoDuration(server, videoUUID, 9) 365 await checkVideoDuration(server, videoUUID, 9)
364 } 366 }
365 }) 367 })
368
369 after(async function () {
370 await objectStorage.cleanupMock()
371 })
366 }) 372 })
367 373
368 after(async function () { 374 after(async function () {
diff --git a/server/tests/cli/create-import-video-file-job.ts b/server/tests/cli/create-import-video-file-job.ts
index 3ece4f2ec..edd727967 100644
--- a/server/tests/cli/create-import-video-file-job.ts
+++ b/server/tests/cli/create-import-video-file-job.ts
@@ -25,25 +25,27 @@ function assertVideoProperties (video: VideoFile, resolution: number, extname: s
25 if (size) expect(video.size).to.equal(size) 25 if (size) expect(video.size).to.equal(size)
26} 26}
27 27
28async function checkFiles (video: VideoDetails, objectStorage: boolean) { 28async function checkFiles (video: VideoDetails, objectStorage: ObjectStorageCommand) {
29 for (const file of video.files) { 29 for (const file of video.files) {
30 if (objectStorage) expectStartWith(file.fileUrl, ObjectStorageCommand.getMockWebTorrentBaseUrl()) 30 if (objectStorage) expectStartWith(file.fileUrl, objectStorage.getMockWebVideosBaseUrl())
31 31
32 await makeRawRequest({ url: file.fileUrl, expectedStatus: HttpStatusCode.OK_200 }) 32 await makeRawRequest({ url: file.fileUrl, expectedStatus: HttpStatusCode.OK_200 })
33 } 33 }
34} 34}
35 35
36function runTests (objectStorage: boolean) { 36function runTests (enableObjectStorage: boolean) {
37 let video1ShortId: string 37 let video1ShortId: string
38 let video2UUID: string 38 let video2UUID: string
39 39
40 let servers: PeerTubeServer[] = [] 40 let servers: PeerTubeServer[] = []
41 41
42 const objectStorage = new ObjectStorageCommand()
43
42 before(async function () { 44 before(async function () {
43 this.timeout(90000) 45 this.timeout(90000)
44 46
45 const config = objectStorage 47 const config = enableObjectStorage
46 ? ObjectStorageCommand.getDefaultMockConfig() 48 ? objectStorage.getDefaultMockConfig()
47 : {} 49 : {}
48 50
49 // Run server 2 to have transcoding enabled 51 // Run server 2 to have transcoding enabled
@@ -52,7 +54,7 @@ function runTests (objectStorage: boolean) {
52 54
53 await doubleFollow(servers[0], servers[1]) 55 await doubleFollow(servers[0], servers[1])
54 56
55 if (objectStorage) await ObjectStorageCommand.prepareDefaultMockBuckets() 57 if (enableObjectStorage) await objectStorage.prepareDefaultMockBuckets()
56 58
57 // Upload two videos for our needs 59 // Upload two videos for our needs
58 { 60 {
@@ -90,7 +92,7 @@ function runTests (objectStorage: boolean) {
90 assertVideoProperties(originalVideo, 720, 'webm', 218910) 92 assertVideoProperties(originalVideo, 720, 'webm', 218910)
91 assertVideoProperties(transcodedVideo, 480, 'webm', 69217) 93 assertVideoProperties(transcodedVideo, 480, 'webm', 69217)
92 94
93 await checkFiles(videoDetails, objectStorage) 95 await checkFiles(videoDetails, enableObjectStorage && objectStorage)
94 } 96 }
95 }) 97 })
96 98
@@ -114,7 +116,7 @@ function runTests (objectStorage: boolean) {
114 assertVideoProperties(transcodedVideo320, 360, 'mp4') 116 assertVideoProperties(transcodedVideo320, 360, 'mp4')
115 assertVideoProperties(transcodedVideo240, 240, 'mp4') 117 assertVideoProperties(transcodedVideo240, 240, 'mp4')
116 118
117 await checkFiles(videoDetails, objectStorage) 119 await checkFiles(videoDetails, enableObjectStorage && objectStorage)
118 } 120 }
119 }) 121 })
120 122
@@ -136,7 +138,7 @@ function runTests (objectStorage: boolean) {
136 assertVideoProperties(video720, 720, 'webm', 942961) 138 assertVideoProperties(video720, 720, 'webm', 942961)
137 assertVideoProperties(video480, 480, 'webm', 69217) 139 assertVideoProperties(video480, 480, 'webm', 69217)
138 140
139 await checkFiles(videoDetails, objectStorage) 141 await checkFiles(videoDetails, enableObjectStorage && objectStorage)
140 } 142 }
141 }) 143 })
142 144
@@ -146,6 +148,8 @@ function runTests (objectStorage: boolean) {
146 }) 148 })
147 149
148 after(async function () { 150 after(async function () {
151 await objectStorage.cleanupMock()
152
149 await cleanupTests(servers) 153 await cleanupTests(servers)
150 }) 154 })
151} 155}
diff --git a/server/tests/cli/create-move-video-storage-job.ts b/server/tests/cli/create-move-video-storage-job.ts
index 4927e0309..33a8cb9f9 100644
--- a/server/tests/cli/create-move-video-storage-job.ts
+++ b/server/tests/cli/create-move-video-storage-job.ts
@@ -15,10 +15,10 @@ import {
15} from '@shared/server-commands' 15} from '@shared/server-commands'
16import { checkDirectoryIsEmpty, expectStartWith } from '../shared' 16import { checkDirectoryIsEmpty, expectStartWith } from '../shared'
17 17
18async function checkFiles (origin: PeerTubeServer, video: VideoDetails, inObjectStorage: boolean) { 18async function checkFiles (origin: PeerTubeServer, video: VideoDetails, objectStorage?: ObjectStorageCommand) {
19 for (const file of video.files) { 19 for (const file of video.files) {
20 const start = inObjectStorage 20 const start = objectStorage
21 ? ObjectStorageCommand.getMockWebTorrentBaseUrl() 21 ? objectStorage.getMockWebVideosBaseUrl()
22 : origin.url 22 : origin.url
23 23
24 expectStartWith(file.fileUrl, start) 24 expectStartWith(file.fileUrl, start)
@@ -26,8 +26,8 @@ async function checkFiles (origin: PeerTubeServer, video: VideoDetails, inObject
26 await makeRawRequest({ url: file.fileUrl, expectedStatus: HttpStatusCode.OK_200 }) 26 await makeRawRequest({ url: file.fileUrl, expectedStatus: HttpStatusCode.OK_200 })
27 } 27 }
28 28
29 const start = inObjectStorage 29 const start = objectStorage
30 ? ObjectStorageCommand.getMockPlaylistBaseUrl() 30 ? objectStorage.getMockPlaylistBaseUrl()
31 : origin.url 31 : origin.url
32 32
33 const hls = video.streamingPlaylists[0] 33 const hls = video.streamingPlaylists[0]
@@ -46,6 +46,7 @@ describe('Test create move video storage job', function () {
46 46
47 let servers: PeerTubeServer[] = [] 47 let servers: PeerTubeServer[] = []
48 const uuids: string[] = [] 48 const uuids: string[] = []
49 const objectStorage = new ObjectStorageCommand()
49 50
50 before(async function () { 51 before(async function () {
51 this.timeout(360000) 52 this.timeout(360000)
@@ -56,7 +57,7 @@ describe('Test create move video storage job', function () {
56 57
57 await doubleFollow(servers[0], servers[1]) 58 await doubleFollow(servers[0], servers[1])
58 59
59 await ObjectStorageCommand.prepareDefaultMockBuckets() 60 await objectStorage.prepareDefaultMockBuckets()
60 61
61 await servers[0].config.enableTranscoding() 62 await servers[0].config.enableTranscoding()
62 63
@@ -68,25 +69,25 @@ describe('Test create move video storage job', function () {
68 await waitJobs(servers) 69 await waitJobs(servers)
69 70
70 await servers[0].kill() 71 await servers[0].kill()
71 await servers[0].run(ObjectStorageCommand.getDefaultMockConfig()) 72 await servers[0].run(objectStorage.getDefaultMockConfig())
72 }) 73 })
73 74
74 it('Should move only one file', async function () { 75 it('Should move only one file', async function () {
75 this.timeout(120000) 76 this.timeout(120000)
76 77
77 const command = `npm run create-move-video-storage-job -- --to-object-storage -v ${uuids[1]}` 78 const command = `npm run create-move-video-storage-job -- --to-object-storage -v ${uuids[1]}`
78 await servers[0].cli.execWithEnv(command, ObjectStorageCommand.getDefaultMockConfig()) 79 await servers[0].cli.execWithEnv(command, objectStorage.getDefaultMockConfig())
79 await waitJobs(servers) 80 await waitJobs(servers)
80 81
81 for (const server of servers) { 82 for (const server of servers) {
82 const video = await server.videos.get({ id: uuids[1] }) 83 const video = await server.videos.get({ id: uuids[1] })
83 84
84 await checkFiles(servers[0], video, true) 85 await checkFiles(servers[0], video, objectStorage)
85 86
86 for (const id of [ uuids[0], uuids[2] ]) { 87 for (const id of [ uuids[0], uuids[2] ]) {
87 const video = await server.videos.get({ id }) 88 const video = await server.videos.get({ id })
88 89
89 await checkFiles(servers[0], video, false) 90 await checkFiles(servers[0], video)
90 } 91 }
91 } 92 }
92 }) 93 })
@@ -95,14 +96,14 @@ describe('Test create move video storage job', function () {
95 this.timeout(120000) 96 this.timeout(120000)
96 97
97 const command = `npm run create-move-video-storage-job -- --to-object-storage --all-videos` 98 const command = `npm run create-move-video-storage-job -- --to-object-storage --all-videos`
98 await servers[0].cli.execWithEnv(command, ObjectStorageCommand.getDefaultMockConfig()) 99 await servers[0].cli.execWithEnv(command, objectStorage.getDefaultMockConfig())
99 await waitJobs(servers) 100 await waitJobs(servers)
100 101
101 for (const server of servers) { 102 for (const server of servers) {
102 for (const id of [ uuids[0], uuids[2] ]) { 103 for (const id of [ uuids[0], uuids[2] ]) {
103 const video = await server.videos.get({ id }) 104 const video = await server.videos.get({ id })
104 105
105 await checkFiles(servers[0], video, true) 106 await checkFiles(servers[0], video, objectStorage)
106 } 107 }
107 } 108 }
108 }) 109 })
diff --git a/server/tests/peertube-runner/live-transcoding.ts b/server/tests/peertube-runner/live-transcoding.ts
index e7ef941c6..c2ca1de96 100644
--- a/server/tests/peertube-runner/live-transcoding.ts
+++ b/server/tests/peertube-runner/live-transcoding.ts
@@ -31,8 +31,8 @@ describe('Test Live transcoding in peertube-runner program', function () {
31 let sqlCommandServer1: SQLCommand 31 let sqlCommandServer1: SQLCommand
32 32
33 function runSuite (options: { 33 function runSuite (options: {
34 objectStorage: boolean 34 objectStorage?: ObjectStorageCommand
35 }) { 35 } = {}) {
36 const { objectStorage } = options 36 const { objectStorage } = options
37 37
38 it('Should enable transcoding without additional resolutions', async function () { 38 it('Should enable transcoding without additional resolutions', async function () {
@@ -117,7 +117,7 @@ describe('Test Live transcoding in peertube-runner program', function () {
117 117
118 for (const file of files) { 118 for (const file of files) {
119 if (objectStorage) { 119 if (objectStorage) {
120 expectStartWith(file.fileUrl, ObjectStorageCommand.getMockPlaylistBaseUrl()) 120 expectStartWith(file.fileUrl, objectStorage.getMockPlaylistBaseUrl())
121 } 121 }
122 122
123 await makeRawRequest({ url: file.fileUrl, expectedStatus: HttpStatusCode.OK_200 }) 123 await makeRawRequest({ url: file.fileUrl, expectedStatus: HttpStatusCode.OK_200 })
@@ -155,24 +155,30 @@ describe('Test Live transcoding in peertube-runner program', function () {
155 await servers[0].config.enableTranscoding(true, false, true) 155 await servers[0].config.enableTranscoding(true, false, true)
156 }) 156 })
157 157
158 runSuite({ objectStorage: false }) 158 runSuite()
159 }) 159 })
160 160
161 describe('With lives on object storage', function () { 161 describe('With lives on object storage', function () {
162 if (areMockObjectStorageTestsDisabled()) return 162 if (areMockObjectStorageTestsDisabled()) return
163 163
164 const objectStorage = new ObjectStorageCommand()
165
164 before(async function () { 166 before(async function () {
165 await ObjectStorageCommand.prepareDefaultMockBuckets() 167 await objectStorage.prepareDefaultMockBuckets()
166 168
167 await servers[0].kill() 169 await servers[0].kill()
168 170
169 await servers[0].run(ObjectStorageCommand.getDefaultMockConfig()) 171 await servers[0].run(objectStorage.getDefaultMockConfig())
170 172
171 // Wait for peertube runner socket reconnection 173 // Wait for peertube runner socket reconnection
172 await wait(1500) 174 await wait(1500)
173 }) 175 })
174 176
175 runSuite({ objectStorage: true }) 177 runSuite({ objectStorage })
178
179 after(async function () {
180 await objectStorage.cleanupMock()
181 })
176 }) 182 })
177 183
178 describe('Check cleanup', function () { 184 describe('Check cleanup', function () {
diff --git a/server/tests/peertube-runner/studio-transcoding.ts b/server/tests/peertube-runner/studio-transcoding.ts
index 400203eb3..69b38a536 100644
--- a/server/tests/peertube-runner/studio-transcoding.ts
+++ b/server/tests/peertube-runner/studio-transcoding.ts
@@ -19,8 +19,8 @@ describe('Test studio transcoding in peertube-runner program', function () {
19 let peertubeRunner: PeerTubeRunnerProcess 19 let peertubeRunner: PeerTubeRunnerProcess
20 20
21 function runSuite (options: { 21 function runSuite (options: {
22 objectStorage: boolean 22 objectStorage?: ObjectStorageCommand
23 }) { 23 } = {}) {
24 const { objectStorage } = options 24 const { objectStorage } = options
25 25
26 it('Should run a complex studio transcoding', async function () { 26 it('Should run a complex studio transcoding', async function () {
@@ -45,11 +45,11 @@ describe('Test studio transcoding in peertube-runner program', function () {
45 45
46 if (objectStorage) { 46 if (objectStorage) {
47 for (const webtorrentFile of video.files) { 47 for (const webtorrentFile of video.files) {
48 expectStartWith(webtorrentFile.fileUrl, ObjectStorageCommand.getMockWebTorrentBaseUrl()) 48 expectStartWith(webtorrentFile.fileUrl, objectStorage.getMockWebVideosBaseUrl())
49 } 49 }
50 50
51 for (const hlsFile of video.streamingPlaylists[0].files) { 51 for (const hlsFile of video.streamingPlaylists[0].files) {
52 expectStartWith(hlsFile.fileUrl, ObjectStorageCommand.getMockPlaylistBaseUrl()) 52 expectStartWith(hlsFile.fileUrl, objectStorage.getMockPlaylistBaseUrl())
53 } 53 }
54 } 54 }
55 55
@@ -80,24 +80,30 @@ describe('Test studio transcoding in peertube-runner program', function () {
80 }) 80 })
81 81
82 describe('With videos on local filesystem storage', function () { 82 describe('With videos on local filesystem storage', function () {
83 runSuite({ objectStorage: false }) 83 runSuite()
84 }) 84 })
85 85
86 describe('With videos on object storage', function () { 86 describe('With videos on object storage', function () {
87 if (areMockObjectStorageTestsDisabled()) return 87 if (areMockObjectStorageTestsDisabled()) return
88 88
89 const objectStorage = new ObjectStorageCommand()
90
89 before(async function () { 91 before(async function () {
90 await ObjectStorageCommand.prepareDefaultMockBuckets() 92 await objectStorage.prepareDefaultMockBuckets()
91 93
92 await servers[0].kill() 94 await servers[0].kill()
93 95
94 await servers[0].run(ObjectStorageCommand.getDefaultMockConfig()) 96 await servers[0].run(objectStorage.getDefaultMockConfig())
95 97
96 // Wait for peertube runner socket reconnection 98 // Wait for peertube runner socket reconnection
97 await wait(1500) 99 await wait(1500)
98 }) 100 })
99 101
100 runSuite({ objectStorage: true }) 102 runSuite({ objectStorage })
103
104 after(async function () {
105 await objectStorage.cleanupMock()
106 })
101 }) 107 })
102 108
103 describe('Check cleanup', function () { 109 describe('Check cleanup', function () {
diff --git a/server/tests/peertube-runner/vod-transcoding.ts b/server/tests/peertube-runner/vod-transcoding.ts
index dc505baab..aefec394d 100644
--- a/server/tests/peertube-runner/vod-transcoding.ts
+++ b/server/tests/peertube-runner/vod-transcoding.ts
@@ -26,16 +26,16 @@ describe('Test VOD transcoding in peertube-runner program', function () {
26 function runSuite (options: { 26 function runSuite (options: {
27 webtorrentEnabled: boolean 27 webtorrentEnabled: boolean
28 hlsEnabled: boolean 28 hlsEnabled: boolean
29 objectStorage: boolean 29 objectStorage?: ObjectStorageCommand
30 }) { 30 }) {
31 const { webtorrentEnabled, hlsEnabled, objectStorage } = options 31 const { webtorrentEnabled, hlsEnabled, objectStorage } = options
32 32
33 const objectStorageBaseUrlWebTorrent = objectStorage 33 const objectStorageBaseUrlWebTorrent = objectStorage
34 ? ObjectStorageCommand.getMockWebTorrentBaseUrl() 34 ? objectStorage.getMockWebVideosBaseUrl()
35 : undefined 35 : undefined
36 36
37 const objectStorageBaseUrlHLS = objectStorage 37 const objectStorageBaseUrlHLS = objectStorage
38 ? ObjectStorageCommand.getMockPlaylistBaseUrl() 38 ? objectStorage.getMockPlaylistBaseUrl()
39 : undefined 39 : undefined
40 40
41 it('Should upload a classic video mp4 and transcode it', async function () { 41 it('Should upload a classic video mp4 and transcode it', async function () {
@@ -262,7 +262,7 @@ describe('Test VOD transcoding in peertube-runner program', function () {
262 await servers[0].config.enableTranscoding(true, false, true) 262 await servers[0].config.enableTranscoding(true, false, true)
263 }) 263 })
264 264
265 runSuite({ webtorrentEnabled: true, hlsEnabled: false, objectStorage: false }) 265 runSuite({ webtorrentEnabled: true, hlsEnabled: false })
266 }) 266 })
267 267
268 describe('HLS videos only enabled', function () { 268 describe('HLS videos only enabled', function () {
@@ -271,7 +271,7 @@ describe('Test VOD transcoding in peertube-runner program', function () {
271 await servers[0].config.enableTranscoding(false, true, true) 271 await servers[0].config.enableTranscoding(false, true, true)
272 }) 272 })
273 273
274 runSuite({ webtorrentEnabled: false, hlsEnabled: true, objectStorage: false }) 274 runSuite({ webtorrentEnabled: false, hlsEnabled: true })
275 }) 275 })
276 276
277 describe('Web video & HLS enabled', function () { 277 describe('Web video & HLS enabled', function () {
@@ -280,19 +280,21 @@ describe('Test VOD transcoding in peertube-runner program', function () {
280 await servers[0].config.enableTranscoding(true, true, true) 280 await servers[0].config.enableTranscoding(true, true, true)
281 }) 281 })
282 282
283 runSuite({ webtorrentEnabled: true, hlsEnabled: true, objectStorage: false }) 283 runSuite({ webtorrentEnabled: true, hlsEnabled: true })
284 }) 284 })
285 }) 285 })
286 286
287 describe('With videos on object storage', function () { 287 describe('With videos on object storage', function () {
288 if (areMockObjectStorageTestsDisabled()) return 288 if (areMockObjectStorageTestsDisabled()) return
289 289
290 const objectStorage = new ObjectStorageCommand()
291
290 before(async function () { 292 before(async function () {
291 await ObjectStorageCommand.prepareDefaultMockBuckets() 293 await objectStorage.prepareDefaultMockBuckets()
292 294
293 await servers[0].kill() 295 await servers[0].kill()
294 296
295 await servers[0].run(ObjectStorageCommand.getDefaultMockConfig()) 297 await servers[0].run(objectStorage.getDefaultMockConfig())
296 298
297 // Wait for peertube runner socket reconnection 299 // Wait for peertube runner socket reconnection
298 await wait(1500) 300 await wait(1500)
@@ -304,7 +306,7 @@ describe('Test VOD transcoding in peertube-runner program', function () {
304 await servers[0].config.enableTranscoding(true, false, true) 306 await servers[0].config.enableTranscoding(true, false, true)
305 }) 307 })
306 308
307 runSuite({ webtorrentEnabled: true, hlsEnabled: false, objectStorage: true }) 309 runSuite({ webtorrentEnabled: true, hlsEnabled: false, objectStorage })
308 }) 310 })
309 311
310 describe('HLS videos only enabled', function () { 312 describe('HLS videos only enabled', function () {
@@ -313,7 +315,7 @@ describe('Test VOD transcoding in peertube-runner program', function () {
313 await servers[0].config.enableTranscoding(false, true, true) 315 await servers[0].config.enableTranscoding(false, true, true)
314 }) 316 })
315 317
316 runSuite({ webtorrentEnabled: false, hlsEnabled: true, objectStorage: true }) 318 runSuite({ webtorrentEnabled: false, hlsEnabled: true, objectStorage })
317 }) 319 })
318 320
319 describe('Web video & HLS enabled', function () { 321 describe('Web video & HLS enabled', function () {
@@ -322,7 +324,11 @@ describe('Test VOD transcoding in peertube-runner program', function () {
322 await servers[0].config.enableTranscoding(true, true, true) 324 await servers[0].config.enableTranscoding(true, true, true)
323 }) 325 })
324 326
325 runSuite({ webtorrentEnabled: true, hlsEnabled: true, objectStorage: true }) 327 runSuite({ webtorrentEnabled: true, hlsEnabled: true, objectStorage })
328 })
329
330 after(async function () {
331 await objectStorage.cleanupMock()
326 }) 332 })
327 }) 333 })
328 334
diff --git a/server/tests/shared/live.ts b/server/tests/shared/live.ts
index 8f837c97a..9d8c1d941 100644
--- a/server/tests/shared/live.ts
+++ b/server/tests/shared/live.ts
@@ -46,7 +46,7 @@ async function testLiveVideoResolutions (options: {
46 resolutions: number[] 46 resolutions: number[]
47 transcoded: boolean 47 transcoded: boolean
48 48
49 objectStorage: boolean 49 objectStorage?: ObjectStorageCommand
50 objectStorageBaseUrl?: string 50 objectStorageBaseUrl?: string
51}) { 51}) {
52 const { 52 const {
@@ -57,7 +57,7 @@ async function testLiveVideoResolutions (options: {
57 resolutions, 57 resolutions,
58 transcoded, 58 transcoded,
59 objectStorage, 59 objectStorage,
60 objectStorageBaseUrl = ObjectStorageCommand.getMockPlaylistBaseUrl() 60 objectStorageBaseUrl = objectStorage?.getMockPlaylistBaseUrl()
61 } = options 61 } = options
62 62
63 for (const server of servers) { 63 for (const server of servers) {
@@ -76,7 +76,7 @@ async function testLiveVideoResolutions (options: {
76 playlistUrl: hlsPlaylist.playlistUrl, 76 playlistUrl: hlsPlaylist.playlistUrl,
77 resolutions, 77 resolutions,
78 transcoded, 78 transcoded,
79 withRetry: objectStorage 79 withRetry: !!objectStorage
80 }) 80 })
81 81
82 if (objectStorage) { 82 if (objectStorage) {
@@ -105,7 +105,7 @@ async function testLiveVideoResolutions (options: {
105 105
106 const subPlaylist = await originServer.streamingPlaylists.get({ 106 const subPlaylist = await originServer.streamingPlaylists.get({
107 url: `${baseUrl}/${video.uuid}/${i}.m3u8`, 107 url: `${baseUrl}/${video.uuid}/${i}.m3u8`,
108 withRetry: objectStorage // With object storage, the request may fail because of inconsistent data in S3 108 withRetry: !!objectStorage // With object storage, the request may fail because of inconsistent data in S3
109 }) 109 })
110 110
111 expect(subPlaylist).to.contain(segmentName) 111 expect(subPlaylist).to.contain(segmentName)
@@ -116,7 +116,7 @@ async function testLiveVideoResolutions (options: {
116 videoUUID: video.uuid, 116 videoUUID: video.uuid,
117 segmentName, 117 segmentName,
118 hlsPlaylist, 118 hlsPlaylist,
119 withRetry: objectStorage // With object storage, the request may fail because of inconsistent data in S3 119 withRetry: !!objectStorage // With object storage, the request may fail because of inconsistent data in S3
120 }) 120 })
121 121
122 if (originServer.internalServerNumber === server.internalServerNumber) { 122 if (originServer.internalServerNumber === server.internalServerNumber) {
diff --git a/shared/server-commands/server/object-storage-command.ts b/shared/server-commands/server/object-storage-command.ts
index a1fe4f0f7..7d8ec93cd 100644
--- a/shared/server-commands/server/object-storage-command.ts
+++ b/shared/server-commands/server/object-storage-command.ts
@@ -1,34 +1,17 @@
1 1import { randomInt } from 'crypto'
2import { HttpStatusCode } from '@shared/models' 2import { HttpStatusCode } from '@shared/models'
3import { makePostBodyRequest } from '../requests' 3import { makePostBodyRequest } from '../requests'
4import { AbstractCommand } from '../shared'
5
6export class ObjectStorageCommand extends AbstractCommand {
7 static readonly DEFAULT_PLAYLIST_MOCK_BUCKET = 'streaming-playlists'
8 static readonly DEFAULT_WEBTORRENT_MOCK_BUCKET = 'videos'
9 4
5export class ObjectStorageCommand {
10 static readonly DEFAULT_SCALEWAY_BUCKET = 'peertube-ci-test' 6 static readonly DEFAULT_SCALEWAY_BUCKET = 'peertube-ci-test'
11 7
12 // --------------------------------------------------------------------------- 8 private readonly bucketsCreated: string[] = []
13 9 private readonly seed: number
14 static getDefaultMockConfig () {
15 return {
16 object_storage: {
17 enabled: true,
18 endpoint: 'http://' + this.getMockEndpointHost(),
19 region: this.getMockRegion(),
20
21 credentials: this.getMockCredentialsConfig(),
22 10
23 streaming_playlists: { 11 // ---------------------------------------------------------------------------
24 bucket_name: this.DEFAULT_PLAYLIST_MOCK_BUCKET
25 },
26 12
27 videos: { 13 constructor () {
28 bucket_name: this.DEFAULT_WEBTORRENT_MOCK_BUCKET 14 this.seed = randomInt(0, 10000)
29 }
30 }
31 }
32 } 15 }
33 16
34 static getMockCredentialsConfig () { 17 static getMockCredentialsConfig () {
@@ -46,35 +29,79 @@ export class ObjectStorageCommand extends AbstractCommand {
46 return 'us-east-1' 29 return 'us-east-1'
47 } 30 }
48 31
49 static getMockWebTorrentBaseUrl () { 32 getDefaultMockConfig () {
50 return `http://${this.DEFAULT_WEBTORRENT_MOCK_BUCKET}.${this.getMockEndpointHost()}/` 33 return {
34 object_storage: {
35 enabled: true,
36 endpoint: 'http://' + ObjectStorageCommand.getMockEndpointHost(),
37 region: ObjectStorageCommand.getMockRegion(),
38
39 credentials: ObjectStorageCommand.getMockCredentialsConfig(),
40
41 streaming_playlists: {
42 bucket_name: this.getMockStreamingPlaylistsBucketName()
43 },
44
45 videos: {
46 bucket_name: this.getMockWebVideosBucketName()
47 }
48 }
49 }
51 } 50 }
52 51
53 static getMockPlaylistBaseUrl () { 52 getMockWebVideosBaseUrl () {
54 return `http://${this.DEFAULT_PLAYLIST_MOCK_BUCKET}.${this.getMockEndpointHost()}/` 53 return `http://${this.getMockWebVideosBucketName()}.${ObjectStorageCommand.getMockEndpointHost()}/`
55 } 54 }
56 55
57 static async prepareDefaultMockBuckets () { 56 getMockPlaylistBaseUrl () {
58 await this.createMockBucket(this.DEFAULT_PLAYLIST_MOCK_BUCKET) 57 return `http://${this.getMockStreamingPlaylistsBucketName()}.${ObjectStorageCommand.getMockEndpointHost()}/`
59 await this.createMockBucket(this.DEFAULT_WEBTORRENT_MOCK_BUCKET)
60 } 58 }
61 59
62 static async createMockBucket (name: string) { 60 async prepareDefaultMockBuckets () {
61 await this.createMockBucket(this.getMockStreamingPlaylistsBucketName())
62 await this.createMockBucket(this.getMockWebVideosBucketName())
63 }
64
65 async createMockBucket (name: string) {
66 this.bucketsCreated.push(name)
67
68 await this.deleteMockBucket(name)
69
63 await makePostBodyRequest({ 70 await makePostBodyRequest({
64 url: this.getMockEndpointHost(), 71 url: ObjectStorageCommand.getMockEndpointHost(),
65 path: '/ui/' + name + '?delete', 72 path: '/ui/' + name + '?create',
66 expectedStatus: HttpStatusCode.TEMPORARY_REDIRECT_307 73 expectedStatus: HttpStatusCode.TEMPORARY_REDIRECT_307
67 }) 74 })
68 75
69 await makePostBodyRequest({ 76 await makePostBodyRequest({
70 url: this.getMockEndpointHost(), 77 url: ObjectStorageCommand.getMockEndpointHost(),
71 path: '/ui/' + name + '?create', 78 path: '/ui/' + name + '?make-public',
72 expectedStatus: HttpStatusCode.TEMPORARY_REDIRECT_307 79 expectedStatus: HttpStatusCode.TEMPORARY_REDIRECT_307
73 }) 80 })
81 }
74 82
83 async cleanupMock () {
84 for (const name of this.bucketsCreated) {
85 await this.deleteMockBucket(name)
86 }
87 }
88
89 getMockStreamingPlaylistsBucketName (name = 'streaming-playlists') {
90 return this.getMockBucketName(name)
91 }
92
93 getMockWebVideosBucketName (name = 'web-videos') {
94 return this.getMockBucketName(name)
95 }
96
97 getMockBucketName (name: string) {
98 return `${this.seed}-${name}`
99 }
100
101 private async deleteMockBucket (name: string) {
75 await makePostBodyRequest({ 102 await makePostBodyRequest({
76 url: this.getMockEndpointHost(), 103 url: ObjectStorageCommand.getMockEndpointHost(),
77 path: '/ui/' + name + '?make-public', 104 path: '/ui/' + name + '?delete',
78 expectedStatus: HttpStatusCode.TEMPORARY_REDIRECT_307 105 expectedStatus: HttpStatusCode.TEMPORARY_REDIRECT_307
79 }) 106 })
80 } 107 }
diff --git a/shared/server-commands/server/server.ts b/shared/server-commands/server/server.ts
index 66b7ff09d..70f7a3ee2 100644
--- a/shared/server-commands/server/server.ts
+++ b/shared/server-commands/server/server.ts
@@ -48,7 +48,6 @@ import { DebugCommand } from './debug-command'
48import { FollowsCommand } from './follows-command' 48import { FollowsCommand } from './follows-command'
49import { JobsCommand } from './jobs-command' 49import { JobsCommand } from './jobs-command'
50import { MetricsCommand } from './metrics-command' 50import { MetricsCommand } from './metrics-command'
51import { ObjectStorageCommand } from './object-storage-command'
52import { PluginsCommand } from './plugins-command' 51import { PluginsCommand } from './plugins-command'
53import { RedundancyCommand } from './redundancy-command' 52import { RedundancyCommand } from './redundancy-command'
54import { ServersCommand } from './servers-command' 53import { ServersCommand } from './servers-command'
@@ -140,7 +139,6 @@ export class PeerTubeServer {
140 servers?: ServersCommand 139 servers?: ServersCommand
141 login?: LoginCommand 140 login?: LoginCommand
142 users?: UsersCommand 141 users?: UsersCommand
143 objectStorage?: ObjectStorageCommand
144 videoStudio?: VideoStudioCommand 142 videoStudio?: VideoStudioCommand
145 videos?: VideosCommand 143 videos?: VideosCommand
146 videoStats?: VideoStatsCommand 144 videoStats?: VideoStatsCommand
@@ -429,7 +427,6 @@ export class PeerTubeServer {
429 this.login = new LoginCommand(this) 427 this.login = new LoginCommand(this)
430 this.users = new UsersCommand(this) 428 this.users = new UsersCommand(this)
431 this.videos = new VideosCommand(this) 429 this.videos = new VideosCommand(this)
432 this.objectStorage = new ObjectStorageCommand(this)
433 this.videoStudio = new VideoStudioCommand(this) 430 this.videoStudio = new VideoStudioCommand(this)
434 this.videoStats = new VideoStatsCommand(this) 431 this.videoStats = new VideoStatsCommand(this)
435 this.views = new ViewsCommand(this) 432 this.views = new ViewsCommand(this)
diff --git a/shared/server-commands/videos/live-command.ts b/shared/server-commands/videos/live-command.ts
index 73f4eefd3..44d625970 100644
--- a/shared/server-commands/videos/live-command.ts
+++ b/shared/server-commands/videos/live-command.ts
@@ -192,7 +192,7 @@ export class LiveCommand extends AbstractCommand {
192 videoUUID: string 192 videoUUID: string
193 playlistNumber: number 193 playlistNumber: number
194 segment: number 194 segment: number
195 objectStorage: boolean 195 objectStorage?: ObjectStorageCommand
196 objectStorageBaseUrl?: string 196 objectStorageBaseUrl?: string
197 }) { 197 }) {
198 const { 198 const {
@@ -201,12 +201,12 @@ export class LiveCommand extends AbstractCommand {
201 playlistNumber, 201 playlistNumber,
202 segment, 202 segment,
203 videoUUID, 203 videoUUID,
204 objectStorageBaseUrl = ObjectStorageCommand.getMockPlaylistBaseUrl() 204 objectStorageBaseUrl
205 } = options 205 } = options
206 206
207 const segmentName = `${playlistNumber}-00000${segment}.ts` 207 const segmentName = `${playlistNumber}-00000${segment}.ts`
208 const baseUrl = objectStorage 208 const baseUrl = objectStorage
209 ? join(objectStorageBaseUrl, 'hls') 209 ? join(objectStorageBaseUrl || objectStorage.getMockPlaylistBaseUrl(), 'hls')
210 : server.url + '/static/streaming-playlists/hls' 210 : server.url + '/static/streaming-playlists/hls'
211 211
212 let error = true 212 let error = true
@@ -226,7 +226,7 @@ export class LiveCommand extends AbstractCommand {
226 const hlsPlaylist = video.streamingPlaylists[0] 226 const hlsPlaylist = video.streamingPlaylists[0]
227 227
228 // Check SHA generation 228 // Check SHA generation
229 const shaBody = await server.streamingPlaylists.getSegmentSha256({ url: hlsPlaylist.segmentsSha256Url, withRetry: objectStorage }) 229 const shaBody = await server.streamingPlaylists.getSegmentSha256({ url: hlsPlaylist.segmentsSha256Url, withRetry: !!objectStorage })
230 if (!shaBody[segmentName]) { 230 if (!shaBody[segmentName]) {
231 throw new Error('Segment SHA does not exist') 231 throw new Error('Segment SHA does not exist')
232 } 232 }
@@ -261,13 +261,13 @@ export class LiveCommand extends AbstractCommand {
261 videoUUID: string 261 videoUUID: string
262 playlistNumber: number 262 playlistNumber: number
263 segment: number 263 segment: number
264 objectStorage?: boolean // default false 264 objectStorage?: ObjectStorageCommand
265 }) { 265 }) {
266 const { playlistNumber, segment, videoUUID, objectStorage = false } = options 266 const { playlistNumber, segment, videoUUID, objectStorage } = options
267 267
268 const segmentName = `${playlistNumber}-00000${segment}.ts` 268 const segmentName = `${playlistNumber}-00000${segment}.ts`
269 const baseUrl = objectStorage 269 const baseUrl = objectStorage
270 ? ObjectStorageCommand.getMockPlaylistBaseUrl() 270 ? objectStorage.getMockPlaylistBaseUrl()
271 : `${this.server.url}/static/streaming-playlists/hls` 271 : `${this.server.url}/static/streaming-playlists/hls`
272 272
273 const url = `${baseUrl}/${videoUUID}/${segmentName}` 273 const url = `${baseUrl}/${videoUUID}/${segmentName}`
@@ -284,12 +284,12 @@ export class LiveCommand extends AbstractCommand {
284 getPlaylistFile (options: OverrideCommandOptions & { 284 getPlaylistFile (options: OverrideCommandOptions & {
285 videoUUID: string 285 videoUUID: string
286 playlistName: string 286 playlistName: string
287 objectStorage?: boolean // default false 287 objectStorage?: ObjectStorageCommand
288 }) { 288 }) {
289 const { playlistName, videoUUID, objectStorage = false } = options 289 const { playlistName, videoUUID, objectStorage } = options
290 290
291 const baseUrl = objectStorage 291 const baseUrl = objectStorage
292 ? ObjectStorageCommand.getMockPlaylistBaseUrl() 292 ? objectStorage.getMockPlaylistBaseUrl()
293 : `${this.server.url}/static/streaming-playlists/hls` 293 : `${this.server.url}/static/streaming-playlists/hls`
294 294
295 const url = `${baseUrl}/${videoUUID}/${playlistName}` 295 const url = `${baseUrl}/${videoUUID}/${playlistName}`