]>
git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/run-backend-api-tests.sh
3 # SHELL_TRACE=true ./run-backend-api-tests.sh to enable debugging
4 [ -v SHELL_TRACE
] && set -x
6 # cross shell: Are we sourced?
7 # Source: https://stackoverflow.com/a/28776166/3185053
8 ([[ -n $ZSH_EVAL_CONTEXT && $ZSH_EVAL_CONTEXT = ~
: file $
]] ||
9 [[ -n $KSH_VERSION && $
( cd "$(dirname -- " $0 ")" &&
10 printf '%s' " ${PWD%/} /" ) $
( basename -- " $0 " ) != " ${.sh.file} " ]] ||
11 [[ -n $BASH_VERSION ]] && ( return 0 2 >/ dev
/ null
)) && sourced
= 1 || sourced
= 0
13 if [ " $sourced " -eq 0 ] ; then
17 if [[ " $1 " = "-h" ||
" $1 " = "--help" ]]; then
18 echo "Usage (run from ./):"
19 echo -e " \t ./run-backend-api-tests.sh"
20 echo -e " \t ./run-backend-api-tests.sh [tests]..."
23 echo -e " \t ./run-backend-api-tests.sh tasks.mgr.dashboard.test_pool.DashboardTest"
25 echo "Or source this script. This allows to re-run tests faster:"
26 echo -e " \t source run-backend-api-tests.sh"
27 echo -e " \t run_teuthology_tests [tests]..."
28 echo -e " \t cleanup_teuthology"
34 get_cmake_variable
() {
36 grep " $variable " CMakeCache.txt | cut
-d "=" -f 2
39 [ -z " $BUILD_DIR " ] && BUILD_DIR
= build
41 LOCAL_BUILD_DIR
= $
( cd " $CURR_DIR /../../../../ $BUILD_DIR " ; pwd )
47 ${TEUTHOLOGY_PYTHON_BIN:-/usr/bin/python3} -m venv venv
48 source venv
/ bin
/ activate
49 pip
install -U pip
'setuptools>=12,<60'
50 pip
install "git+https://github.com/ceph/teuthology@9e4bf63#egg=teuthology[test]"
52 pip
install -r requirements.txt
-c constraints.txt
59 # In CI environment we cannot install coverage in system, so we install it in a dedicated venv
60 # so only coverage is available when adding this path.
62 / usr
/ bin
/ python3
-m venv coverage-venv
63 source coverage-venv
/ bin
/ activate
65 pip
install coverage
== 4.5.2
66 COVERAGE_PATH
= $
( python
-c "import sysconfig; print(sysconfig.get_paths()['platlib'])" )
76 local log_files
= $
( find " $CEPH_OUT_DIR " -iname " ${daemon} .*.log" |
tr ' \n ' ' ' )
77 for log_file
in ${log_files[@]} ; do
78 printf " \n\n Displaying last ${lines} lines of: ${log_file} \n\n "
79 tail -n ${lines} $log_file
80 printf " \n\n End of: ${log_file} \n\n "
82 printf " \n\n TEST FAILED. \n\n "
87 if [[ -n " $JENKINS_HOME " && -z " $ON_TESTS_ERROR_RUN " ]]; then
88 CEPH_OUT_DIR
= ${CEPH_OUT_DIR:-"$LOCAL_BUILD_DIR"/out}
89 display_log
"mgr" 1500
90 display_log
"osd" 1000
96 run_teuthology_tests
() {
97 trap on_tests_error ERR
100 find ..
/ src
/ pybind
/ mgr
/ dashboard
/ -name '*.pyc' -exec rm -f {} \
;
104 if [[ "$@" == '' ||
"$@" == '--create-cluster-only' ]]; then
105 TEST_CASES
= `for i in \` ls $LOCAL_BUILD_DIR / ..
/ qa
/ tasks
/ mgr
/ dashboard
/ test_
* \
`; do F=$(basename $i ); M=" ${F%.*} "; echo -n " tasks.mgr.dashboard. $M "; done`
106 # Mgr selftest module tests have to be run at the end as they stress the mgr daemon.
107 TEST_CASES
= "tasks.mgr.test_dashboard $TEST_CASES tasks.mgr.test_module_selftest"
108 if [[ "$@" == '--create-cluster-only' ]]; then
113 TEST_CASES
= " $TEST_CASES $t "
117 export PATH
= $LOCAL_BUILD_DIR / bin
: $PATH
118 source $TEMP_DIR / venv
/ bin
/ activate
# Run after setting PATH as it does the last PATH export.
119 export LD_LIBRARY_PATH
= $LOCAL_BUILD_DIR / lib
/ cython_modules
/ lib
.3 /: $LOCAL_BUILD_DIR / lib
120 local source_dir
= $
( dirname " $LOCAL_BUILD_DIR " )
121 local pybind_dir
= $source_dir / src
/ pybind
122 local python_common_dir
= $source_dir / src
/ python-common
123 # In CI environment we set python paths inside build (where you find the required frontend build: "dist" dir).
124 if [[ -n " $JENKINS_HOME " ]]; then
125 pybind_dir
+= ": $LOCAL_BUILD_DIR /src/pybind"
127 export PYTHONPATH
= $source_dir / qa
: $LOCAL_BUILD_DIR / lib
/ cython_modules
/ lib
.3 /: $pybind_dir : $python_common_dir : ${COVERAGE_PATH}
128 export DASHBOARD_SSL
= 1
132 export COVERAGE_ENABLED
= true
133 export COVERAGE_FILE
= .coverage.mgr.dashboard
134 export CEPH_OUT_CLIENT_DIR
= ${LOCAL_BUILD_DIR} / out
/ client
135 find .
-iname "* ${COVERAGE_FILE} *" -type f
-delete
137 python ..
/ qa
/ tasks
/ vstart_runner.py
--ignore-missing-binaries --no-verbose $OPTIONS $
( echo $TEST_CASES ) ||
144 cleanup_teuthology
() {
145 cd " $LOCAL_BUILD_DIR "
148 if [[ " $COVERAGE_ENABLED " == 'true' ]]; then
149 source $TEMP_DIR / coverage-venv
/ bin
/ activate
150 ( coverage combine
&& coverage report
) || true
161 unset LOCAL_BUILD_DIR
163 unset setup_teuthology
166 unset run_teuthology_tests
167 unset cleanup_teuthology
170 export LC_ALL
= en_US.UTF-8
174 run_teuthology_tests
--create-cluster-only
176 # End sourced section. Do not exit shell when the script has been sourced.
177 if [ " $sourced " -eq 1 ] ; then
181 run_teuthology_tests
"$@"