]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/run-backend-api-tests.sh
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / pybind / mgr / dashboard / run-backend-api-tests.sh
1 #!/usr/bin/env bash
2
3 if [[ "$1" = "-h" || "$1" = "--help" ]]; then
4 echo "Usage (run from ./):"
5 echo -e "\t./run-backend-api-tests.sh"
6 echo -e "\t./run-backend-api-tests.sh [tests]..."
7 echo
8 echo "Example:"
9 echo -e "\t./run-backend-api-tests.sh tasks.mgr.dashboard.test_pool.DashboardTest"
10 echo
11 echo "Or source this script. This allows to re-run tests faster:"
12 echo -e "\tsource run-backend-api-tests.sh"
13 echo -e "\trun_teuthology_tests [tests]..."
14 echo -e "\tcleanup_teuthology"
15 echo
16
17 exit 0
18 fi
19
20 # creating temp directory to store virtualenv and teuthology
21
22 get_cmake_variable() {
23 local variable=$1
24 grep "$variable" CMakeCache.txt | cut -d "=" -f 2
25 }
26
27 setup_teuthology() {
28 TEMP_DIR=`mktemp -d`
29
30 CURR_DIR=`pwd`
31 BUILD_DIR="$CURR_DIR/../../../../build"
32
33 read -r -d '' TEUTHOLOGY_PY_REQS <<EOF
34 apache-libcloud==2.2.1 \
35 asn1crypto==0.22.0 \
36 backports.ssl-match-hostname==3.5.0.1 \
37 bcrypt==3.1.4 \
38 certifi==2018.1.18 \
39 cffi==1.10.0 \
40 chardet==3.0.4 \
41 configobj==5.0.6 \
42 cryptography==2.1.4 \
43 enum34==1.1.6 \
44 gevent==1.2.2 \
45 greenlet==0.4.13 \
46 idna==2.5 \
47 ipaddress==1.0.18 \
48 Jinja2==2.9.6 \
49 manhole==1.5.0 \
50 MarkupSafe==1.0 \
51 netaddr==0.7.19 \
52 packaging==16.8 \
53 paramiko==2.4.0 \
54 pexpect==4.4.0 \
55 psutil==5.4.3 \
56 ptyprocess==0.5.2 \
57 pyasn1==0.2.3 \
58 pycparser==2.17 \
59 PyNaCl==1.2.1 \
60 pyparsing==2.2.0 \
61 python-dateutil==2.6.1 \
62 PyYAML==3.12 \
63 requests==2.18.4 \
64 six==1.10.0 \
65 urllib3==1.22
66 EOF
67
68
69
70 cd $TEMP_DIR
71
72 virtualenv --python=/usr/bin/python venv
73 source venv/bin/activate
74 eval pip install $TEUTHOLOGY_PY_REQS
75 pip install -r $CURR_DIR/requirements.txt
76 deactivate
77
78 git clone --depth 1 https://github.com/ceph/teuthology.git
79
80 cd $BUILD_DIR
81
82 CEPH_MGR_PY_VERSION_MAJOR=$(get_cmake_variable MGR_PYTHON_VERSION | cut -d '.' -f1)
83 if [ -n "$CEPH_MGR_PY_VERSION_MAJOR" ]; then
84 CEPH_PY_VERSION_MAJOR=${CEPH_MGR_PY_VERSION_MAJOR}
85 else
86 if [ $(get_cmake_variable WITH_PYTHON2) = ON ]; then
87 CEPH_PY_VERSION_MAJOR=2
88 else
89 CEPH_PY_VERSION_MAJOR=3
90 fi
91 fi
92
93 cd $CURR_DIR
94
95 COVERAGE_VERSION=$(cat requirements.txt | grep coverage)
96 if [[ "$CEPH_MGR_PY_VERSION_MAJOR" == '3' ]]; then
97 pip3 install "$COVERAGE_VERSION"
98 else
99 pip install "$COVERAGE_VERSION"
100 fi
101 }
102
103 run_teuthology_tests() {
104 cd "$BUILD_DIR"
105 find ../src/pybind/mgr/dashboard/ -name '*.pyc' -exec rm -f {} \;
106 source $TEMP_DIR/venv/bin/activate
107
108 OPTIONS=''
109 TEST_CASES=''
110 if [[ "$@" == '' || "$@" == '--create-cluster-only' ]]; then
111 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`
112 TEST_CASES="tasks.mgr.test_module_selftest tasks.mgr.test_dashboard $TEST_CASES"
113 if [[ "$@" == '--create-cluster-only' ]]; then
114 OPTIONS="$@"
115 fi
116 else
117 for t in "$@"; do
118 TEST_CASES="$TEST_CASES $t"
119 done
120 fi
121
122 export PATH=$BUILD_DIR/bin:$PATH
123 export LD_LIBRARY_PATH=$BUILD_DIR/lib/cython_modules/lib.${CEPH_PY_VERSION_MAJOR}/:$BUILD_DIR/lib
124 export PYTHONPATH=$TEMP_DIR/teuthology:$BUILD_DIR/../qa:$BUILD_DIR/lib/cython_modules/lib.${CEPH_PY_VERSION_MAJOR}/:$BUILD_DIR/../src/pybind
125 if [[ -z "$RGW" ]]; then
126 export RGW=1
127 fi
128
129 export COVERAGE_ENABLED=true
130 export COVERAGE_FILE=.coverage.mgr.dashboard
131 find . -iname "*${COVERAGE_FILE}*" -type f -delete
132
133 eval python ../qa/tasks/vstart_runner.py $OPTIONS $TEST_CASES
134
135 deactivate
136 cd $CURR_DIR
137 }
138
139 cleanup_teuthology() {
140 cd "$BUILD_DIR"
141 killall ceph-mgr
142 sleep 10
143 if [[ "$COVERAGE_ENABLED" == 'true' ]]; then
144 source $TEMP_DIR/venv/bin/activate
145 (coverage combine && coverage report) || true
146 deactivate
147 fi
148 ../src/stop.sh
149 sleep 5
150
151 cd $CURR_DIR
152 rm -rf $TEMP_DIR
153
154 unset TEMP_DIR
155 unset CURR_DIR
156 unset BUILD_DIR
157 unset setup_teuthology
158 unset run_teuthology_tests
159 unset cleanup_teuthology
160 }
161
162 setup_teuthology
163 run_teuthology_tests --create-cluster-only
164
165 # End sourced section
166 return 2> /dev/null
167
168 run_teuthology_tests "$@"
169 cleanup_teuthology