diff options
-rw-r--r-- | server/lib/schedulers/videos-redundancy-scheduler.ts | 1 | ||||
-rw-r--r-- | server/models/redundancy/video-redundancy.ts | 4 | ||||
-rw-r--r-- | server/tests/api/server/redundancy.ts | 21 | ||||
-rw-r--r-- | server/tests/utils/requests/requests.ts | 10 |
4 files changed, 23 insertions, 13 deletions
diff --git a/server/lib/schedulers/videos-redundancy-scheduler.ts b/server/lib/schedulers/videos-redundancy-scheduler.ts index 97df3e4f5..06cfa1101 100644 --- a/server/lib/schedulers/videos-redundancy-scheduler.ts +++ b/server/lib/schedulers/videos-redundancy-scheduler.ts | |||
@@ -11,7 +11,6 @@ import { getServerActor } from '../../helpers/utils' | |||
11 | import { sendCreateCacheFile, sendUpdateCacheFile } from '../activitypub/send' | 11 | import { sendCreateCacheFile, sendUpdateCacheFile } from '../activitypub/send' |
12 | import { VideoModel } from '../../models/video/video' | 12 | import { VideoModel } from '../../models/video/video' |
13 | import { getVideoCacheFileActivityPubUrl } from '../activitypub/url' | 13 | import { getVideoCacheFileActivityPubUrl } from '../activitypub/url' |
14 | import { isTestInstance } from '../../helpers/core-utils' | ||
15 | import { removeVideoRedundancy } from '../redundancy' | 14 | import { removeVideoRedundancy } from '../redundancy' |
16 | 15 | ||
17 | export class VideosRedundancyScheduler extends AbstractScheduler { | 16 | export class VideosRedundancyScheduler extends AbstractScheduler { |
diff --git a/server/models/redundancy/video-redundancy.ts b/server/models/redundancy/video-redundancy.ts index 970d2fe06..58c4f354c 100644 --- a/server/models/redundancy/video-redundancy.ts +++ b/server/models/redundancy/video-redundancy.ts | |||
@@ -286,8 +286,8 @@ export class VideoRedundancyModel extends Model<VideoRedundancyModel> { | |||
286 | raw: true, | 286 | raw: true, |
287 | attributes: [ | 287 | attributes: [ |
288 | [ Sequelize.fn('COALESCE', Sequelize.fn('SUM', Sequelize.col('VideoFile.size')), '0'), 'totalUsed' ], | 288 | [ Sequelize.fn('COALESCE', Sequelize.fn('SUM', Sequelize.col('VideoFile.size')), '0'), 'totalUsed' ], |
289 | [ Sequelize.fn('COUNT', Sequelize.fn('DISTINCT', 'videoId')), 'totalVideos' ], | 289 | [ Sequelize.fn('COUNT', Sequelize.fn('DISTINCT', Sequelize.col('videoId'))), 'totalVideos' ], |
290 | [ Sequelize.fn('COUNT', 'videoFileId'), 'totalVideoFiles' ] | 290 | [ Sequelize.fn('COUNT', Sequelize.col('videoFileId')), 'totalVideoFiles' ] |
291 | ], | 291 | ], |
292 | where: { | 292 | where: { |
293 | strategy, | 293 | strategy, |
diff --git a/server/tests/api/server/redundancy.ts b/server/tests/api/server/redundancy.ts index a773e3de4..f4ae4c065 100644 --- a/server/tests/api/server/redundancy.ts +++ b/server/tests/api/server/redundancy.ts | |||
@@ -9,7 +9,7 @@ import { | |||
9 | getFollowingListPaginationAndSort, | 9 | getFollowingListPaginationAndSort, |
10 | getVideo, | 10 | getVideo, |
11 | immutableAssign, | 11 | immutableAssign, |
12 | killallServers, | 12 | killallServers, makeGetRequest, |
13 | root, | 13 | root, |
14 | ServerInfo, | 14 | ServerInfo, |
15 | setAccessTokensToServers, | 15 | setAccessTokensToServers, |
@@ -147,11 +147,22 @@ async function check2Webseeds (strategy: VideoRedundancyStrategy, videoUUID?: st | |||
147 | } | 147 | } |
148 | } | 148 | } |
149 | 149 | ||
150 | const files = await readdir(join(root(), 'test1', 'videos')) | 150 | for (const url of [ 'http://localhost:9001', 'http://localhost:9002' ]) { |
151 | expect(files).to.have.lengthOf(4) | 151 | await makeGetRequest({ |
152 | url, | ||
153 | statusCodeExpected: 200, | ||
154 | path: '/static/webseed/' + videoUUID, | ||
155 | contentType: null | ||
156 | }) | ||
157 | } | ||
152 | 158 | ||
153 | for (const resolution of [ 240, 360, 480, 720 ]) { | 159 | for (const directory of [ 'test1', 'test2' ]) { |
154 | expect(files.find(f => f === `${videoUUID}-${resolution}.mp4`)).to.not.be.undefined | 160 | const files = await readdir(join(root(), directory, 'videos')) |
161 | expect(files).to.have.length.at.least(4) | ||
162 | |||
163 | for (const resolution of [ 240, 360, 480, 720 ]) { | ||
164 | expect(files.find(f => f === `${videoUUID}-${resolution}.mp4`)).to.not.be.undefined | ||
165 | } | ||
155 | } | 166 | } |
156 | } | 167 | } |
157 | 168 | ||
diff --git a/server/tests/utils/requests/requests.ts b/server/tests/utils/requests/requests.ts index fc7b38b8c..27a529eda 100644 --- a/server/tests/utils/requests/requests.ts +++ b/server/tests/utils/requests/requests.ts | |||
@@ -7,20 +7,20 @@ function makeGetRequest (options: { | |||
7 | path: string, | 7 | path: string, |
8 | query?: any, | 8 | query?: any, |
9 | token?: string, | 9 | token?: string, |
10 | statusCodeExpected?: number | 10 | statusCodeExpected?: number, |
11 | contentType?: string | ||
11 | }) { | 12 | }) { |
12 | if (!options.statusCodeExpected) options.statusCodeExpected = 400 | 13 | if (!options.statusCodeExpected) options.statusCodeExpected = 400 |
14 | if (options.contentType === undefined) options.contentType = 'application/json' | ||
13 | 15 | ||
14 | const req = request(options.url) | 16 | const req = request(options.url) |
15 | .get(options.path) | 17 | .get(options.path) |
16 | .set('Accept', 'application/json') | ||
17 | 18 | ||
19 | if (options.contentType) req.set('Accept', options.contentType) | ||
18 | if (options.token) req.set('Authorization', 'Bearer ' + options.token) | 20 | if (options.token) req.set('Authorization', 'Bearer ' + options.token) |
19 | if (options.query) req.query(options.query) | 21 | if (options.query) req.query(options.query) |
20 | 22 | ||
21 | return req | 23 | return req.expect(options.statusCodeExpected) |
22 | .expect('Content-Type', /json/) | ||
23 | .expect(options.statusCodeExpected) | ||
24 | } | 24 | } |
25 | 25 | ||
26 | function makeDeleteRequest (options: { | 26 | function makeDeleteRequest (options: { |