diff options
author | Chocobozzz <me@florianbigard.com> | 2023-05-23 10:49:45 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2023-05-23 10:49:45 +0200 |
commit | f89189907bbdff6c4bc6d3460ed9ef4c49515f17 (patch) | |
tree | c55e50e3fc02ae9b3f2d1d19d95160af98cc7d7c /server/tests/cli/create-import-video-file-job.ts | |
parent | 41cde76bbf5ac16a90b5f158672523069db74009 (diff) | |
download | PeerTube-f89189907bbdff6c4bc6d3460ed9ef4c49515f17.tar.gz PeerTube-f89189907bbdff6c4bc6d3460ed9ef4c49515f17.tar.zst PeerTube-f89189907bbdff6c4bc6d3460ed9ef4c49515f17.zip |
Prevent object storage mock conflicts
When running tests in parallel
Diffstat (limited to 'server/tests/cli/create-import-video-file-job.ts')
-rw-r--r-- | server/tests/cli/create-import-video-file-job.ts | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/server/tests/cli/create-import-video-file-job.ts b/server/tests/cli/create-import-video-file-job.ts index 3ece4f2ec..edd727967 100644 --- a/server/tests/cli/create-import-video-file-job.ts +++ b/server/tests/cli/create-import-video-file-job.ts | |||
@@ -25,25 +25,27 @@ function assertVideoProperties (video: VideoFile, resolution: number, extname: s | |||
25 | if (size) expect(video.size).to.equal(size) | 25 | if (size) expect(video.size).to.equal(size) |
26 | } | 26 | } |
27 | 27 | ||
28 | async function checkFiles (video: VideoDetails, objectStorage: boolean) { | 28 | async function checkFiles (video: VideoDetails, objectStorage: ObjectStorageCommand) { |
29 | for (const file of video.files) { | 29 | for (const file of video.files) { |
30 | if (objectStorage) expectStartWith(file.fileUrl, ObjectStorageCommand.getMockWebTorrentBaseUrl()) | 30 | if (objectStorage) expectStartWith(file.fileUrl, objectStorage.getMockWebVideosBaseUrl()) |
31 | 31 | ||
32 | await makeRawRequest({ url: file.fileUrl, expectedStatus: HttpStatusCode.OK_200 }) | 32 | await makeRawRequest({ url: file.fileUrl, expectedStatus: HttpStatusCode.OK_200 }) |
33 | } | 33 | } |
34 | } | 34 | } |
35 | 35 | ||
36 | function runTests (objectStorage: boolean) { | 36 | function runTests (enableObjectStorage: boolean) { |
37 | let video1ShortId: string | 37 | let video1ShortId: string |
38 | let video2UUID: string | 38 | let video2UUID: string |
39 | 39 | ||
40 | let servers: PeerTubeServer[] = [] | 40 | let servers: PeerTubeServer[] = [] |
41 | 41 | ||
42 | const objectStorage = new ObjectStorageCommand() | ||
43 | |||
42 | before(async function () { | 44 | before(async function () { |
43 | this.timeout(90000) | 45 | this.timeout(90000) |
44 | 46 | ||
45 | const config = objectStorage | 47 | const config = enableObjectStorage |
46 | ? ObjectStorageCommand.getDefaultMockConfig() | 48 | ? objectStorage.getDefaultMockConfig() |
47 | : {} | 49 | : {} |
48 | 50 | ||
49 | // Run server 2 to have transcoding enabled | 51 | // Run server 2 to have transcoding enabled |
@@ -52,7 +54,7 @@ function runTests (objectStorage: boolean) { | |||
52 | 54 | ||
53 | await doubleFollow(servers[0], servers[1]) | 55 | await doubleFollow(servers[0], servers[1]) |
54 | 56 | ||
55 | if (objectStorage) await ObjectStorageCommand.prepareDefaultMockBuckets() | 57 | if (enableObjectStorage) await objectStorage.prepareDefaultMockBuckets() |
56 | 58 | ||
57 | // Upload two videos for our needs | 59 | // Upload two videos for our needs |
58 | { | 60 | { |
@@ -90,7 +92,7 @@ function runTests (objectStorage: boolean) { | |||
90 | assertVideoProperties(originalVideo, 720, 'webm', 218910) | 92 | assertVideoProperties(originalVideo, 720, 'webm', 218910) |
91 | assertVideoProperties(transcodedVideo, 480, 'webm', 69217) | 93 | assertVideoProperties(transcodedVideo, 480, 'webm', 69217) |
92 | 94 | ||
93 | await checkFiles(videoDetails, objectStorage) | 95 | await checkFiles(videoDetails, enableObjectStorage && objectStorage) |
94 | } | 96 | } |
95 | }) | 97 | }) |
96 | 98 | ||
@@ -114,7 +116,7 @@ function runTests (objectStorage: boolean) { | |||
114 | assertVideoProperties(transcodedVideo320, 360, 'mp4') | 116 | assertVideoProperties(transcodedVideo320, 360, 'mp4') |
115 | assertVideoProperties(transcodedVideo240, 240, 'mp4') | 117 | assertVideoProperties(transcodedVideo240, 240, 'mp4') |
116 | 118 | ||
117 | await checkFiles(videoDetails, objectStorage) | 119 | await checkFiles(videoDetails, enableObjectStorage && objectStorage) |
118 | } | 120 | } |
119 | }) | 121 | }) |
120 | 122 | ||
@@ -136,7 +138,7 @@ function runTests (objectStorage: boolean) { | |||
136 | assertVideoProperties(video720, 720, 'webm', 942961) | 138 | assertVideoProperties(video720, 720, 'webm', 942961) |
137 | assertVideoProperties(video480, 480, 'webm', 69217) | 139 | assertVideoProperties(video480, 480, 'webm', 69217) |
138 | 140 | ||
139 | await checkFiles(videoDetails, objectStorage) | 141 | await checkFiles(videoDetails, enableObjectStorage && objectStorage) |
140 | } | 142 | } |
141 | }) | 143 | }) |
142 | 144 | ||
@@ -146,6 +148,8 @@ function runTests (objectStorage: boolean) { | |||
146 | }) | 148 | }) |
147 | 149 | ||
148 | after(async function () { | 150 | after(async function () { |
151 | await objectStorage.cleanupMock() | ||
152 | |||
149 | await cleanupTests(servers) | 153 | await cleanupTests(servers) |
150 | }) | 154 | }) |
151 | } | 155 | } |