Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Wait timed out after 10055ms
at onFailure (/var/lib/jenkins/workspace/elastic+kibana+master/JOB/x-pack-ciGroup7/node/immutable/kibana/test/common/services/retry/retry_for_success.ts:68:13)]]>
</failure>
</testcase>
<testcase name="maps app &quot;after all&quot; hook" classname="Chrome X-Pack UI Functional Tests.x-pack/test/functional/apps/maps" time="0.179">
<testcase name="maps app &quot;after all&quot; hook" classname="Chrome X-Pack UI Functional Tests.x-pack/test/functional/apps/maps" time="0.179" metadata-json="{&quot;messages&quot;:[&quot;foo&quot;],&quot;screenshots&quot;:[{&quot;name&quot;:&quot;failure[dashboard app using current data dashboard snapshots compare TSVB snapshot]&quot;,&quot;url&quot;:&quot;https://storage.googleapis.com/kibana-ci-artifacts/jobs/elastic+kibana+7.x/1632/kibana-oss-tests/test/functional/screenshots/failure/dashboard%20app%20using%20current%20data%20dashboard%20snapshots%20compare%20TSVB%20snapshot.png&quot;}]}">
<system-out>
<![CDATA[[00:00:00] │
[00:07:04] └-: maps app
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ it('rewrites ftr reports with minimal changes', async () => {
+ at onFailure (/var/lib/jenkins/workspace/elastic+kibana+master/JOB/x-pack-ciGroup7/node/immutable/kibana/test/common/services/retry/retry_for_success.ts:68:13)
‹/failure›
‹/testcase›
‹testcase name="maps app &quot;after all&quot; hook" classname="Chrome X-Pack UI Functional Tests.x-pack/test/functional/apps/maps" time="0.179"›
‹testcase name="maps app &quot;after all&quot; hook" classname="Chrome X-Pack UI Functional Tests.x-pack/test/functional/apps/maps" time="0.179" metadata-json="{&quot;messages&quot;:[&quot;foo&quot;],&quot;screenshots&quot;:[{&quot;name&quot;:&quot;failure[dashboard app using current data dashboard snapshots compare TSVB snapshot]&quot;,&quot;url&quot;:&quot;https://storage.googleapis.com/kibana-ci-artifacts/jobs/elastic+kibana+7.x/1632/kibana-oss-tests/test/functional/screenshots/failure/dashboard%20app%20using%20current%20data%20dashboard%20snapshots%20compare%20TSVB%20snapshot.png&quot;}]}"
‹system-out›
- ‹![CDATA[[00:00:00] │
+ [00:00:00] │
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ it('discovers failures in ftr report', async () => {
at process._tickCallback (internal/process/next_tick.js:68:7) name: 'NoSuchSessionError', remoteStacktrace: '' }
",
"likelyIrrelevant": true,
"metadata-json": "{\\"messages\\":[\\"foo\\"],\\"screenshots\\":[{\\"name\\":\\"failure[dashboard app using current data dashboard snapshots compare TSVB snapshot]\\",\\"url\\":\\"https://storage.googleapis.com/kibana-ci-artifacts/jobs/elastic+kibana+7.x/1632/kibana-oss-tests/test/functional/screenshots/failure/dashboard%20app%20using%20current%20data%20dashboard%20snapshots%20compare%20TSVB%20snapshot.png\\"}]}",
"name": "maps app \\"after all\\" hook",
"time": "0.179",
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { getReportMessageIter } from './report_metadata';
import { parseTestReport } from './test_report';
import { FTR_REPORT, JEST_REPORT, KARMA_REPORT, MOCHA_REPORT } from './__fixtures__';

it('reads messages and screenshots from metadata-json properties', async () => {
const ftrReport = await parseTestReport(FTR_REPORT);
expect(Array.from(getReportMessageIter(ftrReport))).toMatchInlineSnapshot(`
Array [
Object {
"classname": "Chrome X-Pack UI Functional Tests.x-pack/test/functional/apps/maps",
"message": "foo",
"name": "maps app \\"after all\\" hook",
},
Object {
"classname": "Chrome X-Pack UI Functional Tests.x-pack/test/functional/apps/maps",
"message": "Screenshot: failure[dashboard app using current data dashboard snapshots compare TSVB snapshot] https://storage.googleapis.com/kibana-ci-artifacts/jobs/elastic+kibana+7.x/1632/kibana-oss-tests/test/functional/screenshots/failure/dashboard%20app%20using%20current%20data%20dashboard%20snapshots%20compare%20TSVB%20snapshot.png",
"name": "maps app \\"after all\\" hook",
},
]
`);

const jestReport = await parseTestReport(JEST_REPORT);
expect(Array.from(getReportMessageIter(jestReport))).toMatchInlineSnapshot(`Array []`);

const mochaReport = await parseTestReport(MOCHA_REPORT);
expect(Array.from(getReportMessageIter(mochaReport))).toMatchInlineSnapshot(`Array []`);

const karmaReport = await parseTestReport(KARMA_REPORT);
expect(Array.from(getReportMessageIter(karmaReport))).toMatchInlineSnapshot(`Array []`);
});
25 changes: 7 additions & 18 deletions packages/kbn-test/src/failed_tests_reporter/report_metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,36 +18,25 @@
*/

import { TestReport, makeTestCaseIter } from './test_report';
import { Message } from './add_messages_to_report';

export function* getMetadataIter(report: TestReport) {
export function* getReportMessageIter(report: TestReport) {
for (const testCase of makeTestCaseIter(report)) {
if (!testCase.$['metadata-json']) {
yield [{}, testCase];
} else {
yield [{}, JSON.parse(testCase.$['metadata-json'])];
}
}
}
const metadata = testCase.$['metadata-json'] ? JSON.parse(testCase.$['metadata-json']) : {};

export function getReportMessages(report: TestReport) {
const messages: Message[] = [];
for (const [metadata, testCase] of getMetadataIter(report)) {
for (const message of metadata.messages || []) {
messages.push({
yield {
classname: testCase.$.classname,
name: testCase.$.name,
message,
});
message: String(message),
};
}

for (const screenshot of metadata.screenshots || []) {
messages.push({
yield {
classname: testCase.$.classname,
name: testCase.$.name,
message: `Screenshot: ${screenshot.name} ${screenshot.url}`,
});
};
}
}
return messages;
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { updateFailureIssue, createFailureIssue } from './report_failure';
import { getIssueMetadata } from './issue_metadata';
import { readTestReport } from './test_report';
import { addMessagesToReport } from './add_messages_to_report';
import { getReportMessages } from './report_metadata';
import { getReportMessageIter } from './report_metadata';

export function runFailedTestsReporterCli() {
run(
Expand Down Expand Up @@ -75,7 +75,7 @@ export function runFailedTestsReporterCli() {

for (const reportPath of reportPaths) {
const report = await readTestReport(reportPath);
const messages = getReportMessages(report);
const messages = Array.from(getReportMessageIter(report));

for (const failure of await getFailures(report)) {
const pushMessage = (msg: string) => {
Expand Down