2 # Copyright (c) 2013-2014 Red Hat, Inc. <http://www.redhat.com>
6 function check_dependencies()
8 ## Check all dependencies are present
12 env dbench --usage > /dev/null 2>&1
14 MISSING="$MISSING dbench"
18 env git --version > /dev/null 2>&1
20 MISSING="$MISSING git"
23 # Check for nfs-utils (Linux-only: built-in NetBSD with different name)
24 if [ "x`uname -s`" = "xLinux" ] ; then
25 env mount.nfs -V > /dev/null 2>&1
27 MISSING="$MISSING nfs-utils"
31 # Check for the Perl Test Harness
32 env prove --version > /dev/null 2>&1
34 MISSING="$MISSING perl-Test-Harness"
37 which json_verify > /dev/null
39 MISSING="$MISSING json_verify"
42 # Check for XFS programs (Linux Only: NetBSD does without)
43 if [ "x`uname -s`" = "xLinux" ] ; then
44 env mkfs.xfs -V > /dev/null 2>&1
46 MISSING="$MISSING xfsprogs"
51 env getfattr --version > /dev/null 2>&1
53 MISSING="$MISSING attr"
57 pidof pidof > /dev/null 2>&1
59 MISSING="$MISSING pidof"
62 # check for psutil python package
63 test `uname -s` == "Darwin" || test `uname -s` == "FreeBSD" && {
64 pip show psutil | grep -q psutil >/dev/null 2>&1
66 MISSING="$MISSING psutil"
70 ## If dependencies are missing, warn the user and abort
71 if [ "x$MISSING" != "x" ]; then
72 test "x${force}" != "xyes" && echo "Aborting."
74 echo "The following required tools are missing:"
76 for pkg in $MISSING; do
80 test "x${force}" = "xyes" && return
81 echo "Please install them and try again."
87 function check_location()
89 regression_testsdir=$(dirname $0);
91 if [ ! -f ${regression_testsdir}/tests/include.rc ]; then
94 echo "The tests/ subdirectory seems to be missing."
96 echo "Please correct the problem and try again."
102 function check_user()
104 # If we're not running as root, warn the user and abort
105 MYUID=`/usr/bin/id -u`
106 if [ 0${MYUID} -ne 0 ]; then
109 echo "The GlusterFS Test Framework must be run as root."
111 echo "Please change to the root user and try again."
122 # Patterns considered valid:
123 # 1. full or partial file/directory names
124 # basic matches tests/basic
125 # basic/afr matches tests/basic/afr
127 # basic/* matches all files and directories in basic
128 # basic/*/ matches subdirectories in basic (afr|ec)
129 # 3. numbered bug matching
130 # 884455 matches bugs/bug-884455.t
131 # 859927 matches bugs/859927, bugs/bug-859927.t
132 # 1015990 matches /bugs/bug-1015990-rep.t, bug-1015990.t
133 # ...lots of other cases accepted as well, since globbing is tricky.
140 # Allow matching on globs like 'basic/*/'
145 *$a|*/bugs/$a/|*/bugs/$a.t|*/bugs/bug-$a.t|*/bugs/bug-$a-*.t)
150 if [ "${DONE[$(dirname $t)]}" != "" ] ; then
151 # Parentdir is already matched
154 # Ignore subdirectory as well
157 elif [ $match -eq 0 -a -d $t ] ; then
158 # Make sure children of this matched directory will be ignored
160 elif [[ -f $t && ! $t =~ .*\.t ]] ; then
161 # Ignore files not ending in .t
167 for t in $(find ${regression_testsdir}/tests | LC_COLLATE=C sort) ; do
168 if match $t "$@" ; then
170 echo "Running tests in directory $t"
172 elif [ -f $t ] ; then
173 echo "Running tests in file $t"
177 if [ ${TMP_RES} -ne 0 ] ; then
183 if [ ${RES} -ne 0 ] ; then
184 FAILED=$( echo ${FAILED} | tr ' ' '\n' | sort -u )
185 echo "Failed tests ${FAILED}"
190 # If you're submitting a fix related to one of these tests and want its result
191 # to be considered, you'll need to remove it from the list as part of your
193 function is_bad_test ()
196 for bt in ./tests/basic/quota-anon-fd-nfs.t \
197 ./tests/bugs/quota/bug-1235182.t \
198 ./tests/basic/quota-nfs.t \
199 ./tests/basic/tier/tier_lookup_heal.t \
200 ./tests/basic/tier/bug-1214222-directories_missing_after_attach_tier.t \
201 ./tests/basic/tier/fops-during-migration.t \
202 ./tests/basic/tier/record-metadata-heat.t \
203 ./tests/bugs/snapshot/bug-1109889.t \
204 ./tests/bugs/distribute/bug-1066798.t \
205 ./tests/bugs/glusterd/bug-1238706-daemons-stop-on-peer-cleanup.t \
206 ./tests/geo-rep/georep-basic-dr-rsync.t \
207 ./tests/geo-rep/georep-basic-dr-tarssh.t \
208 ./tests/bugs/replicate/bug-1221481-allow-fops-on-dir-split-brain.t \
210 [ x"$name" = x"$bt" ] && return 0 # bash: zero means true/success
212 return 1 # bash: non-zero means false/failure
217 find ${regression_testsdir}/tests -name '*.t' \
218 | LC_COLLATE=C sort \
220 old_cores=$(ls /core.* 2> /dev/null | wc -l)
224 if [ ${TMP_RES} -ne 0 ] ; then
225 echo "$t: bad status $TMP_RES"
228 new_cores=$(ls /core.* 2> /dev/null | wc -l)
229 if [ x"$new_cores" != x"$old_cores" ]; then
230 core_diff=$((new_cores-old_cores))
231 echo "$t: $core_diff new core files"
234 if [ $retval -ne 0 ]; then
235 if is_bad_test $t; then
236 echo "Ignoring failure from known-bad test $t"
240 echo "Running failed test $t in debug mode"
241 echo "Just for debug data, does not change test result"
253 if [ $# -lt 1 ]; then
254 echo "Running all the regression test cases (new way)"
255 #prove -rf --timer ${regression_testsdir}/tests;
262 function main_and_retry()
264 RESFILE=`mktemp /tmp/${0##*/}.XXXXXX` || exit 1
265 main "$@" | tee ${RESFILE}
268 FAILED=$( awk '/Failed: /{print $1}' ${RESFILE} )
269 if [ "x${FAILED}" != "x" ] ; then
271 echo " *********************************"
272 echo " * REGRESSION FAILED *"
273 echo " * Retrying failed tests in case *"
274 echo " * we got some spurous failures *"
275 echo " *********************************"
286 echo ... GlusterFS Test Framework ...
293 while [ $# -gt 0 ]; do
302 # Make sure we're running as the root user
305 # Make sure the needed programs are available
308 # Check we're running from the right location
312 if [ "x${retry}" = "xyes" ] ; then