diff options
Diffstat (limited to 'server/tests/api/object-storage')
-rw-r--r-- | server/tests/api/object-storage/videos.ts | 42 |
1 files changed, 33 insertions, 9 deletions
diff --git a/server/tests/api/object-storage/videos.ts b/server/tests/api/object-storage/videos.ts index 498efcb17..22ad06305 100644 --- a/server/tests/api/object-storage/videos.ts +++ b/server/tests/api/object-storage/videos.ts | |||
@@ -1,9 +1,17 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import bytes from 'bytes' | ||
4 | import * as chai from 'chai' | 5 | import * as chai from 'chai' |
6 | import { stat } from 'fs-extra' | ||
5 | import { merge } from 'lodash' | 7 | import { merge } from 'lodash' |
6 | import { checkTmpIsEmpty, expectLogDoesNotContain, expectStartWith, MockObjectStorage } from '@server/tests/shared' | 8 | import { |
9 | checkTmpIsEmpty, | ||
10 | expectLogDoesNotContain, | ||
11 | expectStartWith, | ||
12 | generateHighBitrateVideo, | ||
13 | MockObjectStorage | ||
14 | } from '@server/tests/shared' | ||
7 | import { areObjectStorageTestsDisabled } from '@shared/core-utils' | 15 | import { areObjectStorageTestsDisabled } from '@shared/core-utils' |
8 | import { HttpStatusCode, VideoDetails } from '@shared/models' | 16 | import { HttpStatusCode, VideoDetails } from '@shared/models' |
9 | import { | 17 | import { |
@@ -107,6 +115,10 @@ async function checkFiles (options: { | |||
107 | } | 115 | } |
108 | 116 | ||
109 | function runTestSuite (options: { | 117 | function runTestSuite (options: { |
118 | fixture?: string | ||
119 | |||
120 | maxUploadPart?: string | ||
121 | |||
110 | playlistBucket: string | 122 | playlistBucket: string |
111 | playlistPrefix?: string | 123 | playlistPrefix?: string |
112 | 124 | ||
@@ -114,10 +126,9 @@ function runTestSuite (options: { | |||
114 | webtorrentPrefix?: string | 126 | webtorrentPrefix?: string |
115 | 127 | ||
116 | useMockBaseUrl?: boolean | 128 | useMockBaseUrl?: boolean |
117 | |||
118 | maxUploadPart?: string | ||
119 | }) { | 129 | }) { |
120 | const mockObjectStorage = new MockObjectStorage() | 130 | const mockObjectStorage = new MockObjectStorage() |
131 | const { fixture } = options | ||
121 | let baseMockUrl: string | 132 | let baseMockUrl: string |
122 | 133 | ||
123 | let servers: PeerTubeServer[] | 134 | let servers: PeerTubeServer[] |
@@ -144,7 +155,7 @@ function runTestSuite (options: { | |||
144 | 155 | ||
145 | credentials: ObjectStorageCommand.getCredentialsConfig(), | 156 | credentials: ObjectStorageCommand.getCredentialsConfig(), |
146 | 157 | ||
147 | max_upload_part: options.maxUploadPart || '2MB', | 158 | max_upload_part: options.maxUploadPart || '5MB', |
148 | 159 | ||
149 | streaming_playlists: { | 160 | streaming_playlists: { |
150 | bucket_name: options.playlistBucket, | 161 | bucket_name: options.playlistBucket, |
@@ -181,7 +192,7 @@ function runTestSuite (options: { | |||
181 | it('Should upload a video and move it to the object storage without transcoding', async function () { | 192 | it('Should upload a video and move it to the object storage without transcoding', async function () { |
182 | this.timeout(40000) | 193 | this.timeout(40000) |
183 | 194 | ||
184 | const { uuid } = await servers[0].videos.quickUpload({ name: 'video 1' }) | 195 | const { uuid } = await servers[0].videos.quickUpload({ name: 'video 1', fixture }) |
185 | uuidsToDelete.push(uuid) | 196 | uuidsToDelete.push(uuid) |
186 | 197 | ||
187 | await waitJobs(servers) | 198 | await waitJobs(servers) |
@@ -197,7 +208,7 @@ function runTestSuite (options: { | |||
197 | it('Should upload a video and move it to the object storage with transcoding', async function () { | 208 | it('Should upload a video and move it to the object storage with transcoding', async function () { |
198 | this.timeout(120000) | 209 | this.timeout(120000) |
199 | 210 | ||
200 | const { uuid } = await servers[1].videos.quickUpload({ name: 'video 2' }) | 211 | const { uuid } = await servers[1].videos.quickUpload({ name: 'video 2', fixture }) |
201 | uuidsToDelete.push(uuid) | 212 | uuidsToDelete.push(uuid) |
202 | 213 | ||
203 | await waitJobs(servers) | 214 | await waitJobs(servers) |
@@ -390,12 +401,25 @@ describe('Object storage for videos', function () { | |||
390 | }) | 401 | }) |
391 | }) | 402 | }) |
392 | 403 | ||
393 | describe('Test object storage with small upload part', function () { | 404 | describe('Test object storage with file bigger than upload part', function () { |
405 | let fixture: string | ||
406 | const maxUploadPart = '5MB' | ||
407 | |||
408 | before(async function () { | ||
409 | fixture = await generateHighBitrateVideo() | ||
410 | |||
411 | const { size } = await stat(fixture) | ||
412 | |||
413 | if (bytes.parse(maxUploadPart) > size) { | ||
414 | throw Error(`Fixture file is too small (${size}) to make sense for this test.`) | ||
415 | } | ||
416 | }) | ||
417 | |||
394 | runTestSuite({ | 418 | runTestSuite({ |
419 | maxUploadPart, | ||
395 | playlistBucket: 'streaming-playlists', | 420 | playlistBucket: 'streaming-playlists', |
396 | webtorrentBucket: 'videos', | 421 | webtorrentBucket: 'videos', |
397 | 422 | fixture | |
398 | maxUploadPart: '5KB' | ||
399 | }) | 423 | }) |
400 | }) | 424 | }) |
401 | }) | 425 | }) |