aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/transcoding
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/transcoding')
-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
4 files changed, 47 insertions, 26 deletions
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 () {