aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-07-05 15:43:21 +0200
committerChocobozzz <me@florianbigard.com>2022-07-06 15:13:55 +0200
commit630d0a1bf5897fff203cb07e426223f55dcc882d (patch)
tree5e6fa9d26f3f21178a538bd1ac38fa0a3f4f228c /server/tests/api
parent15b43b214eb37b05aa65aa8ef61fd0e6aa0b62d2 (diff)
downloadPeerTube-630d0a1bf5897fff203cb07e426223f55dcc882d.tar.gz
PeerTube-630d0a1bf5897fff203cb07e426223f55dcc882d.tar.zst
PeerTube-630d0a1bf5897fff203cb07e426223f55dcc882d.zip
Introduce experimental telemetry
Diffstat (limited to 'server/tests/api')
-rw-r--r--server/tests/api/server/index.ts1
-rw-r--r--server/tests/api/server/no-client.ts3
-rw-r--r--server/tests/api/server/open-telemetry.ts95
3 files changed, 97 insertions, 2 deletions
diff --git a/server/tests/api/server/index.ts b/server/tests/api/server/index.ts
index 45be107ce..78522c246 100644
--- a/server/tests/api/server/index.ts
+++ b/server/tests/api/server/index.ts
@@ -17,5 +17,6 @@ import './slow-follows'
17import './stats' 17import './stats'
18import './tracker' 18import './tracker'
19import './no-client' 19import './no-client'
20import './open-telemetry'
20import './plugins' 21import './plugins'
21import './proxy' 22import './proxy'
diff --git a/server/tests/api/server/no-client.ts b/server/tests/api/server/no-client.ts
index 913907788..193f6c987 100644
--- a/server/tests/api/server/no-client.ts
+++ b/server/tests/api/server/no-client.ts
@@ -1,7 +1,6 @@
1import 'mocha'
2import request from 'supertest' 1import request from 'supertest'
3import { cleanupTests, createSingleServer, PeerTubeServer } from '@shared/server-commands'
4import { HttpStatusCode } from '@shared/models' 2import { HttpStatusCode } from '@shared/models'
3import { cleanupTests, createSingleServer, PeerTubeServer } from '@shared/server-commands'
5 4
6describe('Start and stop server without web client routes', function () { 5describe('Start and stop server without web client routes', function () {
7 let server: PeerTubeServer 6 let server: PeerTubeServer
diff --git a/server/tests/api/server/open-telemetry.ts b/server/tests/api/server/open-telemetry.ts
new file mode 100644
index 000000000..20909429f
--- /dev/null
+++ b/server/tests/api/server/open-telemetry.ts
@@ -0,0 +1,95 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2
3import { expect } from 'chai'
4import { expectLogContain, expectLogDoesNotContain, MockHTTP } from '@server/tests/shared'
5import { HttpStatusCode, VideoPrivacy } from '@shared/models'
6import { cleanupTests, createSingleServer, makeRawRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands'
7
8describe('Open Telemetry', function () {
9 let server: PeerTubeServer
10
11 describe('Metrics', function () {
12 const metricsUrl = 'http://localhost:9091/metrics'
13
14 it('Should not enable open telemetry metrics', async function () {
15 server = await createSingleServer(1)
16
17 let hasError = false
18 try {
19 await makeRawRequest(metricsUrl, HttpStatusCode.NOT_FOUND_404)
20 } catch (err) {
21 hasError = err.message.includes('ECONNREFUSED')
22 }
23
24 expect(hasError).to.be.true
25
26 await server.kill()
27 })
28
29 it('Should enable open telemetry metrics', async function () {
30 server = await createSingleServer(1, {
31 open_telemetry: {
32 metrics: {
33 enabled: true
34 }
35 }
36 })
37
38 const res = await makeRawRequest(metricsUrl, HttpStatusCode.OK_200)
39 expect(res.text).to.contain('peertube_job_queue_total')
40
41 await server.kill()
42 })
43 })
44
45 describe('Tracing', function () {
46 let mockHTTP: MockHTTP
47 let mockPort: number
48
49 before(async function () {
50 mockHTTP = new MockHTTP()
51 mockPort = await mockHTTP.initialize()
52 })
53
54 it('Should enable open telemetry tracing', async function () {
55 server = await createSingleServer(1)
56
57 await expectLogDoesNotContain(server, 'Registering Open Telemetry tracing')
58
59 await server.kill()
60 })
61
62 it('Should enable open telemetry metrics', async function () {
63 server = await createSingleServer(1, {
64 open_telemetry: {
65 tracing: {
66 enabled: true,
67 jaeger_exporter: {
68 endpoint: 'http://localhost:' + mockPort
69 }
70 }
71 }
72 })
73
74 await expectLogContain(server, 'Registering Open Telemetry tracing')
75 })
76
77 it('Should upload a video and correctly works', async function () {
78 await setAccessTokensToServers([ server ])
79
80 const { uuid } = await server.videos.quickUpload({ name: 'video', privacy: VideoPrivacy.PUBLIC })
81
82 const video = await server.videos.get({ id: uuid })
83
84 expect(video.name).to.equal('video')
85 })
86
87 after(async function () {
88 await mockHTTP.terminate()
89 })
90 })
91
92 after(async function () {
93 await cleanupTests([ server ])
94 })
95})