Skip to content

Commit

Permalink
[cli/serve/integrationTests] log stdout from process when parsing fai…
Browse files Browse the repository at this point in the history
…ls (#98699) (#98816)

Co-authored-by: spalger <[email protected]>

Co-authored-by: Spencer <[email protected]>
Co-authored-by: spalger <[email protected]>
  • Loading branch information
3 people authored Apr 29, 2021
1 parent afea14d commit 385cb54
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions src/cli/serve/integration_tests/invalid_config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@ const INVALID_CONFIG_PATH = require.resolve('./__fixtures__/invalid_config.yml')

interface LogEntry {
message: string;
tags: string[];
tags?: string[];
type: string;
}

// FLAKY: https://github.com/elastic/kibana/issues/32240
describe.skip('cli invalid config support', function () {
describe('cli invalid config support', function () {
it(
'exits with statusCode 64 and logs a single line when config is invalid',
function () {
Expand All @@ -33,18 +32,25 @@ describe.skip('cli invalid config support', function () {
}
);

const [fatalLogLine] = stdout
.toString('utf8')
.split('\n')
.filter(Boolean)
.map((line) => JSON.parse(line) as LogEntry)
.filter((line) => line.tags.includes('fatal'))
.map((obj) => ({
...obj,
pid: '## PID ##',
'@timestamp': '## @timestamp ##',
error: '## Error with stack trace ##',
}));
let fatalLogLine;
try {
[fatalLogLine] = stdout
.toString('utf8')
.split('\n')
.filter(Boolean)
.map((line) => JSON.parse(line) as LogEntry)
.filter((line) => line.tags?.includes('fatal'))
.map((obj) => ({
...obj,
pid: '## PID ##',
'@timestamp': '## @timestamp ##',
error: '## Error with stack trace ##',
}));
} catch (e) {
throw new Error(
`error parsing log output:\n\n${e.stack}\n\nstdout: \n${stdout}\n\nstderr:\n${stderr}`
);
}

expect(error).toBe(undefined);

Expand Down

0 comments on commit 385cb54

Please sign in to comment.