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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 0 additions & 10 deletions src/pybind/mgr/dashboard/CMakeLists.txt
@@ -1,13 +1,3 @@
set(MGR_DASHBOARD_VIRTUALENV ${CEPH_BUILD_VIRTUALENV}/mgr-dashboard-virtualenv)

add_custom_target(mgr-dashboard-test-venv
COMMAND
${CMAKE_SOURCE_DIR}/src/tools/setup-virtualenv.sh --python=python2.7 ${MGR_DASHBOARD_VIRTUALENV} &&
${MGR_DASHBOARD_VIRTUALENV}/bin/pip install --no-index --find-links=file:${CMAKE_SOURCE_DIR}/src/pybind/mgr/dashboard/wheelhouse -r requirements.txt
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/src/pybind/mgr/dashboard
COMMENT "dashboard tests virtualenv is being created")
add_dependencies(tests mgr-dashboard-test-venv)

if(WITH_MGR_DASHBOARD_FRONTEND AND NOT CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|AARCH64|arm|ARM")

set(mgr-dashboard-nodeenv ${CMAKE_CURRENT_BINARY_DIR}/node-env)
Expand Down
4 changes: 2 additions & 2 deletions src/pybind/mgr/dashboard/awsauth.py
Expand Up @@ -39,7 +39,7 @@
try:
from urlparse import urlparse, unquote
from base64 import encodestring
except:
except ImportError:
py3k = True
from urllib.parse import urlparse, unquote
from base64 import encodebytes as encodestring
Expand Down Expand Up @@ -113,7 +113,7 @@ def get_canonical_string(self, url, headers, method):
lk = key.lower()
try:
lk = lk.decode('utf-8')
except:
except UnicodeDecodeError:
pass
if headers[key] and (lk in interesting_headers.keys()
or lk.startswith('x-amz-')):
Expand Down
14 changes: 7 additions & 7 deletions src/pybind/mgr/dashboard/run-tox.sh
Expand Up @@ -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
Expand All @@ -15,13 +17,11 @@ if [ -z $CEPH_BUILD_DIR ]; then
export CEPH_BUILD_DIR=$(dirname ${TOX_PATH})
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}
48 changes: 16 additions & 32 deletions src/pybind/mgr/dashboard/tox.ini
@@ -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 .
5 changes: 1 addition & 4 deletions src/test/CMakeLists.txt
Expand Up @@ -584,9 +584,6 @@ endif(WITH_MGR)

set(CEPH_DISK_VIRTUALENV ${CEPH_BUILD_VIRTUALENV}/ceph-disk-virtualenv)
set(CEPH_DETECT_INIT_VIRTUALENV ${CEPH_BUILD_VIRTUALENV}/ceph-detect-init-virtualenv)
if(WITH_MGR)
set(MGR_DASHBOARD_VIRTUALENV ${CEPH_BUILD_VIRTUALENV}/mgr-dashboard-virtualenv)
endif(WITH_MGR)

set_property(TEST
run-tox-ceph-disk
Expand All @@ -600,10 +597,10 @@ set_property(TEST
CEPH_BUILD_VIRTUALENV=${CEPH_BUILD_VIRTUALENV}
CEPH_DISK_VIRTUALENV=${CEPH_DISK_VIRTUALENV}
CEPH_DETECT_INIT_VIRTUALENV=${CEPH_DETECT_INIT_VIRTUALENV}
MGR_DASHBOARD_VIRTUALENV=${MGR_DASHBOARD_VIRTUALENV}
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}
)

Expand Down