diff options
Diffstat (limited to 'server/tests/api/object-storage/live.ts')
-rw-r--r-- | server/tests/api/object-storage/live.ts | 58 |
1 files changed, 37 insertions, 21 deletions
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 | ||
39 | async function checkFilesExist (servers: PeerTubeServer[], videoUUID: string, numberOfFiles: number) { | 39 | async 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 | ||
57 | async function checkFilesCleanup (server: PeerTubeServer, videoUUID: string, resolutions: number[]) { | 64 | async 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 | }) |