Commit c7f620fc authored by Jérome Perrin's avatar Jérome Perrin

stack/erp5: handle coverage reporting from erp5.git

This now supports producing html reports directly
parent 9c6ed6c5
Pipeline #34571 passed with stage
in 0 seconds
...@@ -590,6 +590,12 @@ ...@@ -590,6 +590,12 @@
"examples": [ "examples": [
"https://user:password@example.com/{test_result_id}/{test_name}.coverage.sqlite3" "https://user:password@example.com/{test_result_id}/{test_name}.coverage.sqlite3"
] ]
},
"fail-under": {
"description": "Make the test reporting coverage fail if combined coverage is below this percentage value.",
"type": "number",
"minimum": 0,
"maximum": 100
} }
} }
}, },
......
...@@ -73,7 +73,6 @@ parts += ...@@ -73,7 +73,6 @@ parts +=
slapos-cookbook slapos-cookbook
mroonga-mariadb mroonga-mariadb
tesseract tesseract
.coveragerc
# Buildoutish # Buildoutish
eggs-all-scripts eggs-all-scripts
...@@ -432,52 +431,15 @@ initialization = ...@@ -432,52 +431,15 @@ initialization =
if coverage_process: if coverage_process:
coverage_process.stop() coverage_process.stop()
coverage_process.save() coverage_process.save()
# upload the coverage so that they can be combined from another machine # upload the coverage so that they can be combined
upload_url = test_runner_configuration['coverage'].get('upload-url') upload_url = test_runner_configuration['coverage'].get('upload-url')
if upload_url: if upload_url:
import requests import Products.ERP5Type.tests.coverage_report
import time Products.ERP5Type.tests.coverage_report.upload(
import uritemplate coverage_data_file,
from six.moves.urllib.parse import urlparse upload_url,
test_name)
auth_list = (None, )
parsed_url = urlparse(upload_url)
if parsed_url.username:
# try Digest and Basic authentication and retry 5 times to tolerate transiant errors
auth_list = (
requests.auth.HTTPDigestAuth(parsed_url.username, parsed_url.password),
requests.auth.HTTPBasicAuth(parsed_url.username, parsed_url.password),
) * 5
url = uritemplate.URITemplate(upload_url).expand(
test_name=test_name,
# Environment variables are set in parts/erp5/product/ERP5Type/tests/runTestSuite.py
test_result_id=os.environ.get('ERP5_TEST_RESULT_ID', 'unknown_test_result_id'),
test_result_revision=os.environ.get('ERP5_TEST_RESULT_REVISION', 'unknown_test_result_revision'),
)
for auth in auth_list:
with open(coverage_data_file, 'rb') as f:
resp = requests.put(url, data=f, auth=auth)
if resp.ok:
# print just the hostname, not to include the auth part
print('Uploaded coverage data to {parsed_url.hostname}'.format(parsed_url=parsed_url))
break
print('Error {resp.status_code} uploading coverage data to {parsed_url.hostname} with {auth.__class__.__name__}'.format(
resp=resp, parsed_url=parsed_url, auth=auth))
time.sleep(1)
else:
sys.stderr.write('Error uploading coverage data to {parsed_url.hostname}\n'.format(parsed_url=parsed_url))
[.coveragerc]
recipe = slapos.recipe.template
output = ${buildout:directory}/${:_buildout_section_name_}
inline =
# coverage configuration file, useful when making html report
[run]
plugins =
erp5_coverage_plugin
relative_files = true
[test-suite-runner] [test-suite-runner]
# XXX: Workaround for fact ERP5Type is not an distribution and does not # XXX: Workaround for fact ERP5Type is not an distribution and does not
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment