diff options
Diffstat (limited to 'server/tests/api/transcoding/create-transcoding.ts')
-rw-r--r-- | server/tests/api/transcoding/create-transcoding.ts | 35 |
1 files changed, 19 insertions, 16 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 | ||
20 | async function checkFilesInObjectStorage (video: VideoDetails) { | 20 | async 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 | ||
41 | function runTests (objectStorage: boolean) { | 41 | function 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 | } |