Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: only test enabled python bindings #21293

Merged
merged 3 commits into from Apr 13, 2018

Conversation

tchaikov
Copy link
Contributor

@tchaikov tchaikov commented Apr 9, 2018

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.

@rjfd
Copy link
Contributor

rjfd commented Apr 9, 2018

@tchaikov make check failed but it doesn't look like it's because of the changes in this PR.

@tchaikov
Copy link
Contributor Author

tchaikov commented Apr 9, 2018

retest this please.

@tchaikov tchaikov force-pushed the wip-no-venv-for-dashboard branch 4 times, most recently from f8a337d to f28a096 Compare April 9, 2018 10:14
@tchaikov tchaikov requested review from smithfarm and removed request for rjfd April 9, 2018 11:58
@tchaikov tchaikov changed the title cmake: no need to setup venv for dashboard test: only test enabled python bindings Apr 9, 2018
@tchaikov tchaikov added tests and removed build/ops labels Apr 9, 2018
fi
ENV_LIST+="cov-report,lint"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, the change here is that when WITH_PYTHON2=ON and WITH_PYTHON3=OFF, py3 is not included in ENV_LIST

That seems reasonable to me

Copy link
Contributor Author

@tchaikov tchaikov Apr 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, the change is to get the test pass, even if WITH_PYTHON2=OFF and WITH_PYTHON3=ON.

Copy link
Contributor

@sebastian-philipp sebastian-philipp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks sane to me. But haven't tested the code.

@@ -17,11 +17,14 @@ fi

source ${MGR_DASHBOARD_VIRTUALENV}/bin/activate

ENV_LIST="cov-init,"
if [ "$WITH_PYTHON2" = "ON" ]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we declared a default value for WITH_PYTHON2 in the beginning of the script (as we do with WITH_PYTHON3) so that the script runs well outside ctest.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rjfd fixed and repushed.

@rjfd
Copy link
Contributor

rjfd commented Apr 11, 2018

@tchaikov I tested this PR in my environment where I have WITH_PYTHON2=OFF and there is still one small thing we need to fix. The "lint" env is running always in python 2 and fails because I don't have the rbd and rados python bindings built for python 2. I created this patch that solves this issue:

diff --git a/src/pybind/mgr/dashboard/run-tox.sh b/src/pybind/mgr/dashboard/run-tox.sh
index 564c75b308..fe11683245 100755
--- a/src/pybind/mgr/dashboard/run-tox.sh
+++ b/src/pybind/mgr/dashboard/run-tox.sh
@@ -25,7 +25,13 @@ fi
 if [ "$WITH_PYTHON3" = "ON" ]; then
   ENV_LIST+="py3,"
 fi
-ENV_LIST+="cov-report,lint"
+ENV_LIST+="cov-report,"
+if [ "$WITH_PYTHON2" = "ON" ]; then
+  ENV_LIST+="lint2"
+fi
+if [ "$WITH_PYTHON3" = "ON" ]; then
+  ENV_LIST+="lint3"
+fi
 
 tox -c ${TOX_PATH} -e $ENV_LIST
 
diff --git a/src/pybind/mgr/dashboard/tox.ini b/src/pybind/mgr/dashboard/tox.ini
index 743a8a6929..9b07e15e8e 100644
--- a/src/pybind/mgr/dashboard/tox.ini
+++ b/src/pybind/mgr/dashboard/tox.ini
@@ -1,5 +1,5 @@
 [tox]
-envlist = cov-init,py27,py3,cov-report,lint
+envlist = cov-init,py27,py3,cov-report,lint2,lint3
 skipsdist = true
 
 [testenv]
@@ -30,9 +30,20 @@ commands =
     coverage report
     coverage xml
 
-[testenv:lint]
+[testenv:lint2]
+basepython=python2
 setenv =
-    PYTHONPATH = {toxinidir}/../../../../build/lib/cython_modules/lib.3:{toxinidir}/../../../../build/lib/cython_modules/lib.2
+    PYTHONPATH = {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 --ignore=E402,E121,E123,E126,E226,E24,E704,W503 .
+
+[testenv:lint3]
+basepython=python3
+setenv =
+    PYTHONPATH = {toxinidir}/../../../../build/lib/cython_modules/lib.3
     LD_LIBRARY_PATH = {toxinidir}/../../../../build/lib
 deps=-r{toxinidir}/requirements.txt
 commands=

Can you apply it to this PR?

@tchaikov tchaikov force-pushed the wip-no-venv-for-dashboard branch 2 times, most recently from 9635f30 to 473eacb Compare April 11, 2018 11:13
@tchaikov
Copy link
Contributor Author

@rjfd i restructured the tox.ini to dedup the settings. could you take another look? thanks!

deps=-r{toxinidir}/requirements.txt
basepython =
py27: python2.7
py3: python3
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some unknown reason, the virtual environments are being created outside of .tox directory, please add this additional line to fix it:
envdir = {toxinidir}/.tox/{envname}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rjfd it's on purpose. i wanted to avoid creating the venvs in the source directory. see https://github.com/ceph/ceph/pull/21293/files#diff-cc2ee9d8e56f3a2cd98b8148935d3829R28. why do you think we should put them into .tox?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. I usually run run-tox.sh manually in the source directory and I was getting unstaged changes in my repo because of those directories. I was suggesting to move them into .tox directory because .tox is in the .gitignore.

Instead of creating them inside .tox, we can add the virtualenv directories to the .gitignore?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rjfd hmm, how about this:

  • add a default value for CEPH_BUILD_DIR in run-tox.sh to point it to $PWD/.tox

?

anyway, IMHO, ctest is a more handy way to run tests.

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=python2.7,.tox,venv,frontend --ignore=E402,E121,E123,E126,E226,E24,E704,W503 .
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can remove the python2.7 from the exclude filter.

@tchaikov
Copy link
Contributor Author

tchaikov commented Apr 11, 2018

changelog

  • dropped basepython setting from testenv. because tox set it automatically.
  • dropped python2.7 from --exclude

@rjfd fixed and repushed.

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>
unlike ceph-disk and ceph-detect-init, dashboard is not a standalone
python application, it is a python application hosted by ceph-mgr,
so no need to create a venv in which it is deployed. the python env
created by tox would suffice.

Signed-off-by: Kefu Chai <kchai@redhat.com>
@tchaikov
Copy link
Contributor Author

changelog

  • add default value of CEPH_BUILD_DIR
  • add the commit to drop MGR_DASHBOARD_VIRTUALENV for testing dashboard

Copy link
Contributor

@rjfd rjfd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

this silences following errors:

9: ./awsauth.py:42:1: E722 do not use bare except'
9: ./awsauth.py:116:13: E722 do not use bare except'

Signed-off-by: Kefu Chai <kchai@redhat.com>
@tchaikov tchaikov merged commit d02710d into ceph:master Apr 13, 2018
@tchaikov tchaikov deleted the wip-no-venv-for-dashboard branch April 13, 2018 09:45
@votdev
Copy link
Member

votdev commented Apr 13, 2018

This PR causes a make check problem, see http://tracker.ceph.com/issues/23709.

@tchaikov
Copy link
Contributor Author

#21416 should address this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants