]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test/dashboard: only test enabled python bindings
authorKefu Chai <kchai@redhat.com>
Wed, 11 Apr 2018 09:46:26 +0000 (17:46 +0800)
committerKefu Chai <kchai@redhat.com>
Wed, 11 Apr 2018 14:25:12 +0000 (22:25 +0800)
we should test the python version of MGR_PYTHON_VERSION_MAJOR, if we are
testing both py2.7 and py3, we are preparing for distributing dashboard
as a separated package independent of ceph-mgr.

restructure the dashboard tests as 2 matrices, so we have 2*2 tests for
coverage and lint respectively.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/pybind/mgr/dashboard/run-tox.sh
src/pybind/mgr/dashboard/tox.ini
src/test/CMakeLists.txt

index 5f24bb698d105acd5678d14f8fecb917a922ce44..835382560d059f405c6dde34619dc52a03b4901f 100755 (executable)
@@ -2,7 +2,9 @@
 
 # run from ./ or from ../
 : ${MGR_DASHBOARD_VIRTUALENV:=/tmp/mgr-dashboard-virtualenv}
+: ${WITH_PYTHON2:=ON}
 : ${WITH_PYTHON3:=ON}
+: ${CEPH_BUILD_DIR:=$PWD/.tox}
 test -d dashboard && cd dashboard
 
 if [ -e tox.ini ]; then
@@ -17,11 +19,11 @@ fi
 
 source ${MGR_DASHBOARD_VIRTUALENV}/bin/activate
 
+if [ "$WITH_PYTHON2" = "ON" ]; then
+  ENV_LIST+="py27-cov,py27-lint,"
+fi
 if [ "$WITH_PYTHON3" = "ON" ]; then
-  ENV_LIST="cov-init,py27,py3,cov-report,lint"
-else
-  ENV_LIST="cov-init,py27,cov-report,lint"
+  ENV_LIST+="py3-cov,py3-lint"
 fi
 
-tox -c ${TOX_PATH} -e $ENV_LIST
-
+tox -c ${TOX_PATH} -e $ENV_LIST --workdir ${CEPH_BUILD_DIR}
index c8b01091735fe8ee4d370e58ee96edffe82820b8..a5cce362c66a4b61a14fbf275d616ee75c37dc54 100644 (file)
@@ -1,40 +1,24 @@
 [tox]
-envlist = cov-init,py27,py3,cov-report,lint
+envlist = {py27,py3}-cov,{py27,py3}-lint
 skipsdist = true
 
 [testenv]
-deps=-r{toxinidir}/requirements.txt
+deps =
+    -r{toxinidir}/requirements.txt
 setenv=
-    UNITTEST=true
-    WEBTEST_INTERACTIVE=false
-    COVERAGE_FILE= .coverage.{envname}
-    PYTHONPATH = {toxinidir}/../../../../build/lib/cython_modules/lib.3:{toxinidir}/../../../../build/lib/cython_modules/lib.2
+    UNITTEST = true
+    WEBTEST_INTERACTIVE = false
     LD_LIBRARY_PATH = {toxinidir}/../../../../build/lib
     PATH = {toxinidir}/../../../../build/bin:$PATH
+    py27: PYTHONPATH = {toxinidir}/../../../../build/lib/cython_modules/lib.2
+    py3:  PYTHONPATH = {toxinidir}/../../../../build/lib/cython_modules/lib.3
+    cov:  UNITTEST = true
+    cov:  COVERAGE_FILE = .coverage.{envname}
 commands=
-    {envbindir}/py.test --cov=. --cov-report= --junitxml=junit.{envname}.xml --doctest-modules controllers/rbd.py services/ tools.py tests/
-
-[testenv:cov-init]
-setenv =
-    COVERAGE_FILE = .coverage
-deps = coverage
-commands =
-    coverage erase
-
-[testenv:cov-report]
-setenv =
-    COVERAGE_FILE = .coverage
-deps = coverage
-commands =
-    coverage combine
-    coverage report
-    coverage xml
-
-[testenv:lint]
-setenv =
-    PYTHONPATH = {toxinidir}/../../../../build/lib/cython_modules/lib.3:{toxinidir}/../../../../build/lib/cython_modules/lib.2
-    LD_LIBRARY_PATH = {toxinidir}/../../../../build/lib
-deps=-r{toxinidir}/requirements.txt
-commands=
-    pylint --rcfile=.pylintrc --jobs=5 . module.py tools.py controllers tests services
-    pycodestyle --max-line-length=100 --exclude=python2.7,.tox,venv,frontend,awsauth.py --ignore=E402,E121,E123,E126,E226,E24,E704,W503 .
+    cov: coverage erase
+    cov: {envbindir}/py.test --cov=. --cov-report= --junitxml=junit.{envname}.xml --doctest-modules controllers/rbd.py services/ tests/ tools.py
+    cov: coverage combine {toxinidir}/{env:COVERAGE_FILE}
+    cov: coverage report
+    cov: coverage xml
+    lint: pylint --rcfile=.pylintrc --jobs=5 . module.py tools.py controllers tests services
+    lint: pycodestyle --max-line-length=100 --exclude=.tox,venv,frontend --ignore=E402,E121,E123,E126,E226,E24,E704,W503 .
index eb3d82b98777337e8e11cb7939baed3b0777e043..19643b598e4d0ea80d73203c9d6271230c300f9a 100644 (file)
@@ -604,6 +604,7 @@ set_property(TEST
   LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib
   PATH=$ENV{PATH}:${CMAKE_RUNTIME_OUTPUT_DIRECTORY}:${CMAKE_SOURCE_DIR}/src
   PYTHONPATH=${CMAKE_SOURCE_DIR}/src/pybind
+  WITH_PYTHON2=${WITH_PYTHON2}
   WITH_PYTHON3=${WITH_PYTHON3}
   )