Fix stats tests

pull/3770/head
Chocobozzz 2021-02-19 14:30:00 +01:00 committed by Chocobozzz
parent d7764e2eb7
commit 94d721efdc
5 changed files with 32 additions and 8 deletions

View File

@ -10,11 +10,8 @@ fi
killall -q peertube || true
retries=3
jobs=2
runTest () {
retries=3
jobname=$1
shift

View File

@ -23,9 +23,11 @@ import {
testFfmpegStreamError,
updateCustomSubConfig,
updateVideo,
wait,
waitJobs,
waitUntilLiveEnded,
waitUntilLivePublished
waitUntilLivePublished,
waitUntilLiveSaved
} from '../../../../shared/extra-utils'
const expect = chai.expect
@ -81,6 +83,12 @@ describe('Save replay setting', function () {
}
}
async function waitUntilLiveSavedOnAllServers (videoId: string) {
for (const server of servers) {
await waitUntilLiveSaved(server.url, server.accessToken, videoId)
}
}
before(async function () {
this.timeout(120000)
@ -158,8 +166,6 @@ describe('Save replay setting', function () {
await checkVideosExist(liveVideoUUID, false, HttpStatusCode.OK_200)
await checkVideoState(liveVideoUUID, VideoState.LIVE_ENDED)
await waitJobs(servers)
// No resolutions saved since we did not save replay
await checkLiveCleanup(servers[0], liveVideoUUID, [])
})
@ -188,6 +194,8 @@ describe('Save replay setting', function () {
await getVideo(servers[0].url, liveVideoUUID, HttpStatusCode.UNAUTHORIZED_401)
await getVideo(servers[1].url, liveVideoUUID, HttpStatusCode.NOT_FOUND_404)
await wait(5000)
await waitJobs(servers)
await checkLiveCleanup(servers[0], liveVideoUUID, [])
})
@ -208,6 +216,7 @@ describe('Save replay setting', function () {
removeVideo(servers[0].url, servers[0].accessToken, liveVideoUUID)
])
await wait(5000)
await waitJobs(servers)
await checkVideosExist(liveVideoUUID, false, HttpStatusCode.NOT_FOUND_404)
@ -245,6 +254,7 @@ describe('Save replay setting', function () {
await stopFfmpeg(ffmpegCommand)
await waitUntilLiveSavedOnAllServers(liveVideoUUID)
await waitJobs(servers)
// Live has been transcoded
@ -292,6 +302,8 @@ describe('Save replay setting', function () {
await getVideo(servers[0].url, liveVideoUUID, HttpStatusCode.UNAUTHORIZED_401)
await getVideo(servers[1].url, liveVideoUUID, HttpStatusCode.NOT_FOUND_404)
await wait(5000)
await waitJobs(servers)
await checkLiveCleanup(servers[0], liveVideoUUID, [ 720 ])
})
@ -311,6 +323,7 @@ describe('Save replay setting', function () {
testFfmpegStreamError(ffmpegCommand, true)
])
await wait(5000)
await waitJobs(servers)
await checkVideosExist(liveVideoUUID, false, HttpStatusCode.NOT_FOUND_404)

View File

@ -314,7 +314,7 @@ describe('Test user notifications', function () {
})
it('Should not send a notification before the video is published', async function () {
this.timeout(40000)
this.timeout(50000)
const updateAt = new Date(new Date().getTime() + 1000000)

View File

@ -195,12 +195,14 @@ describe('Test stats (excluding redundancy)', function () {
await waitJobs(servers)
await wait(6000)
const res2 = await getStats(servers[1].url)
const second: ServerStats = res2.body
expect(second.totalActivityPubMessagesProcessed).to.be.greaterThan(first.totalActivityPubMessagesProcessed)
await wait(5000)
await wait(6000)
const res3 = await getStats(servers[1].url)
const third: ServerStats = res3.body

View File

@ -164,6 +164,17 @@ async function waitUntilLiveState (url: string, token: string, videoId: number |
} while (video.state.id !== state)
}
async function waitUntilLiveSaved (url: string, token: string, videoId: number | string) {
let video: VideoDetails
do {
const res = await getVideoWithToken(url, token, videoId)
video = res.body
await wait(500)
} while (video.isLive === true && video.state.id !== VideoState.PUBLISHED)
}
async function checkLiveCleanup (server: ServerInfo, videoUUID: string, resolutions: number[] = []) {
const basePath = buildServerDirectory(server, 'streaming-playlists')
const hlsPath = join(basePath, 'hls', videoUUID)
@ -203,6 +214,7 @@ async function getPlaylistsCount (server: ServerInfo, videoUUID: string) {
export {
getLive,
getPlaylistsCount,
waitUntilLiveSaved,
waitUntilLivePublished,
updateLive,
createLive,