5 if [[ "$1" = "-h" ||
"$1" = "--help" ]]; then
6 echo "Usage (run from ./):"
7 echo -e "\t./run-backend-api-tests.sh"
8 echo -e "\t./run-backend-api-tests.sh [tests]..."
11 echo -e "\t./run-backend-api-tests.sh tasks.mgr.dashboard.test_pool.DashboardTest"
13 echo "Or source this script. This allows to re-run tests faster:"
14 echo -e "\tsource run-backend-api-tests.sh"
15 echo -e "\trun_teuthology_tests [tests]..."
16 echo -e "\tcleanup_teuthology"
22 get_cmake_variable
() {
24 grep "$variable" CMakeCache.txt | cut
-d "=" -f 2
27 get_build_py_version
() {
29 BUILD_DIR
="$CURR_DIR/../../../../build"
32 CEPH_MGR_PY_VERSION_MAJOR
=$
(get_cmake_variable MGR_PYTHON_VERSION | cut
-d '.' -f1)
33 if [ -n "$CEPH_MGR_PY_VERSION_MAJOR" ]; then
34 CEPH_PY_VERSION_MAJOR
=${CEPH_MGR_PY_VERSION_MAJOR}
36 if [ $
(get_cmake_variable WITH_PYTHON2
) = ON
]; then
37 CEPH_PY_VERSION_MAJOR
=2
39 CEPH_PY_VERSION_MAJOR
=3
47 apache-libcloud==2.2.1
49 backports.ssl-match-hostname==3.5.0.1
74 python-dateutil==2.6.1
82 virtualenv
--python=${TEUTHOLOGY_PYTHON_BIN:-/usr/bin/python} venv
83 source venv
/bin
/activate
84 pip
install 'setuptools >= 12'
85 eval pip
install $TEUTHOLOGY_PY_REQS
86 pip
install -r $CURR_DIR/requirements.txt
88 git clone
--depth 1 https
://github.com
/ceph
/teuthology.git
94 # In CI environment we cannot install coverage in system, so we install it in a dedicated venv
95 # so only coverage is available when adding this path.
97 virtualenv
--python=${TEUTHOLOGY_PYTHON_BIN:-/usr/bin/python} coverage-venv
98 source coverage-venv
/bin
/activate
100 pip
install coverage
==4.5.2
101 COVERAGE_PATH
=$
(python
-c "import sysconfig; print(sysconfig.get_paths()['purelib'])")
106 if [[ -n "$JENKINS_HOME" ]]; then
107 CEPH_OUT_DIR
=${CEPH_OUT_DIR:-"$BUILD_DIR"/out}
108 MGR_LOG_FILES
=$
(find "$CEPH_OUT_DIR" -iname "mgr.*.log" |
tr '\n' ' ')
109 MGR_LOG_FILE_LAST_LINES
=60000
110 for mgr_log_file
in ${MGR_LOG_FILES[@]}; do
111 printf "\n\nDisplaying last ${MGR_LOG_FILE_LAST_LINES} lines of: $mgr_log_file\n\n"
112 tail -n ${MGR_LOG_FILE_LAST_LINES} $mgr_log_file
113 printf "\n\nEnd of: $mgr_log_file\n\n"
115 printf "\n\nTEST FAILED.\n\n"
119 run_teuthology_tests
() {
120 trap on_tests_error ERR
123 find ..
/src
/pybind
/mgr
/dashboard
/ -name '*.pyc' -exec rm -f {} \
;
127 if [[ "$@" == '' ||
"$@" == '--create-cluster-only' ]]; then
128 TEST_CASES
=`for i in \`ls $BUILD_DIR/..
/qa
/tasks
/mgr
/dashboard
/test_
*\
`; do F=$(basename $i); M="${F%.*}"; echo -n " tasks.mgr.dashboard.$M"; done`
129 # Mgr selftest module tests have to be run at the end as they stress the mgr daemon.
130 TEST_CASES
="tasks.mgr.test_dashboard $TEST_CASES tasks.mgr.test_module_selftest"
131 if [[ "$@" == '--create-cluster-only' ]]; then
136 TEST_CASES
="$TEST_CASES $t"
140 export PATH
=$BUILD_DIR/bin
:$PATH
141 source $TEMP_DIR/venv
/bin
/activate
# Run after setting PATH as it does the last PATH export.
142 export LD_LIBRARY_PATH
=$BUILD_DIR/lib
/cython_modules
/lib.
${CEPH_PY_VERSION_MAJOR}/:$BUILD_DIR/lib
143 local source_dir
=$
(dirname "$BUILD_DIR")
144 local pybind_dir
=$source_dir/src
/pybind
145 local python_common_dir
=$source_dir/src
/python-common
146 # In CI environment we set python paths inside build (where you find the required frontend build: "dist" dir).
147 if [[ -n "$JENKINS_HOME" ]]; then
148 export PYBIND
=$BUILD_DIR/src
/pybind
151 export PYTHONPATH
=$TEMP_DIR/teuthology
:$source_dir/qa
:$BUILD_DIR/lib
/cython_modules
/lib.
${CEPH_PY_VERSION_MAJOR}/:$pybind_dir:$python_common_dir:${COVERAGE_PATH}
154 export COVERAGE_ENABLED
=true
155 export COVERAGE_FILE
=.coverage.mgr.dashboard
156 find .
-iname "*${COVERAGE_FILE}*" -type f
-delete
158 python ..
/qa
/tasks
/vstart_runner.py
--ignore-missing-binaries $OPTIONS $TEST_CASES
164 cleanup_teuthology
() {
168 if [[ "$COVERAGE_ENABLED" == 'true' ]]; then
169 source $TEMP_DIR/coverage-venv
/bin
/activate
170 (coverage combine
&& coverage report
) || true
183 unset get_build_py_version
184 unset setup_teuthology
187 unset run_teuthology_tests
188 unset cleanup_teuthology
194 run_teuthology_tests
--create-cluster-only
196 # End sourced section. Do not exit shell when the script has been sourced.
198 return 2>/dev
/null ||
set -eo pipefail
200 run_teuthology_tests
"$@"