mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
refactor tests
This commit is contained in:
parent
c3a167eb40
commit
464b3e2daf
4 changed files with 12 additions and 6 deletions
|
@ -42,6 +42,7 @@ export default async function ({ readConfigFile }: FtrConfigProviderContext) {
|
|||
`--elasticsearch.hosts=${servers.elasticsearch.protocol}://${servers.elasticsearch.hostname}:${servers.elasticsearch.port}`,
|
||||
`--elasticsearch.ssl.certificateAuthorities=${CA_CERT_PATH}`,
|
||||
|
||||
'--server.requestId.allowFromAnyIp=true',
|
||||
'--execution_context.enabled=true',
|
||||
'--logging.appenders.file.type=file',
|
||||
`--logging.appenders.file.fileName=${logFilePath}`,
|
||||
|
|
|
@ -98,8 +98,7 @@ export class FixturePlugin implements Plugin<void, void, FixtureSetupDeps, Fixtu
|
|||
transaction?.end();
|
||||
subscription.unsubscribe();
|
||||
});
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('>>> in handler', apmAgent.isStarted(), apmAgent.currentTraceIds);
|
||||
|
||||
await ctx.core.elasticsearch.client.asInternalUser.ping();
|
||||
|
||||
return res.ok({
|
||||
|
|
|
@ -40,7 +40,7 @@ export async function assertLogContains({
|
|||
retry: RetryService;
|
||||
}): Promise<void> {
|
||||
// logs are written to disk asynchronously. I sacrificed performance to reduce flakiness.
|
||||
await retry.waitForWithTimeout(description, 60_000, async () => {
|
||||
await retry.waitFor(description, async () => {
|
||||
const logsStr = await Fs.readFile(logFilePath, 'utf-8');
|
||||
const normalizedRecords = logsStr
|
||||
.split(endOfLine)
|
||||
|
|
|
@ -14,7 +14,10 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
|
||||
describe('Log Correlation', () => {
|
||||
it('Emits "trace.id" into the logs', async () => {
|
||||
const response1 = await supertest.get('/emit_log_with_trace_id');
|
||||
const response1 = await supertest
|
||||
.get('/emit_log_with_trace_id')
|
||||
.set('x-opaque-id', 'myheader1');
|
||||
|
||||
expect(response1.body.traceId).to.be.a('string');
|
||||
|
||||
const response2 = await supertest.get('/emit_log_with_trace_id');
|
||||
|
@ -23,8 +26,11 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
expect(response2.body.traceId).not.to.be(response1.body.traceId);
|
||||
|
||||
await assertLogContains({
|
||||
description: `traceId ${response1.body.traceId} included in the Kibana logs`,
|
||||
predicate: (record) => record.trace?.id === response1.body.traceId,
|
||||
description: 'traceId included in the Kibana logs',
|
||||
predicate: (record) =>
|
||||
// we don't check trace.id value since trace.id in the test plugin and Kibana are different on CI.
|
||||
// because different 'elastic-apm-node' instaces are imported
|
||||
Boolean(record.http?.request?.id?.includes('myheader1') && record.trace?.id),
|
||||
retry,
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue