aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/api/redundancy/redundancy.ts15
-rw-r--r--server/tests/api/server/stats.ts63
2 files changed, 27 insertions, 51 deletions
diff --git a/server/tests/api/redundancy/redundancy.ts b/server/tests/api/redundancy/redundancy.ts
index 5b970473c..e4ea99de6 100644
--- a/server/tests/api/redundancy/redundancy.ts
+++ b/server/tests/api/redundancy/redundancy.ts
@@ -5,7 +5,6 @@ import * as chai from 'chai'
5import { readdir } from 'fs-extra' 5import { readdir } from 'fs-extra'
6import * as magnetUtil from 'magnet-uri' 6import * as magnetUtil from 'magnet-uri'
7import { join } from 'path' 7import { join } from 'path'
8import { removeVideoRedundancy } from '@server/lib/redundancy'
9import { HttpStatusCode } from '@shared/core-utils' 8import { HttpStatusCode } from '@shared/core-utils'
10import { 9import {
11 checkSegmentHash, 10 checkSegmentHash,
@@ -30,15 +29,7 @@ import {
30 waitJobs, 29 waitJobs,
31 waitUntilLog 30 waitUntilLog
32} from '@shared/extra-utils' 31} from '@shared/extra-utils'
33import { getStats } from '@shared/extra-utils/server/stats' 32import { VideoDetails, VideoPrivacy, VideoRedundancyStrategy, VideoRedundancyStrategyWithManual } from '@shared/models'
34import {
35 ServerStats,
36 VideoDetails,
37 VideoPrivacy,
38 VideoRedundancy,
39 VideoRedundancyStrategy,
40 VideoRedundancyStrategyWithManual
41} from '@shared/models'
42 33
43const expect = chai.expect 34const expect = chai.expect
44 35
@@ -241,9 +232,7 @@ async function checkStatsGlobal (strategy: VideoRedundancyStrategyWithManual) {
241 statsLength = 2 232 statsLength = 2
242 } 233 }
243 234
244 const res = await getStats(servers[0].url) 235 const data = await servers[0].statsCommand.get()
245 const data: ServerStats = res.body
246
247 expect(data.videosRedundancy).to.have.lengthOf(statsLength) 236 expect(data.videosRedundancy).to.have.lengthOf(statsLength)
248 237
249 const stat = data.videosRedundancy[0] 238 const stat = data.videosRedundancy[0]
diff --git a/server/tests/api/server/stats.ts b/server/tests/api/server/stats.ts
index f609ea725..36114a297 100644
--- a/server/tests/api/server/stats.ts
+++ b/server/tests/api/server/stats.ts
@@ -19,8 +19,7 @@ import {
19 wait, 19 wait,
20 waitJobs 20 waitJobs
21} from '@shared/extra-utils' 21} from '@shared/extra-utils'
22import { getStats } from '@shared/extra-utils/server/stats' 22import { ActivityType, VideoPlaylistPrivacy } from '@shared/models'
23import { ActivityType, ServerStats, VideoPlaylistPrivacy } from '@shared/models'
24 23
25const expect = chai.expect 24const expect = chai.expect
26 25
@@ -58,8 +57,7 @@ describe('Test stats (excluding redundancy)', function () {
58 }) 57 })
59 58
60 it('Should have the correct stats on instance 1', async function () { 59 it('Should have the correct stats on instance 1', async function () {
61 const res = await getStats(servers[0].url) 60 const data = await servers[0].statsCommand.get()
62 const data: ServerStats = res.body
63 61
64 expect(data.totalLocalVideoComments).to.equal(1) 62 expect(data.totalLocalVideoComments).to.equal(1)
65 expect(data.totalLocalVideos).to.equal(1) 63 expect(data.totalLocalVideos).to.equal(1)
@@ -74,8 +72,7 @@ describe('Test stats (excluding redundancy)', function () {
74 }) 72 })
75 73
76 it('Should have the correct stats on instance 2', async function () { 74 it('Should have the correct stats on instance 2', async function () {
77 const res = await getStats(servers[1].url) 75 const data = await servers[1].statsCommand.get()
78 const data: ServerStats = res.body
79 76
80 expect(data.totalLocalVideoComments).to.equal(0) 77 expect(data.totalLocalVideoComments).to.equal(0)
81 expect(data.totalLocalVideos).to.equal(0) 78 expect(data.totalLocalVideos).to.equal(0)
@@ -90,8 +87,7 @@ describe('Test stats (excluding redundancy)', function () {
90 }) 87 })
91 88
92 it('Should have the correct stats on instance 3', async function () { 89 it('Should have the correct stats on instance 3', async function () {
93 const res = await getStats(servers[2].url) 90 const data = await servers[2].statsCommand.get()
94 const data: ServerStats = res.body
95 91
96 expect(data.totalLocalVideoComments).to.equal(0) 92 expect(data.totalLocalVideoComments).to.equal(0)
97 expect(data.totalLocalVideos).to.equal(0) 93 expect(data.totalLocalVideos).to.equal(0)
@@ -110,8 +106,7 @@ describe('Test stats (excluding redundancy)', function () {
110 await servers[2].followsCommand.unfollow({ target: servers[0] }) 106 await servers[2].followsCommand.unfollow({ target: servers[0] })
111 await waitJobs(servers) 107 await waitJobs(servers)
112 108
113 const res = await getStats(servers[2].url) 109 const data = await servers[2].statsCommand.get()
114 const data: ServerStats = res.body
115 110
116 expect(data.totalVideos).to.equal(0) 111 expect(data.totalVideos).to.equal(0)
117 }) 112 })
@@ -120,8 +115,8 @@ describe('Test stats (excluding redundancy)', function () {
120 const server = servers[0] 115 const server = servers[0]
121 116
122 { 117 {
123 const res = await getStats(server.url) 118 const data = await server.statsCommand.get()
124 const data: ServerStats = res.body 119
125 expect(data.totalDailyActiveUsers).to.equal(1) 120 expect(data.totalDailyActiveUsers).to.equal(1)
126 expect(data.totalWeeklyActiveUsers).to.equal(1) 121 expect(data.totalWeeklyActiveUsers).to.equal(1)
127 expect(data.totalMonthlyActiveUsers).to.equal(1) 122 expect(data.totalMonthlyActiveUsers).to.equal(1)
@@ -130,8 +125,8 @@ describe('Test stats (excluding redundancy)', function () {
130 { 125 {
131 await userLogin(server, user) 126 await userLogin(server, user)
132 127
133 const res = await getStats(server.url) 128 const data = await server.statsCommand.get()
134 const data: ServerStats = res.body 129
135 expect(data.totalDailyActiveUsers).to.equal(2) 130 expect(data.totalDailyActiveUsers).to.equal(2)
136 expect(data.totalWeeklyActiveUsers).to.equal(2) 131 expect(data.totalWeeklyActiveUsers).to.equal(2)
137 expect(data.totalMonthlyActiveUsers).to.equal(2) 132 expect(data.totalMonthlyActiveUsers).to.equal(2)
@@ -142,8 +137,8 @@ describe('Test stats (excluding redundancy)', function () {
142 const server = servers[0] 137 const server = servers[0]
143 138
144 { 139 {
145 const res = await getStats(server.url) 140 const data = await server.statsCommand.get()
146 const data: ServerStats = res.body 141
147 expect(data.totalLocalDailyActiveVideoChannels).to.equal(1) 142 expect(data.totalLocalDailyActiveVideoChannels).to.equal(1)
148 expect(data.totalLocalWeeklyActiveVideoChannels).to.equal(1) 143 expect(data.totalLocalWeeklyActiveVideoChannels).to.equal(1)
149 expect(data.totalLocalMonthlyActiveVideoChannels).to.equal(1) 144 expect(data.totalLocalMonthlyActiveVideoChannels).to.equal(1)
@@ -157,8 +152,8 @@ describe('Test stats (excluding redundancy)', function () {
157 const resChannel = await addVideoChannel(server.url, server.accessToken, channelAttributes) 152 const resChannel = await addVideoChannel(server.url, server.accessToken, channelAttributes)
158 channelId = resChannel.body.videoChannel.id 153 channelId = resChannel.body.videoChannel.id
159 154
160 const res = await getStats(server.url) 155 const data = await server.statsCommand.get()
161 const data: ServerStats = res.body 156
162 expect(data.totalLocalDailyActiveVideoChannels).to.equal(1) 157 expect(data.totalLocalDailyActiveVideoChannels).to.equal(1)
163 expect(data.totalLocalWeeklyActiveVideoChannels).to.equal(1) 158 expect(data.totalLocalWeeklyActiveVideoChannels).to.equal(1)
164 expect(data.totalLocalMonthlyActiveVideoChannels).to.equal(1) 159 expect(data.totalLocalMonthlyActiveVideoChannels).to.equal(1)
@@ -167,8 +162,8 @@ describe('Test stats (excluding redundancy)', function () {
167 { 162 {
168 await uploadVideo(server.url, server.accessToken, { fixture: 'video_short.webm', channelId }) 163 await uploadVideo(server.url, server.accessToken, { fixture: 'video_short.webm', channelId })
169 164
170 const res = await getStats(server.url) 165 const data = await server.statsCommand.get()
171 const data: ServerStats = res.body 166
172 expect(data.totalLocalDailyActiveVideoChannels).to.equal(2) 167 expect(data.totalLocalDailyActiveVideoChannels).to.equal(2)
173 expect(data.totalLocalWeeklyActiveVideoChannels).to.equal(2) 168 expect(data.totalLocalWeeklyActiveVideoChannels).to.equal(2)
174 expect(data.totalLocalMonthlyActiveVideoChannels).to.equal(2) 169 expect(data.totalLocalMonthlyActiveVideoChannels).to.equal(2)
@@ -179,9 +174,8 @@ describe('Test stats (excluding redundancy)', function () {
179 const server = servers[0] 174 const server = servers[0]
180 175
181 { 176 {
182 const resStats = await getStats(server.url) 177 const data = await server.statsCommand.get()
183 const dataStats: ServerStats = resStats.body 178 expect(data.totalLocalPlaylists).to.equal(0)
184 expect(dataStats.totalLocalPlaylists).to.equal(0)
185 } 179 }
186 180
187 { 181 {
@@ -195,9 +189,8 @@ describe('Test stats (excluding redundancy)', function () {
195 } 189 }
196 }) 190 })
197 191
198 const resStats = await getStats(server.url) 192 const data = await server.statsCommand.get()
199 const dataStats: ServerStats = resStats.body 193 expect(data.totalLocalPlaylists).to.equal(1)
200 expect(dataStats.totalLocalPlaylists).to.equal(1)
201 } 194 }
202 }) 195 })
203 196
@@ -231,14 +224,12 @@ describe('Test stats (excluding redundancy)', function () {
231 await waitJobs(servers) 224 await waitJobs(servers)
232 225
233 { 226 {
234 const res = await getStats(servers[1].url) 227 const data = await servers[1].statsCommand.get()
235 const data: ServerStats = res.body
236 expect(data.totalLocalVideoFilesSize).to.equal(0) 228 expect(data.totalLocalVideoFilesSize).to.equal(0)
237 } 229 }
238 230
239 { 231 {
240 const res = await getStats(servers[0].url) 232 const data = await servers[0].statsCommand.get()
241 const data: ServerStats = res.body
242 expect(data.totalLocalVideoFilesSize).to.be.greaterThan(500000) 233 expect(data.totalLocalVideoFilesSize).to.be.greaterThan(500000)
243 expect(data.totalLocalVideoFilesSize).to.be.lessThan(600000) 234 expect(data.totalLocalVideoFilesSize).to.be.lessThan(600000)
244 } 235 }
@@ -253,8 +244,7 @@ describe('Test stats (excluding redundancy)', function () {
253 } 244 }
254 }) 245 })
255 246
256 const res1 = await getStats(servers[1].url) 247 const first = await servers[1].statsCommand.get()
257 const first = res1.body as ServerStats
258 248
259 for (let i = 0; i < 10; i++) { 249 for (let i = 0; i < 10; i++) {
260 await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video' }) 250 await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video' })
@@ -264,10 +254,9 @@ describe('Test stats (excluding redundancy)', function () {
264 254
265 await wait(6000) 255 await wait(6000)
266 256
267 const res2 = await getStats(servers[1].url) 257 const second = await servers[1].statsCommand.get()
268 const second: ServerStats = res2.body
269
270 expect(second.totalActivityPubMessagesProcessed).to.be.greaterThan(first.totalActivityPubMessagesProcessed) 258 expect(second.totalActivityPubMessagesProcessed).to.be.greaterThan(first.totalActivityPubMessagesProcessed)
259
271 const apTypes: ActivityType[] = [ 260 const apTypes: ActivityType[] = [
272 'Create', 'Update', 'Delete', 'Follow', 'Accept', 'Announce', 'Undo', 'Like', 'Reject', 'View', 'Dislike', 'Flag' 261 'Create', 'Update', 'Delete', 'Follow', 'Accept', 'Announce', 'Undo', 'Like', 'Reject', 'View', 'Dislike', 'Flag'
273 ] 262 ]
@@ -287,9 +276,7 @@ describe('Test stats (excluding redundancy)', function () {
287 276
288 await wait(6000) 277 await wait(6000)
289 278
290 const res3 = await getStats(servers[1].url) 279 const third = await servers[1].statsCommand.get()
291 const third: ServerStats = res3.body
292
293 expect(third.totalActivityPubMessagesWaiting).to.equal(0) 280 expect(third.totalActivityPubMessagesWaiting).to.equal(0)
294 expect(third.activityPubMessagesProcessedPerSecond).to.be.lessThan(second.activityPubMessagesProcessedPerSecond) 281 expect(third.activityPubMessagesProcessedPerSecond).to.be.lessThan(second.activityPubMessagesProcessedPerSecond)
295 }) 282 })