add coverage reports - #8464
Conversation
💔 Tests Failed
Expand to view the summary
Build stats
Test stats 🧪
Test errors
Expand to view the tests failures
|
|
This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation. |
mrodm
left a comment
There was a problem hiding this comment.
In the comment written by sonarqube there is no coverage report as it was done by Jenkins #8454 (comment), is it reported somewhere else ?
About quality gates, I think currently should not be set here... These coverage do not represent the same as in other repositories. These coverage reports have a different meaning here in integrations or elastic-package repositories:
https://github.com/elastic/integrations/blob/main/docs/testing_and_validation.md#review-test-coverage
| - "buildkite-agent artifact download coverage.out ." | ||
| - "buildkite-agent artifact download test-unit.out.xml ." |
There was a problem hiding this comment.
These files should not be generated using that new script ".buildkite/scripts/unit_test.sh".
These coverage XML files should be taken from the files generated by elastic-package command.
Every step that checks each package creates XML files in this path:
Line 412 in 90c6765
Could all those XML files generated be merged somehow to show a global coverage as it is done in Jenkins?
Lines 428 to 432 in 90c6765
There was a problem hiding this comment.
Yes, it could be merged, and thanks for the new inputs.
Will do that.
| go test -covermode=atomic -v -coverprofile=coverage.out ./... | tee ${testsFileName} | ||
|
|
||
| go install github.com/jstemmer/go-junit-report@latest | ||
| go-junit-report > "${testsFileName}.xml" < ${testsFileName} |
There was a problem hiding this comment.
Coverage report is generated by elastic-package since it is used with the parameter --test-coverage
There was a problem hiding this comment.
@mrodm, I don't see the coverage report in the artifacts, despite generating the reports with the correct option --test-coverage.
There are 2 files generated by the unit_test script (go test -coverprofile=coverage.out.....):
https://buildkite.com/organizations/elastic/pipelines/integrations/builds/6284/jobs/018bba52-cdb2-44dc-bc43-4e67eeb08fc3/artifacts/018bba53-9986-4484-9f18-5863a365dd7f
https://buildkite.com/organizations/elastic/pipelines/integrations/builds/6284/jobs/018bba52-cdb2-44dc-bc43-4e67eeb08fc3/artifacts/018bba53-9986-4b5f-89ba-15490e50941c
and there are we can see the coverage reports.
There was a problem hiding this comment.
IIRC artifact paths for coverage reports are not added in the step definitions created.
integrations/.buildkite/scripts/trigger_integrations_in_parallel.sh
Lines 60 to 62 in af38b97
Just tried locally to generate those files and it works:
$ cd /path/integrations/repo
$ cd packages/elastic_package_registry
$ elastic-package stack up -v -d --version 8.11-SNAPSHOT
...
$ elastic-package test -v --test-coverage
...
$ cd ../../
$ ls -l build/test-coverage/
total 24
-rw-r--r-- 1 mariorodriguez mariorodriguez 11755 nov 13 10:50 coverage-elastic_package_registry-1699869049973807711-report.xml
-rw-r--r-- 1 mariorodriguez mariorodriguez 912 nov 13 10:50 coverage-elastic_package_registry-1699869050248885422-report.xml
-rw-r--r-- 1 mariorodriguez mariorodriguez 912 nov 13 10:51 coverage-elastic_package_registry-1699869115891481631-report.xml
-rw-r--r-- 1 mariorodriguez mariorodriguez 911 nov 13 10:51 coverage-elastic_package_registry-1699869119250577740-report.xml
Here in this repository, it would be special. Here it is interesting the coverage of the packages, not the ones from the check sources step. @jsoriano is that correct?
There was a problem hiding this comment.
- These reports contain only zeros everywhere. It's OK?
- These reports have another data format:
coverage-barracuda_cloudgen_firewall-1699871427106197266-report.xml: Invalid go coverage, expect 'mode:' on the first line
The SonaqQube requires the files with data-format as I was getting the in the unit_test script -coverage.out...
There was a problem hiding this comment.
These reports contain only zeros everywhere. It's OK?
The contents of these files should be XML. For instance in the test that I run above:
$ head -n 20 build/test-coverage/coverage-elastic_package_registry-1699869049973807711-report.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE coverage SYSTEM "http://cobertura.sourceforge.net/xml/coverage-04.dtd">
<coverage line-rate="0" branch-rate="0" version="" timestamp="1699869049973807711" lines-covered="20" lines-valid="20" branches-covered="0" branches-valid="0" complexity="0">
<sources>
<source>/home/mariorodriguez/Coding/work/integrations/packages</source>
</sources>
<packages>
<package name="elastic_package_registry.metrics" line-rate="0" branch-rate="0" complexity="0">
<classes>
<class name="default" filename="elastic_package_registry/data_stream/metrics/elasticsearch/ingest_pipeline/default.yml" line-rate="0" branch-rate="0" complexity="0">
<methods>
<method name="set" signature="" line-rate="0" branch-rate="0" complexity="0" hits="1">
<lines>
<line number="4" hits="1"></line>
<line number="5" hits="1"></line>
<line number="6" hits="1"></line>
</lines>
</method>
<method name="set" signature="" line-rate="0" branch-rate="0" complexity="0" hits="1">
There was a problem hiding this comment.
I saw that, almost all values = 0
🌐 Coverage report
|
| # sonar.java.coveragePlugin=cobertura | ||
| sonar.cobertura.reportPath==build/test-coverage/coverage_merged.xml | ||
| # sonar.cobertura.reportPath==build/test-coverage/coverage_merged.xml | ||
| sonar.cobertura.reportPath==build/test-coverage/coverage-*.xml |
There was a problem hiding this comment.
This will not work. Sonar will not merge reports, you must use one which has been consolidated before uploading it.
Co-authored-by: Mario Rodriguez Molins <marrodmo@gmail.com>
|
|
Hi @sharbuz, please update your branch with the latest contents from main branch. There was an important PR merged updating the CI pipelines. Thanks! |
| # sonar.dynamicAnalysis=reuseReports | ||
| # sonar.java.coveragePlugin=cobertura | ||
| # sonar.cobertura.reportPath=build/test-coverage/coverage_merged.xml | ||
| sonar.python.coverage.reportPaths=build/test-coverage/coverage-report/coverage.xml |
There was a problem hiding this comment.
It looks like python test coverage tries to process the coverage XML
It shows this error:
INFO: Sensor Cobertura Sensor for Python coverage [python]
INFO: Python test coverage
INFO: Parsing report '/buildkite/builds/bk-agent-prod-k8s-1702313828449526795/elastic/integrations/build/test-coverage/coverage-report/coverage.xml'
ERROR: Cannot resolve the file path 'elastic_package_registry/metrics' of the coverage report, the file does not exist in all 'source'.
Probably, elastic-package can add data_stream as part of the filename (elastic_package_registry/data_stream/metrics) to see if that would be valid for Sonar. Not sure if it would be required also to include packages , but that would out of the context where elastic-package command runs.
There was a problem hiding this comment.
Tried in these two pull requests, and now with python coverage is able to parse the files, but it still does not appear any report
Relates Pull requests
- Updating elastic-package to add specific filepaths: Add generic test coverage report format for SonarQube elastic-package#1612
- Updated elastic-package version in integrations test: Add coverage reports analysis of packages #8787
|
Hi! We just realized that we haven't looked into this PR in a while. We're sorry! We're labeling this issue as |



Proposed commit message
The partial migration of the Jenkins pipelines to the Buildkite pipelines.
How to test this PR locally
The result should be seen in each PR
Related issues