aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/check-params/metrics.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/check-params/metrics.ts')
-rw-r--r--server/tests/api/check-params/metrics.ts208
1 files changed, 0 insertions, 208 deletions
diff --git a/server/tests/api/check-params/metrics.ts b/server/tests/api/check-params/metrics.ts
deleted file mode 100644
index 302bef4f5..000000000
--- a/server/tests/api/check-params/metrics.ts
+++ /dev/null
@@ -1,208 +0,0 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2
3import { omit } from '@shared/core-utils'
4import { HttpStatusCode, PlaybackMetricCreate, VideoResolution } from '@shared/models'
5import { cleanupTests, createSingleServer, makePostBodyRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands'
6
7describe('Test metrics API validators', function () {
8 let server: PeerTubeServer
9 let videoUUID: string
10
11 // ---------------------------------------------------------------
12
13 before(async function () {
14 this.timeout(120000)
15
16 server = await createSingleServer(1, {
17 open_telemetry: {
18 metrics: {
19 enabled: true
20 }
21 }
22 })
23
24 await setAccessTokensToServers([ server ])
25
26 const { uuid } = await server.videos.quickUpload({ name: 'video' })
27 videoUUID = uuid
28 })
29
30 describe('When adding playback metrics', function () {
31 const path = '/api/v1/metrics/playback'
32 let baseParams: PlaybackMetricCreate
33
34 before(function () {
35 baseParams = {
36 playerMode: 'p2p-media-loader',
37 resolution: VideoResolution.H_1080P,
38 fps: 30,
39 resolutionChanges: 1,
40 errors: 2,
41 p2pEnabled: true,
42 downloadedBytesP2P: 0,
43 downloadedBytesHTTP: 0,
44 uploadedBytesP2P: 0,
45 videoId: videoUUID
46 }
47 })
48
49 it('Should fail with an invalid resolution', async function () {
50 await makePostBodyRequest({
51 url: server.url,
52 path,
53 fields: { ...baseParams, resolution: 'toto' }
54 })
55 })
56
57 it('Should fail with an invalid fps', async function () {
58 await makePostBodyRequest({
59 url: server.url,
60 path,
61 fields: { ...baseParams, fps: 'toto' }
62 })
63 })
64
65 it('Should fail with a missing/invalid player mode', async function () {
66 await makePostBodyRequest({
67 url: server.url,
68 path,
69 fields: omit(baseParams, [ 'playerMode' ])
70 })
71
72 await makePostBodyRequest({
73 url: server.url,
74 path,
75 fields: { ...baseParams, playerMode: 'toto' }
76 })
77 })
78
79 it('Should fail with an missing/invalid resolution changes', async function () {
80 await makePostBodyRequest({
81 url: server.url,
82 path,
83 fields: omit(baseParams, [ 'resolutionChanges' ])
84 })
85
86 await makePostBodyRequest({
87 url: server.url,
88 path,
89 fields: { ...baseParams, resolutionChanges: 'toto' }
90 })
91 })
92
93 it('Should fail with an missing/invalid errors', async function () {
94 await makePostBodyRequest({
95 url: server.url,
96 path,
97 fields: omit(baseParams, [ 'errors' ])
98 })
99
100 await makePostBodyRequest({
101 url: server.url,
102 path,
103 fields: { ...baseParams, errors: 'toto' }
104 })
105 })
106
107 it('Should fail with an missing/invalid downloadedBytesP2P', async function () {
108 await makePostBodyRequest({
109 url: server.url,
110 path,
111 fields: omit(baseParams, [ 'downloadedBytesP2P' ])
112 })
113
114 await makePostBodyRequest({
115 url: server.url,
116 path,
117 fields: { ...baseParams, downloadedBytesP2P: 'toto' }
118 })
119 })
120
121 it('Should fail with an missing/invalid downloadedBytesHTTP', async function () {
122 await makePostBodyRequest({
123 url: server.url,
124 path,
125 fields: omit(baseParams, [ 'downloadedBytesHTTP' ])
126 })
127
128 await makePostBodyRequest({
129 url: server.url,
130 path,
131 fields: { ...baseParams, downloadedBytesHTTP: 'toto' }
132 })
133 })
134
135 it('Should fail with an missing/invalid uploadedBytesP2P', async function () {
136 await makePostBodyRequest({
137 url: server.url,
138 path,
139 fields: omit(baseParams, [ 'uploadedBytesP2P' ])
140 })
141
142 await makePostBodyRequest({
143 url: server.url,
144 path,
145 fields: { ...baseParams, uploadedBytesP2P: 'toto' }
146 })
147 })
148
149 it('Should fail with a missing/invalid p2pEnabled', async function () {
150 await makePostBodyRequest({
151 url: server.url,
152 path,
153 fields: omit(baseParams, [ 'p2pEnabled' ])
154 })
155
156 await makePostBodyRequest({
157 url: server.url,
158 path,
159 fields: { ...baseParams, p2pEnabled: 'toto' }
160 })
161 })
162
163 it('Should fail with an invalid totalPeers', async function () {
164 await makePostBodyRequest({
165 url: server.url,
166 path,
167 fields: { ...baseParams, p2pPeers: 'toto' }
168 })
169 })
170
171 it('Should fail with a bad video id', async function () {
172 await makePostBodyRequest({
173 url: server.url,
174 path,
175 fields: { ...baseParams, videoId: 'toto' }
176 })
177 })
178
179 it('Should fail with an unknown video', async function () {
180 await makePostBodyRequest({
181 url: server.url,
182 path,
183 fields: { ...baseParams, videoId: 42 },
184 expectedStatus: HttpStatusCode.NOT_FOUND_404
185 })
186 })
187
188 it('Should succeed with the correct params', async function () {
189 await makePostBodyRequest({
190 url: server.url,
191 path,
192 fields: baseParams,
193 expectedStatus: HttpStatusCode.NO_CONTENT_204
194 })
195
196 await makePostBodyRequest({
197 url: server.url,
198 path,
199 fields: { ...baseParams, p2pEnabled: false, totalPeers: 32 },
200 expectedStatus: HttpStatusCode.NO_CONTENT_204
201 })
202 })
203 })
204
205 after(async function () {
206 await cleanupTests([ server ])
207 })
208})