Fix tests
This commit is contained in:
parent
56df7815b5
commit
6949a1a111
|
@ -1,5 +1,5 @@
|
||||||
import { sample } from 'lodash'
|
import { sample } from 'lodash'
|
||||||
import { col, FindOptions, fn, literal, Op, QueryTypes, Transaction, WhereOptions } from 'sequelize'
|
import { FindOptions, literal, Op, QueryTypes, Transaction, WhereOptions } from 'sequelize'
|
||||||
import {
|
import {
|
||||||
AllowNull,
|
AllowNull,
|
||||||
BeforeDestroy,
|
BeforeDestroy,
|
||||||
|
@ -36,7 +36,6 @@ import { VideoModel } from '../video/video'
|
||||||
import { VideoChannelModel } from '../video/video-channel'
|
import { VideoChannelModel } from '../video/video-channel'
|
||||||
import { VideoFileModel } from '../video/video-file'
|
import { VideoFileModel } from '../video/video-file'
|
||||||
import { VideoStreamingPlaylistModel } from '../video/video-streaming-playlist'
|
import { VideoStreamingPlaylistModel } from '../video/video-streaming-playlist'
|
||||||
import { forEachSeries } from 'async'
|
|
||||||
|
|
||||||
export enum ScopeNames {
|
export enum ScopeNames {
|
||||||
WITH_VIDEO = 'WITH_VIDEO'
|
WITH_VIDEO = 'WITH_VIDEO'
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
||||||
|
|
||||||
import * as chai from 'chai'
|
|
||||||
import 'mocha'
|
import 'mocha'
|
||||||
|
import * as chai from 'chai'
|
||||||
|
import { listVideoRedundancies, updateRedundancy } from '@shared/extra-utils/server/redundancy'
|
||||||
|
import { VideoPrivacy } from '@shared/models'
|
||||||
import {
|
import {
|
||||||
cleanupTests,
|
cleanupTests,
|
||||||
flushAndRunServer,
|
flushAndRunServer,
|
||||||
|
@ -10,11 +12,11 @@ import {
|
||||||
reRunServer,
|
reRunServer,
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
|
updateVideo,
|
||||||
uploadVideo,
|
uploadVideo,
|
||||||
waitUntilLog
|
waitUntilLog
|
||||||
} from '../../../../shared/extra-utils'
|
} from '../../../../shared/extra-utils'
|
||||||
import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
|
import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
|
||||||
import { listVideoRedundancies, updateRedundancy } from '@shared/extra-utils/server/redundancy'
|
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
|
|
||||||
|
@ -23,6 +25,31 @@ describe('Test redundancy constraints', function () {
|
||||||
let localServer: ServerInfo
|
let localServer: ServerInfo
|
||||||
let servers: ServerInfo[]
|
let servers: ServerInfo[]
|
||||||
|
|
||||||
|
const remoteServerConfig = {
|
||||||
|
redundancy: {
|
||||||
|
videos: {
|
||||||
|
check_interval: '1 second',
|
||||||
|
strategies: [
|
||||||
|
{
|
||||||
|
strategy: 'recently-added',
|
||||||
|
min_lifetime: '1 hour',
|
||||||
|
size: '100MB',
|
||||||
|
min_views: 0
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function uploadWrapper (videoName: string) {
|
||||||
|
// Wait for transcoding
|
||||||
|
const res = await uploadVideo(localServer.url, localServer.accessToken, { name: 'to transcode', privacy: VideoPrivacy.PRIVATE })
|
||||||
|
await waitJobs([ localServer ])
|
||||||
|
|
||||||
|
// Update video to schedule a federation
|
||||||
|
await updateVideo(localServer.url, localServer.accessToken, res.body.video.id, { name: videoName, privacy: VideoPrivacy.PUBLIC })
|
||||||
|
}
|
||||||
|
|
||||||
async function getTotalRedundanciesLocalServer () {
|
async function getTotalRedundanciesLocalServer () {
|
||||||
const res = await listVideoRedundancies({
|
const res = await listVideoRedundancies({
|
||||||
url: localServer.url,
|
url: localServer.url,
|
||||||
|
@ -47,22 +74,7 @@ describe('Test redundancy constraints', function () {
|
||||||
this.timeout(120000)
|
this.timeout(120000)
|
||||||
|
|
||||||
{
|
{
|
||||||
const config = {
|
remoteServer = await flushAndRunServer(1, remoteServerConfig)
|
||||||
redundancy: {
|
|
||||||
videos: {
|
|
||||||
check_interval: '1 second',
|
|
||||||
strategies: [
|
|
||||||
{
|
|
||||||
strategy: 'recently-added',
|
|
||||||
min_lifetime: '1 hour',
|
|
||||||
size: '100MB',
|
|
||||||
min_views: 0
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
remoteServer = await flushAndRunServer(1, config)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -124,9 +136,8 @@ describe('Test redundancy constraints', function () {
|
||||||
await killallServers([ localServer ])
|
await killallServers([ localServer ])
|
||||||
await reRunServer(localServer, config)
|
await reRunServer(localServer, config)
|
||||||
|
|
||||||
await uploadVideo(localServer.url, localServer.accessToken, { name: 'video 2 server 2' })
|
await uploadWrapper('video 2 server 2')
|
||||||
|
|
||||||
await waitJobs(servers)
|
|
||||||
await waitUntilLog(remoteServer, 'Duplicated ', 10)
|
await waitUntilLog(remoteServer, 'Duplicated ', 10)
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
|
@ -154,9 +165,8 @@ describe('Test redundancy constraints', function () {
|
||||||
await killallServers([ localServer ])
|
await killallServers([ localServer ])
|
||||||
await reRunServer(localServer, config)
|
await reRunServer(localServer, config)
|
||||||
|
|
||||||
await uploadVideo(localServer.url, localServer.accessToken, { name: 'video 3 server 2' })
|
await uploadWrapper('video 3 server 2')
|
||||||
|
|
||||||
await waitJobs(servers)
|
|
||||||
await waitUntilLog(remoteServer, 'Duplicated ', 15)
|
await waitUntilLog(remoteServer, 'Duplicated ', 15)
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
|
@ -177,9 +187,7 @@ describe('Test redundancy constraints', function () {
|
||||||
await follow(localServer.url, [ remoteServer.url ], localServer.accessToken)
|
await follow(localServer.url, [ remoteServer.url ], localServer.accessToken)
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
await uploadVideo(localServer.url, localServer.accessToken, { name: 'video 4 server 2' })
|
await uploadWrapper('video 4 server 2')
|
||||||
|
|
||||||
await waitJobs(servers)
|
|
||||||
await waitUntilLog(remoteServer, 'Duplicated ', 20)
|
await waitUntilLog(remoteServer, 'Duplicated ', 20)
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
||||||
|
|
||||||
import * as chai from 'chai'
|
|
||||||
import 'mocha'
|
import 'mocha'
|
||||||
import { VideoDetails } from '../../../../shared/models/videos'
|
import * as chai from 'chai'
|
||||||
|
import { readdir } from 'fs-extra'
|
||||||
|
import * as magnetUtil from 'magnet-uri'
|
||||||
|
import { join } from 'path'
|
||||||
|
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
||||||
import {
|
import {
|
||||||
checkSegmentHash,
|
checkSegmentHash,
|
||||||
checkVideoFilesWereRemoved,
|
checkVideoFilesWereRemoved,
|
||||||
|
@ -21,29 +24,23 @@ import {
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
unfollow,
|
unfollow,
|
||||||
updateCustomConfig,
|
|
||||||
updateCustomSubConfig,
|
|
||||||
uploadVideo,
|
uploadVideo,
|
||||||
viewVideo,
|
viewVideo,
|
||||||
wait,
|
wait,
|
||||||
waitUntilLog
|
waitUntilLog
|
||||||
} from '../../../../shared/extra-utils'
|
} from '../../../../shared/extra-utils'
|
||||||
import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
|
import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
|
||||||
|
|
||||||
import * as magnetUtil from 'magnet-uri'
|
|
||||||
import {
|
import {
|
||||||
addVideoRedundancy,
|
addVideoRedundancy,
|
||||||
listVideoRedundancies,
|
listVideoRedundancies,
|
||||||
removeVideoRedundancy,
|
removeVideoRedundancy,
|
||||||
updateRedundancy
|
updateRedundancy
|
||||||
} from '../../../../shared/extra-utils/server/redundancy'
|
} from '../../../../shared/extra-utils/server/redundancy'
|
||||||
import { ActorFollow } from '../../../../shared/models/actors'
|
|
||||||
import { readdir } from 'fs-extra'
|
|
||||||
import { join } from 'path'
|
|
||||||
import { VideoRedundancy, VideoRedundancyStrategy, VideoRedundancyStrategyWithManual } from '../../../../shared/models/redundancy'
|
|
||||||
import { getStats } from '../../../../shared/extra-utils/server/stats'
|
import { getStats } from '../../../../shared/extra-utils/server/stats'
|
||||||
|
import { ActorFollow } from '../../../../shared/models/actors'
|
||||||
|
import { VideoRedundancy, VideoRedundancyStrategy, VideoRedundancyStrategyWithManual } from '../../../../shared/models/redundancy'
|
||||||
import { ServerStats } from '../../../../shared/models/server/server-stats.model'
|
import { ServerStats } from '../../../../shared/models/server/server-stats.model'
|
||||||
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
import { VideoDetails } from '../../../../shared/models/videos'
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
|
|
||||||
|
@ -258,11 +255,11 @@ async function checkStatsGlobal (strategy: VideoRedundancyStrategyWithManual) {
|
||||||
return stat
|
return stat
|
||||||
}
|
}
|
||||||
|
|
||||||
async function checkStatsWith1Redundancy (strategy: VideoRedundancyStrategyWithManual) {
|
async function checkStatsWith1Redundancy (strategy: VideoRedundancyStrategyWithManual, onlyHls = false) {
|
||||||
const stat = await checkStatsGlobal(strategy)
|
const stat = await checkStatsGlobal(strategy)
|
||||||
|
|
||||||
expect(stat.totalUsed).to.be.at.least(1).and.below(409601)
|
expect(stat.totalUsed).to.be.at.least(1).and.below(409601)
|
||||||
expect(stat.totalVideoFiles).to.equal(4)
|
expect(stat.totalVideoFiles).to.equal(onlyHls ? 4 : 8)
|
||||||
expect(stat.totalVideos).to.equal(1)
|
expect(stat.totalVideos).to.equal(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -519,7 +516,7 @@ describe('Test videos redundancy', function () {
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
await check1PlaylistRedundancies()
|
await check1PlaylistRedundancies()
|
||||||
await checkStatsWith1Redundancy(strategy)
|
await checkStatsWith1Redundancy(strategy, true)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should remove the video and the redundancy files', async function () {
|
it('Should remove the video and the redundancy files', async function () {
|
||||||
|
@ -533,6 +530,10 @@ describe('Test videos redundancy', function () {
|
||||||
await checkVideoFilesWereRemoved(video1Server2UUID, server.internalServerNumber)
|
await checkVideoFilesWereRemoved(video1Server2UUID, server.internalServerNumber)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
after(async function () {
|
||||||
|
await cleanupTests(servers)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('With manual strategy', function () {
|
describe('With manual strategy', function () {
|
||||||
|
|
Loading…
Reference in New Issue