From ac907dc7c158056e9b6a5cb58acd27df5c7c2670 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 6 Apr 2022 08:50:43 +0200 Subject: Improve viewer counter More precise, avoid weird decrease, reuse an id to federate viewers --- server/tests/api/check-params/views.ts | 2 +- server/tests/api/views/video-views-counter.ts | 9 +++++---- server/tests/api/views/video-views-overall-stats.ts | 6 +++--- server/tests/api/views/video-views-retention-stats.ts | 2 +- server/tests/api/views/video-views-timeserie-stats.ts | 4 ++-- 5 files changed, 12 insertions(+), 11 deletions(-) (limited to 'server/tests/api') diff --git a/server/tests/api/check-params/views.ts b/server/tests/api/check-params/views.ts index 185b04af1..ca4752345 100644 --- a/server/tests/api/check-params/views.ts +++ b/server/tests/api/check-params/views.ts @@ -19,7 +19,7 @@ describe('Test videos views', function () { let userAccessToken: string before(async function () { - this.timeout(30000) + this.timeout(120000) servers = await createMultipleServers(2) await setAccessTokensToServers(servers) diff --git a/server/tests/api/views/video-views-counter.ts b/server/tests/api/views/video-views-counter.ts index b68aaa350..b8969d52d 100644 --- a/server/tests/api/views/video-views-counter.ts +++ b/server/tests/api/views/video-views-counter.ts @@ -57,10 +57,11 @@ describe('Test video views/viewers counters', function () { }) it('Should not view again this video with the same IP', async function () { - await servers[0].views.simulateViewer({ id: videoUUID, currentTimes: [ 1, 4 ] }) + await servers[0].views.simulateViewer({ id: videoUUID, xForwardedFor: '0.0.0.1,127.0.0.1', currentTimes: [ 1, 4 ] }) + await servers[0].views.simulateViewer({ id: videoUUID, xForwardedFor: '0.0.0.1,127.0.0.1', currentTimes: [ 1, 4 ] }) await processViewsBuffer(servers) - await checkCounter('views', videoUUID, 1) + await checkCounter('views', videoUUID, 2) }) it('Should view the video from server 2 and send the event', async function () { @@ -68,7 +69,7 @@ describe('Test video views/viewers counters', function () { await waitJobs(servers) await processViewsBuffer(servers) - await checkCounter('views', videoUUID, 2) + await checkCounter('views', videoUUID, 3) }) }) @@ -78,7 +79,7 @@ describe('Test video views/viewers counters', function () { let command: FfmpegCommand before(async function () { - this.timeout(60000); + this.timeout(120000); ({ vodVideoId, liveVideoId, ffmpegCommand: command } = await prepareViewsVideos({ servers, live: true, vod: true })) }) diff --git a/server/tests/api/views/video-views-overall-stats.ts b/server/tests/api/views/video-views-overall-stats.ts index 22761d6ec..d8de73cbc 100644 --- a/server/tests/api/views/video-views-overall-stats.ts +++ b/server/tests/api/views/video-views-overall-stats.ts @@ -21,7 +21,7 @@ describe('Test views overall stats', function () { let vodVideoId: string before(async function () { - this.timeout(60000); + this.timeout(120000); ({ vodVideoId } = await prepareViewsVideos({ servers, live: false, vod: true })) }) @@ -74,7 +74,7 @@ describe('Test views overall stats', function () { let command: FfmpegCommand before(async function () { - this.timeout(60000); + this.timeout(120000); ({ vodVideoId, liveVideoId, ffmpegCommand: command } = await prepareViewsVideos({ servers, live: true, vod: true })) }) @@ -189,7 +189,7 @@ describe('Test views overall stats', function () { let videoUUID: string before(async function () { - this.timeout(60000); + this.timeout(120000); ({ vodVideoId: videoUUID } = await prepareViewsVideos({ servers, live: true, vod: true })) }) diff --git a/server/tests/api/views/video-views-retention-stats.ts b/server/tests/api/views/video-views-retention-stats.ts index 98be7bfdb..a27141d68 100644 --- a/server/tests/api/views/video-views-retention-stats.ts +++ b/server/tests/api/views/video-views-retention-stats.ts @@ -20,7 +20,7 @@ describe('Test views retention stats', function () { let vodVideoId: string before(async function () { - this.timeout(60000); + this.timeout(120000); ({ vodVideoId } = await prepareViewsVideos({ servers, live: false, vod: true })) }) diff --git a/server/tests/api/views/video-views-timeserie-stats.ts b/server/tests/api/views/video-views-timeserie-stats.ts index 98c041cdf..858edeff7 100644 --- a/server/tests/api/views/video-views-timeserie-stats.ts +++ b/server/tests/api/views/video-views-timeserie-stats.ts @@ -24,7 +24,7 @@ describe('Test views timeserie stats', function () { let vodVideoId: string before(async function () { - this.timeout(60000); + this.timeout(120000); ({ vodVideoId } = await prepareViewsVideos({ servers, live: false, vod: true })) }) @@ -63,7 +63,7 @@ describe('Test views timeserie stats', function () { } before(async function () { - this.timeout(60000); + this.timeout(120000); ({ vodVideoId, liveVideoId, ffmpegCommand: command } = await prepareViewsVideos({ servers, live: true, vod: true })) }) -- cgit v1.2.3