aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/object-storage
diff options
context:
space:
mode:
authorkontrollanten <6680299+kontrollanten@users.noreply.github.com>2022-04-19 15:22:18 +0200
committerGitHub <noreply@github.com>2022-04-19 15:22:18 +0200
commit156cdbac227b5501116a66063812b9fc9b0e89c7 (patch)
tree1efb4398708f1552cafeffc84c1818262dbaca04 /server/tests/api/object-storage
parent33ac85bf610d74d353ee456a286159872cdd83cc (diff)
downloadPeerTube-156cdbac227b5501116a66063812b9fc9b0e89c7.tar.gz
PeerTube-156cdbac227b5501116a66063812b9fc9b0e89c7.tar.zst
PeerTube-156cdbac227b5501116a66063812b9fc9b0e89c7.zip
object-storage: @aws-sdk/lib-storage for multipart (#4903)
* object-storage: @aws-sdk/lib-storage for multipart * gitignore: add .DS_Store * test(object-storage): remove only * test(object-storage/multipart): generate video * fix lint issue * test(obj-storage/video): ensure file size * Styling Co-authored-by: Chocobozzz <me@florianbigard.com>
Diffstat (limited to 'server/tests/api/object-storage')
-rw-r--r--server/tests/api/object-storage/videos.ts42
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
3import 'mocha' 3import 'mocha'
4import bytes from 'bytes'
4import * as chai from 'chai' 5import * as chai from 'chai'
6import { stat } from 'fs-extra'
5import { merge } from 'lodash' 7import { merge } from 'lodash'
6import { checkTmpIsEmpty, expectLogDoesNotContain, expectStartWith, MockObjectStorage } from '@server/tests/shared' 8import {
9 checkTmpIsEmpty,
10 expectLogDoesNotContain,
11 expectStartWith,
12 generateHighBitrateVideo,
13 MockObjectStorage
14} from '@server/tests/shared'
7import { areObjectStorageTestsDisabled } from '@shared/core-utils' 15import { areObjectStorageTestsDisabled } from '@shared/core-utils'
8import { HttpStatusCode, VideoDetails } from '@shared/models' 16import { HttpStatusCode, VideoDetails } from '@shared/models'
9import { 17import {
@@ -107,6 +115,10 @@ async function checkFiles (options: {
107} 115}
108 116
109function runTestSuite (options: { 117function 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})