mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-02-25 18:55:32 -06:00
Fix redundancy with HLS only files
This commit is contained in:
@@ -21,6 +21,8 @@ import {
|
||||
ServerInfo,
|
||||
setAccessTokensToServers,
|
||||
unfollow,
|
||||
updateCustomConfig,
|
||||
updateCustomSubConfig,
|
||||
uploadVideo,
|
||||
viewVideo,
|
||||
wait,
|
||||
@@ -60,7 +62,7 @@ function checkMagnetWebseeds (file: { magnetUri: string, resolution: { id: numbe
|
||||
expect(parsed.urlList).to.have.lengthOf(baseWebseeds.length)
|
||||
}
|
||||
|
||||
async function flushAndRunServers (strategy: VideoRedundancyStrategy | null, additionalParams: any = {}) {
|
||||
async function flushAndRunServers (strategy: VideoRedundancyStrategy | null, additionalParams: any = {}, withWebtorrent = true) {
|
||||
const strategies: any[] = []
|
||||
|
||||
if (strategy !== null) {
|
||||
@@ -75,6 +77,9 @@ async function flushAndRunServers (strategy: VideoRedundancyStrategy | null, add
|
||||
|
||||
const config = {
|
||||
transcoding: {
|
||||
webtorrent: {
|
||||
enabled: withWebtorrent
|
||||
},
|
||||
hls: {
|
||||
enabled: true
|
||||
}
|
||||
@@ -253,7 +258,7 @@ async function checkStatsGlobal (strategy: VideoRedundancyStrategyWithManual) {
|
||||
return stat
|
||||
}
|
||||
|
||||
async function checkStatsWith2Webseed (strategy: VideoRedundancyStrategyWithManual) {
|
||||
async function checkStatsWith1Redundancy (strategy: VideoRedundancyStrategyWithManual) {
|
||||
const stat = await checkStatsGlobal(strategy)
|
||||
|
||||
expect(stat.totalUsed).to.be.at.least(1).and.below(409601)
|
||||
@@ -261,7 +266,7 @@ async function checkStatsWith2Webseed (strategy: VideoRedundancyStrategyWithManu
|
||||
expect(stat.totalVideos).to.equal(1)
|
||||
}
|
||||
|
||||
async function checkStatsWith1Webseed (strategy: VideoRedundancyStrategyWithManual) {
|
||||
async function checkStatsWithoutRedundancy (strategy: VideoRedundancyStrategyWithManual) {
|
||||
const stat = await checkStatsGlobal(strategy)
|
||||
|
||||
expect(stat.totalUsed).to.equal(0)
|
||||
@@ -313,7 +318,7 @@ describe('Test videos redundancy', function () {
|
||||
it('Should have 1 webseed on the first video', async function () {
|
||||
await check1WebSeed()
|
||||
await check0PlaylistRedundancies()
|
||||
await checkStatsWith1Webseed(strategy)
|
||||
await checkStatsWithoutRedundancy(strategy)
|
||||
})
|
||||
|
||||
it('Should enable redundancy on server 1', function () {
|
||||
@@ -329,7 +334,7 @@ describe('Test videos redundancy', function () {
|
||||
|
||||
await check2Webseeds()
|
||||
await check1PlaylistRedundancies()
|
||||
await checkStatsWith2Webseed(strategy)
|
||||
await checkStatsWith1Redundancy(strategy)
|
||||
})
|
||||
|
||||
it('Should undo redundancy on server 1 and remove duplicated videos', async function () {
|
||||
@@ -363,7 +368,7 @@ describe('Test videos redundancy', function () {
|
||||
it('Should have 1 webseed on the first video', async function () {
|
||||
await check1WebSeed()
|
||||
await check0PlaylistRedundancies()
|
||||
await checkStatsWith1Webseed(strategy)
|
||||
await checkStatsWithoutRedundancy(strategy)
|
||||
})
|
||||
|
||||
it('Should enable redundancy on server 1', function () {
|
||||
@@ -379,7 +384,7 @@ describe('Test videos redundancy', function () {
|
||||
|
||||
await check2Webseeds()
|
||||
await check1PlaylistRedundancies()
|
||||
await checkStatsWith2Webseed(strategy)
|
||||
await checkStatsWith1Redundancy(strategy)
|
||||
})
|
||||
|
||||
it('Should unfollow on server 1 and remove duplicated videos', async function () {
|
||||
@@ -413,7 +418,7 @@ describe('Test videos redundancy', function () {
|
||||
it('Should have 1 webseed on the first video', async function () {
|
||||
await check1WebSeed()
|
||||
await check0PlaylistRedundancies()
|
||||
await checkStatsWith1Webseed(strategy)
|
||||
await checkStatsWithoutRedundancy(strategy)
|
||||
})
|
||||
|
||||
it('Should enable redundancy on server 1', function () {
|
||||
@@ -429,7 +434,7 @@ describe('Test videos redundancy', function () {
|
||||
|
||||
await check1WebSeed()
|
||||
await check0PlaylistRedundancies()
|
||||
await checkStatsWith1Webseed(strategy)
|
||||
await checkStatsWithoutRedundancy(strategy)
|
||||
})
|
||||
|
||||
it('Should view 2 times the first video to have > min_views config', async function () {
|
||||
@@ -451,7 +456,7 @@ describe('Test videos redundancy', function () {
|
||||
|
||||
await check2Webseeds()
|
||||
await check1PlaylistRedundancies()
|
||||
await checkStatsWith2Webseed(strategy)
|
||||
await checkStatsWith1Redundancy(strategy)
|
||||
})
|
||||
|
||||
it('Should remove the video and the redundancy files', async function () {
|
||||
@@ -471,6 +476,65 @@ describe('Test videos redundancy', function () {
|
||||
})
|
||||
})
|
||||
|
||||
describe('With only HLS files', function () {
|
||||
const strategy = 'recently-added'
|
||||
|
||||
before(async function () {
|
||||
this.timeout(120000)
|
||||
|
||||
await flushAndRunServers(strategy, { min_views: 3 }, false)
|
||||
})
|
||||
|
||||
it('Should have 0 playlist redundancy on the first video', async function () {
|
||||
await check1WebSeed()
|
||||
await check0PlaylistRedundancies()
|
||||
})
|
||||
|
||||
it('Should enable redundancy on server 1', function () {
|
||||
return enableRedundancyOnServer1()
|
||||
})
|
||||
|
||||
it('Should still have 0 redundancy on the first video', async function () {
|
||||
this.timeout(80000)
|
||||
|
||||
await waitJobs(servers)
|
||||
await wait(15000)
|
||||
await waitJobs(servers)
|
||||
|
||||
await check0PlaylistRedundancies()
|
||||
await checkStatsWithoutRedundancy(strategy)
|
||||
})
|
||||
|
||||
it('Should have 1 redundancy on the first video', async function () {
|
||||
this.timeout(160000)
|
||||
|
||||
await viewVideo(servers[0].url, video1Server2UUID)
|
||||
await viewVideo(servers[2].url, video1Server2UUID)
|
||||
|
||||
await wait(10000)
|
||||
await waitJobs(servers)
|
||||
|
||||
await waitJobs(servers)
|
||||
await waitUntilLog(servers[0], 'Duplicated ', 1)
|
||||
await waitJobs(servers)
|
||||
|
||||
await check1PlaylistRedundancies()
|
||||
await checkStatsWith1Redundancy(strategy)
|
||||
})
|
||||
|
||||
it('Should remove the video and the redundancy files', async function () {
|
||||
this.timeout(20000)
|
||||
|
||||
await removeVideo(servers[1].url, servers[1].accessToken, video1Server2UUID)
|
||||
|
||||
await waitJobs(servers)
|
||||
|
||||
for (const server of servers) {
|
||||
await checkVideoFilesWereRemoved(video1Server2UUID, server.internalServerNumber)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
describe('With manual strategy', function () {
|
||||
before(function () {
|
||||
this.timeout(120000)
|
||||
@@ -481,7 +545,7 @@ describe('Test videos redundancy', function () {
|
||||
it('Should have 1 webseed on the first video', async function () {
|
||||
await check1WebSeed()
|
||||
await check0PlaylistRedundancies()
|
||||
await checkStatsWith1Webseed('manual')
|
||||
await checkStatsWithoutRedundancy('manual')
|
||||
})
|
||||
|
||||
it('Should create a redundancy on first video', async function () {
|
||||
@@ -501,7 +565,7 @@ describe('Test videos redundancy', function () {
|
||||
|
||||
await check2Webseeds()
|
||||
await check1PlaylistRedundancies()
|
||||
await checkStatsWith2Webseed('manual')
|
||||
await checkStatsWith1Redundancy('manual')
|
||||
})
|
||||
|
||||
it('Should manually remove redundancies on server 1 and remove duplicated videos', async function () {
|
||||
@@ -619,7 +683,7 @@ describe('Test videos redundancy', function () {
|
||||
|
||||
await check2Webseeds()
|
||||
await check1PlaylistRedundancies()
|
||||
await checkStatsWith2Webseed(strategy)
|
||||
await checkStatsWith1Redundancy(strategy)
|
||||
|
||||
const res = await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video 2 server 2' })
|
||||
video2Server2UUID = res.body.video.uuid
|
||||
|
||||
Reference in New Issue
Block a user