import 'mocha'
import * as chai from 'chai'
import { readdir } from 'fs-extra'
-import * as magnetUtil from 'magnet-uri'
+import magnetUtil from 'magnet-uri'
import { basename, join } from 'path'
+import { checkSegmentHash, checkVideoFilesWereRemoved, saveVideoInServers } from '@server/tests/shared'
+import { root, wait } from '@shared/core-utils'
+import {
+ HttpStatusCode,
+ VideoDetails,
+ VideoFile,
+ VideoPrivacy,
+ VideoRedundancyStrategy,
+ VideoRedundancyStrategyWithManual
+} from '@shared/models'
import {
- checkSegmentHash,
- checkVideoFilesWereRemoved,
cleanupTests,
createMultipleServers,
doubleFollow,
killallServers,
makeRawRequest,
PeerTubeServer,
- root,
- saveVideoInServers,
setAccessTokensToServers,
- wait,
waitJobs
-} from '@shared/extra-utils'
-import {
- HttpStatusCode,
- VideoDetails,
- VideoFile,
- VideoPrivacy,
- VideoRedundancyStrategy,
- VideoRedundancyStrategyWithManual
-} from '@shared/models'
+} from '@shared/server-commands'
const expect = chai.expect
}
}
-async function createSingleServers (strategy: VideoRedundancyStrategy | null, additionalParams: any = {}, withWebtorrent = true) {
+async function createServers (strategy: VideoRedundancyStrategy | null, additionalParams: any = {}, withWebtorrent = true) {
const strategies: any[] = []
if (strategy !== null) {
strategies.push(
{
min_lifetime: '1 hour',
- strategy: strategy,
+ strategy,
size: '400KB',
...additionalParams
const { id } = await servers[1].videos.upload({ attributes: { name: 'video 1 server 2' } })
video1Server2 = await servers[1].videos.get({ id })
- await servers[1].videos.view({ id })
+ await servers[1].views.simulateView({ id })
}
await waitJobs(servers)
const strategy = 'most-views'
before(function () {
- this.timeout(120000)
+ this.timeout(240000)
- return createSingleServers(strategy)
+ return createServers(strategy)
})
it('Should have 1 webseed on the first video', async function () {
const strategy = 'trending'
before(function () {
- this.timeout(120000)
+ this.timeout(240000)
- return createSingleServers(strategy)
+ return createServers(strategy)
})
it('Should have 1 webseed on the first video', async function () {
await checkStatsWith1Redundancy(strategy)
})
- it('Should unfollow on server 1 and remove duplicated videos', async function () {
+ it('Should unfollow server 3 and keep duplicated videos', async function () {
+ this.timeout(80000)
+
+ await servers[0].follows.unfollow({ target: servers[2] })
+
+ await waitJobs(servers)
+ await wait(5000)
+
+ await check2Webseeds()
+ await check1PlaylistRedundancies()
+ await checkStatsWith1Redundancy(strategy)
+ })
+
+ it('Should unfollow server 2 and remove duplicated videos', async function () {
this.timeout(80000)
await servers[0].follows.unfollow({ target: servers[1] })
const strategy = 'recently-added'
before(function () {
- this.timeout(120000)
+ this.timeout(240000)
- return createSingleServers(strategy, { min_views: 3 })
+ return createServers(strategy, { min_views: 3 })
})
it('Should have 1 webseed on the first video', async function () {
it('Should view 2 times the first video to have > min_views config', async function () {
this.timeout(80000)
- await servers[0].videos.view({ id: video1Server2.uuid })
- await servers[2].videos.view({ id: video1Server2.uuid })
+ await servers[0].views.simulateView({ id: video1Server2.uuid })
+ await servers[2].views.simulateView({ id: video1Server2.uuid })
await wait(10000)
await waitJobs(servers)
const strategy = 'recently-added'
before(async function () {
- this.timeout(120000)
+ this.timeout(240000)
- await createSingleServers(strategy, { min_views: 3 }, false)
+ await createServers(strategy, { min_views: 3 }, false)
})
it('Should have 0 playlist redundancy on the first video', async function () {
it('Should have 1 redundancy on the first video', async function () {
this.timeout(160000)
- await servers[0].videos.view({ id: video1Server2.uuid })
- await servers[2].videos.view({ id: video1Server2.uuid })
+ await servers[0].views.simulateView({ id: video1Server2.uuid })
+ await servers[2].views.simulateView({ id: video1Server2.uuid })
await wait(10000)
await waitJobs(servers)
describe('With manual strategy', function () {
before(function () {
- this.timeout(120000)
+ this.timeout(240000)
- return createSingleServers(null)
+ return createServers(null)
})
it('Should have 1 webseed on the first video', async function () {
}
before(async function () {
- this.timeout(120000)
+ this.timeout(240000)
- await createSingleServers(strategy, { min_lifetime: '7 seconds', min_views: 0 })
+ await createServers(strategy, { min_lifetime: '7 seconds', min_views: 0 })
await enableRedundancyOnServer1()
})
const strategy = 'recently-added'
before(async function () {
- this.timeout(120000)
+ this.timeout(240000)
- await createSingleServers(strategy, { min_lifetime: '7 seconds', min_views: 0 })
+ await createServers(strategy, { min_lifetime: '7 seconds', min_views: 0 })
await enableRedundancyOnServer1()
})
it('Should cache video 2 webseeds on the first video', async function () {
- this.timeout(120000)
+ this.timeout(240000)
await waitJobs(servers)