I am using coverage py with parallel mode in Jenkins.
coverage run --source=${coverage_path} --branch --parallel-mode
In Jenkins , we have tests which run parallel on different slaves and for each slave the workspace path is different. We have 3 different worspaces wherein coverage.py generates .coverage files .
finally all .coverage files from all three slaves are stashed in one slave and we combine and calculate coverage.
The "coverage combine -- append" is able to find the workspace path of all slaves as the workspace is a NFS filer and the path can be accessed from another slave.
So when we combine all .coverage files an into single .coverage and generate html report i see multiple html files for same python code. In coverage documentation ,
"it is said to be possible to combine all data files into single report by mentioning paths where the first value must be an actual file path on the machine where the reporting will happen, so that source code can be found. The other values can be file patterns"
============================================
here sjc12, sjc2,sjc8 are three different slave with different source paths while coverage run is done.
but we combine them from sjc-12 slave it can access other slave source paths so combine is not a problem . Problem is with reporting, i get multiple reports each for a slave.
.coverage.nao-sjc12-lnx.105693.058242
.coverage.nao-sjc12-lnx.105694.068668
.coverage.nao-sjc12-lnx.105696.943817
.coverage.nao-sjc12-lnx.110171.478266
.coverage.nao-sjc12-lnx.110172.068159
.coverage.nao-sjc12-lnx.110173.976072
.coverage.nao-sjc2-lnx.26621.578881
.coverage.nao-sjc2-lnx.26622.099643
.coverage.nao-sjc2-lnx.26624.352776
.coverage.nao-sjc2-lnx.28400.035535
.coverage.nao-sjc2-lnx.28403.875349
.coverage.nao-sjc2-lnx.28404.837247
.coverage.nao-sjc8-lnx.42791.487008
.coverage.nao-sjc8-lnx.42794.238996
.coverage.nao-sjc8-lnx.42795.270589
.coverage.nao-sjc8-lnx.44519.822884
.coverage.nao-sjc8-lnx.44520.194302
.coverage.nao-sjc8-lnx.44522.414372
Report for same files there is one report for each slave
SGD4JUHGNRMSKX6HRQNZMFODKXT45J7KWX3WAUVMU2ZA_test_state_packages-in-use_cur_1-nf_py_3658c19353d9718b31000d57c7bd376e453d7a62.html
聽
SGD4JUHGNRMSKX6HRQNZMFODKXT45J7KWX3WAUVMU2ZA_test_state_packages-in-use_cur_1-nf_py_b45594b3d310fcebb90433fc33fd96317cb6cb86.html
Please guide me .
my covargerc is
# .coveragerc to control coverage.py
[run]
branch = True
parallel= True
[paths]
source =
/opt/jenkins/workspace/a-multibranch_N-QNP53J7OSGD4JUHGNRMSKX6HRQNZMFODKXT45J7KWX3WAUVMU2ZA/test/no/state/packages-in-use/state/packages-in-use/1/folder/python
/data/local/jenkins/workspace/**/python/mypath/*.py
/data/local/jenkins/workspace/**/python/*.py
[report]
# Regexes for lines to exclude from consideration
exclude_lines =
# Have to re-enable the standard pragma
pragma: no cover
# Don't complain about missing debug-only code:
def __repr__
if self\.debug
# Don't complain if tests don't hit defensive assertion code:
raise AssertionError
raise NotImplementedError
# Don't complain if non-runnable code isn't run:
if 0:
if __name__ == .__main__.:
# ignore_errors = True
[html]
directory = coverage_html_report
It's a little hard to tell what is going on here, but two points:
1) You have a very specific path as the first element of your [paths] configuration. Why not use some wildcards to make it match any jenkins workspace?
2) The first element of [paths] should be the path where the real sources will be found when doing reporting. Make sure it's a path that can be used to find the sources.
Thanks nedbat for your kind reply.
In our case we are running tests on 3 different hosts and each host generates .covarge.host files with hardcoded path for python source code.
For example
1] On host 1
cat python_coverage_report/dot_coverage/.coverage.pso-sjc12-lnx.59784.754910
Note here in path source is slave 12
!coverage.py: This is a private format, don't read it directly!{"arcs":{"/auto/pso/jenkins-slaves-data/shared-workspace/slave12/workspace/a-multibranch_Nao-359-Subbu-QNP53J7OSGD4JUHGNRMSKX6HRQNZMFODKXT45J7KWX3WAUVMU2ZA/test/ncs/state/packages-in-use.cur/1/packagep1/python/vi.py":[]
2] On host2
cat python_coverage_report/dot_coverage/.coverage.pso-sjc9-lnx.18260.839298
Note here in path source is slave 9
!coverage.py: This is a private format, don't read it directly!{"arcs":{"/auto/pso/jenkins-slaves-data/shared-workspace/slave9/workspace/a-multibranch_Nao-359-Subbu-QNP53J7OSGD4JUHGNRMSKX6HRQNZMFODKXT45J7KWX3WAUVMU2ZA/test/ncs/state/packages-in-use.cur/1/packagep1/python/vi.py":[]
3] On host3
cat python_coverage_report/dot_coverage/.coverage.pso-sjc8-lnx.10260.839235
Note here in path source is slave 8
!coverage.py: This is a private format, don't read it directly!{"arcs":{"/auto/pso/jenkins-slaves-data/shared-workspace/slave8/workspace/a-multibranch_Nao-359-Subbu-QNP53J7OSGD4JUHGNRMSKX6HRQNZMFODKXT45J7KWX3WAUVMU2ZA/test/ncs/state/packages-in-use.cur/1/packagep1/python/vi.py":[]
When we combine all these .coverage files from different hosts and combine them on host1 and generate the report ,we get error for source files not found for files on hosts2 and host3.
When .coverage is generated on any host the absolute source path of python file is hard coded as shown above
while generating report we tried by specifying path in coveragerc file as this now . We tried ** in filepath and also * in path none of them is generating report properly. Main objective is how to create .coverage files with relative path instead of absolute hardcoded path so that while generating report it is able to combine and create report irrespective of any specific machine location.
[paths]
source =
/state/packages-in-use/1/package1/python/,
/state/packages-in-use/1/package2/python,
/state/packages-in-use/1/package3/python
===================================================================================================
Your [paths] list should start with a specific readable directory that contains the source. The rest of the entries should be wildcards that should be considered equivalent to the first directory. This will be easier if the reporting machine has a consistent path for accessing the source, something like this:
[paths]
source =
/auto/pso/jenkins-slaves-data/shared-workspace/src/packagep1
/auto/pso/jenkins-slaves-data/shared-workspace/*/packagep1
Any news on this problem?