refactor(core): Port endpoints config (no-changelog) (#10268)

This commit is contained in:
Iván Ovejero
2024-07-31 17:45:11 +02:00
committed by GitHub
parent d91eb2cdd5
commit 1608d2527b
21 changed files with 275 additions and 228 deletions

View File

@@ -2,17 +2,48 @@ import { Container } from 'typedi';
import { parse as semverParse } from 'semver';
import request, { type Response } from 'supertest';
import config from '@/config';
import { N8N_VERSION } from '@/constants';
import { PrometheusMetricsService } from '@/metrics/prometheus-metrics.service';
import { setupTestServer } from './shared/utils';
import { mockInstance } from '@test/mocking';
import { GlobalConfig } from '@n8n/config';
jest.unmock('@/eventbus/MessageEventBus/MessageEventBus');
const toLines = (response: Response) => response.text.trim().split('\n');
config.set('endpoints.metrics.enable', true);
config.set('endpoints.metrics.prefix', 'n8n_test_');
mockInstance(GlobalConfig, {
database: {
type: 'sqlite',
sqlite: {
database: 'database.sqlite',
enableWAL: false,
executeVacuumOnStartup: false,
poolSize: 0,
},
logging: {
enabled: false,
maxQueryExecutionTime: 0,
options: 'error',
},
tablePrefix: '',
},
endpoints: {
metrics: {
prefix: 'n8n_test_',
includeDefaultMetrics: true,
includeApiEndpoints: true,
includeCacheMetrics: true,
includeMessageEventBusMetrics: true,
includeCredentialTypeLabel: false,
includeNodeTypeLabel: false,
includeWorkflowIdLabel: false,
includeApiPathLabel: true,
includeApiMethodLabel: true,
includeApiStatusCodeLabel: true,
},
},
});
const server = setupTestServer({ endpointGroups: ['metrics'] });
const agent = request.agent(server.app);