mirror of https://github.com/Chocobozzz/PeerTube
Fix redundancy totalVideos stats
parent
660d11e91e
commit
ebdb612458
|
@ -11,7 +11,6 @@ import { getServerActor } from '../../helpers/utils'
|
||||||
import { sendCreateCacheFile, sendUpdateCacheFile } from '../activitypub/send'
|
import { sendCreateCacheFile, sendUpdateCacheFile } from '../activitypub/send'
|
||||||
import { VideoModel } from '../../models/video/video'
|
import { VideoModel } from '../../models/video/video'
|
||||||
import { getVideoCacheFileActivityPubUrl } from '../activitypub/url'
|
import { getVideoCacheFileActivityPubUrl } from '../activitypub/url'
|
||||||
import { isTestInstance } from '../../helpers/core-utils'
|
|
||||||
import { removeVideoRedundancy } from '../redundancy'
|
import { removeVideoRedundancy } from '../redundancy'
|
||||||
|
|
||||||
export class VideosRedundancyScheduler extends AbstractScheduler {
|
export class VideosRedundancyScheduler extends AbstractScheduler {
|
||||||
|
|
|
@ -286,8 +286,8 @@ export class VideoRedundancyModel extends Model<VideoRedundancyModel> {
|
||||||
raw: true,
|
raw: true,
|
||||||
attributes: [
|
attributes: [
|
||||||
[ Sequelize.fn('COALESCE', Sequelize.fn('SUM', Sequelize.col('VideoFile.size')), '0'), 'totalUsed' ],
|
[ Sequelize.fn('COALESCE', Sequelize.fn('SUM', Sequelize.col('VideoFile.size')), '0'), 'totalUsed' ],
|
||||||
[ Sequelize.fn('COUNT', Sequelize.fn('DISTINCT', 'videoId')), 'totalVideos' ],
|
[ Sequelize.fn('COUNT', Sequelize.fn('DISTINCT', Sequelize.col('videoId'))), 'totalVideos' ],
|
||||||
[ Sequelize.fn('COUNT', 'videoFileId'), 'totalVideoFiles' ]
|
[ Sequelize.fn('COUNT', Sequelize.col('videoFileId')), 'totalVideoFiles' ]
|
||||||
],
|
],
|
||||||
where: {
|
where: {
|
||||||
strategy,
|
strategy,
|
||||||
|
|
|
@ -9,7 +9,7 @@ import {
|
||||||
getFollowingListPaginationAndSort,
|
getFollowingListPaginationAndSort,
|
||||||
getVideo,
|
getVideo,
|
||||||
immutableAssign,
|
immutableAssign,
|
||||||
killallServers,
|
killallServers, makeGetRequest,
|
||||||
root,
|
root,
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
|
@ -147,13 +147,24 @@ async function check2Webseeds (strategy: VideoRedundancyStrategy, videoUUID?: st
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const files = await readdir(join(root(), 'test1', 'videos'))
|
for (const url of [ 'http://localhost:9001', 'http://localhost:9002' ]) {
|
||||||
expect(files).to.have.lengthOf(4)
|
await makeGetRequest({
|
||||||
|
url,
|
||||||
|
statusCodeExpected: 200,
|
||||||
|
path: '/static/webseed/' + videoUUID,
|
||||||
|
contentType: null
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const directory of [ 'test1', 'test2' ]) {
|
||||||
|
const files = await readdir(join(root(), directory, 'videos'))
|
||||||
|
expect(files).to.have.length.at.least(4)
|
||||||
|
|
||||||
for (const resolution of [ 240, 360, 480, 720 ]) {
|
for (const resolution of [ 240, 360, 480, 720 ]) {
|
||||||
expect(files.find(f => f === `${videoUUID}-${resolution}.mp4`)).to.not.be.undefined
|
expect(files.find(f => f === `${videoUUID}-${resolution}.mp4`)).to.not.be.undefined
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function enableRedundancyOnServer1 () {
|
async function enableRedundancyOnServer1 () {
|
||||||
await updateRedundancy(servers[ 0 ].url, servers[ 0 ].accessToken, servers[ 1 ].host, true)
|
await updateRedundancy(servers[ 0 ].url, servers[ 0 ].accessToken, servers[ 1 ].host, true)
|
||||||
|
|
|
@ -7,20 +7,20 @@ function makeGetRequest (options: {
|
||||||
path: string,
|
path: string,
|
||||||
query?: any,
|
query?: any,
|
||||||
token?: string,
|
token?: string,
|
||||||
statusCodeExpected?: number
|
statusCodeExpected?: number,
|
||||||
|
contentType?: string
|
||||||
}) {
|
}) {
|
||||||
if (!options.statusCodeExpected) options.statusCodeExpected = 400
|
if (!options.statusCodeExpected) options.statusCodeExpected = 400
|
||||||
|
if (options.contentType === undefined) options.contentType = 'application/json'
|
||||||
|
|
||||||
const req = request(options.url)
|
const req = request(options.url)
|
||||||
.get(options.path)
|
.get(options.path)
|
||||||
.set('Accept', 'application/json')
|
|
||||||
|
|
||||||
|
if (options.contentType) req.set('Accept', options.contentType)
|
||||||
if (options.token) req.set('Authorization', 'Bearer ' + options.token)
|
if (options.token) req.set('Authorization', 'Bearer ' + options.token)
|
||||||
if (options.query) req.query(options.query)
|
if (options.query) req.query(options.query)
|
||||||
|
|
||||||
return req
|
return req.expect(options.statusCodeExpected)
|
||||||
.expect('Content-Type', /json/)
|
|
||||||
.expect(options.statusCodeExpected)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function makeDeleteRequest (options: {
|
function makeDeleteRequest (options: {
|
||||||
|
|
Loading…
Reference in New Issue