summaryrefslogtreecommitdiffstats
path: root/src/pybind
diff options
context:
space:
mode:
authoralfonsomthd <almartin@redhat.com>2019-03-08 17:35:34 +0100
committeralfonsomthd <almartin@redhat.com>2019-03-08 17:35:34 +0100
commitda52919f69e332b3f25fff1d22ffdf83f7a62420 (patch)
treeff918415f93ce582bad0d9a713f8b129e84922f8 /src/pybind
parentMerge PR #26823 into master (diff)
downloadceph-da52919f69e332b3f25fff1d22ffdf83f7a62420.tar.xz
ceph-da52919f69e332b3f25fff1d22ffdf83f7a62420.zip
mgr/dashboard: enable coverage for API tests
* Fixed: install in system the 'coverage' version set in requirements.txt as dashboard/module.py uses system version. * Updated 'coverage' to latest stable version. * Added teuthology missing dependency: backports.ssl-match-hostname * More precise coverage measurement through CherryPy Bus API. * Coverage report shown when no ceph-mgr running (cleanup_teuthology). Fixes: https://tracker.ceph.com/issues/36176 Signed-off-by: Alfonso Martínez <almartin@redhat.com>
Diffstat (limited to '')
-rw-r--r--src/pybind/mgr/dashboard/module.py14
-rw-r--r--src/pybind/mgr/dashboard/requirements.txt2
-rwxr-xr-xsrc/pybind/mgr/dashboard/run-backend-api-tests.sh20
3 files changed, 24 insertions, 12 deletions
diff --git a/src/pybind/mgr/dashboard/module.py b/src/pybind/mgr/dashboard/module.py
index 9a6f3748324..6be074d2a49 100644
--- a/src/pybind/mgr/dashboard/module.py
+++ b/src/pybind/mgr/dashboard/module.py
@@ -63,8 +63,12 @@ if cherrypy is not None:
if 'COVERAGE_ENABLED' in os.environ:
import coverage
- _cov = coverage.Coverage(config_file="{}/.coveragerc".format(os.path.dirname(__file__)))
- _cov.start()
+ __cov = coverage.Coverage(config_file="{}/.coveragerc".format(os.path.dirname(__file__)),
+ data_suffix=True)
+
+ cherrypy.engine.subscribe('start', __cov.start)
+ cherrypy.engine.subscribe('after_request', __cov.save)
+ cherrypy.engine.subscribe('stop', __cov.stop)
# pylint: disable=wrong-import-position
from . import logger, mgr
@@ -305,9 +309,6 @@ class Module(MgrModule, CherryPyConfig):
return os.path.join(current_dir, 'frontend/dist')
def serve(self):
- if 'COVERAGE_ENABLED' in os.environ:
- _cov.start()
-
AuthManager.initialize()
load_sso_db()
@@ -346,9 +347,6 @@ class Module(MgrModule, CherryPyConfig):
self.shutdown_event.clear()
NotificationQueue.stop()
cherrypy.engine.stop()
- if 'COVERAGE_ENABLED' in os.environ:
- _cov.stop()
- _cov.save()
logger.info('Engine stopped')
def shutdown(self):
diff --git a/src/pybind/mgr/dashboard/requirements.txt b/src/pybind/mgr/dashboard/requirements.txt
index 3bc95178126..caa1db80e96 100644
--- a/src/pybind/mgr/dashboard/requirements.txt
+++ b/src/pybind/mgr/dashboard/requirements.txt
@@ -4,7 +4,7 @@ bcrypt==3.1.4
cheroot==6.0.0
CherryPy==13.1.0
configparser==3.5.0
-coverage==4.4.2
+coverage==4.5.2
enum34==1.1.6
funcsigs==1.0.2
isort==4.2.15
diff --git a/src/pybind/mgr/dashboard/run-backend-api-tests.sh b/src/pybind/mgr/dashboard/run-backend-api-tests.sh
index 630adac9e0a..9a3a47fe763 100755
--- a/src/pybind/mgr/dashboard/run-backend-api-tests.sh
+++ b/src/pybind/mgr/dashboard/run-backend-api-tests.sh
@@ -33,6 +33,7 @@ setup_teuthology() {
read -r -d '' TEUTHOLOGY_PY_REQS <<EOF
apache-libcloud==2.2.1 \
asn1crypto==0.22.0 \
+backports.ssl-match-hostname==3.5.0.1 \
bcrypt==3.1.4 \
certifi==2018.1.18 \
cffi==1.10.0 \
@@ -89,10 +90,14 @@ EOF
fi
fi
-# export COVERAGE_ENABLED=true
-# export COVERAGE_FILE=.coverage.mgr.dashboard
-
cd $CURR_DIR
+
+ COVERAGE_VERSION=$(cat requirements.txt | grep coverage)
+ if [[ "$CEPH_MGR_PY_VERSION_MAJOR" == '3' ]]; then
+ pip3 install "$COVERAGE_VERSION"
+ else
+ pip install "$COVERAGE_VERSION"
+ fi
}
run_teuthology_tests() {
@@ -121,6 +126,10 @@ run_teuthology_tests() {
export RGW=1
fi
+ export COVERAGE_ENABLED=true
+ export COVERAGE_FILE=.coverage.mgr.dashboard
+ find . -iname "*${COVERAGE_FILE}*" -type f -delete
+
eval python ../qa/tasks/vstart_runner.py $OPTIONS $TEST_CASES
deactivate
@@ -131,6 +140,11 @@ cleanup_teuthology() {
cd "$BUILD_DIR"
killall ceph-mgr
sleep 10
+ if [[ "$COVERAGE_ENABLED" == 'true' ]]; then
+ source $TEMP_DIR/venv/bin/activate
+ (coverage combine && coverage report) || true
+ deactivate
+ fi
../src/stop.sh
sleep 5