diff options
-rw-r--r-- | client/e2e/src/po/login.po.ts | 4 | ||||
-rw-r--r-- | client/e2e/src/suites-local/signup.e2e-spec.ts | 6 | ||||
-rw-r--r-- | client/e2e/src/utils/hooks.ts | 2 | ||||
-rw-r--r-- | client/e2e/src/utils/mock-smtp.ts | 17 | ||||
-rw-r--r-- | client/e2e/wdio.local-test.conf.ts | 26 | ||||
-rw-r--r-- | client/e2e/wdio.local.conf.ts | 14 | ||||
-rw-r--r-- | client/package.json | 2 | ||||
-rw-r--r-- | client/yarn.lock | 18 | ||||
-rw-r--r-- | config/default.yaml | 4 | ||||
-rw-r--r-- | config/production.yaml.example | 4 | ||||
-rw-r--r-- | server/initializers/checker-before-init.ts | 1 | ||||
-rw-r--r-- | server/initializers/config.ts | 4 | ||||
-rw-r--r-- | server/lib/opentelemetry/metrics.ts | 4 | ||||
-rw-r--r-- | server/tests/api/check-params/users-emails.ts | 3 | ||||
-rw-r--r-- | server/tests/api/server/open-telemetry.ts | 27 | ||||
-rw-r--r-- | server/tests/shared/mock-servers/mock-email.ts | 15 | ||||
-rw-r--r-- | support/doc/development/tests.md | 2 |
17 files changed, 103 insertions, 50 deletions
diff --git a/client/e2e/src/po/login.po.ts b/client/e2e/src/po/login.po.ts index f1d13a2b0..30469cf1b 100644 --- a/client/e2e/src/po/login.po.ts +++ b/client/e2e/src/po/login.po.ts | |||
@@ -60,6 +60,10 @@ export class LoginPage { | |||
60 | } | 60 | } |
61 | 61 | ||
62 | loginOnPeerTube2 () { | 62 | loginOnPeerTube2 () { |
63 | if (!process.env.PEERTUBE2_E2E_PASSWORD) { | ||
64 | throw new Error('PEERTUBE2_E2E_PASSWORD env is missing for user e2e on peertube2.cpy.re') | ||
65 | } | ||
66 | |||
63 | return this.login({ username: 'e2e', password: process.env.PEERTUBE2_E2E_PASSWORD, url: 'https://peertube2.cpy.re/login' }) | 67 | return this.login({ username: 'e2e', password: process.env.PEERTUBE2_E2E_PASSWORD, url: 'https://peertube2.cpy.re/login' }) |
64 | } | 68 | } |
65 | 69 | ||
diff --git a/client/e2e/src/suites-local/signup.e2e-spec.ts b/client/e2e/src/suites-local/signup.e2e-spec.ts index 7c822a6e6..ad0cc218e 100644 --- a/client/e2e/src/suites-local/signup.e2e-spec.ts +++ b/client/e2e/src/suites-local/signup.e2e-spec.ts | |||
@@ -244,9 +244,9 @@ describe('Signup', () => { | |||
244 | 244 | ||
245 | before(async () => { | 245 | before(async () => { |
246 | // FIXME: typings are wrong, get returns a promise | 246 | // FIXME: typings are wrong, get returns a promise |
247 | emailPort = await browser.sharedStore.get('emailPort') as unknown as number | 247 | emailPort = await (browser.sharedStore.get(browser.config.baseUrl + '-emailPort') as unknown as Promise<number>) |
248 | 248 | ||
249 | MockSMTPServer.Instance.collectEmails(emailPort, emails) | 249 | await MockSMTPServer.Instance.collectEmails(emailPort, emails) |
250 | }) | 250 | }) |
251 | 251 | ||
252 | describe('Direct registration', function () { | 252 | describe('Direct registration', function () { |
@@ -404,7 +404,7 @@ describe('Signup', () => { | |||
404 | }) | 404 | }) |
405 | }) | 405 | }) |
406 | 406 | ||
407 | before(() => { | 407 | after(() => { |
408 | MockSMTPServer.Instance.kill() | 408 | MockSMTPServer.Instance.kill() |
409 | }) | 409 | }) |
410 | }) | 410 | }) |
diff --git a/client/e2e/src/utils/hooks.ts b/client/e2e/src/utils/hooks.ts index e57584b44..1daff5fcc 100644 --- a/client/e2e/src/utils/hooks.ts +++ b/client/e2e/src/utils/hooks.ts | |||
@@ -32,7 +32,7 @@ async function beforeLocalSession (config: { baseUrl: string }, capabilities: { | |||
32 | 32 | ||
33 | config.baseUrl = 'http://localhost:900' + appInstance | 33 | config.baseUrl = 'http://localhost:900' + appInstance |
34 | 34 | ||
35 | await setValue('emailPort', emailPort) | 35 | await setValue(config.baseUrl + '-emailPort', emailPort) |
36 | } | 36 | } |
37 | 37 | ||
38 | async function onBrowserStackPrepare () { | 38 | async function onBrowserStackPrepare () { |
diff --git a/client/e2e/src/utils/mock-smtp.ts b/client/e2e/src/utils/mock-smtp.ts index 614477d7d..be6f8b259 100644 --- a/client/e2e/src/utils/mock-smtp.ts +++ b/client/e2e/src/utils/mock-smtp.ts | |||
@@ -1,11 +1,10 @@ | |||
1 | import { ChildProcess } from 'child_process' | ||
2 | import MailDev from '@peertube/maildev' | 1 | import MailDev from '@peertube/maildev' |
3 | 2 | ||
4 | class MockSMTPServer { | 3 | class MockSMTPServer { |
5 | 4 | ||
6 | private static instance: MockSMTPServer | 5 | private static instance: MockSMTPServer |
7 | private started = false | 6 | private started = false |
8 | private emailChildProcess: ChildProcess | 7 | private maildev: any |
9 | private emails: object[] | 8 | private emails: object[] |
10 | 9 | ||
11 | collectEmails (port: number, emailsCollection: object[]) { | 10 | collectEmails (port: number, emailsCollection: object[]) { |
@@ -16,18 +15,20 @@ class MockSMTPServer { | |||
16 | return res(undefined) | 15 | return res(undefined) |
17 | } | 16 | } |
18 | 17 | ||
19 | const maildev = new MailDev({ | 18 | this.maildev = new MailDev({ |
20 | ip: '127.0.0.1', | 19 | ip: '127.0.0.1', |
21 | smtp: port, | 20 | smtp: port, |
22 | disableWeb: true, | 21 | disableWeb: true, |
23 | silent: true | 22 | silent: true |
24 | }) | 23 | }) |
25 | 24 | ||
26 | maildev.on('new', email => { | 25 | this.maildev.on('new', email => { |
27 | this.emails.push(email) | 26 | this.emails.push(email) |
27 | |||
28 | console.log('pushed email', email) | ||
28 | }) | 29 | }) |
29 | 30 | ||
30 | maildev.listen(err => { | 31 | this.maildev.listen(err => { |
31 | if (err) return rej(err) | 32 | if (err) return rej(err) |
32 | 33 | ||
33 | this.started = true | 34 | this.started = true |
@@ -38,11 +39,11 @@ class MockSMTPServer { | |||
38 | } | 39 | } |
39 | 40 | ||
40 | kill () { | 41 | kill () { |
41 | if (!this.emailChildProcess) return | 42 | if (!this.maildev) return |
42 | 43 | ||
43 | process.kill(this.emailChildProcess.pid) | 44 | this.maildev.close() |
44 | 45 | ||
45 | this.emailChildProcess = null | 46 | this.maildev = null |
46 | MockSMTPServer.instance = null | 47 | MockSMTPServer.instance = null |
47 | } | 48 | } |
48 | 49 | ||
diff --git a/client/e2e/wdio.local-test.conf.ts b/client/e2e/wdio.local-test.conf.ts index bc15123a0..3c19e4e9a 100644 --- a/client/e2e/wdio.local-test.conf.ts +++ b/client/e2e/wdio.local-test.conf.ts | |||
@@ -8,6 +8,12 @@ const prefs = { | |||
8 | // Chrome headless does not support prefs | 8 | // Chrome headless does not support prefs |
9 | process.env.LANG = 'en' | 9 | process.env.LANG = 'en' |
10 | 10 | ||
11 | // https://github.com/mozilla/geckodriver/issues/1354#issuecomment-479456411 | ||
12 | process.env.MOZ_HEADLESS_WIDTH = '1280' | ||
13 | process.env.MOZ_HEADLESS_HEIGHT = '1024' | ||
14 | |||
15 | const windowSizeArg = `--window-size=${process.env.MOZ_HEADLESS_WIDTH},${process.env.MOZ_HEADLESS_HEIGHT}` | ||
16 | |||
11 | module.exports = { | 17 | module.exports = { |
12 | config: { | 18 | config: { |
13 | ...mainConfig, | 19 | ...mainConfig, |
@@ -22,19 +28,19 @@ module.exports = { | |||
22 | browserName: 'chrome', | 28 | browserName: 'chrome', |
23 | acceptInsecureCerts: true, | 29 | acceptInsecureCerts: true, |
24 | 'goog:chromeOptions': { | 30 | 'goog:chromeOptions': { |
25 | args: [ '--disable-gpu', '--window-size=1280,1024' ], | 31 | args: [ '--disable-gpu', windowSizeArg ], |
32 | prefs | ||
33 | } | ||
34 | }, | ||
35 | { | ||
36 | browserName: 'firefox', | ||
37 | 'moz:firefoxOptions': { | ||
38 | binary: '/usr/bin/firefox-developer-edition', | ||
39 | args: [ '--headless', windowSizeArg ], | ||
40 | |||
26 | prefs | 41 | prefs |
27 | } | 42 | } |
28 | } | 43 | } |
29 | // { | ||
30 | // browserName: 'firefox', | ||
31 | // 'moz:firefoxOptions': { | ||
32 | // binary: '/usr/bin/firefox-developer-edition', | ||
33 | // args: [ '--headless', '--window-size=1280,1024' ], | ||
34 | |||
35 | // prefs | ||
36 | // } | ||
37 | // } | ||
38 | ], | 44 | ], |
39 | 45 | ||
40 | services: [ 'chromedriver', 'geckodriver', 'shared-store' ], | 46 | services: [ 'chromedriver', 'geckodriver', 'shared-store' ], |
diff --git a/client/e2e/wdio.local.conf.ts b/client/e2e/wdio.local.conf.ts index 27c6e867b..903235b86 100644 --- a/client/e2e/wdio.local.conf.ts +++ b/client/e2e/wdio.local.conf.ts | |||
@@ -1,11 +1,15 @@ | |||
1 | import { afterLocalSuite, beforeLocalSession, beforeLocalSuite } from './src/utils' | 1 | import { afterLocalSuite, beforeLocalSession, beforeLocalSuite } from './src/utils' |
2 | import { config as mainConfig } from './wdio.main.conf' | 2 | import { config as mainConfig } from './wdio.main.conf' |
3 | 3 | ||
4 | const prefs = { | 4 | const prefs = { 'intl.accept_languages': 'en' } |
5 | 'intl.accept_languages': 'en' | ||
6 | } | ||
7 | process.env.LANG = 'en' | 5 | process.env.LANG = 'en' |
8 | 6 | ||
7 | // https://github.com/mozilla/geckodriver/issues/1354#issuecomment-479456411 | ||
8 | process.env.MOZ_HEADLESS_WIDTH = '1280' | ||
9 | process.env.MOZ_HEADLESS_HEIGHT = '1024' | ||
10 | |||
11 | const windowSizeArg = `--window-size=${process.env.MOZ_HEADLESS_WIDTH},${process.env.MOZ_HEADLESS_HEIGHT}` | ||
12 | |||
9 | module.exports = { | 13 | module.exports = { |
10 | config: { | 14 | config: { |
11 | ...mainConfig, | 15 | ...mainConfig, |
@@ -18,7 +22,7 @@ module.exports = { | |||
18 | { | 22 | { |
19 | browserName: 'chrome', | 23 | browserName: 'chrome', |
20 | 'goog:chromeOptions': { | 24 | 'goog:chromeOptions': { |
21 | args: [ '--headless', '--disable-gpu', '--window-size=1280,1024' ], | 25 | args: [ '--headless', '--disable-gpu', windowSizeArg ], |
22 | prefs | 26 | prefs |
23 | } | 27 | } |
24 | }, | 28 | }, |
@@ -26,7 +30,7 @@ module.exports = { | |||
26 | browserName: 'firefox', | 30 | browserName: 'firefox', |
27 | 'moz:firefoxOptions': { | 31 | 'moz:firefoxOptions': { |
28 | binary: '/usr/bin/firefox-developer-edition', | 32 | binary: '/usr/bin/firefox-developer-edition', |
29 | args: [ '--headless', '--window-size=1280,1024' ], | 33 | args: [ '--headless', windowSizeArg ], |
30 | 34 | ||
31 | prefs | 35 | prefs |
32 | } | 36 | } |
diff --git a/client/package.json b/client/package.json index 53fb02d12..9bad50362 100644 --- a/client/package.json +++ b/client/package.json | |||
@@ -86,7 +86,7 @@ | |||
86 | "cache-chunk-store": "^3.0.0", | 86 | "cache-chunk-store": "^3.0.0", |
87 | "chart.js": "^3.8.0", | 87 | "chart.js": "^3.8.0", |
88 | "chartjs-plugin-zoom": "~1.2.1", | 88 | "chartjs-plugin-zoom": "~1.2.1", |
89 | "chromedriver": "^107.0.3", | 89 | "chromedriver": "^110.0.0", |
90 | "core-js": "^3.22.8", | 90 | "core-js": "^3.22.8", |
91 | "css-loader": "^6.2.0", | 91 | "css-loader": "^6.2.0", |
92 | "debug": "^4.3.1", | 92 | "debug": "^4.3.1", |
diff --git a/client/yarn.lock b/client/yarn.lock index 227f6b522..d9cd8a7ef 100644 --- a/client/yarn.lock +++ b/client/yarn.lock | |||
@@ -3278,10 +3278,10 @@ aws4@^1.8.0: | |||
3278 | resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.12.0.tgz#ce1c9d143389679e253b314241ea9aa5cec980d3" | 3278 | resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.12.0.tgz#ce1c9d143389679e253b314241ea9aa5cec980d3" |
3279 | integrity sha512-NmWvPnx0F1SfrQbYwOi7OeaNGokp9XhzNioJ/CSBs8Qa4vxug81mhJEAVZwxXuBmYB5KDRfMq/F3RR0BIU7sWg== | 3279 | integrity sha512-NmWvPnx0F1SfrQbYwOi7OeaNGokp9XhzNioJ/CSBs8Qa4vxug81mhJEAVZwxXuBmYB5KDRfMq/F3RR0BIU7sWg== |
3280 | 3280 | ||
3281 | axios@^1.1.3: | 3281 | axios@^1.2.1: |
3282 | version "1.3.3" | 3282 | version "1.3.4" |
3283 | resolved "https://registry.yarnpkg.com/axios/-/axios-1.3.3.tgz#e7011384ba839b885007c9c9fae1ff23dceb295b" | 3283 | resolved "https://registry.yarnpkg.com/axios/-/axios-1.3.4.tgz#f5760cefd9cfb51fd2481acf88c05f67c4523024" |
3284 | integrity sha512-eYq77dYIFS77AQlhzEL937yUBSepBfPIe8FcgEDN35vMNZKMrs81pgnyrQpwfy4NF4b4XWX1Zgx7yX+25w8QJA== | 3284 | integrity sha512-toYm+Bsyl6VC5wSkfkbbNB6ROv7KY93PEBBL6xyDczaIHasAiv4wPqQ/c4RjoQzipxRD2W5g21cOqQulZ7rHwQ== |
3285 | dependencies: | 3285 | dependencies: |
3286 | follow-redirects "^1.15.0" | 3286 | follow-redirects "^1.15.0" |
3287 | form-data "^4.0.0" | 3287 | form-data "^4.0.0" |
@@ -3946,13 +3946,13 @@ chrome-trace-event@^1.0.2: | |||
3946 | resolved "https://registry.yarnpkg.com/chrome-trace-event/-/chrome-trace-event-1.0.3.tgz#1015eced4741e15d06664a957dbbf50d041e26ac" | 3946 | resolved "https://registry.yarnpkg.com/chrome-trace-event/-/chrome-trace-event-1.0.3.tgz#1015eced4741e15d06664a957dbbf50d041e26ac" |
3947 | integrity sha512-p3KULyQg4S7NIHixdwbGX+nFHkoBiA4YQmyWtjb8XngSKV124nJmRysgAeujbUVb15vh+RvFUfCPqU7rXk+hZg== | 3947 | integrity sha512-p3KULyQg4S7NIHixdwbGX+nFHkoBiA4YQmyWtjb8XngSKV124nJmRysgAeujbUVb15vh+RvFUfCPqU7rXk+hZg== |
3948 | 3948 | ||
3949 | chromedriver@^107.0.3: | 3949 | chromedriver@^110.0.0: |
3950 | version "107.0.3" | 3950 | version "110.0.0" |
3951 | resolved "https://registry.yarnpkg.com/chromedriver/-/chromedriver-107.0.3.tgz#330c0808bb14a53f13ab7e2b0c78adf3cdb4c14b" | 3951 | resolved "https://registry.yarnpkg.com/chromedriver/-/chromedriver-110.0.0.tgz#d00a1a2976592d933faa8e9839e97692922834a4" |
3952 | integrity sha512-jmzpZgctCRnhYAn0l/NIjP4vYN3L8GFVbterTrRr2Ly3W5rFMb9H8EKGuM5JCViPKSit8FbE718kZTEt3Yvffg== | 3952 | integrity sha512-Le6q8xrA/3fAt+g8qiN0YjsYxINIhQMC6wj9X3W5L77uN4NspEzklDrqYNwBcEVn7PcAEJ73nLlS7mTyZRspHA== |
3953 | dependencies: | 3953 | dependencies: |
3954 | "@testim/chrome-version" "^1.1.3" | 3954 | "@testim/chrome-version" "^1.1.3" |
3955 | axios "^1.1.3" | 3955 | axios "^1.2.1" |
3956 | compare-versions "^5.0.1" | 3956 | compare-versions "^5.0.1" |
3957 | extract-zip "^2.0.1" | 3957 | extract-zip "^2.0.1" |
3958 | https-proxy-agent "^5.0.1" | 3958 | https-proxy-agent "^5.0.1" |
diff --git a/config/default.yaml b/config/default.yaml index 7ce345e2d..db014cc87 100644 --- a/config/default.yaml +++ b/config/default.yaml | |||
@@ -222,6 +222,10 @@ open_telemetry: | |||
222 | metrics: | 222 | metrics: |
223 | enabled: false | 223 | enabled: false |
224 | 224 | ||
225 | http_request_duration: | ||
226 | # You can disable HTTP request duration metric that can have a high tag cardinality | ||
227 | enabled: true | ||
228 | |||
225 | # Create a prometheus exporter server on this port so prometheus server can scrape PeerTube metrics | 229 | # Create a prometheus exporter server on this port so prometheus server can scrape PeerTube metrics |
226 | prometheus_exporter: | 230 | prometheus_exporter: |
227 | hostname: '127.0.0.1' | 231 | hostname: '127.0.0.1' |
diff --git a/config/production.yaml.example b/config/production.yaml.example index 877d77e01..a169c6c0e 100644 --- a/config/production.yaml.example +++ b/config/production.yaml.example | |||
@@ -220,6 +220,10 @@ open_telemetry: | |||
220 | metrics: | 220 | metrics: |
221 | enabled: false | 221 | enabled: false |
222 | 222 | ||
223 | http_request_duration: | ||
224 | # You can disable HTTP request duration metric that can have a high tag cardinality | ||
225 | enabled: true | ||
226 | |||
223 | # Create a prometheus exporter server on this port so prometheus server can scrape PeerTube metrics | 227 | # Create a prometheus exporter server on this port so prometheus server can scrape PeerTube metrics |
224 | prometheus_exporter: | 228 | prometheus_exporter: |
225 | hostname: '127.0.0.1' | 229 | hostname: '127.0.0.1' |
diff --git a/server/initializers/checker-before-init.ts b/server/initializers/checker-before-init.ts index 74fed251c..1351749a6 100644 --- a/server/initializers/checker-before-init.ts +++ b/server/initializers/checker-before-init.ts | |||
@@ -23,6 +23,7 @@ function checkMissedConfig () { | |||
23 | 'log.log_ping_requests', 'log.log_tracker_unknown_infohash', 'log.prettify_sql', 'log.accept_client_log', | 23 | 'log.log_ping_requests', 'log.log_tracker_unknown_infohash', 'log.prettify_sql', 'log.accept_client_log', |
24 | 'open_telemetry.metrics.enabled', 'open_telemetry.metrics.prometheus_exporter.hostname', | 24 | 'open_telemetry.metrics.enabled', 'open_telemetry.metrics.prometheus_exporter.hostname', |
25 | 'open_telemetry.metrics.prometheus_exporter.port', 'open_telemetry.tracing.enabled', 'open_telemetry.tracing.jaeger_exporter.endpoint', | 25 | 'open_telemetry.metrics.prometheus_exporter.port', 'open_telemetry.tracing.enabled', 'open_telemetry.tracing.jaeger_exporter.endpoint', |
26 | 'open_telemetry.metrics.http_request_duration.enabled', | ||
26 | 'user.video_quota', 'user.video_quota_daily', | 27 | 'user.video_quota', 'user.video_quota_daily', |
27 | 'video_channels.max_per_user', | 28 | 'video_channels.max_per_user', |
28 | 'csp.enabled', 'csp.report_only', 'csp.report_uri', | 29 | 'csp.enabled', 'csp.report_only', 'csp.report_uri', |
diff --git a/server/initializers/config.ts b/server/initializers/config.ts index 7ad258f7a..eb9d0079c 100644 --- a/server/initializers/config.ts +++ b/server/initializers/config.ts | |||
@@ -195,6 +195,10 @@ const CONFIG = { | |||
195 | METRICS: { | 195 | METRICS: { |
196 | ENABLED: config.get<boolean>('open_telemetry.metrics.enabled'), | 196 | ENABLED: config.get<boolean>('open_telemetry.metrics.enabled'), |
197 | 197 | ||
198 | HTTP_REQUEST_DURATION: { | ||
199 | ENABLED: config.get<boolean>('open_telemetry.metrics.http_request_duration.enabled') | ||
200 | }, | ||
201 | |||
198 | PROMETHEUS_EXPORTER: { | 202 | PROMETHEUS_EXPORTER: { |
199 | HOSTNAME: config.get<string>('open_telemetry.metrics.prometheus_exporter.hostname'), | 203 | HOSTNAME: config.get<string>('open_telemetry.metrics.prometheus_exporter.hostname'), |
200 | PORT: config.get<number>('open_telemetry.metrics.prometheus_exporter.port') | 204 | PORT: config.get<number>('open_telemetry.metrics.prometheus_exporter.port') |
diff --git a/server/lib/opentelemetry/metrics.ts b/server/lib/opentelemetry/metrics.ts index 9cc067e4a..bffe00840 100644 --- a/server/lib/opentelemetry/metrics.ts +++ b/server/lib/opentelemetry/metrics.ts | |||
@@ -62,7 +62,9 @@ class OpenTelemetryMetrics { | |||
62 | 62 | ||
63 | this.meter = metrics.getMeter('default') | 63 | this.meter = metrics.getMeter('default') |
64 | 64 | ||
65 | this.buildRequestObserver() | 65 | if (CONFIG.OPEN_TELEMETRY.METRICS.HTTP_REQUEST_DURATION.ENABLED === true) { |
66 | this.buildRequestObserver() | ||
67 | } | ||
66 | 68 | ||
67 | this.playbackMetrics = new PlaybackMetrics(this.meter) | 69 | this.playbackMetrics = new PlaybackMetrics(this.meter) |
68 | this.playbackMetrics.buildCounters() | 70 | this.playbackMetrics.buildCounters() |
diff --git a/server/tests/api/check-params/users-emails.ts b/server/tests/api/check-params/users-emails.ts index 8cfb1d15f..6ebcc8ffe 100644 --- a/server/tests/api/check-params/users-emails.ts +++ b/server/tests/api/check-params/users-emails.ts | |||
@@ -1,5 +1,4 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | import { MockSmtpServer } from '@server/tests/shared' | ||
3 | import { HttpStatusCode, UserRole } from '@shared/models' | 2 | import { HttpStatusCode, UserRole } from '@shared/models' |
4 | import { cleanupTests, createSingleServer, makePostBodyRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' | 3 | import { cleanupTests, createSingleServer, makePostBodyRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' |
5 | 4 | ||
@@ -112,8 +111,6 @@ describe('Test users API validators', function () { | |||
112 | }) | 111 | }) |
113 | 112 | ||
114 | after(async function () { | 113 | after(async function () { |
115 | MockSmtpServer.Instance.kill() | ||
116 | |||
117 | await cleanupTests([ server ]) | 114 | await cleanupTests([ server ]) |
118 | }) | 115 | }) |
119 | }) | 116 | }) |
diff --git a/server/tests/api/server/open-telemetry.ts b/server/tests/api/server/open-telemetry.ts index db76a3d7f..49f3b520b 100644 --- a/server/tests/api/server/open-telemetry.ts +++ b/server/tests/api/server/open-telemetry.ts | |||
@@ -29,6 +29,8 @@ describe('Open Telemetry', function () { | |||
29 | }) | 29 | }) |
30 | 30 | ||
31 | it('Should enable open telemetry metrics', async function () { | 31 | it('Should enable open telemetry metrics', async function () { |
32 | this.timeout(120000) | ||
33 | |||
32 | server = await createSingleServer(1, { | 34 | server = await createSingleServer(1, { |
33 | open_telemetry: { | 35 | open_telemetry: { |
34 | metrics: { | 36 | metrics: { |
@@ -37,8 +39,12 @@ describe('Open Telemetry', function () { | |||
37 | } | 39 | } |
38 | }) | 40 | }) |
39 | 41 | ||
42 | // Simulate a HTTP request | ||
43 | await server.videos.list() | ||
44 | |||
40 | const res = await makeRawRequest({ url: metricsUrl, expectedStatus: HttpStatusCode.OK_200 }) | 45 | const res = await makeRawRequest({ url: metricsUrl, expectedStatus: HttpStatusCode.OK_200 }) |
41 | expect(res.text).to.contain('peertube_job_queue_total{') | 46 | expect(res.text).to.contain('peertube_job_queue_total{') |
47 | expect(res.text).to.contain('http_request_duration_ms_bucket{') | ||
42 | }) | 48 | }) |
43 | 49 | ||
44 | it('Should have playback metrics', async function () { | 50 | it('Should have playback metrics', async function () { |
@@ -64,6 +70,27 @@ describe('Open Telemetry', function () { | |||
64 | expect(res.text).to.contain('peertube_playback_http_downloaded_bytes_total{') | 70 | expect(res.text).to.contain('peertube_playback_http_downloaded_bytes_total{') |
65 | }) | 71 | }) |
66 | 72 | ||
73 | it('Should disable http request duration metrics', async function () { | ||
74 | await server.kill() | ||
75 | |||
76 | server = await createSingleServer(1, { | ||
77 | open_telemetry: { | ||
78 | metrics: { | ||
79 | enabled: true, | ||
80 | http_request_duration: { | ||
81 | enabled: false | ||
82 | } | ||
83 | } | ||
84 | } | ||
85 | }) | ||
86 | |||
87 | // Simulate a HTTP request | ||
88 | await server.videos.list() | ||
89 | |||
90 | const res = await makeRawRequest({ url: metricsUrl, expectedStatus: HttpStatusCode.OK_200 }) | ||
91 | expect(res.text).to.not.contain('http_request_duration_ms_bucket{') | ||
92 | }) | ||
93 | |||
67 | after(async function () { | 94 | after(async function () { |
68 | await server.kill() | 95 | await server.kill() |
69 | }) | 96 | }) |
diff --git a/server/tests/shared/mock-servers/mock-email.ts b/server/tests/shared/mock-servers/mock-email.ts index c518679c9..5f37f6ae0 100644 --- a/server/tests/shared/mock-servers/mock-email.ts +++ b/server/tests/shared/mock-servers/mock-email.ts | |||
@@ -1,4 +1,3 @@ | |||
1 | import { ChildProcess } from 'child_process' | ||
2 | import MailDev from '@peertube/maildev' | 1 | import MailDev from '@peertube/maildev' |
3 | import { parallelTests, randomInt } from '@shared/core-utils' | 2 | import { parallelTests, randomInt } from '@shared/core-utils' |
4 | 3 | ||
@@ -6,7 +5,7 @@ class MockSmtpServer { | |||
6 | 5 | ||
7 | private static instance: MockSmtpServer | 6 | private static instance: MockSmtpServer |
8 | private started = false | 7 | private started = false |
9 | private emailChildProcess: ChildProcess | 8 | private maildev: any |
10 | private emails: object[] | 9 | private emails: object[] |
11 | 10 | ||
12 | private constructor () { } | 11 | private constructor () { } |
@@ -20,18 +19,18 @@ class MockSmtpServer { | |||
20 | return res(undefined) | 19 | return res(undefined) |
21 | } | 20 | } |
22 | 21 | ||
23 | const maildev = new MailDev({ | 22 | this.maildev = new MailDev({ |
24 | ip: '127.0.0.1', | 23 | ip: '127.0.0.1', |
25 | smtp: port, | 24 | smtp: port, |
26 | disableWeb: true, | 25 | disableWeb: true, |
27 | silent: true | 26 | silent: true |
28 | }) | 27 | }) |
29 | 28 | ||
30 | maildev.on('new', email => { | 29 | this.maildev.on('new', email => { |
31 | this.emails.push(email) | 30 | this.emails.push(email) |
32 | }) | 31 | }) |
33 | 32 | ||
34 | maildev.listen(err => { | 33 | this.maildev.listen(err => { |
35 | if (err) return rej(err) | 34 | if (err) return rej(err) |
36 | 35 | ||
37 | this.started = true | 36 | this.started = true |
@@ -42,11 +41,11 @@ class MockSmtpServer { | |||
42 | } | 41 | } |
43 | 42 | ||
44 | kill () { | 43 | kill () { |
45 | if (!this.emailChildProcess) return | 44 | if (!this.maildev) return |
46 | 45 | ||
47 | process.kill(this.emailChildProcess.pid) | 46 | this.maildev.close() |
48 | 47 | ||
49 | this.emailChildProcess = null | 48 | this.maildev = null |
50 | MockSmtpServer.instance = null | 49 | MockSmtpServer.instance = null |
51 | } | 50 | } |
52 | 51 | ||
diff --git a/support/doc/development/tests.md b/support/doc/development/tests.md index 207d4f984..6eb499f0c 100644 --- a/support/doc/development/tests.md +++ b/support/doc/development/tests.md | |||
@@ -100,7 +100,7 @@ tail -f test1/logs/peertube.log | npm run parse-log -- --level debug --files - | |||
100 | To run tests on local web browsers (comment web browsers you don't have in `client/e2e/wdio.local.conf.ts`): | 100 | To run tests on local web browsers (comment web browsers you don't have in `client/e2e/wdio.local.conf.ts`): |
101 | 101 | ||
102 | ```bash | 102 | ```bash |
103 | $ npm run e2e:local | 103 | $ PEERTUBE2_E2E_PASSWORD=password npm run e2e:local |
104 | ``` | 104 | ``` |
105 | 105 | ||
106 | ### Browserstack tests | 106 | ### Browserstack tests |