2020-01-31 16:56:52 +01:00
|
|
|
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
2018-02-28 18:04:46 +01:00
|
|
|
|
2022-08-17 15:44:32 +02:00
|
|
|
import { expect } from 'chai'
|
2023-07-31 14:34:36 +02:00
|
|
|
import { wait } from '@peertube/peertube-core-utils'
|
2024-02-21 13:48:52 +01:00
|
|
|
import { AbuseState, ActivityType, VideoPlaylistPrivacy } from '@peertube/peertube-models'
|
2018-02-28 18:04:46 +01:00
|
|
|
import {
|
2019-04-24 15:10:37 +02:00
|
|
|
cleanupTests,
|
2021-07-16 09:47:51 +02:00
|
|
|
createMultipleServers,
|
2021-07-16 14:27:30 +02:00
|
|
|
doubleFollow,
|
2021-07-16 09:47:51 +02:00
|
|
|
PeerTubeServer,
|
2021-07-07 09:16:40 +02:00
|
|
|
setAccessTokensToServers,
|
2022-06-17 16:16:28 +02:00
|
|
|
setDefaultAccountAvatar,
|
|
|
|
setDefaultChannelAvatar,
|
2021-07-07 09:16:40 +02:00
|
|
|
waitJobs
|
2023-07-31 14:34:36 +02:00
|
|
|
} from '@peertube/peertube-server-commands'
|
2018-02-28 18:04:46 +01:00
|
|
|
|
2018-09-14 14:57:59 +02:00
|
|
|
describe('Test stats (excluding redundancy)', function () {
|
2021-07-16 09:47:51 +02:00
|
|
|
let servers: PeerTubeServer[] = []
|
2021-04-12 11:19:07 +02:00
|
|
|
let channelId
|
2024-02-21 13:48:52 +01:00
|
|
|
const user = { username: 'user1', password: 'super_password' }
|
|
|
|
let userAccountId: number
|
2018-02-28 18:04:46 +01:00
|
|
|
|
|
|
|
before(async function () {
|
2022-07-12 16:00:15 +02:00
|
|
|
this.timeout(120000)
|
2020-11-10 08:07:21 +01:00
|
|
|
|
2021-07-16 09:47:51 +02:00
|
|
|
servers = await createMultipleServers(3)
|
2020-11-10 08:07:21 +01:00
|
|
|
|
2018-02-28 18:04:46 +01:00
|
|
|
await setAccessTokensToServers(servers)
|
2022-06-17 16:16:28 +02:00
|
|
|
await setDefaultChannelAvatar(servers)
|
|
|
|
await setDefaultAccountAvatar(servers)
|
2018-02-28 18:04:46 +01:00
|
|
|
|
|
|
|
await doubleFollow(servers[0], servers[1])
|
|
|
|
|
2024-02-21 13:48:52 +01:00
|
|
|
const { account } = await servers[0].users.create({ username: user.username, password: user.password })
|
|
|
|
userAccountId = account.id
|
2018-02-28 18:04:46 +01:00
|
|
|
|
2021-07-16 09:04:35 +02:00
|
|
|
const { uuid } = await servers[0].videos.upload({ attributes: { fixture: 'video_short.webm' } })
|
2018-02-28 18:04:46 +01:00
|
|
|
|
2021-07-16 09:04:35 +02:00
|
|
|
await servers[0].comments.createThread({ videoId: uuid, text: 'comment' })
|
2018-02-28 18:04:46 +01:00
|
|
|
|
2022-03-24 13:36:47 +01:00
|
|
|
await servers[0].views.simulateView({ id: uuid })
|
2018-02-28 18:04:46 +01:00
|
|
|
|
2018-08-29 16:26:25 +02:00
|
|
|
// Wait the video views repeatable job
|
|
|
|
await wait(8000)
|
|
|
|
|
2021-07-20 14:15:15 +02:00
|
|
|
await servers[2].follows.follow({ hosts: [ servers[0].url ] })
|
2018-06-13 10:06:50 +02:00
|
|
|
await waitJobs(servers)
|
2018-02-28 18:04:46 +01:00
|
|
|
})
|
|
|
|
|
2024-02-21 13:48:52 +01:00
|
|
|
describe('Total stats', function () {
|
2018-02-28 18:04:46 +01:00
|
|
|
|
2024-02-21 13:48:52 +01:00
|
|
|
it('Should have the correct stats on instance 1', async function () {
|
|
|
|
const data = await servers[0].stats.get()
|
2018-02-28 18:04:46 +01:00
|
|
|
|
2024-02-21 13:48:52 +01:00
|
|
|
expect(data.totalLocalVideoComments).to.equal(1)
|
|
|
|
expect(data.totalLocalVideos).to.equal(1)
|
|
|
|
expect(data.totalLocalVideoViews).to.equal(1)
|
|
|
|
expect(data.totalLocalVideoFilesSize).to.equal(218910)
|
|
|
|
expect(data.totalUsers).to.equal(2)
|
|
|
|
expect(data.totalVideoComments).to.equal(1)
|
|
|
|
expect(data.totalVideos).to.equal(1)
|
|
|
|
expect(data.totalInstanceFollowers).to.equal(2)
|
|
|
|
expect(data.totalInstanceFollowing).to.equal(1)
|
|
|
|
expect(data.totalLocalPlaylists).to.equal(0)
|
|
|
|
})
|
2018-02-28 18:04:46 +01:00
|
|
|
|
2024-02-21 13:48:52 +01:00
|
|
|
it('Should have the correct stats on instance 2', async function () {
|
|
|
|
const data = await servers[1].stats.get()
|
2020-05-07 10:39:09 +02:00
|
|
|
|
2024-02-21 13:48:52 +01:00
|
|
|
expect(data.totalLocalVideoComments).to.equal(0)
|
|
|
|
expect(data.totalLocalVideos).to.equal(0)
|
|
|
|
expect(data.totalLocalVideoViews).to.equal(0)
|
|
|
|
expect(data.totalLocalVideoFilesSize).to.equal(0)
|
|
|
|
expect(data.totalUsers).to.equal(1)
|
|
|
|
expect(data.totalVideoComments).to.equal(1)
|
|
|
|
expect(data.totalVideos).to.equal(1)
|
|
|
|
expect(data.totalInstanceFollowers).to.equal(1)
|
|
|
|
expect(data.totalInstanceFollowing).to.equal(1)
|
|
|
|
expect(data.totalLocalPlaylists).to.equal(0)
|
|
|
|
})
|
2020-03-13 13:43:26 +01:00
|
|
|
|
2024-02-21 13:48:52 +01:00
|
|
|
it('Should have the correct stats on instance 3', async function () {
|
|
|
|
const data = await servers[2].stats.get()
|
|
|
|
|
|
|
|
expect(data.totalLocalVideoComments).to.equal(0)
|
|
|
|
expect(data.totalLocalVideos).to.equal(0)
|
|
|
|
expect(data.totalLocalVideoViews).to.equal(0)
|
|
|
|
expect(data.totalUsers).to.equal(1)
|
|
|
|
expect(data.totalVideoComments).to.equal(1)
|
|
|
|
expect(data.totalVideos).to.equal(1)
|
|
|
|
expect(data.totalInstanceFollowing).to.equal(1)
|
|
|
|
expect(data.totalInstanceFollowers).to.equal(0)
|
|
|
|
expect(data.totalLocalPlaylists).to.equal(0)
|
|
|
|
})
|
2020-03-13 13:43:26 +01:00
|
|
|
|
2024-02-21 13:48:52 +01:00
|
|
|
it('Should have the correct total videos stats after an unfollow', async function () {
|
|
|
|
this.timeout(15000)
|
2020-03-13 13:43:26 +01:00
|
|
|
|
2024-02-21 13:48:52 +01:00
|
|
|
await servers[2].follows.unfollow({ target: servers[0] })
|
|
|
|
await waitJobs(servers)
|
2020-05-07 10:39:09 +02:00
|
|
|
|
2024-02-21 13:48:52 +01:00
|
|
|
const data = await servers[2].stats.get()
|
2021-07-07 11:07:12 +02:00
|
|
|
|
2024-02-21 13:48:52 +01:00
|
|
|
expect(data.totalVideos).to.equal(0)
|
|
|
|
})
|
2020-05-07 10:39:09 +02:00
|
|
|
|
2024-02-21 13:48:52 +01:00
|
|
|
it('Should have the correct active user stats', async function () {
|
|
|
|
const server = servers[0]
|
2020-05-07 10:39:09 +02:00
|
|
|
|
2024-02-21 13:48:52 +01:00
|
|
|
{
|
|
|
|
const data = await server.stats.get()
|
2021-07-07 11:07:12 +02:00
|
|
|
|
2024-02-21 13:48:52 +01:00
|
|
|
expect(data.totalDailyActiveUsers).to.equal(1)
|
|
|
|
expect(data.totalWeeklyActiveUsers).to.equal(1)
|
|
|
|
expect(data.totalMonthlyActiveUsers).to.equal(1)
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
await server.login.getAccessToken(user)
|
2020-05-07 10:39:09 +02:00
|
|
|
|
2024-02-21 13:48:52 +01:00
|
|
|
const data = await server.stats.get()
|
|
|
|
|
|
|
|
expect(data.totalDailyActiveUsers).to.equal(2)
|
|
|
|
expect(data.totalWeeklyActiveUsers).to.equal(2)
|
|
|
|
expect(data.totalMonthlyActiveUsers).to.equal(2)
|
|
|
|
}
|
|
|
|
})
|
2021-04-12 11:19:07 +02:00
|
|
|
|
2024-02-21 13:48:52 +01:00
|
|
|
it('Should have the correct active channel stats', async function () {
|
|
|
|
const server = servers[0]
|
2021-07-07 11:07:12 +02:00
|
|
|
|
2024-02-21 13:48:52 +01:00
|
|
|
{
|
|
|
|
const data = await server.stats.get()
|
2021-04-12 11:19:07 +02:00
|
|
|
|
2024-02-21 13:48:52 +01:00
|
|
|
expect(data.totalLocalVideoChannels).to.equal(2)
|
|
|
|
expect(data.totalLocalDailyActiveVideoChannels).to.equal(1)
|
|
|
|
expect(data.totalLocalWeeklyActiveVideoChannels).to.equal(1)
|
|
|
|
expect(data.totalLocalMonthlyActiveVideoChannels).to.equal(1)
|
2021-04-12 11:19:07 +02:00
|
|
|
}
|
|
|
|
|
2024-02-21 13:48:52 +01:00
|
|
|
{
|
|
|
|
const attributes = {
|
|
|
|
name: 'stats_channel',
|
|
|
|
displayName: 'My stats channel'
|
|
|
|
}
|
|
|
|
const created = await server.channels.create({ attributes })
|
|
|
|
channelId = created.id
|
2021-07-07 11:07:12 +02:00
|
|
|
|
2024-02-21 13:48:52 +01:00
|
|
|
const data = await server.stats.get()
|
2021-04-12 11:19:07 +02:00
|
|
|
|
2024-02-21 13:48:52 +01:00
|
|
|
expect(data.totalLocalVideoChannels).to.equal(3)
|
|
|
|
expect(data.totalLocalDailyActiveVideoChannels).to.equal(1)
|
|
|
|
expect(data.totalLocalWeeklyActiveVideoChannels).to.equal(1)
|
|
|
|
expect(data.totalLocalMonthlyActiveVideoChannels).to.equal(1)
|
|
|
|
}
|
2021-04-12 11:19:07 +02:00
|
|
|
|
2024-02-21 13:48:52 +01:00
|
|
|
{
|
|
|
|
await server.videos.upload({ attributes: { fixture: 'video_short.webm', channelId } })
|
2021-07-07 11:07:12 +02:00
|
|
|
|
2024-02-21 13:48:52 +01:00
|
|
|
const data = await server.stats.get()
|
2021-04-12 11:19:07 +02:00
|
|
|
|
2024-02-21 13:48:52 +01:00
|
|
|
expect(data.totalLocalVideoChannels).to.equal(3)
|
|
|
|
expect(data.totalLocalDailyActiveVideoChannels).to.equal(2)
|
|
|
|
expect(data.totalLocalWeeklyActiveVideoChannels).to.equal(2)
|
|
|
|
expect(data.totalLocalMonthlyActiveVideoChannels).to.equal(2)
|
|
|
|
}
|
|
|
|
})
|
2021-04-12 11:19:07 +02:00
|
|
|
|
2024-02-21 13:48:52 +01:00
|
|
|
it('Should have the correct playlist stats', async function () {
|
|
|
|
const server = servers[0]
|
2021-04-12 11:19:07 +02:00
|
|
|
|
2024-02-21 13:48:52 +01:00
|
|
|
{
|
|
|
|
const data = await server.stats.get()
|
|
|
|
expect(data.totalLocalPlaylists).to.equal(0)
|
|
|
|
}
|
2021-04-12 11:19:07 +02:00
|
|
|
|
2024-02-21 13:48:52 +01:00
|
|
|
{
|
|
|
|
await server.playlists.create({
|
|
|
|
attributes: {
|
|
|
|
displayName: 'playlist for count',
|
|
|
|
privacy: VideoPlaylistPrivacy.PUBLIC,
|
|
|
|
videoChannelId: channelId
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
const data = await server.stats.get()
|
|
|
|
expect(data.totalLocalPlaylists).to.equal(1)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
2020-11-10 08:07:21 +01:00
|
|
|
|
2024-02-21 13:48:52 +01:00
|
|
|
describe('File sizes', function () {
|
|
|
|
|
|
|
|
it('Should correctly count video file sizes if transcoding is enabled', async function () {
|
|
|
|
this.timeout(120000)
|
|
|
|
|
|
|
|
await servers[0].config.updateCustomSubConfig({
|
|
|
|
newConfig: {
|
|
|
|
transcoding: {
|
|
|
|
enabled: true,
|
|
|
|
webVideos: {
|
|
|
|
enabled: true
|
|
|
|
},
|
|
|
|
hls: {
|
|
|
|
enabled: true
|
|
|
|
},
|
|
|
|
resolutions: {
|
|
|
|
'0p': false,
|
|
|
|
'144p': false,
|
|
|
|
'240p': false,
|
|
|
|
'360p': false,
|
|
|
|
'480p': false,
|
|
|
|
'720p': false,
|
|
|
|
'1080p': false,
|
|
|
|
'1440p': false,
|
|
|
|
'2160p': false
|
|
|
|
}
|
2021-07-07 11:51:09 +02:00
|
|
|
}
|
2020-11-10 08:07:21 +01:00
|
|
|
}
|
2024-02-21 13:48:52 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
await servers[0].videos.upload({ attributes: { name: 'video', fixture: 'video_short.webm' } })
|
|
|
|
|
|
|
|
await waitJobs(servers)
|
|
|
|
|
|
|
|
{
|
|
|
|
const data = await servers[1].stats.get()
|
|
|
|
expect(data.totalLocalVideoFilesSize).to.equal(0)
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
const data = await servers[0].stats.get()
|
|
|
|
expect(data.totalLocalVideoFilesSize).to.be.greaterThan(500000)
|
|
|
|
expect(data.totalLocalVideoFilesSize).to.be.lessThan(600000)
|
2020-11-10 08:07:21 +01:00
|
|
|
}
|
|
|
|
})
|
2024-02-21 13:48:52 +01:00
|
|
|
})
|
2020-11-10 08:07:21 +01:00
|
|
|
|
2024-02-21 13:48:52 +01:00
|
|
|
describe('ActivityPub', function () {
|
2020-11-10 08:07:21 +01:00
|
|
|
|
2024-02-21 13:48:52 +01:00
|
|
|
it('Should have the correct AP stats', async function () {
|
|
|
|
this.timeout(240000)
|
2020-11-10 08:07:21 +01:00
|
|
|
|
2024-02-21 13:48:52 +01:00
|
|
|
await servers[0].config.disableTranscoding()
|
|
|
|
|
|
|
|
const first = await servers[1].stats.get()
|
|
|
|
|
|
|
|
for (let i = 0; i < 10; i++) {
|
|
|
|
await servers[0].videos.upload({ attributes: { name: 'video' } })
|
|
|
|
}
|
|
|
|
|
|
|
|
await waitJobs(servers)
|
|
|
|
|
|
|
|
await wait(6000)
|
|
|
|
|
|
|
|
const second = await servers[1].stats.get()
|
|
|
|
expect(second.totalActivityPubMessagesProcessed).to.be.greaterThan(first.totalActivityPubMessagesProcessed)
|
|
|
|
|
|
|
|
const apTypes: ActivityType[] = [
|
|
|
|
'Create', 'Update', 'Delete', 'Follow', 'Accept', 'Announce', 'Undo', 'Like', 'Reject', 'View', 'Dislike', 'Flag'
|
|
|
|
]
|
|
|
|
|
|
|
|
const processed = apTypes.reduce(
|
|
|
|
(previous, type) => previous + second['totalActivityPub' + type + 'MessagesSuccesses'],
|
|
|
|
0
|
|
|
|
)
|
|
|
|
expect(second.totalActivityPubMessagesProcessed).to.equal(processed)
|
|
|
|
expect(second.totalActivityPubMessagesSuccesses).to.equal(processed)
|
|
|
|
|
|
|
|
expect(second.totalActivityPubMessagesErrors).to.equal(0)
|
2020-11-10 08:07:21 +01:00
|
|
|
|
2024-02-21 13:48:52 +01:00
|
|
|
for (const apType of apTypes) {
|
|
|
|
expect(second['totalActivityPub' + apType + 'MessagesErrors']).to.equal(0)
|
|
|
|
}
|
|
|
|
|
|
|
|
await wait(6000)
|
|
|
|
|
|
|
|
const third = await servers[1].stats.get()
|
|
|
|
expect(third.totalActivityPubMessagesWaiting).to.equal(0)
|
|
|
|
expect(third.activityPubMessagesProcessedPerSecond).to.be.lessThan(second.activityPubMessagesProcessedPerSecond)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('User registration requests stats', function () {
|
|
|
|
let id2: number
|
|
|
|
let beforeTimestamp: number
|
|
|
|
let lastResponseTime: number
|
|
|
|
|
|
|
|
before(async function () {
|
|
|
|
await servers[0].config.enableSignup(true)
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should not have registration requests stats available', async function () {
|
2021-07-16 09:04:35 +02:00
|
|
|
const data = await servers[0].stats.get()
|
2024-02-21 13:48:52 +01:00
|
|
|
|
|
|
|
expect(data.totalRegistrationRequests).to.equal(0)
|
|
|
|
expect(data.totalRegistrationRequestsProcessed).to.equal(0)
|
|
|
|
expect(data.averageRegistrationRequestResponseTimeMs).to.be.null
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should create registration requests, accept one and have correct stats', async function () {
|
|
|
|
beforeTimestamp = new Date().getTime()
|
|
|
|
|
|
|
|
const { id: id1 } = await servers[0].registrations.requestRegistration({ username: 'user2', registrationReason: 'reason 1' });
|
|
|
|
({ id: id2 } = await servers[0].registrations.requestRegistration({ username: 'user3', registrationReason: 'reason 2' }))
|
|
|
|
await servers[0].registrations.requestRegistration({ username: 'user4', registrationReason: 'reason 3' })
|
|
|
|
|
|
|
|
await wait(1500)
|
|
|
|
|
|
|
|
await servers[0].registrations.accept({ id: id1, moderationResponse: 'thanks' })
|
|
|
|
|
|
|
|
const middleTimestamp = new Date().getTime()
|
|
|
|
|
|
|
|
{
|
|
|
|
const data = await servers[0].stats.get()
|
|
|
|
|
|
|
|
expect(data.totalRegistrationRequests).to.equal(3)
|
|
|
|
expect(data.totalRegistrationRequestsProcessed).to.equal(1)
|
|
|
|
|
|
|
|
expect(data.averageRegistrationRequestResponseTimeMs).to.be.greaterThan(1000)
|
|
|
|
expect(data.averageRegistrationRequestResponseTimeMs).to.be.below(middleTimestamp - beforeTimestamp)
|
|
|
|
|
|
|
|
lastResponseTime = data.averageRegistrationRequestResponseTimeMs
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should accept another request and update stats', async function () {
|
|
|
|
await wait(1500)
|
|
|
|
|
|
|
|
await servers[0].registrations.accept({ id: id2, moderationResponse: 'thanks' })
|
|
|
|
|
|
|
|
const lastTimestamp = new Date().getTime()
|
|
|
|
|
|
|
|
{
|
|
|
|
const data = await servers[0].stats.get()
|
|
|
|
|
|
|
|
expect(data.totalRegistrationRequests).to.equal(3)
|
|
|
|
expect(data.totalRegistrationRequestsProcessed).to.equal(2)
|
|
|
|
|
|
|
|
expect(data.averageRegistrationRequestResponseTimeMs).to.be.greaterThan(lastResponseTime)
|
|
|
|
expect(data.averageRegistrationRequestResponseTimeMs).to.be.below(lastTimestamp - beforeTimestamp)
|
|
|
|
}
|
|
|
|
})
|
2020-11-10 08:07:21 +01:00
|
|
|
})
|
|
|
|
|
2024-02-21 13:48:52 +01:00
|
|
|
describe('Abuses stats', function () {
|
|
|
|
let abuse2: number
|
|
|
|
let videoId: number
|
|
|
|
let commentId: number
|
|
|
|
let beforeTimestamp: number
|
|
|
|
let lastResponseTime: number
|
|
|
|
let userToken: string
|
2020-12-15 13:34:58 +01:00
|
|
|
|
2024-02-21 13:48:52 +01:00
|
|
|
before(async function () {
|
|
|
|
userToken = await servers[0].users.generateUserAndToken('reporter');
|
2020-12-16 10:36:15 +01:00
|
|
|
|
2024-02-21 13:48:52 +01:00
|
|
|
({ id: videoId } = await servers[0].videos.quickUpload({ name: 'to_report' }));
|
|
|
|
({ id: commentId } = await servers[0].comments.createThread({ videoId, text: 'text' }))
|
|
|
|
})
|
2020-12-16 14:59:33 +01:00
|
|
|
|
2024-02-21 13:48:52 +01:00
|
|
|
it('Should not abuses stats available', async function () {
|
|
|
|
const data = await servers[0].stats.get()
|
2020-12-15 13:34:58 +01:00
|
|
|
|
2024-02-21 13:48:52 +01:00
|
|
|
expect(data.totalAbuses).to.equal(0)
|
|
|
|
expect(data.totalAbusesProcessed).to.equal(0)
|
|
|
|
expect(data.averageAbuseResponseTimeMs).to.be.null
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should create abuses, process one and have correct stats', async function () {
|
|
|
|
beforeTimestamp = new Date().getTime()
|
|
|
|
|
|
|
|
const { abuse: abuse1 } = await servers[0].abuses.report({ videoId, token: userToken, reason: 'abuse reason' });
|
|
|
|
({ abuse: { id: abuse2 } } = await servers[0].abuses.report({ accountId: userAccountId, token: userToken, reason: 'abuse reason' }))
|
|
|
|
await servers[0].abuses.report({ commentId, token: userToken, reason: 'abuse reason' })
|
|
|
|
|
|
|
|
await wait(1500)
|
|
|
|
|
|
|
|
await servers[0].abuses.update({ abuseId: abuse1.id, body: { state: AbuseState.REJECTED } })
|
|
|
|
|
|
|
|
const middleTimestamp = new Date().getTime()
|
|
|
|
|
|
|
|
{
|
|
|
|
const data = await servers[0].stats.get()
|
|
|
|
|
|
|
|
expect(data.totalAbuses).to.equal(3)
|
|
|
|
expect(data.totalAbusesProcessed).to.equal(1)
|
|
|
|
|
|
|
|
expect(data.averageAbuseResponseTimeMs).to.be.greaterThan(1000)
|
|
|
|
expect(data.averageAbuseResponseTimeMs).to.be.below(middleTimestamp - beforeTimestamp)
|
2020-12-15 13:34:58 +01:00
|
|
|
|
2024-02-21 13:48:52 +01:00
|
|
|
lastResponseTime = data.averageAbuseResponseTimeMs
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should accept another request and update stats', async function () {
|
|
|
|
await wait(1500)
|
|
|
|
|
|
|
|
await servers[0].abuses.addMessage({ abuseId: abuse2, message: 'my message' })
|
|
|
|
|
|
|
|
const lastTimestamp = new Date().getTime()
|
|
|
|
|
|
|
|
{
|
|
|
|
const data = await servers[0].stats.get()
|
|
|
|
|
|
|
|
expect(data.totalAbuses).to.equal(3)
|
|
|
|
expect(data.totalAbusesProcessed).to.equal(2)
|
2021-02-19 14:30:00 +01:00
|
|
|
|
2024-02-21 13:48:52 +01:00
|
|
|
expect(data.averageAbuseResponseTimeMs).to.be.greaterThan(lastResponseTime)
|
|
|
|
expect(data.averageAbuseResponseTimeMs).to.be.below(lastTimestamp - beforeTimestamp)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
2021-07-07 11:07:12 +02:00
|
|
|
|
2024-02-21 13:48:52 +01:00
|
|
|
describe('Disabling stats', async function () {
|
2021-02-26 10:28:11 +01:00
|
|
|
|
2024-02-21 13:48:52 +01:00
|
|
|
it('Should disable registration requests and abuses stats', async function () {
|
|
|
|
this.timeout(60000)
|
2021-02-26 10:28:11 +01:00
|
|
|
|
2024-02-21 13:48:52 +01:00
|
|
|
await servers[0].kill()
|
|
|
|
await servers[0].run({
|
|
|
|
stats: {
|
|
|
|
registration_requests: { enabled: false },
|
|
|
|
abuses: { enabled: false }
|
|
|
|
}
|
|
|
|
})
|
2021-02-26 10:28:11 +01:00
|
|
|
|
2024-02-21 13:48:52 +01:00
|
|
|
const data = await servers[0].stats.get()
|
2020-12-15 13:34:58 +01:00
|
|
|
|
2024-02-21 13:48:52 +01:00
|
|
|
expect(data.totalRegistrationRequests).to.be.null
|
|
|
|
expect(data.totalRegistrationRequestsProcessed).to.be.null
|
|
|
|
expect(data.averageRegistrationRequestResponseTimeMs).to.be.null
|
2020-12-15 13:34:58 +01:00
|
|
|
|
2024-02-21 13:48:52 +01:00
|
|
|
expect(data.totalAbuses).to.be.null
|
|
|
|
expect(data.totalAbusesProcessed).to.be.null
|
|
|
|
expect(data.averageAbuseResponseTimeMs).to.be.null
|
|
|
|
})
|
2020-12-15 13:34:58 +01:00
|
|
|
})
|
|
|
|
|
2019-04-24 15:10:37 +02:00
|
|
|
after(async function () {
|
|
|
|
await cleanupTests(servers)
|
2018-02-28 18:04:46 +01:00
|
|
|
})
|
|
|
|
})
|