From 64d698d19ac8f079fb8f81000451432401cb6930 Mon Sep 17 00:00:00 2001 From: Dzmitry Lemechko Date: Wed, 10 Feb 2021 11:08:50 +0100 Subject: [PATCH 1/6] [coverage] fix jest merging --- .../shell_scripts/copy_jest_report.sh | 10 ++++++++++ .../shell_scripts/fix_html_reports_parallel.sh | 6 ------ ...nerate_team_assignments_and_ingest_coverage.sh | 15 +++++++++++---- ...jest_and_functional.sh => merge_functional.sh} | 4 +--- test/scripts/jenkins_unit.sh | 3 +++ vars/kibanaCoverage.groovy | 9 +++++---- vars/kibanaPipeline.groovy | 2 +- 7 files changed, 31 insertions(+), 18 deletions(-) create mode 100755 src/dev/code_coverage/shell_scripts/copy_jest_report.sh rename src/dev/code_coverage/shell_scripts/{merge_jest_and_functional.sh => merge_functional.sh} (54%) mode change 100644 => 100755 diff --git a/src/dev/code_coverage/shell_scripts/copy_jest_report.sh b/src/dev/code_coverage/shell_scripts/copy_jest_report.sh new file mode 100755 index 0000000000000..8369d5b467c02 --- /dev/null +++ b/src/dev/code_coverage/shell_scripts/copy_jest_report.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +EXTRACT_START_DIR=tmp/extracted_coverage +EXTRACT_END_DIR=target/kibana-coverage +COMBINED_EXRACT_DIR=/${EXTRACT_START_DIR}/${EXTRACT_END_DIR} + + +echo "### Copy combined jest report" +mkdir -p $EXTRACT_END_DIR/jest-combined +cp -r $COMBINED_EXRACT_DIR/jest-combined/. $EXTRACT_END_DIR/jest-combined/ diff --git a/src/dev/code_coverage/shell_scripts/fix_html_reports_parallel.sh b/src/dev/code_coverage/shell_scripts/fix_html_reports_parallel.sh index 01003b6dc880c..6e6ba9e1b1118 100644 --- a/src/dev/code_coverage/shell_scripts/fix_html_reports_parallel.sh +++ b/src/dev/code_coverage/shell_scripts/fix_html_reports_parallel.sh @@ -7,12 +7,6 @@ COMBINED_EXRACT_DIR=/${EXTRACT_START_DIR}/${EXTRACT_END_DIR} PWD=$(pwd) du -sh $COMBINED_EXRACT_DIR -echo "### Jest: replacing path in json files" -for i in oss oss-integration xpack; do - sed -i "s|/dev/shm/workspace/kibana|${PWD}|g" $COMBINED_EXRACT_DIR/jest/${i}-coverage-final.json & -done -wait - echo "### Functional: replacing path in json files" for i in {1..9}; do sed -i "s|/dev/shm/workspace/kibana|${PWD}|g" $COMBINED_EXRACT_DIR/functional/${i}*.json & diff --git a/src/dev/code_coverage/shell_scripts/generate_team_assignments_and_ingest_coverage.sh b/src/dev/code_coverage/shell_scripts/generate_team_assignments_and_ingest_coverage.sh index caa1f1a761367..d403860185707 100644 --- a/src/dev/code_coverage/shell_scripts/generate_team_assignments_and_ingest_coverage.sh +++ b/src/dev/code_coverage/shell_scripts/generate_team_assignments_and_ingest_coverage.sh @@ -10,7 +10,7 @@ echo "### debug COVERAGE_JOB_NAME: ${COVERAGE_JOB_NAME}" BUILD_ID=$2 export BUILD_ID -CI_RUN_URL=$3 +CI_RUN_URL = $ 3 export CI_RUN_URL echo "### debug CI_RUN_URL: ${CI_RUN_URL}" @@ -32,11 +32,18 @@ TEAM_ASSIGN_PATH=$5 # Build team assignments dat file node scripts/generate_team_assignments.js --verbose --src .github/CODEOWNERS --dest $TEAM_ASSIGN_PATH -for x in jest functional; do - echo "### Ingesting coverage for ${x}" +echo "### Ingesting coverage for functional" - COVERAGE_SUMMARY_FILE=target/kibana-coverage/${x}-combined/coverage-summary.json +COVERAGE_SUMMARY_FILE=target/kibana-coverage/functional-combined/coverage-summary.json +node scripts/ingest_coverage.js --verbose --path ${COVERAGE_SUMMARY_FILE} --vcsInfoPath ./VCS_INFO.txt --teamAssignmentsPath $TEAM_ASSIGN_PATH +for x in functional jest; do + echo "### Ingesting coverage for ${x}" + COVERAGE_SUMMARY_FILE=target/kibana-coverage/${x}-combined/coverage-summary.json + if [[ $x == "jest" ]]; then + # Need to override COVERAGE_INGESTION_KIBANA_ROOT since json file has original intake worker path + export COVERAGE_INGESTION_KIBANA_ROOT=/dev/shm/workspace/kibana + be node scripts/ingest_coverage.js --verbose --path ${COVERAGE_SUMMARY_FILE} --vcsInfoPath ./VCS_INFO.txt --teamAssignmentsPath $TEAM_ASSIGN_PATH done diff --git a/src/dev/code_coverage/shell_scripts/merge_jest_and_functional.sh b/src/dev/code_coverage/shell_scripts/merge_functional.sh old mode 100644 new mode 100755 similarity index 54% rename from src/dev/code_coverage/shell_scripts/merge_jest_and_functional.sh rename to src/dev/code_coverage/shell_scripts/merge_functional.sh index 707c6de3f88a0..5f03e5f24528a --- a/src/dev/code_coverage/shell_scripts/merge_jest_and_functional.sh +++ b/src/dev/code_coverage/shell_scripts/merge_functional.sh @@ -4,6 +4,4 @@ COVERAGE_TEMP_DIR=/tmp/extracted_coverage/target/kibana-coverage/ export COVERAGE_TEMP_DIR echo "### Merge coverage reports" -for x in jest functional; do - yarn nyc report --nycrc-path src/dev/code_coverage/nyc_config/nyc.${x}.config.js -done +yarn nyc report --nycrc-path src/dev/code_coverage/nyc_config/nyc.functional.config.js diff --git a/test/scripts/jenkins_unit.sh b/test/scripts/jenkins_unit.sh index 9e387f97a016e..a483f8378b8b4 100755 --- a/test/scripts/jenkins_unit.sh +++ b/test/scripts/jenkins_unit.sh @@ -32,4 +32,7 @@ else echo " -> Running jest integration tests with coverage" node scripts/jest_integration --ci --verbose --coverage || true; + + echo " -> Combine code coverage in a single report" + yarn nyc report --nycrc-path src/dev/code_coverage/nyc_config/nyc.jest.config.js fi diff --git a/vars/kibanaCoverage.groovy b/vars/kibanaCoverage.groovy index e393f3a5d2150..186134aee1d85 100644 --- a/vars/kibanaCoverage.groovy +++ b/vars/kibanaCoverage.groovy @@ -148,9 +148,10 @@ def generateReports(title) { cd .. . src/dev/code_coverage/shell_scripts/extract_archives.sh . src/dev/code_coverage/shell_scripts/fix_html_reports_parallel.sh - . src/dev/code_coverage/shell_scripts/merge_jest_and_functional.sh - # zip combined reports - tar -czf kibana-coverage.tar.gz target/kibana-coverage/**/* + . src/dev/code_coverage/shell_scripts/merge_functional.sh + . src/dev/code_coverage/shell_scripts/copy_jest_report.sh + # zip functional combined report + tar -czf kibana-functional-coverage.tar.gz target/kibana-coverage/functional/* """, title) } @@ -162,7 +163,7 @@ def uploadCombinedReports() { kibanaPipeline.uploadGcsArtifact( "kibana-ci-artifacts/jobs/${env.JOB_NAME}/${BUILD_NUMBER}/coverage/combined", - 'kibana-coverage.tar.gz' + 'kibana-functional-coverage.tar.gz' ) } diff --git a/vars/kibanaPipeline.groovy b/vars/kibanaPipeline.groovy index 5efcea3edb9bb..7adf755bfc583 100644 --- a/vars/kibanaPipeline.groovy +++ b/vars/kibanaPipeline.groovy @@ -188,7 +188,7 @@ def withGcsArtifactUpload(workerName, closure) { def ARTIFACT_PATTERNS = [ 'target/junit/**/*', 'target/kibana-*', - 'target/kibana-coverage/**/*', + 'target/kibana-coverage/jest/**/*', 'target/kibana-security-solution/**/*.png', 'target/test-metrics/*', 'target/test-suites-ci-plan.json', From bfb433c88c31879e55b377b1d5efde93bd83659a Mon Sep 17 00:00:00 2001 From: Dzmitry Lemechko Date: Fri, 12 Feb 2021 11:44:12 +0100 Subject: [PATCH 2/6] fix path to functional results --- vars/kibanaCoverage.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vars/kibanaCoverage.groovy b/vars/kibanaCoverage.groovy index 186134aee1d85..1d5fd211f830f 100644 --- a/vars/kibanaCoverage.groovy +++ b/vars/kibanaCoverage.groovy @@ -151,7 +151,7 @@ def generateReports(title) { . src/dev/code_coverage/shell_scripts/merge_functional.sh . src/dev/code_coverage/shell_scripts/copy_jest_report.sh # zip functional combined report - tar -czf kibana-functional-coverage.tar.gz target/kibana-coverage/functional/* + tar -czf kibana-functional-coverage.tar.gz target/kibana-coverage/functional-combined/* """, title) } From 93b3a6f41a4185a3bf1c5f6bdd916e09e799ccfb Mon Sep 17 00:00:00 2001 From: Dzmitry Lemechko Date: Fri, 12 Feb 2021 11:52:59 +0100 Subject: [PATCH 3/6] revert wrong change --- .../generate_team_assignments_and_ingest_coverage.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dev/code_coverage/shell_scripts/generate_team_assignments_and_ingest_coverage.sh b/src/dev/code_coverage/shell_scripts/generate_team_assignments_and_ingest_coverage.sh index d403860185707..d1b4dac197e69 100644 --- a/src/dev/code_coverage/shell_scripts/generate_team_assignments_and_ingest_coverage.sh +++ b/src/dev/code_coverage/shell_scripts/generate_team_assignments_and_ingest_coverage.sh @@ -10,7 +10,7 @@ echo "### debug COVERAGE_JOB_NAME: ${COVERAGE_JOB_NAME}" BUILD_ID=$2 export BUILD_ID -CI_RUN_URL = $ 3 +CI_RUN_URL=$3 export CI_RUN_URL echo "### debug CI_RUN_URL: ${CI_RUN_URL}" From d45324a0a081f00a0813016e296c2ee67b98bb08 Mon Sep 17 00:00:00 2001 From: Dzmitry Lemechko Date: Fri, 12 Feb 2021 21:13:15 +0100 Subject: [PATCH 4/6] fix ingest script --- ...generate_team_assignments_and_ingest_coverage.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/dev/code_coverage/shell_scripts/generate_team_assignments_and_ingest_coverage.sh b/src/dev/code_coverage/shell_scripts/generate_team_assignments_and_ingest_coverage.sh index d1b4dac197e69..fb1b26ae8a37f 100644 --- a/src/dev/code_coverage/shell_scripts/generate_team_assignments_and_ingest_coverage.sh +++ b/src/dev/code_coverage/shell_scripts/generate_team_assignments_and_ingest_coverage.sh @@ -39,11 +39,14 @@ node scripts/ingest_coverage.js --verbose --path ${COVERAGE_SUMMARY_FILE} --vcsI for x in functional jest; do echo "### Ingesting coverage for ${x}" - COVERAGE_SUMMARY_FILE=target/kibana-coverage/${x}-combined/coverage-summary.json - if [[ $x == "jest" ]]; then - # Need to override COVERAGE_INGESTION_KIBANA_ROOT since json file has original intake worker path - export COVERAGE_INGESTION_KIBANA_ROOT=/dev/shm/workspace/kibana - be + + COVERAGE_SUMMARY_FILE=target/kibana-coverage/${x}-combined/coverage-summary.json + + if [[ $x == "jest" ]]; then + # Need to override COVERAGE_INGESTION_KIBANA_ROOT since json file has original intake worker path + export COVERAGE_INGESTION_KIBANA_ROOT=/dev/shm/workspace/kibana + fi + node scripts/ingest_coverage.js --verbose --path ${COVERAGE_SUMMARY_FILE} --vcsInfoPath ./VCS_INFO.txt --teamAssignmentsPath $TEAM_ASSIGN_PATH done From c51b2d74d2277f3a89994918cab1377d91272c42 Mon Sep 17 00:00:00 2001 From: Dzmitry Lemechko Date: Fri, 12 Feb 2021 21:17:02 +0100 Subject: [PATCH 5/6] fix ingest script --- .../generate_team_assignments_and_ingest_coverage.sh | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/dev/code_coverage/shell_scripts/generate_team_assignments_and_ingest_coverage.sh b/src/dev/code_coverage/shell_scripts/generate_team_assignments_and_ingest_coverage.sh index fb1b26ae8a37f..243dbaa6197e6 100644 --- a/src/dev/code_coverage/shell_scripts/generate_team_assignments_and_ingest_coverage.sh +++ b/src/dev/code_coverage/shell_scripts/generate_team_assignments_and_ingest_coverage.sh @@ -32,11 +32,6 @@ TEAM_ASSIGN_PATH=$5 # Build team assignments dat file node scripts/generate_team_assignments.js --verbose --src .github/CODEOWNERS --dest $TEAM_ASSIGN_PATH -echo "### Ingesting coverage for functional" - -COVERAGE_SUMMARY_FILE=target/kibana-coverage/functional-combined/coverage-summary.json -node scripts/ingest_coverage.js --verbose --path ${COVERAGE_SUMMARY_FILE} --vcsInfoPath ./VCS_INFO.txt --teamAssignmentsPath $TEAM_ASSIGN_PATH - for x in functional jest; do echo "### Ingesting coverage for ${x}" From ce22bdcb3e21b2604674de6bcb83c2248c04544b Mon Sep 17 00:00:00 2001 From: Dzmitry Lemechko Date: Tue, 16 Feb 2021 14:30:40 +0100 Subject: [PATCH 6/6] [coverage plugin] change id to camelCase --- test/common/fixtures/plugins/coverage/kibana.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/common/fixtures/plugins/coverage/kibana.json b/test/common/fixtures/plugins/coverage/kibana.json index d80432534d746..d849db8d0583d 100644 --- a/test/common/fixtures/plugins/coverage/kibana.json +++ b/test/common/fixtures/plugins/coverage/kibana.json @@ -1,5 +1,5 @@ { - "id": "coverage-fixtures", + "id": "coverageFixtures", "version": "kibana", "server": false, "ui": true