From fc6c64b51a27597932dbc2530262543b3b4051d4 Mon Sep 17 00:00:00 2001 From: Tre Date: Fri, 20 Dec 2024 08:40:54 +0000 Subject: [PATCH] [8.x] [Ownership] Add code owner to ftr failure report (#203076) (#204995) # Backport This will backport the following commits from `main` to `8.x`: - [[Ownership] Add code owner to ftr failure report (#203076)](https://github.com/elastic/kibana/pull/203076) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) --- .../failed_tests_reporter/__fixtures__/ftr_report.xml | 8 ++++---- .../failed_tests_reporter/add_messages_to_report.test.ts | 8 ++++---- .../failed_tests_reporter/get_failures.test.ts | 6 ++++++ .../failed_tests_reporter/get_failures.ts | 3 +++ .../failed_tests_reporter/report_failures_to_file.ts | 6 ++++++ .../failed_tests_reporter/test_report.ts | 5 ++++- 6 files changed, 27 insertions(+), 9 deletions(-) diff --git a/packages/kbn-failed-test-reporter-cli/failed_tests_reporter/__fixtures__/ftr_report.xml b/packages/kbn-failed-test-reporter-cli/failed_tests_reporter/__fixtures__/ftr_report.xml index 07f1e79b0f5df..77c0d7691d22d 100644 --- a/packages/kbn-failed-test-reporter-cli/failed_tests_reporter/__fixtures__/ftr_report.xml +++ b/packages/kbn-failed-test-reporter-cli/failed_tests_reporter/__fixtures__/ftr_report.xml @@ -1,7 +1,7 @@ - + - + - + - + { ‹?xml version="1.0" encoding="utf-8"?› ‹testsuites name="ftr" timestamp="2019-06-05T23:37:10" time="903.670" tests="129" failures="5" skipped="71" command-line="node scripts/functional_tests --config=x-pack/test/api_integration/apis/status/config.ts"› ‹testsuite timestamp="2019-06-05T23:37:10" time="903.670" tests="129" failures="5" skipped="71" command-line="node scripts/functional_tests --config=x-pack/test/api_integration/apis/status/config.ts"› - ‹testcase name="maps app maps loaded from sample data ecommerce "before all" hook" classname="Chrome X-Pack UI Functional Tests.x-pack/test/functional/apps/maps/sample_data·js" time="154.378"› + ‹testcase name="maps app maps loaded from sample data ecommerce "before all" hook" classname="Chrome X-Pack UI Functional Tests.x-pack/test/functional/apps/maps/sample_data·js" time="154.378" owners="elastic/kibana-presentation"› - ‹system-out› - ‹![CDATA[[00:00:00] │ + ‹system-out›Failed Tests Reporter: @@ -88,7 +88,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" 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"}]}"› + ‹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"}]}" owners="elastic/kibana-presentation"› ‹system-out› - ‹![CDATA[[00:00:00] │ + [00:00:00] │ @@ -106,7 +106,7 @@ it('rewrites ftr reports with minimal changes', async () => { + at process._tickCallback (internal/process/next_tick.js:68:7) name: 'NoSuchSessionError', remoteStacktrace: '' } ‹/failure› ‹/testcase› - ‹testcase name="InfraOps app feature controls infrastructure security global infrastructure all privileges shows infrastructure navlink" classname="Chrome X-Pack UI Functional Tests.x-pack/test/functional/apps/infra/feature_controls/infrastructure_security·ts"› + ‹testcase name="InfraOps app feature controls infrastructure security global infrastructure all privileges shows infrastructure navlink" classname="Chrome X-Pack UI Functional Tests.x-pack/test/functional/apps/infra/feature_controls/infrastructure_security·ts" owners="elastic/kibana-presentation"› ‹system-out› - ‹![CDATA[[00:00:00] │ + [00:00:00] │ @@ -117,7 +117,7 @@ it('rewrites ftr reports with minimal changes', async () => { ‹/system-out› ‹skipped/› ‹/testcase› - ‹testcase name="machine learning anomaly detection saved search with lucene query job creation opens the advanced section" classname="Firefox XPack UI Functional Tests.x-pack/test/functional/apps/machine_learning/anomaly_detection/saved_search_job·ts" time="6.040"› + ‹testcase name="machine learning anomaly detection saved search with lucene query job creation opens the advanced section" classname="Firefox XPack UI Functional Tests.x-pack/test/functional/apps/machine_learning/anomaly_detection/saved_search_job·ts" time="6.040" owners="elastic/ml-ui"› - ‹system-out›‹![CDATA[[00:21:57] └-: machine learning...]]›‹/system-out› - ‹failure›‹![CDATA[{ NoSuchSessionError: Tried to run command without establishing a connection + ‹system-out›[00:21:57] └-: machine learning...‹/system-out› diff --git a/packages/kbn-failed-test-reporter-cli/failed_tests_reporter/get_failures.test.ts b/packages/kbn-failed-test-reporter-cli/failed_tests_reporter/get_failures.test.ts index b00ef8cb6bc49..52d2858232d52 100644 --- a/packages/kbn-failed-test-reporter-cli/failed_tests_reporter/get_failures.test.ts +++ b/packages/kbn-failed-test-reporter-cli/failed_tests_reporter/get_failures.test.ts @@ -28,6 +28,7 @@ it('discovers failures in ftr report', async () => { ", "likelyIrrelevant": false, "name": "maps app maps loaded from sample data ecommerce \\"before all\\" hook", + "owners": "elastic/kibana-presentation", "system-out": " [00:00:00] │ [00:07:04] └-: maps app @@ -49,6 +50,7 @@ it('discovers failures in ftr report', async () => { "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", + "owners": "elastic/kibana-presentation", "system-out": " [00:00:00] │ [00:07:04] └-: maps app @@ -67,6 +69,7 @@ it('discovers failures in ftr report', async () => { at process._tickCallback (internal/process/next_tick.js:68:7) name: 'NoSuchSessionError', remoteStacktrace: '' }", "likelyIrrelevant": true, "name": "machine learning anomaly detection saved search with lucene query job creation opens the advanced section", + "owners": "elastic/ml-ui", "system-out": "[00:21:57] └-: machine learning...", "time": "6.040", }, @@ -87,6 +90,7 @@ it('discovers failures in jest report', async () => { ", "likelyIrrelevant": false, "name": "launcher can reconnect if process died", + "owners": undefined, "system-out": "", "time": "7.060", }, @@ -116,6 +120,7 @@ it('discovers failures in mocha report', async () => { ", "likelyIrrelevant": true, "name": "code in multiple nodes \\"before all\\" hook", + "owners": undefined, "system-out": " ", @@ -131,6 +136,7 @@ it('discovers failures in mocha report', async () => { ", "likelyIrrelevant": true, "name": "code in multiple nodes \\"after all\\" hook", + "owners": undefined, "system-out": " ", diff --git a/packages/kbn-failed-test-reporter-cli/failed_tests_reporter/get_failures.ts b/packages/kbn-failed-test-reporter-cli/failed_tests_reporter/get_failures.ts index dd5e846dfc01e..d65773810ddf4 100644 --- a/packages/kbn-failed-test-reporter-cli/failed_tests_reporter/get_failures.ts +++ b/packages/kbn-failed-test-reporter-cli/failed_tests_reporter/get_failures.ts @@ -18,6 +18,7 @@ export type TestFailure = FailedTestCase['$'] & { githubIssue?: string; failureCount?: number; commandLine?: string; + owners?: any; }; const getText = (node?: Array) => { @@ -78,6 +79,7 @@ export function getFailures(report: TestReport) { for (const testCase of makeFailedTestCaseIter(report)) { const failure = getText(testCase.failure); const likelyIrrelevant = isLikelyIrrelevant(testCase.$.name, failure); + const owners = testCase.$.owners; const failureObj = { // unwrap xml weirdness @@ -87,6 +89,7 @@ export function getFailures(report: TestReport) { likelyIrrelevant, 'system-out': getText(testCase['system-out']), commandLine, + owners, }; // cleaning up duplicates diff --git a/packages/kbn-failed-test-reporter-cli/failed_tests_reporter/report_failures_to_file.ts b/packages/kbn-failed-test-reporter-cli/failed_tests_reporter/report_failures_to_file.ts index 7876efb8502a5..365c46f8a9988 100644 --- a/packages/kbn-failed-test-reporter-cli/failed_tests_reporter/report_failures_to_file.ts +++ b/packages/kbn-failed-test-reporter-cli/failed_tests_reporter/report_failures_to_file.ts @@ -179,6 +179,12 @@ export async function reportFailuresToFile( ` : '' } +
+ Owners: +
${escape(
+                  failure?.owners ? (failure?.owners as string) : 'Unable to determine code owners'
+                )}
+
Failures in tracked branches: ${failure.failureCount || 0} diff --git a/packages/kbn-failed-test-reporter-cli/failed_tests_reporter/test_report.ts b/packages/kbn-failed-test-reporter-cli/failed_tests_reporter/test_report.ts index e56e4a6810efd..6467cfaab14be 100644 --- a/packages/kbn-failed-test-reporter-cli/failed_tests_reporter/test_report.ts +++ b/packages/kbn-failed-test-reporter-cli/failed_tests_reporter/test_report.ts @@ -11,7 +11,6 @@ import Fs from 'fs'; import { promisify } from 'util'; import xml2js from 'xml2js'; - const readAsync = promisify(Fs.readFile); export type TestReport = @@ -40,6 +39,8 @@ export interface TestSuite { 'metadata-json'?: string; /* the command that ran this suite */ 'command-line'?: string; + /* the codeowners of the file */ + owners?: string; }; testcase?: TestCase[]; } @@ -56,6 +57,8 @@ export interface TestCase { 'metadata-json'?: string; /* the command that ran this suite */ 'command-line'?: string; + /* the codeowners of the file */ + owners?: string; }; /* contents of system-out elements */ 'system-out'?: Array;