mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
[7.5] [failedTests] fix reportMessageIter and add unit test (#… (#52998)
* [failedTests] fix reportMessageIter and add unit test * update related snapshots
This commit is contained in:
parent
aef46afdad
commit
965d809ec6
6 changed files with 61 additions and 22 deletions
|
@ -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 "after all" hook" classname="Chrome X-Pack UI Functional Tests.x-pack/test/functional/apps/maps" time="0.179">
|
||||
<testcase name="maps app "after all" hook" classname="Chrome X-Pack UI Functional Tests.x-pack/test/functional/apps/maps" time="0.179" 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"}]}">
|
||||
<system-out>
|
||||
<![CDATA[[00:00:00] │
|
||||
[00:07:04] └-: maps app
|
||||
|
|
|
@ -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 "after all" hook" classname="Chrome X-Pack UI Functional Tests.x-pack/test/functional/apps/maps" time="0.179"›
|
||||
‹testcase name="maps app "after all" hook" classname="Chrome X-Pack UI Functional Tests.x-pack/test/functional/apps/maps" time="0.179" 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"}]}"›
|
||||
‹system-out›
|
||||
- ‹![CDATA[[00:00:00] │
|
||||
+ [00:00:00] │
|
||||
|
|
|
@ -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",
|
||||
},
|
||||
|
|
|
@ -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 []`);
|
||||
});
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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(
|
||||
|
@ -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) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue