diff options
author | Chocobozzz <me@florianbigard.com> | 2022-07-05 15:43:21 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-07-06 15:13:55 +0200 |
commit | 630d0a1bf5897fff203cb07e426223f55dcc882d (patch) | |
tree | 5e6fa9d26f3f21178a538bd1ac38fa0a3f4f228c /server/tests/api | |
parent | 15b43b214eb37b05aa65aa8ef61fd0e6aa0b62d2 (diff) | |
download | PeerTube-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.ts | 1 | ||||
-rw-r--r-- | server/tests/api/server/no-client.ts | 3 | ||||
-rw-r--r-- | server/tests/api/server/open-telemetry.ts | 95 |
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' | |||
17 | import './stats' | 17 | import './stats' |
18 | import './tracker' | 18 | import './tracker' |
19 | import './no-client' | 19 | import './no-client' |
20 | import './open-telemetry' | ||
20 | import './plugins' | 21 | import './plugins' |
21 | import './proxy' | 22 | import './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 @@ | |||
1 | import 'mocha' | ||
2 | import request from 'supertest' | 1 | import request from 'supertest' |
3 | import { cleanupTests, createSingleServer, PeerTubeServer } from '@shared/server-commands' | ||
4 | import { HttpStatusCode } from '@shared/models' | 2 | import { HttpStatusCode } from '@shared/models' |
3 | import { cleanupTests, createSingleServer, PeerTubeServer } from '@shared/server-commands' | ||
5 | 4 | ||
6 | describe('Start and stop server without web client routes', function () { | 5 | describe('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 | |||
3 | import { expect } from 'chai' | ||
4 | import { expectLogContain, expectLogDoesNotContain, MockHTTP } from '@server/tests/shared' | ||
5 | import { HttpStatusCode, VideoPrivacy } from '@shared/models' | ||
6 | import { cleanupTests, createSingleServer, makeRawRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' | ||
7 | |||
8 | describe('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 | }) | ||