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 {
AllowNull,
BeforeDestroy,
import { VideoChannelModel } from '../video/video-channel'
import { VideoFileModel } from '../video/video-file'
import { VideoStreamingPlaylistModel } from '../video/video-streaming-playlist'
-import { forEachSeries } from 'async'
export enum ScopeNames {
WITH_VIDEO = 'WITH_VIDEO'
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
-import * as chai from 'chai'
import 'mocha'
+import * as chai from 'chai'
+import { listVideoRedundancies, updateRedundancy } from '@shared/extra-utils/server/redundancy'
+import { VideoPrivacy } from '@shared/models'
import {
cleanupTests,
flushAndRunServer,
reRunServer,
ServerInfo,
setAccessTokensToServers,
+ updateVideo,
uploadVideo,
waitUntilLog
} from '../../../../shared/extra-utils'
import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
-import { listVideoRedundancies, updateRedundancy } from '@shared/extra-utils/server/redundancy'
const expect = chai.expect
let localServer: 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 () {
const res = await listVideoRedundancies({
url: localServer.url,
this.timeout(120000)
{
- const config = {
- redundancy: {
- videos: {
- check_interval: '1 second',
- strategies: [
- {
- strategy: 'recently-added',
- min_lifetime: '1 hour',
- size: '100MB',
- min_views: 0
- }
- ]
- }
- }
- }
- remoteServer = await flushAndRunServer(1, config)
+ remoteServer = await flushAndRunServer(1, remoteServerConfig)
}
{
await killallServers([ localServer ])
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 waitJobs(servers)
await killallServers([ localServer ])
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 waitJobs(servers)
await follow(localServer.url, [ remoteServer.url ], localServer.accessToken)
await waitJobs(servers)
- await uploadVideo(localServer.url, localServer.accessToken, { name: 'video 4 server 2' })
-
- await waitJobs(servers)
+ await uploadWrapper('video 4 server 2')
await waitUntilLog(remoteServer, 'Duplicated ', 20)
await waitJobs(servers)
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
-import * as chai from 'chai'
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 {
checkSegmentHash,
checkVideoFilesWereRemoved,
ServerInfo,
setAccessTokensToServers,
unfollow,
- updateCustomConfig,
- updateCustomSubConfig,
uploadVideo,
viewVideo,
wait,
waitUntilLog
} from '../../../../shared/extra-utils'
import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
-
-import * as magnetUtil from 'magnet-uri'
import {
addVideoRedundancy,
listVideoRedundancies,
removeVideoRedundancy,
updateRedundancy
} from '../../../../shared/extra-utils/server/redundancy'
+import { getStats } from '../../../../shared/extra-utils/server/stats'
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 { 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
return stat
}
-async function checkStatsWith1Redundancy (strategy: VideoRedundancyStrategyWithManual) {
+async function checkStatsWith1Redundancy (strategy: VideoRedundancyStrategyWithManual, onlyHls = false) {
const stat = await checkStatsGlobal(strategy)
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)
}
await waitJobs(servers)
await check1PlaylistRedundancies()
- await checkStatsWith1Redundancy(strategy)
+ await checkStatsWith1Redundancy(strategy, true)
})
it('Should remove the video and the redundancy files', async function () {
await checkVideoFilesWereRemoved(video1Server2UUID, server.internalServerNumber)
}
})
+
+ after(async function () {
+ await cleanupTests(servers)
+ })
})
describe('With manual strategy', function () {