Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Fix stats tests

Chocobozzz94d721efdc9a
diff --git a/scripts/ci.sh b/scripts/ci.sh
index 9399a0f590..d90c2cd108 100755
--- a/scripts/ci.sh
+++ b/scripts/ci.sh
@@ -10,11 +10,8 @@ fi
killall -q peertube || true
retries=3
-jobs=2
runTest () {
- retries=3
-
jobname=$1
shift
diff --git a/server/tests/api/live/live-save-replay.ts b/server/tests/api/live/live-save-replay.ts
index 6dd6fb44e1..61c8e74dd4 100644
--- a/server/tests/api/live/live-save-replay.ts
+++ b/server/tests/api/live/live-save-replay.ts
@@ -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)
diff --git a/server/tests/api/notifications/user-notifications.ts b/server/tests/api/notifications/user-notifications.ts
index 6a65447fde..7e88d979b8 100644
--- a/server/tests/api/notifications/user-notifications.ts
+++ b/server/tests/api/notifications/user-notifications.ts
@@ -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)
diff --git a/server/tests/api/server/stats.ts b/server/tests/api/server/stats.ts
index 82065e7702..332c09585f 100644
--- a/server/tests/api/server/stats.ts
+++ b/server/tests/api/server/stats.ts
@@ -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
diff --git a/shared/extra-utils/videos/live.ts b/shared/extra-utils/videos/live.ts
index b0e499ce0b..df73700081 100644
--- a/shared/extra-utils/videos/live.ts
+++ b/shared/extra-utils/videos/live.ts
@@ -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,