diff options
Diffstat (limited to 'server')
32 files changed, 242 insertions, 187 deletions
diff --git a/server/controllers/tracker.ts b/server/controllers/tracker.ts index c4f3a8889..53eab73ac 100644 --- a/server/controllers/tracker.ts +++ b/server/controllers/tracker.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import { Server as TrackerServer } from 'bittorrent-tracker' | 1 | import { Server as TrackerServer } from 'bittorrent-tracker' |
2 | import express from 'express' | 2 | import express from 'express' |
3 | import { createServer } from 'http' | 3 | import { createServer } from 'http' |
4 | import LRUCache from 'lru-cache' | 4 | import { LRUCache } from 'lru-cache' |
5 | import proxyAddr from 'proxy-addr' | 5 | import proxyAddr from 'proxy-addr' |
6 | import { WebSocketServer } from 'ws' | 6 | import { WebSocketServer } from 'ws' |
7 | import { logger } from '../helpers/logger' | 7 | import { logger } from '../helpers/logger' |
diff --git a/server/helpers/custom-validators/videos.ts b/server/helpers/custom-validators/videos.ts index 9e8177f77..5f75ec27c 100644 --- a/server/helpers/custom-validators/videos.ts +++ b/server/helpers/custom-validators/videos.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { UploadFilesForCheck } from 'express' | 1 | import { UploadFilesForCheck } from 'express' |
2 | import magnetUtil from 'magnet-uri' | 2 | import { decode as magnetUriDecode } from 'magnet-uri' |
3 | import validator from 'validator' | 3 | import validator from 'validator' |
4 | import { VideoFilter, VideoInclude, VideoPrivacy, VideoRateType } from '@shared/models' | 4 | import { VideoFilter, VideoInclude, VideoPrivacy, VideoRateType } from '@shared/models' |
5 | import { | 5 | import { |
@@ -137,7 +137,7 @@ function isVideoFileSizeValid (value: string) { | |||
137 | function isVideoMagnetUriValid (value: string) { | 137 | function isVideoMagnetUriValid (value: string) { |
138 | if (!exists(value)) return false | 138 | if (!exists(value)) return false |
139 | 139 | ||
140 | const parsed = magnetUtil.decode(value) | 140 | const parsed = magnetUriDecode(value) |
141 | return parsed && isVideoFileInfoHashValid(parsed.infoHash) | 141 | return parsed && isVideoFileInfoHashValid(parsed.infoHash) |
142 | } | 142 | } |
143 | 143 | ||
diff --git a/server/helpers/image-utils.ts b/server/helpers/image-utils.ts index 05b258d8a..f86f7216d 100644 --- a/server/helpers/image-utils.ts +++ b/server/helpers/image-utils.ts | |||
@@ -1,6 +1,7 @@ | |||
1 | import { copy, readFile, remove, rename } from 'fs-extra' | 1 | import { copy, readFile, remove, rename } from 'fs-extra' |
2 | import Jimp, { read as jimpRead } from 'jimp' | 2 | import Jimp, { read as jimpRead } from 'jimp' |
3 | import { join } from 'path' | 3 | import { join } from 'path' |
4 | import { ColorActionName } from '@jimp/plugin-color' | ||
4 | import { getLowercaseExtension } from '@shared/core-utils' | 5 | import { getLowercaseExtension } from '@shared/core-utils' |
5 | import { buildUUID } from '@shared/extra-utils' | 6 | import { buildUUID } from '@shared/extra-utils' |
6 | import { convertWebPToJPG, generateThumbnailFromVideo, processGIF } from './ffmpeg' | 7 | import { convertWebPToJPG, generateThumbnailFromVideo, processGIF } from './ffmpeg' |
@@ -131,7 +132,7 @@ async function autoResize (options: { | |||
131 | 132 | ||
132 | if (sourceIsPortrait && !destIsPortraitOrSquare) { | 133 | if (sourceIsPortrait && !destIsPortraitOrSquare) { |
133 | const baseImage = sourceImage.cloneQuiet().cover(newSize.width, newSize.height) | 134 | const baseImage = sourceImage.cloneQuiet().cover(newSize.width, newSize.height) |
134 | .color([ { apply: 'shade', params: [ 50 ] } ]) | 135 | .color([ { apply: ColorActionName.SHADE, params: [ 50 ] } ]) |
135 | 136 | ||
136 | const topImage = sourceImage.cloneQuiet().contain(newSize.width, newSize.height) | 137 | const topImage = sourceImage.cloneQuiet().contain(newSize.width, newSize.height) |
137 | 138 | ||
diff --git a/server/helpers/webtorrent.ts b/server/helpers/webtorrent.ts index e690e3890..f33a7bccd 100644 --- a/server/helpers/webtorrent.ts +++ b/server/helpers/webtorrent.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import { decode, encode } from 'bencode' | 1 | import { decode, encode } from 'bencode' |
2 | import createTorrent from 'create-torrent' | 2 | import createTorrent from 'create-torrent' |
3 | import { createWriteStream, ensureDir, pathExists, readFile, remove, writeFile } from 'fs-extra' | 3 | import { createWriteStream, ensureDir, pathExists, readFile, remove, writeFile } from 'fs-extra' |
4 | import magnetUtil from 'magnet-uri' | 4 | import { encode as magnetUriEncode } from 'magnet-uri' |
5 | import parseTorrent from 'parse-torrent' | 5 | import parseTorrent from 'parse-torrent' |
6 | import { dirname, join } from 'path' | 6 | import { dirname, join } from 'path' |
7 | import { pipeline } from 'stream' | 7 | import { pipeline } from 'stream' |
@@ -185,7 +185,7 @@ function generateMagnetUri ( | |||
185 | name: video.name | 185 | name: video.name |
186 | } | 186 | } |
187 | 187 | ||
188 | return magnetUtil.encode(magnetHash) | 188 | return magnetUriEncode(magnetHash) |
189 | } | 189 | } |
190 | 190 | ||
191 | // --------------------------------------------------------------------------- | 191 | // --------------------------------------------------------------------------- |
diff --git a/server/lib/activitypub/videos/shared/object-to-model-attributes.ts b/server/lib/activitypub/videos/shared/object-to-model-attributes.ts index 86699c5b8..8fd0a816c 100644 --- a/server/lib/activitypub/videos/shared/object-to-model-attributes.ts +++ b/server/lib/activitypub/videos/shared/object-to-model-attributes.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { maxBy, minBy } from 'lodash' | 1 | import { maxBy, minBy } from 'lodash' |
2 | import magnetUtil from 'magnet-uri' | 2 | import { decode as magnetUriDecode } from 'magnet-uri' |
3 | import { basename } from 'path' | 3 | import { basename } from 'path' |
4 | import { isAPVideoFileUrlMetadataObject } from '@server/helpers/custom-validators/activitypub/videos' | 4 | import { isAPVideoFileUrlMetadataObject } from '@server/helpers/custom-validators/activitypub/videos' |
5 | import { isVideoFileInfoHashValid } from '@server/helpers/custom-validators/videos' | 5 | import { isVideoFileInfoHashValid } from '@server/helpers/custom-validators/videos' |
@@ -62,7 +62,7 @@ function getFileAttributesFromUrl ( | |||
62 | 62 | ||
63 | if (!magnet) throw new Error('Cannot find associated magnet uri for file ' + fileUrl.href) | 63 | if (!magnet) throw new Error('Cannot find associated magnet uri for file ' + fileUrl.href) |
64 | 64 | ||
65 | const parsed = magnetUtil.decode(magnet.href) | 65 | const parsed = magnetUriDecode(magnet.href) |
66 | if (!parsed || isVideoFileInfoHashValid(parsed.infoHash) === false) { | 66 | if (!parsed || isVideoFileInfoHashValid(parsed.infoHash) === false) { |
67 | throw new Error('Cannot parse magnet URI ' + magnet.href) | 67 | throw new Error('Cannot parse magnet URI ' + magnet.href) |
68 | } | 68 | } |
diff --git a/server/lib/auth/tokens-cache.ts b/server/lib/auth/tokens-cache.ts index 43efc7d02..e7b12159b 100644 --- a/server/lib/auth/tokens-cache.ts +++ b/server/lib/auth/tokens-cache.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import LRUCache from 'lru-cache' | 1 | import { LRUCache } from 'lru-cache' |
2 | import { MOAuthTokenUser } from '@server/types/models' | 2 | import { MOAuthTokenUser } from '@server/types/models' |
3 | import { LRU_CACHE } from '../../initializers/constants' | 3 | import { LRU_CACHE } from '../../initializers/constants' |
4 | 4 | ||
diff --git a/server/lib/local-actor.ts b/server/lib/local-actor.ts index 8c10ed700..16dc265a3 100644 --- a/server/lib/local-actor.ts +++ b/server/lib/local-actor.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { remove } from 'fs-extra' | 1 | import { remove } from 'fs-extra' |
2 | import LRUCache from 'lru-cache' | 2 | import { LRUCache } from 'lru-cache' |
3 | import { join } from 'path' | 3 | import { join } from 'path' |
4 | import { Transaction } from 'sequelize/types' | 4 | import { Transaction } from 'sequelize/types' |
5 | import { ActorModel } from '@server/models/actor/actor' | 5 | import { ActorModel } from '@server/models/actor/actor' |
diff --git a/server/lib/video-tokens-manager.ts b/server/lib/video-tokens-manager.ts index 17aa29cdd..660533528 100644 --- a/server/lib/video-tokens-manager.ts +++ b/server/lib/video-tokens-manager.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import LRUCache from 'lru-cache' | 1 | import { LRUCache } from 'lru-cache' |
2 | import { LRU_CACHE } from '@server/initializers/constants' | 2 | import { LRU_CACHE } from '@server/initializers/constants' |
3 | import { MUserAccountUrl } from '@server/types/models' | 3 | import { MUserAccountUrl } from '@server/types/models' |
4 | import { pick } from '@shared/core-utils' | 4 | import { pick } from '@shared/core-utils' |
diff --git a/server/middlewares/validators/static.ts b/server/middlewares/validators/static.ts index 45d56bcd6..9c2d890ba 100644 --- a/server/middlewares/validators/static.ts +++ b/server/middlewares/validators/static.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import express from 'express' | 1 | import express from 'express' |
2 | import { query } from 'express-validator' | 2 | import { query } from 'express-validator' |
3 | import LRUCache from 'lru-cache' | 3 | import { LRUCache } from 'lru-cache' |
4 | import { basename, dirname } from 'path' | 4 | import { basename, dirname } from 'path' |
5 | import { exists, isSafePeerTubeFilenameWithoutExtension, isUUIDValid, toBooleanOrNull } from '@server/helpers/custom-validators/misc' | 5 | import { exists, isSafePeerTubeFilenameWithoutExtension, isUUIDValid, toBooleanOrNull } from '@server/helpers/custom-validators/misc' |
6 | import { logger } from '@server/helpers/logger' | 6 | import { logger } from '@server/helpers/logger' |
diff --git a/server/tests/api/check-params/upload-quota.ts b/server/tests/api/check-params/upload-quota.ts index 008537524..06698c056 100644 --- a/server/tests/api/check-params/upload-quota.ts +++ b/server/tests/api/check-params/upload-quota.ts | |||
@@ -54,7 +54,7 @@ describe('Test upload quota', function () { | |||
54 | }) | 54 | }) |
55 | 55 | ||
56 | it('Should fail with a registered user having too many videos with resumable upload', async function () { | 56 | it('Should fail with a registered user having too many videos with resumable upload', async function () { |
57 | this.timeout(30000) | 57 | this.timeout(120000) |
58 | 58 | ||
59 | const user = { username: 'registered' + randomInt(1, 1500), password: 'password' } | 59 | const user = { username: 'registered' + randomInt(1, 1500), password: 'password' } |
60 | await server.registrations.register(user) | 60 | await server.registrations.register(user) |
diff --git a/server/tests/api/live/live-constraints.ts b/server/tests/api/live/live-constraints.ts index 7af6af193..89ea46578 100644 --- a/server/tests/api/live/live-constraints.ts +++ b/server/tests/api/live/live-constraints.ts | |||
@@ -183,7 +183,7 @@ describe('Test live constraints', function () { | |||
183 | await wait(500) | 183 | await wait(500) |
184 | 184 | ||
185 | quotaUser = await servers[0].users.getMyQuotaUsed({ token: userAccessToken }) | 185 | quotaUser = await servers[0].users.getMyQuotaUsed({ token: userAccessToken }) |
186 | } while (quotaUser.videoQuotaUsed < baseQuota.videoQuotaUsed) | 186 | } while (quotaUser.videoQuotaUsed <= baseQuota.videoQuotaUsed) |
187 | 187 | ||
188 | const { data } = await servers[0].users.list() | 188 | const { data } = await servers[0].users.list() |
189 | const quotaAdmin = data.find(u => u.username === 'user1') | 189 | const quotaAdmin = data.find(u => u.username === 'user1') |
@@ -210,7 +210,7 @@ describe('Test live constraints', function () { | |||
210 | live: { | 210 | live: { |
211 | enabled: true, | 211 | enabled: true, |
212 | allowReplay: true, | 212 | allowReplay: true, |
213 | maxDuration: 3, | 213 | maxDuration: 10, |
214 | transcoding: { | 214 | transcoding: { |
215 | enabled: true, | 215 | enabled: true, |
216 | resolutions: ConfigCommand.getCustomConfigResolutions(true) | 216 | resolutions: ConfigCommand.getCustomConfigResolutions(true) |
diff --git a/server/tests/api/live/live-fast-restream.ts b/server/tests/api/live/live-fast-restream.ts index 2169393c2..d7085a957 100644 --- a/server/tests/api/live/live-fast-restream.ts +++ b/server/tests/api/live/live-fast-restream.ts | |||
@@ -65,8 +65,7 @@ describe('Fast restream in live', function () { | |||
65 | server, | 65 | server, |
66 | videoUUID: liveVideoUUID, | 66 | videoUUID: liveVideoUUID, |
67 | segment: 1, | 67 | segment: 1, |
68 | playlistNumber: 0, | 68 | playlistNumber: 0 |
69 | objectStorage: false | ||
70 | }) | 69 | }) |
71 | 70 | ||
72 | return { ffmpegCommand, liveVideoUUID } | 71 | return { ffmpegCommand, liveVideoUUID } |
diff --git a/server/tests/api/live/live-save-replay.ts b/server/tests/api/live/live-save-replay.ts index 05ffe8af9..8985c9b39 100644 --- a/server/tests/api/live/live-save-replay.ts +++ b/server/tests/api/live/live-save-replay.ts | |||
@@ -164,7 +164,7 @@ describe('Save replay setting', function () { | |||
164 | }) | 164 | }) |
165 | 165 | ||
166 | it('Should correctly have updated the live and federated it when streaming in the live', async function () { | 166 | it('Should correctly have updated the live and federated it when streaming in the live', async function () { |
167 | this.timeout(60000) | 167 | this.timeout(120000) |
168 | 168 | ||
169 | ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) | 169 | ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) |
170 | 170 | ||
@@ -179,7 +179,7 @@ describe('Save replay setting', function () { | |||
179 | }) | 179 | }) |
180 | 180 | ||
181 | it('Should correctly delete the video files after the stream ended', async function () { | 181 | it('Should correctly delete the video files after the stream ended', async function () { |
182 | this.timeout(60000) | 182 | this.timeout(120000) |
183 | 183 | ||
184 | sessionEndDateMin = new Date() | 184 | sessionEndDateMin = new Date() |
185 | await stopFfmpeg(ffmpegCommand) | 185 | await stopFfmpeg(ffmpegCommand) |
@@ -217,7 +217,7 @@ describe('Save replay setting', function () { | |||
217 | }) | 217 | }) |
218 | 218 | ||
219 | it('Should correctly terminate the stream on blacklist and delete the live', async function () { | 219 | it('Should correctly terminate the stream on blacklist and delete the live', async function () { |
220 | this.timeout(60000) | 220 | this.timeout(120000) |
221 | 221 | ||
222 | await publishLiveAndBlacklist({ permanent: false, replay: false }) | 222 | await publishLiveAndBlacklist({ permanent: false, replay: false }) |
223 | 223 | ||
@@ -241,7 +241,7 @@ describe('Save replay setting', function () { | |||
241 | }) | 241 | }) |
242 | 242 | ||
243 | it('Should correctly terminate the stream on delete and delete the video', async function () { | 243 | it('Should correctly terminate the stream on delete and delete the video', async function () { |
244 | this.timeout(60000) | 244 | this.timeout(120000) |
245 | 245 | ||
246 | await publishLiveAndDelete({ permanent: false, replay: false }) | 246 | await publishLiveAndDelete({ permanent: false, replay: false }) |
247 | 247 | ||
@@ -253,7 +253,7 @@ describe('Save replay setting', function () { | |||
253 | describe('With save replay enabled on non permanent live', function () { | 253 | describe('With save replay enabled on non permanent live', function () { |
254 | 254 | ||
255 | it('Should correctly create and federate the "waiting for stream" live', async function () { | 255 | it('Should correctly create and federate the "waiting for stream" live', async function () { |
256 | this.timeout(60000) | 256 | this.timeout(120000) |
257 | 257 | ||
258 | liveVideoUUID = await createLiveWrapper({ permanent: false, replay: true, replaySettings: { privacy: VideoPrivacy.UNLISTED } }) | 258 | liveVideoUUID = await createLiveWrapper({ permanent: false, replay: true, replaySettings: { privacy: VideoPrivacy.UNLISTED } }) |
259 | 259 | ||
@@ -265,7 +265,7 @@ describe('Save replay setting', function () { | |||
265 | }) | 265 | }) |
266 | 266 | ||
267 | it('Should correctly have updated the live and federated it when streaming in the live', async function () { | 267 | it('Should correctly have updated the live and federated it when streaming in the live', async function () { |
268 | this.timeout(60000) | 268 | this.timeout(120000) |
269 | 269 | ||
270 | ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) | 270 | ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) |
271 | await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID) | 271 | await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID) |
@@ -278,7 +278,7 @@ describe('Save replay setting', function () { | |||
278 | }) | 278 | }) |
279 | 279 | ||
280 | it('Should correctly have saved the live and federated it after the streaming', async function () { | 280 | it('Should correctly have saved the live and federated it after the streaming', async function () { |
281 | this.timeout(60000) | 281 | this.timeout(120000) |
282 | 282 | ||
283 | const session = await servers[0].live.findLatestSession({ videoId: liveVideoUUID }) | 283 | const session = await servers[0].live.findLatestSession({ videoId: liveVideoUUID }) |
284 | expect(session.endDate).to.not.exist | 284 | expect(session.endDate).to.not.exist |
@@ -319,7 +319,7 @@ describe('Save replay setting', function () { | |||
319 | }) | 319 | }) |
320 | 320 | ||
321 | it('Should update the saved live and correctly federate the updated attributes', async function () { | 321 | it('Should update the saved live and correctly federate the updated attributes', async function () { |
322 | this.timeout(60000) | 322 | this.timeout(120000) |
323 | 323 | ||
324 | await servers[0].videos.update({ id: liveVideoUUID, attributes: { name: 'video updated', privacy: VideoPrivacy.PUBLIC } }) | 324 | await servers[0].videos.update({ id: liveVideoUUID, attributes: { name: 'video updated', privacy: VideoPrivacy.PUBLIC } }) |
325 | await waitJobs(servers) | 325 | await waitJobs(servers) |
@@ -352,7 +352,7 @@ describe('Save replay setting', function () { | |||
352 | }) | 352 | }) |
353 | 353 | ||
354 | it('Should correctly terminate the stream on delete and delete the video', async function () { | 354 | it('Should correctly terminate the stream on delete and delete the video', async function () { |
355 | this.timeout(60000) | 355 | this.timeout(120000) |
356 | 356 | ||
357 | await publishLiveAndDelete({ permanent: false, replay: true, replaySettings: { privacy: VideoPrivacy.PUBLIC } }) | 357 | await publishLiveAndDelete({ permanent: false, replay: true, replaySettings: { privacy: VideoPrivacy.PUBLIC } }) |
358 | 358 | ||
@@ -367,7 +367,7 @@ describe('Save replay setting', function () { | |||
367 | describe('With a first live and its replay', function () { | 367 | describe('With a first live and its replay', function () { |
368 | 368 | ||
369 | it('Should correctly create and federate the "waiting for stream" live', async function () { | 369 | it('Should correctly create and federate the "waiting for stream" live', async function () { |
370 | this.timeout(60000) | 370 | this.timeout(120000) |
371 | 371 | ||
372 | liveVideoUUID = await createLiveWrapper({ permanent: true, replay: true, replaySettings: { privacy: VideoPrivacy.UNLISTED } }) | 372 | liveVideoUUID = await createLiveWrapper({ permanent: true, replay: true, replaySettings: { privacy: VideoPrivacy.UNLISTED } }) |
373 | 373 | ||
@@ -379,7 +379,7 @@ describe('Save replay setting', function () { | |||
379 | }) | 379 | }) |
380 | 380 | ||
381 | it('Should correctly have updated the live and federated it when streaming in the live', async function () { | 381 | it('Should correctly have updated the live and federated it when streaming in the live', async function () { |
382 | this.timeout(60000) | 382 | this.timeout(120000) |
383 | 383 | ||
384 | ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) | 384 | ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) |
385 | await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID) | 385 | await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID) |
@@ -392,7 +392,7 @@ describe('Save replay setting', function () { | |||
392 | }) | 392 | }) |
393 | 393 | ||
394 | it('Should correctly have saved the live and federated it after the streaming', async function () { | 394 | it('Should correctly have saved the live and federated it after the streaming', async function () { |
395 | this.timeout(60000) | 395 | this.timeout(120000) |
396 | 396 | ||
397 | const liveDetails = await servers[0].videos.get({ id: liveVideoUUID }) | 397 | const liveDetails = await servers[0].videos.get({ id: liveVideoUUID }) |
398 | 398 | ||
@@ -457,7 +457,7 @@ describe('Save replay setting', function () { | |||
457 | }) | 457 | }) |
458 | 458 | ||
459 | it('Should correctly have updated the live and federated it when streaming in the live', async function () { | 459 | it('Should correctly have updated the live and federated it when streaming in the live', async function () { |
460 | this.timeout(60000) | 460 | this.timeout(120000) |
461 | 461 | ||
462 | ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) | 462 | ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) |
463 | await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID) | 463 | await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID) |
@@ -470,7 +470,7 @@ describe('Save replay setting', function () { | |||
470 | }) | 470 | }) |
471 | 471 | ||
472 | it('Should correctly have saved the live and federated it after the streaming', async function () { | 472 | it('Should correctly have saved the live and federated it after the streaming', async function () { |
473 | this.timeout(60000) | 473 | this.timeout(120000) |
474 | 474 | ||
475 | const liveDetails = await servers[0].videos.get({ id: liveVideoUUID }) | 475 | const liveDetails = await servers[0].videos.get({ id: liveVideoUUID }) |
476 | 476 | ||
@@ -547,7 +547,7 @@ describe('Save replay setting', function () { | |||
547 | }) | 547 | }) |
548 | 548 | ||
549 | it('Should correctly terminate the stream on delete and not save the video', async function () { | 549 | it('Should correctly terminate the stream on delete and not save the video', async function () { |
550 | this.timeout(60000) | 550 | this.timeout(120000) |
551 | 551 | ||
552 | const { liveDetails } = await publishLiveAndDelete({ | 552 | const { liveDetails } = await publishLiveAndDelete({ |
553 | permanent: true, | 553 | permanent: true, |
diff --git a/server/tests/api/live/live.ts b/server/tests/api/live/live.ts index 65ebbc5f7..7ab67b126 100644 --- a/server/tests/api/live/live.ts +++ b/server/tests/api/live/live.ts | |||
@@ -423,7 +423,6 @@ describe('Test live', function () { | |||
423 | servers, | 423 | servers, |
424 | liveVideoId, | 424 | liveVideoId, |
425 | resolutions: [ 720 ], | 425 | resolutions: [ 720 ], |
426 | objectStorage: false, | ||
427 | transcoded: true | 426 | transcoded: true |
428 | }) | 427 | }) |
429 | 428 | ||
@@ -459,7 +458,6 @@ describe('Test live', function () { | |||
459 | servers, | 458 | servers, |
460 | liveVideoId, | 459 | liveVideoId, |
461 | resolutions: resolutions.concat([ 720 ]), | 460 | resolutions: resolutions.concat([ 720 ]), |
462 | objectStorage: false, | ||
463 | transcoded: true | 461 | transcoded: true |
464 | }) | 462 | }) |
465 | 463 | ||
@@ -512,7 +510,6 @@ describe('Test live', function () { | |||
512 | servers, | 510 | servers, |
513 | liveVideoId, | 511 | liveVideoId, |
514 | resolutions, | 512 | resolutions, |
515 | objectStorage: false, | ||
516 | transcoded: true | 513 | transcoded: true |
517 | }) | 514 | }) |
518 | 515 | ||
@@ -609,7 +606,6 @@ describe('Test live', function () { | |||
609 | servers, | 606 | servers, |
610 | liveVideoId, | 607 | liveVideoId, |
611 | resolutions, | 608 | resolutions, |
612 | objectStorage: false, | ||
613 | transcoded: true | 609 | transcoded: true |
614 | }) | 610 | }) |
615 | 611 | ||
@@ -646,7 +642,6 @@ describe('Test live', function () { | |||
646 | servers, | 642 | servers, |
647 | liveVideoId, | 643 | liveVideoId, |
648 | resolutions: [ 720 ], | 644 | resolutions: [ 720 ], |
649 | objectStorage: false, | ||
650 | transcoded: true | 645 | transcoded: true |
651 | }) | 646 | }) |
652 | 647 | ||
@@ -720,8 +715,7 @@ describe('Test live', function () { | |||
720 | server: servers[0], | 715 | server: servers[0], |
721 | videoUUID, | 716 | videoUUID, |
722 | playlistNumber: 0, | 717 | playlistNumber: 0, |
723 | segment: 2, | 718 | segment: 2 |
724 | objectStorage: false | ||
725 | }) | 719 | }) |
726 | } | 720 | } |
727 | 721 | ||
diff --git a/server/tests/api/object-storage/live.ts b/server/tests/api/object-storage/live.ts index 7f8db40e5..07ff4763b 100644 --- a/server/tests/api/object-storage/live.ts +++ b/server/tests/api/object-storage/live.ts | |||
@@ -36,7 +36,14 @@ async function createLive (server: PeerTubeServer, permanent: boolean) { | |||
36 | return uuid | 36 | return uuid |
37 | } | 37 | } |
38 | 38 | ||
39 | async function checkFilesExist (servers: PeerTubeServer[], videoUUID: string, numberOfFiles: number) { | 39 | async function checkFilesExist (options: { |
40 | servers: PeerTubeServer[] | ||
41 | videoUUID: string | ||
42 | numberOfFiles: number | ||
43 | objectStorage: ObjectStorageCommand | ||
44 | }) { | ||
45 | const { servers, videoUUID, numberOfFiles, objectStorage } = options | ||
46 | |||
40 | for (const server of servers) { | 47 | for (const server of servers) { |
41 | const video = await server.videos.get({ id: videoUUID }) | 48 | const video = await server.videos.get({ id: videoUUID }) |
42 | 49 | ||
@@ -47,14 +54,21 @@ async function checkFilesExist (servers: PeerTubeServer[], videoUUID: string, nu | |||
47 | expect(files).to.have.lengthOf(numberOfFiles) | 54 | expect(files).to.have.lengthOf(numberOfFiles) |
48 | 55 | ||
49 | for (const file of files) { | 56 | for (const file of files) { |
50 | expectStartWith(file.fileUrl, ObjectStorageCommand.getMockPlaylistBaseUrl()) | 57 | expectStartWith(file.fileUrl, objectStorage.getMockPlaylistBaseUrl()) |
51 | 58 | ||
52 | await makeRawRequest({ url: file.fileUrl, expectedStatus: HttpStatusCode.OK_200 }) | 59 | await makeRawRequest({ url: file.fileUrl, expectedStatus: HttpStatusCode.OK_200 }) |
53 | } | 60 | } |
54 | } | 61 | } |
55 | } | 62 | } |
56 | 63 | ||
57 | async function checkFilesCleanup (server: PeerTubeServer, videoUUID: string, resolutions: number[]) { | 64 | async function checkFilesCleanup (options: { |
65 | server: PeerTubeServer | ||
66 | videoUUID: string | ||
67 | resolutions: number[] | ||
68 | objectStorage: ObjectStorageCommand | ||
69 | }) { | ||
70 | const { server, videoUUID, resolutions, objectStorage } = options | ||
71 | |||
58 | const resolutionFiles = resolutions.map((_value, i) => `${i}.m3u8`) | 72 | const resolutionFiles = resolutions.map((_value, i) => `${i}.m3u8`) |
59 | 73 | ||
60 | for (const playlistName of [ 'master.m3u8' ].concat(resolutionFiles)) { | 74 | for (const playlistName of [ 'master.m3u8' ].concat(resolutionFiles)) { |
@@ -62,7 +76,7 @@ async function checkFilesCleanup (server: PeerTubeServer, videoUUID: string, res | |||
62 | videoUUID, | 76 | videoUUID, |
63 | playlistName, | 77 | playlistName, |
64 | expectedStatus: HttpStatusCode.NOT_FOUND_404, | 78 | expectedStatus: HttpStatusCode.NOT_FOUND_404, |
65 | objectStorage: true | 79 | objectStorage |
66 | }) | 80 | }) |
67 | } | 81 | } |
68 | 82 | ||
@@ -70,7 +84,7 @@ async function checkFilesCleanup (server: PeerTubeServer, videoUUID: string, res | |||
70 | videoUUID, | 84 | videoUUID, |
71 | playlistNumber: 0, | 85 | playlistNumber: 0, |
72 | segment: 0, | 86 | segment: 0, |
73 | objectStorage: true, | 87 | objectStorage, |
74 | expectedStatus: HttpStatusCode.NOT_FOUND_404 | 88 | expectedStatus: HttpStatusCode.NOT_FOUND_404 |
75 | }) | 89 | }) |
76 | } | 90 | } |
@@ -80,13 +94,13 @@ describe('Object storage for lives', function () { | |||
80 | 94 | ||
81 | let servers: PeerTubeServer[] | 95 | let servers: PeerTubeServer[] |
82 | let sqlCommandServer1: SQLCommand | 96 | let sqlCommandServer1: SQLCommand |
97 | const objectStorage = new ObjectStorageCommand() | ||
83 | 98 | ||
84 | before(async function () { | 99 | before(async function () { |
85 | this.timeout(120000) | 100 | this.timeout(120000) |
86 | 101 | ||
87 | await ObjectStorageCommand.prepareDefaultMockBuckets() | 102 | await objectStorage.prepareDefaultMockBuckets() |
88 | 103 | servers = await createMultipleServers(2, objectStorage.getDefaultMockConfig()) | |
89 | servers = await createMultipleServers(2, ObjectStorageCommand.getDefaultMockConfig()) | ||
90 | 104 | ||
91 | await setAccessTokensToServers(servers) | 105 | await setAccessTokensToServers(servers) |
92 | await setDefaultVideoChannel(servers) | 106 | await setDefaultVideoChannel(servers) |
@@ -119,7 +133,7 @@ describe('Object storage for lives', function () { | |||
119 | liveVideoId: videoUUID, | 133 | liveVideoId: videoUUID, |
120 | resolutions: [ 720 ], | 134 | resolutions: [ 720 ], |
121 | transcoded: false, | 135 | transcoded: false, |
122 | objectStorage: true | 136 | objectStorage |
123 | }) | 137 | }) |
124 | 138 | ||
125 | await stopFfmpeg(ffmpegCommand) | 139 | await stopFfmpeg(ffmpegCommand) |
@@ -131,11 +145,11 @@ describe('Object storage for lives', function () { | |||
131 | await waitUntilLiveReplacedByReplayOnAllServers(servers, videoUUID) | 145 | await waitUntilLiveReplacedByReplayOnAllServers(servers, videoUUID) |
132 | await waitJobs(servers) | 146 | await waitJobs(servers) |
133 | 147 | ||
134 | await checkFilesExist(servers, videoUUID, 1) | 148 | await checkFilesExist({ servers, videoUUID, numberOfFiles: 1, objectStorage }) |
135 | }) | 149 | }) |
136 | 150 | ||
137 | it('Should have cleaned up live files from object storage', async function () { | 151 | it('Should have cleaned up live files from object storage', async function () { |
138 | await checkFilesCleanup(servers[0], videoUUID, [ 720 ]) | 152 | await checkFilesCleanup({ server: servers[0], videoUUID, resolutions: [ 720 ], objectStorage }) |
139 | }) | 153 | }) |
140 | }) | 154 | }) |
141 | 155 | ||
@@ -166,7 +180,7 @@ describe('Object storage for lives', function () { | |||
166 | liveVideoId: videoUUIDNonPermanent, | 180 | liveVideoId: videoUUIDNonPermanent, |
167 | resolutions, | 181 | resolutions, |
168 | transcoded: true, | 182 | transcoded: true, |
169 | objectStorage: true | 183 | objectStorage |
170 | }) | 184 | }) |
171 | 185 | ||
172 | await stopFfmpeg(ffmpegCommand) | 186 | await stopFfmpeg(ffmpegCommand) |
@@ -178,11 +192,11 @@ describe('Object storage for lives', function () { | |||
178 | await waitUntilLiveReplacedByReplayOnAllServers(servers, videoUUIDNonPermanent) | 192 | await waitUntilLiveReplacedByReplayOnAllServers(servers, videoUUIDNonPermanent) |
179 | await waitJobs(servers) | 193 | await waitJobs(servers) |
180 | 194 | ||
181 | await checkFilesExist(servers, videoUUIDNonPermanent, 5) | 195 | await checkFilesExist({ servers, videoUUID: videoUUIDNonPermanent, numberOfFiles: 5, objectStorage }) |
182 | }) | 196 | }) |
183 | 197 | ||
184 | it('Should have cleaned up live files from object storage', async function () { | 198 | it('Should have cleaned up live files from object storage', async function () { |
185 | await checkFilesCleanup(servers[0], videoUUIDNonPermanent, resolutions) | 199 | await checkFilesCleanup({ server: servers[0], videoUUID: videoUUIDNonPermanent, resolutions, objectStorage }) |
186 | }) | 200 | }) |
187 | }) | 201 | }) |
188 | 202 | ||
@@ -206,7 +220,7 @@ describe('Object storage for lives', function () { | |||
206 | liveVideoId: videoUUIDPermanent, | 220 | liveVideoId: videoUUIDPermanent, |
207 | resolutions, | 221 | resolutions, |
208 | transcoded: true, | 222 | transcoded: true, |
209 | objectStorage: true | 223 | objectStorage |
210 | }) | 224 | }) |
211 | 225 | ||
212 | await stopFfmpeg(ffmpegCommand) | 226 | await stopFfmpeg(ffmpegCommand) |
@@ -221,11 +235,11 @@ describe('Object storage for lives', function () { | |||
221 | const videoLiveDetails = await servers[0].videos.get({ id: videoUUIDPermanent }) | 235 | const videoLiveDetails = await servers[0].videos.get({ id: videoUUIDPermanent }) |
222 | const replay = await findExternalSavedVideo(servers[0], videoLiveDetails) | 236 | const replay = await findExternalSavedVideo(servers[0], videoLiveDetails) |
223 | 237 | ||
224 | await checkFilesExist(servers, replay.uuid, 5) | 238 | await checkFilesExist({ servers, videoUUID: replay.uuid, numberOfFiles: 5, objectStorage }) |
225 | }) | 239 | }) |
226 | 240 | ||
227 | it('Should have cleaned up live files from object storage', async function () { | 241 | it('Should have cleaned up live files from object storage', async function () { |
228 | await checkFilesCleanup(servers[0], videoUUIDPermanent, resolutions) | 242 | await checkFilesCleanup({ server: servers[0], videoUUID: videoUUIDPermanent, resolutions, objectStorage }) |
229 | }) | 243 | }) |
230 | }) | 244 | }) |
231 | }) | 245 | }) |
@@ -238,9 +252,10 @@ describe('Object storage for lives', function () { | |||
238 | this.timeout(120000) | 252 | this.timeout(120000) |
239 | 253 | ||
240 | const port = await mockObjectStorageProxy.initialize() | 254 | const port = await mockObjectStorageProxy.initialize() |
241 | baseMockUrl = `http://127.0.0.1:${port}/streaming-playlists` | 255 | const bucketName = objectStorage.getMockStreamingPlaylistsBucketName() |
256 | baseMockUrl = `http://127.0.0.1:${port}/${bucketName}` | ||
242 | 257 | ||
243 | await ObjectStorageCommand.createMockBucket('streaming-playlists') | 258 | await objectStorage.prepareDefaultMockBuckets() |
244 | 259 | ||
245 | const config = { | 260 | const config = { |
246 | object_storage: { | 261 | object_storage: { |
@@ -251,7 +266,7 @@ describe('Object storage for lives', function () { | |||
251 | credentials: ObjectStorageCommand.getMockCredentialsConfig(), | 266 | credentials: ObjectStorageCommand.getMockCredentialsConfig(), |
252 | 267 | ||
253 | streaming_playlists: { | 268 | streaming_playlists: { |
254 | bucket_name: 'streaming-playlists', | 269 | bucket_name: bucketName, |
255 | prefix: '', | 270 | prefix: '', |
256 | base_url: baseMockUrl | 271 | base_url: baseMockUrl |
257 | } | 272 | } |
@@ -279,7 +294,7 @@ describe('Object storage for lives', function () { | |||
279 | liveVideoId: videoUUIDPermanent, | 294 | liveVideoId: videoUUIDPermanent, |
280 | resolutions: [ 720 ], | 295 | resolutions: [ 720 ], |
281 | transcoded: true, | 296 | transcoded: true, |
282 | objectStorage: true, | 297 | objectStorage, |
283 | objectStorageBaseUrl: baseMockUrl | 298 | objectStorageBaseUrl: baseMockUrl |
284 | }) | 299 | }) |
285 | 300 | ||
@@ -289,6 +304,7 @@ describe('Object storage for lives', function () { | |||
289 | 304 | ||
290 | after(async function () { | 305 | after(async function () { |
291 | await sqlCommandServer1.cleanup() | 306 | await sqlCommandServer1.cleanup() |
307 | await objectStorage.cleanupMock() | ||
292 | 308 | ||
293 | await cleanupTests(servers) | 309 | await cleanupTests(servers) |
294 | }) | 310 | }) |
diff --git a/server/tests/api/object-storage/video-imports.ts b/server/tests/api/object-storage/video-imports.ts index d5fd91b6a..57150e5a6 100644 --- a/server/tests/api/object-storage/video-imports.ts +++ b/server/tests/api/object-storage/video-imports.ts | |||
@@ -32,13 +32,14 @@ describe('Object storage for video import', function () { | |||
32 | if (areMockObjectStorageTestsDisabled()) return | 32 | if (areMockObjectStorageTestsDisabled()) return |
33 | 33 | ||
34 | let server: PeerTubeServer | 34 | let server: PeerTubeServer |
35 | const objectStorage = new ObjectStorageCommand() | ||
35 | 36 | ||
36 | before(async function () { | 37 | before(async function () { |
37 | this.timeout(120000) | 38 | this.timeout(120000) |
38 | 39 | ||
39 | await ObjectStorageCommand.prepareDefaultMockBuckets() | 40 | await objectStorage.prepareDefaultMockBuckets() |
40 | 41 | ||
41 | server = await createSingleServer(1, ObjectStorageCommand.getDefaultMockConfig()) | 42 | server = await createSingleServer(1, objectStorage.getDefaultMockConfig()) |
42 | 43 | ||
43 | await setAccessTokensToServers([ server ]) | 44 | await setAccessTokensToServers([ server ]) |
44 | await setDefaultVideoChannel([ server ]) | 45 | await setDefaultVideoChannel([ server ]) |
@@ -64,7 +65,7 @@ describe('Object storage for video import', function () { | |||
64 | expect(video.streamingPlaylists).to.have.lengthOf(0) | 65 | expect(video.streamingPlaylists).to.have.lengthOf(0) |
65 | 66 | ||
66 | const fileUrl = video.files[0].fileUrl | 67 | const fileUrl = video.files[0].fileUrl |
67 | expectStartWith(fileUrl, ObjectStorageCommand.getMockWebTorrentBaseUrl()) | 68 | expectStartWith(fileUrl, objectStorage.getMockWebVideosBaseUrl()) |
68 | 69 | ||
69 | await makeRawRequest({ url: fileUrl, expectedStatus: HttpStatusCode.OK_200 }) | 70 | await makeRawRequest({ url: fileUrl, expectedStatus: HttpStatusCode.OK_200 }) |
70 | }) | 71 | }) |
@@ -89,13 +90,13 @@ describe('Object storage for video import', function () { | |||
89 | expect(video.streamingPlaylists[0].files).to.have.lengthOf(5) | 90 | expect(video.streamingPlaylists[0].files).to.have.lengthOf(5) |
90 | 91 | ||
91 | for (const file of video.files) { | 92 | for (const file of video.files) { |
92 | expectStartWith(file.fileUrl, ObjectStorageCommand.getMockWebTorrentBaseUrl()) | 93 | expectStartWith(file.fileUrl, objectStorage.getMockWebVideosBaseUrl()) |
93 | 94 | ||
94 | await makeRawRequest({ url: file.fileUrl, expectedStatus: HttpStatusCode.OK_200 }) | 95 | await makeRawRequest({ url: file.fileUrl, expectedStatus: HttpStatusCode.OK_200 }) |
95 | } | 96 | } |
96 | 97 | ||
97 | for (const file of video.streamingPlaylists[0].files) { | 98 | for (const file of video.streamingPlaylists[0].files) { |
98 | expectStartWith(file.fileUrl, ObjectStorageCommand.getMockPlaylistBaseUrl()) | 99 | expectStartWith(file.fileUrl, objectStorage.getMockPlaylistBaseUrl()) |
99 | 100 | ||
100 | await makeRawRequest({ url: file.fileUrl, expectedStatus: HttpStatusCode.OK_200 }) | 101 | await makeRawRequest({ url: file.fileUrl, expectedStatus: HttpStatusCode.OK_200 }) |
101 | } | 102 | } |
@@ -103,6 +104,8 @@ describe('Object storage for video import', function () { | |||
103 | }) | 104 | }) |
104 | 105 | ||
105 | after(async function () { | 106 | after(async function () { |
107 | await objectStorage.cleanupMock() | ||
108 | |||
106 | await cleanupTests([ server ]) | 109 | await cleanupTests([ server ]) |
107 | }) | 110 | }) |
108 | }) | 111 | }) |
diff --git a/server/tests/api/object-storage/videos.ts b/server/tests/api/object-storage/videos.ts index 77ed78ae1..f837d9966 100644 --- a/server/tests/api/object-storage/videos.ts +++ b/server/tests/api/object-storage/videos.ts | |||
@@ -145,6 +145,7 @@ function runTestSuite (options: { | |||
145 | 145 | ||
146 | let servers: PeerTubeServer[] | 146 | let servers: PeerTubeServer[] |
147 | let sqlCommands: SQLCommand[] = [] | 147 | let sqlCommands: SQLCommand[] = [] |
148 | const objectStorage = new ObjectStorageCommand() | ||
148 | 149 | ||
149 | let keptUrls: string[] = [] | 150 | let keptUrls: string[] = [] |
150 | 151 | ||
@@ -159,8 +160,8 @@ function runTestSuite (options: { | |||
159 | ? `http://127.0.0.1:${port}` | 160 | ? `http://127.0.0.1:${port}` |
160 | : undefined | 161 | : undefined |
161 | 162 | ||
162 | await ObjectStorageCommand.createMockBucket(options.playlistBucket) | 163 | await objectStorage.createMockBucket(options.playlistBucket) |
163 | await ObjectStorageCommand.createMockBucket(options.webtorrentBucket) | 164 | await objectStorage.createMockBucket(options.webtorrentBucket) |
164 | 165 | ||
165 | const config = { | 166 | const config = { |
166 | object_storage: { | 167 | object_storage: { |
@@ -275,6 +276,7 @@ function runTestSuite (options: { | |||
275 | 276 | ||
276 | after(async function () { | 277 | after(async function () { |
277 | await mockObjectStorageProxy.terminate() | 278 | await mockObjectStorageProxy.terminate() |
279 | await objectStorage.cleanupMock() | ||
278 | 280 | ||
279 | for (const sqlCommand of sqlCommands) { | 281 | for (const sqlCommand of sqlCommands) { |
280 | await sqlCommand.cleanup() | 282 | await sqlCommand.cleanup() |
@@ -287,26 +289,12 @@ function runTestSuite (options: { | |||
287 | describe('Object storage for videos', function () { | 289 | describe('Object storage for videos', function () { |
288 | if (areMockObjectStorageTestsDisabled()) return | 290 | if (areMockObjectStorageTestsDisabled()) return |
289 | 291 | ||
292 | const objectStorage = new ObjectStorageCommand() | ||
293 | |||
290 | describe('Test config', function () { | 294 | describe('Test config', function () { |
291 | let server: PeerTubeServer | 295 | let server: PeerTubeServer |
292 | 296 | ||
293 | const baseConfig = { | 297 | const baseConfig = objectStorage.getDefaultMockConfig() |
294 | object_storage: { | ||
295 | enabled: true, | ||
296 | endpoint: 'http://' + ObjectStorageCommand.getMockEndpointHost(), | ||
297 | region: ObjectStorageCommand.getMockRegion(), | ||
298 | |||
299 | credentials: ObjectStorageCommand.getMockCredentialsConfig(), | ||
300 | |||
301 | streaming_playlists: { | ||
302 | bucket_name: ObjectStorageCommand.DEFAULT_PLAYLIST_MOCK_BUCKET | ||
303 | }, | ||
304 | |||
305 | videos: { | ||
306 | bucket_name: ObjectStorageCommand.DEFAULT_WEBTORRENT_MOCK_BUCKET | ||
307 | } | ||
308 | } | ||
309 | } | ||
310 | 298 | ||
311 | const badCredentials = { | 299 | const badCredentials = { |
312 | access_key_id: 'AKIAIOSFODNN7EXAMPLE', | 300 | access_key_id: 'AKIAIOSFODNN7EXAMPLE', |
@@ -334,7 +322,7 @@ describe('Object storage for videos', function () { | |||
334 | it('Should fail with bad credentials', async function () { | 322 | it('Should fail with bad credentials', async function () { |
335 | this.timeout(60000) | 323 | this.timeout(60000) |
336 | 324 | ||
337 | await ObjectStorageCommand.prepareDefaultMockBuckets() | 325 | await objectStorage.prepareDefaultMockBuckets() |
338 | 326 | ||
339 | const config = merge({}, baseConfig, { | 327 | const config = merge({}, baseConfig, { |
340 | object_storage: { | 328 | object_storage: { |
@@ -358,7 +346,7 @@ describe('Object storage for videos', function () { | |||
358 | it('Should succeed with credentials from env', async function () { | 346 | it('Should succeed with credentials from env', async function () { |
359 | this.timeout(60000) | 347 | this.timeout(60000) |
360 | 348 | ||
361 | await ObjectStorageCommand.prepareDefaultMockBuckets() | 349 | await objectStorage.prepareDefaultMockBuckets() |
362 | 350 | ||
363 | const config = merge({}, baseConfig, { | 351 | const config = merge({}, baseConfig, { |
364 | object_storage: { | 352 | object_storage: { |
@@ -385,25 +373,27 @@ describe('Object storage for videos', function () { | |||
385 | await waitJobs([ server ], { skipDelayed: true }) | 373 | await waitJobs([ server ], { skipDelayed: true }) |
386 | const video = await server.videos.get({ id: uuid }) | 374 | const video = await server.videos.get({ id: uuid }) |
387 | 375 | ||
388 | expectStartWith(video.files[0].fileUrl, ObjectStorageCommand.getMockWebTorrentBaseUrl()) | 376 | expectStartWith(video.files[0].fileUrl, objectStorage.getMockWebVideosBaseUrl()) |
389 | }) | 377 | }) |
390 | 378 | ||
391 | after(async function () { | 379 | after(async function () { |
380 | await objectStorage.cleanupMock() | ||
381 | |||
392 | await cleanupTests([ server ]) | 382 | await cleanupTests([ server ]) |
393 | }) | 383 | }) |
394 | }) | 384 | }) |
395 | 385 | ||
396 | describe('Test simple object storage', function () { | 386 | describe('Test simple object storage', function () { |
397 | runTestSuite({ | 387 | runTestSuite({ |
398 | playlistBucket: 'streaming-playlists', | 388 | playlistBucket: objectStorage.getMockBucketName('streaming-playlists'), |
399 | webtorrentBucket: 'videos' | 389 | webtorrentBucket: objectStorage.getMockBucketName('videos') |
400 | }) | 390 | }) |
401 | }) | 391 | }) |
402 | 392 | ||
403 | describe('Test object storage with prefix', function () { | 393 | describe('Test object storage with prefix', function () { |
404 | runTestSuite({ | 394 | runTestSuite({ |
405 | playlistBucket: 'mybucket', | 395 | playlistBucket: objectStorage.getMockBucketName('mybucket'), |
406 | webtorrentBucket: 'mybucket', | 396 | webtorrentBucket: objectStorage.getMockBucketName('mybucket'), |
407 | 397 | ||
408 | playlistPrefix: 'streaming-playlists_', | 398 | playlistPrefix: 'streaming-playlists_', |
409 | webtorrentPrefix: 'webtorrent_' | 399 | webtorrentPrefix: 'webtorrent_' |
@@ -412,8 +402,8 @@ describe('Object storage for videos', function () { | |||
412 | 402 | ||
413 | describe('Test object storage with prefix and base URL', function () { | 403 | describe('Test object storage with prefix and base URL', function () { |
414 | runTestSuite({ | 404 | runTestSuite({ |
415 | playlistBucket: 'mybucket', | 405 | playlistBucket: objectStorage.getMockBucketName('mybucket'), |
416 | webtorrentBucket: 'mybucket', | 406 | webtorrentBucket: objectStorage.getMockBucketName('mybucket'), |
417 | 407 | ||
418 | playlistPrefix: 'streaming-playlists/', | 408 | playlistPrefix: 'streaming-playlists/', |
419 | webtorrentPrefix: 'webtorrent/', | 409 | webtorrentPrefix: 'webtorrent/', |
@@ -440,8 +430,8 @@ describe('Object storage for videos', function () { | |||
440 | 430 | ||
441 | runTestSuite({ | 431 | runTestSuite({ |
442 | maxUploadPart, | 432 | maxUploadPart, |
443 | playlistBucket: 'streaming-playlists', | 433 | playlistBucket: objectStorage.getMockBucketName('streaming-playlists'), |
444 | webtorrentBucket: 'videos', | 434 | webtorrentBucket: objectStorage.getMockBucketName('videos'), |
445 | fixture | 435 | fixture |
446 | }) | 436 | }) |
447 | }) | 437 | }) |
diff --git a/server/tests/api/redundancy/redundancy.ts b/server/tests/api/redundancy/redundancy.ts index 57939775e..5262c503f 100644 --- a/server/tests/api/redundancy/redundancy.ts +++ b/server/tests/api/redundancy/redundancy.ts | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | import { expect } from 'chai' | 3 | import { expect } from 'chai' |
4 | import { readdir } from 'fs-extra' | 4 | import { readdir } from 'fs-extra' |
5 | import magnetUtil from 'magnet-uri' | 5 | import { decode as magnetUriDecode } from 'magnet-uri' |
6 | import { basename, join } from 'path' | 6 | import { basename, join } from 'path' |
7 | import { checkSegmentHash, checkVideoFilesWereRemoved, saveVideoInServers } from '@server/tests/shared' | 7 | import { checkSegmentHash, checkVideoFilesWereRemoved, saveVideoInServers } from '@server/tests/shared' |
8 | import { wait } from '@shared/core-utils' | 8 | import { wait } from '@shared/core-utils' |
@@ -29,7 +29,7 @@ let servers: PeerTubeServer[] = [] | |||
29 | let video1Server2: VideoDetails | 29 | let video1Server2: VideoDetails |
30 | 30 | ||
31 | async function checkMagnetWebseeds (file: VideoFile, baseWebseeds: string[], server: PeerTubeServer) { | 31 | async function checkMagnetWebseeds (file: VideoFile, baseWebseeds: string[], server: PeerTubeServer) { |
32 | const parsed = magnetUtil.decode(file.magnetUri) | 32 | const parsed = magnetUriDecode(file.magnetUri) |
33 | 33 | ||
34 | for (const ws of baseWebseeds) { | 34 | for (const ws of baseWebseeds) { |
35 | const found = parsed.urlList.find(url => url === `${ws}${basename(file.fileUrl)}`) | 35 | const found = parsed.urlList.find(url => url === `${ws}${basename(file.fileUrl)}`) |
diff --git a/server/tests/api/server/follows.ts b/server/tests/api/server/follows.ts index dba9e107c..2a5fff82b 100644 --- a/server/tests/api/server/follows.ts +++ b/server/tests/api/server/follows.ts | |||
@@ -279,7 +279,7 @@ describe('Test follows', function () { | |||
279 | }) | 279 | }) |
280 | 280 | ||
281 | it('Should upload a video on server 2 and 3 and propagate only the video of server 2', async function () { | 281 | it('Should upload a video on server 2 and 3 and propagate only the video of server 2', async function () { |
282 | this.timeout(120000) | 282 | this.timeout(160000) |
283 | 283 | ||
284 | await servers[1].videos.upload({ attributes: { name: 'server2' } }) | 284 | await servers[1].videos.upload({ attributes: { name: 'server2' } }) |
285 | await servers[2].videos.upload({ attributes: { name: 'server3' } }) | 285 | await servers[2].videos.upload({ attributes: { name: 'server3' } }) |
diff --git a/server/tests/api/server/proxy.ts b/server/tests/api/server/proxy.ts index 4bf89410e..9337468d5 100644 --- a/server/tests/api/server/proxy.ts +++ b/server/tests/api/server/proxy.ts | |||
@@ -122,38 +122,44 @@ describe('Test proxy', function () { | |||
122 | describe('Object storage', function () { | 122 | describe('Object storage', function () { |
123 | if (areMockObjectStorageTestsDisabled()) return | 123 | if (areMockObjectStorageTestsDisabled()) return |
124 | 124 | ||
125 | const objectStorage = new ObjectStorageCommand() | ||
126 | |||
125 | before(async function () { | 127 | before(async function () { |
126 | this.timeout(30000) | 128 | this.timeout(30000) |
127 | 129 | ||
128 | await ObjectStorageCommand.prepareDefaultMockBuckets() | 130 | await objectStorage.prepareDefaultMockBuckets() |
129 | }) | 131 | }) |
130 | 132 | ||
131 | it('Should succeed to upload to object storage with the appropriate proxy config', async function () { | 133 | it('Should succeed to upload to object storage with the appropriate proxy config', async function () { |
132 | this.timeout(120000) | 134 | this.timeout(120000) |
133 | 135 | ||
134 | await servers[0].kill() | 136 | await servers[0].kill() |
135 | await servers[0].run(ObjectStorageCommand.getDefaultMockConfig(), { env: goodEnv }) | 137 | await servers[0].run(objectStorage.getDefaultMockConfig(), { env: goodEnv }) |
136 | 138 | ||
137 | const { uuid } = await servers[0].videos.quickUpload({ name: 'video' }) | 139 | const { uuid } = await servers[0].videos.quickUpload({ name: 'video' }) |
138 | await waitJobs(servers) | 140 | await waitJobs(servers) |
139 | 141 | ||
140 | const video = await servers[0].videos.get({ id: uuid }) | 142 | const video = await servers[0].videos.get({ id: uuid }) |
141 | 143 | ||
142 | expectStartWith(video.files[0].fileUrl, ObjectStorageCommand.getMockWebTorrentBaseUrl()) | 144 | expectStartWith(video.files[0].fileUrl, objectStorage.getMockWebVideosBaseUrl()) |
143 | }) | 145 | }) |
144 | 146 | ||
145 | it('Should fail to upload to object storage with a wrong proxy config', async function () { | 147 | it('Should fail to upload to object storage with a wrong proxy config', async function () { |
146 | this.timeout(120000) | 148 | this.timeout(120000) |
147 | 149 | ||
148 | await servers[0].kill() | 150 | await servers[0].kill() |
149 | await servers[0].run(ObjectStorageCommand.getDefaultMockConfig(), { env: badEnv }) | 151 | await servers[0].run(objectStorage.getDefaultMockConfig(), { env: badEnv }) |
150 | 152 | ||
151 | const { uuid } = await servers[0].videos.quickUpload({ name: 'video' }) | 153 | const { uuid } = await servers[0].videos.quickUpload({ name: 'video' }) |
152 | await waitJobs(servers, { skipDelayed: true }) | 154 | await waitJobs(servers, { skipDelayed: true }) |
153 | 155 | ||
154 | const video = await servers[0].videos.get({ id: uuid }) | 156 | const video = await servers[0].videos.get({ id: uuid }) |
155 | 157 | ||
156 | expectNotStartWith(video.files[0].fileUrl, ObjectStorageCommand.getMockWebTorrentBaseUrl()) | 158 | expectNotStartWith(video.files[0].fileUrl, objectStorage.getMockWebVideosBaseUrl()) |
159 | }) | ||
160 | |||
161 | after(async function () { | ||
162 | await objectStorage.cleanupMock() | ||
157 | }) | 163 | }) |
158 | }) | 164 | }) |
159 | 165 | ||
diff --git a/server/tests/api/server/tracker.ts b/server/tests/api/server/tracker.ts index 34d450998..a0ce2ca35 100644 --- a/server/tests/api/server/tracker.ts +++ b/server/tests/api/server/tracker.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await,@typescript-eslint/no-floating-promises */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await,@typescript-eslint/no-floating-promises */ |
2 | 2 | ||
3 | import magnetUtil from 'magnet-uri' | 3 | import { decode as magnetUriDecode, encode as magnetUriEncode } from 'magnet-uri' |
4 | import WebTorrent from 'webtorrent' | 4 | import WebTorrent from 'webtorrent' |
5 | import { cleanupTests, createSingleServer, killallServers, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' | 5 | import { cleanupTests, createSingleServer, killallServers, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' |
6 | 6 | ||
@@ -19,10 +19,10 @@ describe('Test tracker', function () { | |||
19 | const video = await server.videos.get({ id: uuid }) | 19 | const video = await server.videos.get({ id: uuid }) |
20 | goodMagnet = video.files[0].magnetUri | 20 | goodMagnet = video.files[0].magnetUri |
21 | 21 | ||
22 | const parsed = magnetUtil.decode(goodMagnet) | 22 | const parsed = magnetUriDecode(goodMagnet) |
23 | parsed.infoHash = '010597bb88b1968a5693a4fa8267c592ca65f2e9' | 23 | parsed.infoHash = '010597bb88b1968a5693a4fa8267c592ca65f2e9' |
24 | 24 | ||
25 | badMagnet = magnetUtil.encode(parsed) | 25 | badMagnet = magnetUriEncode(parsed) |
26 | } | 26 | } |
27 | }) | 27 | }) |
28 | 28 | ||
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 | } |
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 () { |
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 | } |
diff --git a/server/tests/cli/create-move-video-storage-job.ts b/server/tests/cli/create-move-video-storage-job.ts index 4927e0309..253fc983e 100644 --- a/server/tests/cli/create-move-video-storage-job.ts +++ b/server/tests/cli/create-move-video-storage-job.ts | |||
@@ -15,10 +15,10 @@ import { | |||
15 | } from '@shared/server-commands' | 15 | } from '@shared/server-commands' |
16 | import { checkDirectoryIsEmpty, expectStartWith } from '../shared' | 16 | import { checkDirectoryIsEmpty, expectStartWith } from '../shared' |
17 | 17 | ||
18 | async function checkFiles (origin: PeerTubeServer, video: VideoDetails, inObjectStorage: boolean) { | 18 | async function checkFiles (origin: PeerTubeServer, video: VideoDetails, objectStorage?: ObjectStorageCommand) { |
19 | for (const file of video.files) { | 19 | for (const file of video.files) { |
20 | const start = inObjectStorage | 20 | const start = objectStorage |
21 | ? ObjectStorageCommand.getMockWebTorrentBaseUrl() | 21 | ? objectStorage.getMockWebVideosBaseUrl() |
22 | : origin.url | 22 | : origin.url |
23 | 23 | ||
24 | expectStartWith(file.fileUrl, start) | 24 | expectStartWith(file.fileUrl, start) |
@@ -26,8 +26,8 @@ async function checkFiles (origin: PeerTubeServer, video: VideoDetails, inObject | |||
26 | await makeRawRequest({ url: file.fileUrl, expectedStatus: HttpStatusCode.OK_200 }) | 26 | await makeRawRequest({ url: file.fileUrl, expectedStatus: HttpStatusCode.OK_200 }) |
27 | } | 27 | } |
28 | 28 | ||
29 | const start = inObjectStorage | 29 | const start = objectStorage |
30 | ? ObjectStorageCommand.getMockPlaylistBaseUrl() | 30 | ? objectStorage.getMockPlaylistBaseUrl() |
31 | : origin.url | 31 | : origin.url |
32 | 32 | ||
33 | const hls = video.streamingPlaylists[0] | 33 | const hls = video.streamingPlaylists[0] |
@@ -46,6 +46,7 @@ describe('Test create move video storage job', function () { | |||
46 | 46 | ||
47 | let servers: PeerTubeServer[] = [] | 47 | let servers: PeerTubeServer[] = [] |
48 | const uuids: string[] = [] | 48 | const uuids: string[] = [] |
49 | const objectStorage = new ObjectStorageCommand() | ||
49 | 50 | ||
50 | before(async function () { | 51 | before(async function () { |
51 | this.timeout(360000) | 52 | this.timeout(360000) |
@@ -56,7 +57,7 @@ describe('Test create move video storage job', function () { | |||
56 | 57 | ||
57 | await doubleFollow(servers[0], servers[1]) | 58 | await doubleFollow(servers[0], servers[1]) |
58 | 59 | ||
59 | await ObjectStorageCommand.prepareDefaultMockBuckets() | 60 | await objectStorage.prepareDefaultMockBuckets() |
60 | 61 | ||
61 | await servers[0].config.enableTranscoding() | 62 | await servers[0].config.enableTranscoding() |
62 | 63 | ||
@@ -68,25 +69,25 @@ describe('Test create move video storage job', function () { | |||
68 | await waitJobs(servers) | 69 | await waitJobs(servers) |
69 | 70 | ||
70 | await servers[0].kill() | 71 | await servers[0].kill() |
71 | await servers[0].run(ObjectStorageCommand.getDefaultMockConfig()) | 72 | await servers[0].run(objectStorage.getDefaultMockConfig()) |
72 | }) | 73 | }) |
73 | 74 | ||
74 | it('Should move only one file', async function () { | 75 | it('Should move only one file', async function () { |
75 | this.timeout(120000) | 76 | this.timeout(120000) |
76 | 77 | ||
77 | const command = `npm run create-move-video-storage-job -- --to-object-storage -v ${uuids[1]}` | 78 | const command = `npm run create-move-video-storage-job -- --to-object-storage -v ${uuids[1]}` |
78 | await servers[0].cli.execWithEnv(command, ObjectStorageCommand.getDefaultMockConfig()) | 79 | await servers[0].cli.execWithEnv(command, objectStorage.getDefaultMockConfig()) |
79 | await waitJobs(servers) | 80 | await waitJobs(servers) |
80 | 81 | ||
81 | for (const server of servers) { | 82 | for (const server of servers) { |
82 | const video = await server.videos.get({ id: uuids[1] }) | 83 | const video = await server.videos.get({ id: uuids[1] }) |
83 | 84 | ||
84 | await checkFiles(servers[0], video, true) | 85 | await checkFiles(servers[0], video, objectStorage) |
85 | 86 | ||
86 | for (const id of [ uuids[0], uuids[2] ]) { | 87 | for (const id of [ uuids[0], uuids[2] ]) { |
87 | const video = await server.videos.get({ id }) | 88 | const video = await server.videos.get({ id }) |
88 | 89 | ||
89 | await checkFiles(servers[0], video, false) | 90 | await checkFiles(servers[0], video) |
90 | } | 91 | } |
91 | } | 92 | } |
92 | }) | 93 | }) |
@@ -95,14 +96,14 @@ describe('Test create move video storage job', function () { | |||
95 | this.timeout(120000) | 96 | this.timeout(120000) |
96 | 97 | ||
97 | const command = `npm run create-move-video-storage-job -- --to-object-storage --all-videos` | 98 | const command = `npm run create-move-video-storage-job -- --to-object-storage --all-videos` |
98 | await servers[0].cli.execWithEnv(command, ObjectStorageCommand.getDefaultMockConfig()) | 99 | await servers[0].cli.execWithEnv(command, objectStorage.getDefaultMockConfig()) |
99 | await waitJobs(servers) | 100 | await waitJobs(servers) |
100 | 101 | ||
101 | for (const server of servers) { | 102 | for (const server of servers) { |
102 | for (const id of [ uuids[0], uuids[2] ]) { | 103 | for (const id of [ uuids[0], uuids[2] ]) { |
103 | const video = await server.videos.get({ id }) | 104 | const video = await server.videos.get({ id }) |
104 | 105 | ||
105 | await checkFiles(servers[0], video, true) | 106 | await checkFiles(servers[0], video, objectStorage) |
106 | } | 107 | } |
107 | } | 108 | } |
108 | }) | 109 | }) |
@@ -116,6 +117,8 @@ describe('Test create move video storage job', function () { | |||
116 | }) | 117 | }) |
117 | 118 | ||
118 | after(async function () { | 119 | after(async function () { |
120 | await objectStorage.cleanupMock() | ||
121 | |||
119 | await cleanupTests(servers) | 122 | await cleanupTests(servers) |
120 | }) | 123 | }) |
121 | }) | 124 | }) |
diff --git a/server/tests/peertube-runner/live-transcoding.ts b/server/tests/peertube-runner/live-transcoding.ts index e7ef941c6..c2ca1de96 100644 --- a/server/tests/peertube-runner/live-transcoding.ts +++ b/server/tests/peertube-runner/live-transcoding.ts | |||
@@ -31,8 +31,8 @@ describe('Test Live transcoding in peertube-runner program', function () { | |||
31 | let sqlCommandServer1: SQLCommand | 31 | let sqlCommandServer1: SQLCommand |
32 | 32 | ||
33 | function runSuite (options: { | 33 | function runSuite (options: { |
34 | objectStorage: boolean | 34 | objectStorage?: ObjectStorageCommand |
35 | }) { | 35 | } = {}) { |
36 | const { objectStorage } = options | 36 | const { objectStorage } = options |
37 | 37 | ||
38 | it('Should enable transcoding without additional resolutions', async function () { | 38 | it('Should enable transcoding without additional resolutions', async function () { |
@@ -117,7 +117,7 @@ describe('Test Live transcoding in peertube-runner program', function () { | |||
117 | 117 | ||
118 | for (const file of files) { | 118 | for (const file of files) { |
119 | if (objectStorage) { | 119 | if (objectStorage) { |
120 | expectStartWith(file.fileUrl, ObjectStorageCommand.getMockPlaylistBaseUrl()) | 120 | expectStartWith(file.fileUrl, objectStorage.getMockPlaylistBaseUrl()) |
121 | } | 121 | } |
122 | 122 | ||
123 | await makeRawRequest({ url: file.fileUrl, expectedStatus: HttpStatusCode.OK_200 }) | 123 | await makeRawRequest({ url: file.fileUrl, expectedStatus: HttpStatusCode.OK_200 }) |
@@ -155,24 +155,30 @@ describe('Test Live transcoding in peertube-runner program', function () { | |||
155 | await servers[0].config.enableTranscoding(true, false, true) | 155 | await servers[0].config.enableTranscoding(true, false, true) |
156 | }) | 156 | }) |
157 | 157 | ||
158 | runSuite({ objectStorage: false }) | 158 | runSuite() |
159 | }) | 159 | }) |
160 | 160 | ||
161 | describe('With lives on object storage', function () { | 161 | describe('With lives on object storage', function () { |
162 | if (areMockObjectStorageTestsDisabled()) return | 162 | if (areMockObjectStorageTestsDisabled()) return |
163 | 163 | ||
164 | const objectStorage = new ObjectStorageCommand() | ||
165 | |||
164 | before(async function () { | 166 | before(async function () { |
165 | await ObjectStorageCommand.prepareDefaultMockBuckets() | 167 | await objectStorage.prepareDefaultMockBuckets() |
166 | 168 | ||
167 | await servers[0].kill() | 169 | await servers[0].kill() |
168 | 170 | ||
169 | await servers[0].run(ObjectStorageCommand.getDefaultMockConfig()) | 171 | await servers[0].run(objectStorage.getDefaultMockConfig()) |
170 | 172 | ||
171 | // Wait for peertube runner socket reconnection | 173 | // Wait for peertube runner socket reconnection |
172 | await wait(1500) | 174 | await wait(1500) |
173 | }) | 175 | }) |
174 | 176 | ||
175 | runSuite({ objectStorage: true }) | 177 | runSuite({ objectStorage }) |
178 | |||
179 | after(async function () { | ||
180 | await objectStorage.cleanupMock() | ||
181 | }) | ||
176 | }) | 182 | }) |
177 | 183 | ||
178 | describe('Check cleanup', function () { | 184 | describe('Check cleanup', function () { |
diff --git a/server/tests/peertube-runner/studio-transcoding.ts b/server/tests/peertube-runner/studio-transcoding.ts index 400203eb3..69b38a536 100644 --- a/server/tests/peertube-runner/studio-transcoding.ts +++ b/server/tests/peertube-runner/studio-transcoding.ts | |||
@@ -19,8 +19,8 @@ describe('Test studio transcoding in peertube-runner program', function () { | |||
19 | let peertubeRunner: PeerTubeRunnerProcess | 19 | let peertubeRunner: PeerTubeRunnerProcess |
20 | 20 | ||
21 | function runSuite (options: { | 21 | function runSuite (options: { |
22 | objectStorage: boolean | 22 | objectStorage?: ObjectStorageCommand |
23 | }) { | 23 | } = {}) { |
24 | const { objectStorage } = options | 24 | const { objectStorage } = options |
25 | 25 | ||
26 | it('Should run a complex studio transcoding', async function () { | 26 | it('Should run a complex studio transcoding', async function () { |
@@ -45,11 +45,11 @@ describe('Test studio transcoding in peertube-runner program', function () { | |||
45 | 45 | ||
46 | if (objectStorage) { | 46 | if (objectStorage) { |
47 | for (const webtorrentFile of video.files) { | 47 | for (const webtorrentFile of video.files) { |
48 | expectStartWith(webtorrentFile.fileUrl, ObjectStorageCommand.getMockWebTorrentBaseUrl()) | 48 | expectStartWith(webtorrentFile.fileUrl, objectStorage.getMockWebVideosBaseUrl()) |
49 | } | 49 | } |
50 | 50 | ||
51 | for (const hlsFile of video.streamingPlaylists[0].files) { | 51 | for (const hlsFile of video.streamingPlaylists[0].files) { |
52 | expectStartWith(hlsFile.fileUrl, ObjectStorageCommand.getMockPlaylistBaseUrl()) | 52 | expectStartWith(hlsFile.fileUrl, objectStorage.getMockPlaylistBaseUrl()) |
53 | } | 53 | } |
54 | } | 54 | } |
55 | 55 | ||
@@ -80,24 +80,30 @@ describe('Test studio transcoding in peertube-runner program', function () { | |||
80 | }) | 80 | }) |
81 | 81 | ||
82 | describe('With videos on local filesystem storage', function () { | 82 | describe('With videos on local filesystem storage', function () { |
83 | runSuite({ objectStorage: false }) | 83 | runSuite() |
84 | }) | 84 | }) |
85 | 85 | ||
86 | describe('With videos on object storage', function () { | 86 | describe('With videos on object storage', function () { |
87 | if (areMockObjectStorageTestsDisabled()) return | 87 | if (areMockObjectStorageTestsDisabled()) return |
88 | 88 | ||
89 | const objectStorage = new ObjectStorageCommand() | ||
90 | |||
89 | before(async function () { | 91 | before(async function () { |
90 | await ObjectStorageCommand.prepareDefaultMockBuckets() | 92 | await objectStorage.prepareDefaultMockBuckets() |
91 | 93 | ||
92 | await servers[0].kill() | 94 | await servers[0].kill() |
93 | 95 | ||
94 | await servers[0].run(ObjectStorageCommand.getDefaultMockConfig()) | 96 | await servers[0].run(objectStorage.getDefaultMockConfig()) |
95 | 97 | ||
96 | // Wait for peertube runner socket reconnection | 98 | // Wait for peertube runner socket reconnection |
97 | await wait(1500) | 99 | await wait(1500) |
98 | }) | 100 | }) |
99 | 101 | ||
100 | runSuite({ objectStorage: true }) | 102 | runSuite({ objectStorage }) |
103 | |||
104 | after(async function () { | ||
105 | await objectStorage.cleanupMock() | ||
106 | }) | ||
101 | }) | 107 | }) |
102 | 108 | ||
103 | describe('Check cleanup', function () { | 109 | describe('Check cleanup', function () { |
diff --git a/server/tests/peertube-runner/vod-transcoding.ts b/server/tests/peertube-runner/vod-transcoding.ts index f1670c1fb..aefec394d 100644 --- a/server/tests/peertube-runner/vod-transcoding.ts +++ b/server/tests/peertube-runner/vod-transcoding.ts | |||
@@ -26,16 +26,16 @@ describe('Test VOD transcoding in peertube-runner program', function () { | |||
26 | function runSuite (options: { | 26 | function runSuite (options: { |
27 | webtorrentEnabled: boolean | 27 | webtorrentEnabled: boolean |
28 | hlsEnabled: boolean | 28 | hlsEnabled: boolean |
29 | objectStorage: boolean | 29 | objectStorage?: ObjectStorageCommand |
30 | }) { | 30 | }) { |
31 | const { webtorrentEnabled, hlsEnabled, objectStorage } = options | 31 | const { webtorrentEnabled, hlsEnabled, objectStorage } = options |
32 | 32 | ||
33 | const objectStorageBaseUrlWebTorrent = objectStorage | 33 | const objectStorageBaseUrlWebTorrent = objectStorage |
34 | ? ObjectStorageCommand.getMockWebTorrentBaseUrl() | 34 | ? objectStorage.getMockWebVideosBaseUrl() |
35 | : undefined | 35 | : undefined |
36 | 36 | ||
37 | const objectStorageBaseUrlHLS = objectStorage | 37 | const objectStorageBaseUrlHLS = objectStorage |
38 | ? ObjectStorageCommand.getMockPlaylistBaseUrl() | 38 | ? objectStorage.getMockPlaylistBaseUrl() |
39 | : undefined | 39 | : undefined |
40 | 40 | ||
41 | it('Should upload a classic video mp4 and transcode it', async function () { | 41 | it('Should upload a classic video mp4 and transcode it', async function () { |
@@ -189,7 +189,7 @@ describe('Test VOD transcoding in peertube-runner program', function () { | |||
189 | }) | 189 | }) |
190 | 190 | ||
191 | it('Should transcode videos on manual run', async function () { | 191 | it('Should transcode videos on manual run', async function () { |
192 | this.timeout(360000) | 192 | this.timeout(120000) |
193 | 193 | ||
194 | await servers[0].config.disableTranscoding() | 194 | await servers[0].config.disableTranscoding() |
195 | 195 | ||
@@ -262,7 +262,7 @@ describe('Test VOD transcoding in peertube-runner program', function () { | |||
262 | await servers[0].config.enableTranscoding(true, false, true) | 262 | await servers[0].config.enableTranscoding(true, false, true) |
263 | }) | 263 | }) |
264 | 264 | ||
265 | runSuite({ webtorrentEnabled: true, hlsEnabled: false, objectStorage: false }) | 265 | runSuite({ webtorrentEnabled: true, hlsEnabled: false }) |
266 | }) | 266 | }) |
267 | 267 | ||
268 | describe('HLS videos only enabled', function () { | 268 | describe('HLS videos only enabled', function () { |
@@ -271,7 +271,7 @@ describe('Test VOD transcoding in peertube-runner program', function () { | |||
271 | await servers[0].config.enableTranscoding(false, true, true) | 271 | await servers[0].config.enableTranscoding(false, true, true) |
272 | }) | 272 | }) |
273 | 273 | ||
274 | runSuite({ webtorrentEnabled: false, hlsEnabled: true, objectStorage: false }) | 274 | runSuite({ webtorrentEnabled: false, hlsEnabled: true }) |
275 | }) | 275 | }) |
276 | 276 | ||
277 | describe('Web video & HLS enabled', function () { | 277 | describe('Web video & HLS enabled', function () { |
@@ -280,19 +280,21 @@ describe('Test VOD transcoding in peertube-runner program', function () { | |||
280 | await servers[0].config.enableTranscoding(true, true, true) | 280 | await servers[0].config.enableTranscoding(true, true, true) |
281 | }) | 281 | }) |
282 | 282 | ||
283 | runSuite({ webtorrentEnabled: true, hlsEnabled: true, objectStorage: false }) | 283 | runSuite({ webtorrentEnabled: true, hlsEnabled: true }) |
284 | }) | 284 | }) |
285 | }) | 285 | }) |
286 | 286 | ||
287 | describe('With videos on object storage', function () { | 287 | describe('With videos on object storage', function () { |
288 | if (areMockObjectStorageTestsDisabled()) return | 288 | if (areMockObjectStorageTestsDisabled()) return |
289 | 289 | ||
290 | const objectStorage = new ObjectStorageCommand() | ||
291 | |||
290 | before(async function () { | 292 | before(async function () { |
291 | await ObjectStorageCommand.prepareDefaultMockBuckets() | 293 | await objectStorage.prepareDefaultMockBuckets() |
292 | 294 | ||
293 | await servers[0].kill() | 295 | await servers[0].kill() |
294 | 296 | ||
295 | await servers[0].run(ObjectStorageCommand.getDefaultMockConfig()) | 297 | await servers[0].run(objectStorage.getDefaultMockConfig()) |
296 | 298 | ||
297 | // Wait for peertube runner socket reconnection | 299 | // Wait for peertube runner socket reconnection |
298 | await wait(1500) | 300 | await wait(1500) |
@@ -304,7 +306,7 @@ describe('Test VOD transcoding in peertube-runner program', function () { | |||
304 | await servers[0].config.enableTranscoding(true, false, true) | 306 | await servers[0].config.enableTranscoding(true, false, true) |
305 | }) | 307 | }) |
306 | 308 | ||
307 | runSuite({ webtorrentEnabled: true, hlsEnabled: false, objectStorage: true }) | 309 | runSuite({ webtorrentEnabled: true, hlsEnabled: false, objectStorage }) |
308 | }) | 310 | }) |
309 | 311 | ||
310 | describe('HLS videos only enabled', function () { | 312 | describe('HLS videos only enabled', function () { |
@@ -313,7 +315,7 @@ describe('Test VOD transcoding in peertube-runner program', function () { | |||
313 | await servers[0].config.enableTranscoding(false, true, true) | 315 | await servers[0].config.enableTranscoding(false, true, true) |
314 | }) | 316 | }) |
315 | 317 | ||
316 | runSuite({ webtorrentEnabled: false, hlsEnabled: true, objectStorage: true }) | 318 | runSuite({ webtorrentEnabled: false, hlsEnabled: true, objectStorage }) |
317 | }) | 319 | }) |
318 | 320 | ||
319 | describe('Web video & HLS enabled', function () { | 321 | describe('Web video & HLS enabled', function () { |
@@ -322,7 +324,11 @@ describe('Test VOD transcoding in peertube-runner program', function () { | |||
322 | await servers[0].config.enableTranscoding(true, true, true) | 324 | await servers[0].config.enableTranscoding(true, true, true) |
323 | }) | 325 | }) |
324 | 326 | ||
325 | runSuite({ webtorrentEnabled: true, hlsEnabled: true, objectStorage: true }) | 327 | runSuite({ webtorrentEnabled: true, hlsEnabled: true, objectStorage }) |
328 | }) | ||
329 | |||
330 | after(async function () { | ||
331 | await objectStorage.cleanupMock() | ||
326 | }) | 332 | }) |
327 | }) | 333 | }) |
328 | 334 | ||
diff --git a/server/tests/shared/live.ts b/server/tests/shared/live.ts index 8f837c97a..9d8c1d941 100644 --- a/server/tests/shared/live.ts +++ b/server/tests/shared/live.ts | |||
@@ -46,7 +46,7 @@ async function testLiveVideoResolutions (options: { | |||
46 | resolutions: number[] | 46 | resolutions: number[] |
47 | transcoded: boolean | 47 | transcoded: boolean |
48 | 48 | ||
49 | objectStorage: boolean | 49 | objectStorage?: ObjectStorageCommand |
50 | objectStorageBaseUrl?: string | 50 | objectStorageBaseUrl?: string |
51 | }) { | 51 | }) { |
52 | const { | 52 | const { |
@@ -57,7 +57,7 @@ async function testLiveVideoResolutions (options: { | |||
57 | resolutions, | 57 | resolutions, |
58 | transcoded, | 58 | transcoded, |
59 | objectStorage, | 59 | objectStorage, |
60 | objectStorageBaseUrl = ObjectStorageCommand.getMockPlaylistBaseUrl() | 60 | objectStorageBaseUrl = objectStorage?.getMockPlaylistBaseUrl() |
61 | } = options | 61 | } = options |
62 | 62 | ||
63 | for (const server of servers) { | 63 | for (const server of servers) { |
@@ -76,7 +76,7 @@ async function testLiveVideoResolutions (options: { | |||
76 | playlistUrl: hlsPlaylist.playlistUrl, | 76 | playlistUrl: hlsPlaylist.playlistUrl, |
77 | resolutions, | 77 | resolutions, |
78 | transcoded, | 78 | transcoded, |
79 | withRetry: objectStorage | 79 | withRetry: !!objectStorage |
80 | }) | 80 | }) |
81 | 81 | ||
82 | if (objectStorage) { | 82 | if (objectStorage) { |
@@ -105,7 +105,7 @@ async function testLiveVideoResolutions (options: { | |||
105 | 105 | ||
106 | const subPlaylist = await originServer.streamingPlaylists.get({ | 106 | const subPlaylist = await originServer.streamingPlaylists.get({ |
107 | url: `${baseUrl}/${video.uuid}/${i}.m3u8`, | 107 | url: `${baseUrl}/${video.uuid}/${i}.m3u8`, |
108 | withRetry: objectStorage // With object storage, the request may fail because of inconsistent data in S3 | 108 | withRetry: !!objectStorage // With object storage, the request may fail because of inconsistent data in S3 |
109 | }) | 109 | }) |
110 | 110 | ||
111 | expect(subPlaylist).to.contain(segmentName) | 111 | expect(subPlaylist).to.contain(segmentName) |
@@ -116,7 +116,7 @@ async function testLiveVideoResolutions (options: { | |||
116 | videoUUID: video.uuid, | 116 | videoUUID: video.uuid, |
117 | segmentName, | 117 | segmentName, |
118 | hlsPlaylist, | 118 | hlsPlaylist, |
119 | withRetry: objectStorage // With object storage, the request may fail because of inconsistent data in S3 | 119 | withRetry: !!objectStorage // With object storage, the request may fail because of inconsistent data in S3 |
120 | }) | 120 | }) |
121 | 121 | ||
122 | if (originServer.internalServerNumber === server.internalServerNumber) { | 122 | if (originServer.internalServerNumber === server.internalServerNumber) { |
diff --git a/server/tests/shared/mock-servers/mock-proxy.ts b/server/tests/shared/mock-servers/mock-proxy.ts index cbc7c4466..e741d6735 100644 --- a/server/tests/shared/mock-servers/mock-proxy.ts +++ b/server/tests/shared/mock-servers/mock-proxy.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { createServer, Server } from 'http' | 1 | import { createServer, Server } from 'http' |
2 | import proxy from 'proxy' | 2 | import { createProxy } from 'proxy' |
3 | import { getPort, terminateServer } from './shared' | 3 | import { getPort, terminateServer } from './shared' |
4 | 4 | ||
5 | class MockProxy { | 5 | class MockProxy { |
@@ -7,7 +7,7 @@ class MockProxy { | |||
7 | 7 | ||
8 | initialize () { | 8 | initialize () { |
9 | return new Promise<number>(res => { | 9 | return new Promise<number>(res => { |
10 | this.server = proxy(createServer()) | 10 | this.server = createProxy(createServer()) |
11 | this.server.listen(0, () => res(getPort(this.server))) | 11 | this.server.listen(0, () => res(getPort(this.server))) |
12 | }) | 12 | }) |
13 | } | 13 | } |