mirror of
https://github.com/ceph/ceph
synced 2025-02-23 02:57:21 +00:00
cmake: use script/run_tox.sh for running tox for dashboard
* adapt script/run_tox.sh to use different envs for dashboard's tox test. * use script/run_tox.sh for running dashboard's tox test * remove pybind/mgr/dashboard/run-tox.sh Signed-off-by: Kefu Chai <kchai@redhat.com>
This commit is contained in:
parent
d359227ec0
commit
f0079a1030
@ -1,12 +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=${MGR_PYTHON_EXECUTABLE} ${MGR_DASHBOARD_VIRTUALENV}
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/src/pybind/mgr/dashboard
|
||||
COMMENT "dashboard tests virtualenv is being created")
|
||||
add_dependencies(tests mgr-dashboard-test-venv)
|
||||
|
||||
include(CMakeParseArguments)
|
||||
function(add_npm_command)
|
||||
set(options NODEENV)
|
||||
|
@ -1,51 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
function dump_envvars {
|
||||
echo "WITH_PYTHON2: ->$WITH_PYTHON2<-"
|
||||
echo "WITH_PYTHON3: ->$WITH_PYTHON3<-"
|
||||
echo "TOX_PATH: ->$TOX_PATH<-"
|
||||
echo "ENV_LIST: ->$ENV_LIST<-"
|
||||
}
|
||||
|
||||
# run from ./ or from ../
|
||||
: ${CEPH_BUILD_DIR:=$PWD/.tox}
|
||||
: ${MGR_DASHBOARD_VIRTUALENV:=$CEPH_BUILD_DIR/mgr-dashboard-virtualenv}
|
||||
: ${WITH_PYTHON2:=ON}
|
||||
: ${WITH_PYTHON3:=3}
|
||||
test -d dashboard && cd dashboard
|
||||
|
||||
if [ -e tox.ini ]; then
|
||||
TOX_PATH=$(readlink -f tox.ini)
|
||||
else
|
||||
TOX_PATH=$(readlink -f $(dirname $0)/tox.ini)
|
||||
fi
|
||||
|
||||
# tox.ini will take care of this.
|
||||
unset PYTHONPATH
|
||||
export CEPH_BUILD_DIR=$CEPH_BUILD_DIR
|
||||
|
||||
source ${MGR_DASHBOARD_VIRTUALENV}/bin/activate
|
||||
|
||||
if [ "$WITH_PYTHON2" = "ON" ]; then
|
||||
if [[ -n "$@" ]]; then
|
||||
ENV_LIST+="py27-run,"
|
||||
else
|
||||
ENV_LIST+="py27-cov,py27-lint,py27-check,"
|
||||
fi
|
||||
fi
|
||||
# WITH_PYTHON3 might be set to "ON" or to the python3 RPM version number
|
||||
# prevailing on the system - e.g. "3", "36"
|
||||
if [[ "$WITH_PYTHON3" =~ (^3|^ON) ]]; then
|
||||
if [[ -n "$@" ]]; then
|
||||
ENV_LIST+="py3-run,"
|
||||
else
|
||||
ENV_LIST+="py3-cov,py3-lint,py3-check,"
|
||||
fi
|
||||
fi
|
||||
# use bash string manipulation to strip off any trailing comma
|
||||
ENV_LIST=${ENV_LIST%,}
|
||||
|
||||
tox -c "${TOX_PATH}" -e "${ENV_LIST}" "$@"
|
||||
TOX_STATUS="$?"
|
||||
test "$TOX_STATUS" -ne "0" && dump_envvars
|
||||
exit $TOX_STATUS
|
@ -28,6 +28,46 @@ function get_tox_path() {
|
||||
fi
|
||||
}
|
||||
|
||||
function get_env_list_for_dashboard() {
|
||||
local with_python2=$1
|
||||
shift
|
||||
local with_python3=$1
|
||||
shift
|
||||
local env_list
|
||||
if $with_python2; then
|
||||
if [ $# -gt 0 ]; then
|
||||
env_list+="py27-run,"
|
||||
else
|
||||
env_list+="py27-cov,py27-lint,py27-check,"
|
||||
fi
|
||||
fi
|
||||
if $with_python3; then
|
||||
if [ $# -gt 0 ]; then
|
||||
env_list+="py3-run,"
|
||||
else
|
||||
env_list+="py3-cov,py3-lint,py3-check,"
|
||||
fi
|
||||
fi
|
||||
# use bash string manipulation to strip off any trailing comma
|
||||
echo "${env_list%,}"
|
||||
}
|
||||
|
||||
function get_env_list() {
|
||||
local with_python2=$1
|
||||
shift
|
||||
local with_python3=$1
|
||||
shift
|
||||
local env_list
|
||||
if $with_python2; then
|
||||
env_list+="py27,"
|
||||
fi
|
||||
if $with_python3; then
|
||||
env_list+="py3,"
|
||||
fi
|
||||
# use bash string manipulation to strip off any trailing comma
|
||||
echo "${env_list%,}"
|
||||
}
|
||||
|
||||
function main() {
|
||||
local tox_path
|
||||
local script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
@ -71,15 +111,23 @@ function main() {
|
||||
esac
|
||||
done
|
||||
|
||||
# normalize options
|
||||
[ "$with_python2" = "ON" ] && with_python2=true || with_python2=false
|
||||
# WITH_PYTHON3 might be set to "ON" or to the python3 RPM version number
|
||||
# prevailing on the system - e.g. "3", "36"
|
||||
[[ "$with_python3" =~ (^3|^ON) ]] && with_python3=true || with_python3=false
|
||||
|
||||
local test_name
|
||||
if [ -z "$tox_path" ]; then
|
||||
# try harder
|
||||
local test_name
|
||||
if [ $# -gt 0 ]; then
|
||||
test_name=$1
|
||||
shift
|
||||
fi
|
||||
tox_path=$(get_tox_path $test_name)
|
||||
venv_path="$build_dir/$test_name"
|
||||
else
|
||||
test_name=$(basename $tox_path)
|
||||
fi
|
||||
|
||||
if [ ! -f ${venv_path}/bin/activate ]; then
|
||||
@ -91,17 +139,13 @@ function main() {
|
||||
# tox.ini will take care of this.
|
||||
export CEPH_BUILD_DIR=$build_dir
|
||||
|
||||
if [ "$with_python2" = "ON" ]; then
|
||||
ENV_LIST+="py27,"
|
||||
local env_list
|
||||
if [ $test_name = "dashboard" ]; then
|
||||
env_list=$(get_env_list_for_dashboard $with_python2 $with_python3 "$@")
|
||||
else
|
||||
env_list=$(get_env_list $with_python2 $with_python3)
|
||||
fi
|
||||
# WITH_PYTHON3 might be set to "ON" or to the python3 RPM version number
|
||||
# prevailing on the system - e.g. "3", "36"
|
||||
if [[ "$with_python3" =~ (^3|^ON) ]]; then
|
||||
ENV_LIST+="py3,"
|
||||
fi
|
||||
# use bash string manipulation to strip off any trailing comma
|
||||
ENV_LIST=${ENV_LIST%,}
|
||||
tox -c $tox_path/tox.ini -e "${ENV_LIST}" "$@"
|
||||
tox -c $tox_path/tox.ini -e "$env_list" "$@"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
@ -540,34 +540,15 @@ add_ceph_test(test_objectstore_memstore.sh ${CMAKE_CURRENT_SOURCE_DIR}/test_obje
|
||||
|
||||
add_ceph_test(smoke.sh ${CMAKE_CURRENT_SOURCE_DIR}/smoke.sh)
|
||||
|
||||
# XXX are these safe to remove? they used to be around for ceph-disk tox testing
|
||||
set(env_vars_for_tox_tests
|
||||
CEPH_BUILD_DIR=${CMAKE_BINARY_DIR}
|
||||
CEPH_ROOT=${CMAKE_SOURCE_DIR}
|
||||
CEPH_BIN=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
|
||||
CEPH_LIB=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
|
||||
CEPH_BUILD_VIRTUALENV=${CEPH_BUILD_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})
|
||||
|
||||
if(WITH_MGR)
|
||||
add_test(NAME run-tox-mgr-dashboard COMMAND bash ${CMAKE_SOURCE_DIR}/src/pybind/mgr/dashboard/run-tox.sh)
|
||||
list(APPEND tox_tests run-tox-mgr-dashboard)
|
||||
set(MGR_DASHBOARD_VIRTUALENV ${CEPH_BUILD_VIRTUALENV}/mgr-dashboard-virtualenv)
|
||||
list(APPEND env_vars_for_tox_tests MGR_DASHBOARD_VIRTUALENV=${MGR_DASHBOARD_VIRTUALENV})
|
||||
|
||||
add_tox_test(mgr-dashboard
|
||||
${CMAKE_SOURCE_DIR}/src/pybind/mgr/dashboard)
|
||||
add_tox_test(mgr-insights
|
||||
${CMAKE_SOURCE_DIR}/src/pybind/mgr/insights)
|
||||
|
||||
add_tox_test(mgr-ansible
|
||||
${CMAKE_SOURCE_DIR}/src/pybind/mgr/ansible)
|
||||
|
||||
add_tox_test(mgr-orchestrator_cli
|
||||
${CMAKE_SOURCE_DIR}/src/pybind/mgr/orchestrator_cli)
|
||||
|
||||
add_tox_test(python-common
|
||||
${CMAKE_SOURCE_DIR}/src/python-common)
|
||||
endif()
|
||||
|
Loading…
Reference in New Issue
Block a user