Whamcloud - gitweb
New tag 2.15.63
[fs/lustre-release.git] / lustre / tests / auster
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3
4 #
5 # This file is part of Lustre, http://www.lustre.org/
6 #
7 # lustre/tests/auster
8 #
9 # Drive lustre tests
10 #
11
12 #
13 # TODO
14 #  1. --time-limt <seconds>  add per test time limit, kill test if it runs to long
15 #  2. Read list of tests to run from a file. same syntax as cli, but one test per line
16 #  3. Run test on remote node
17 #
18
19 set -e
20
21 export TF_FAIL=/tmp/tf.fail
22 export TF_SKIP=/tmp/tf.skip
23
24 usage() {
25         less -F <<EOF
26 Usage ${0##*/} [options]  suite [suite options] [suite [suite options]]
27 Run Lustre regression tests suites.
28       -c, --config CONFIG   Test environment config file
29       -C, --client-only     Run client-side sanity tests against an already setup
30                             filesystem. Users must define FSNAME and mgs_HOST manually.
31       -d, --log-dir LOGDIR            Top level directory for logs
32       -D, --full-log-dir FULLLOGDIR   Full directory for logs
33       -f, --cfg-name STR    Config name (cfg/<name>.sh)
34       -g, --group GROUP     Test group file (Overrides tests listed on command line)
35       -S, --suite TESTSUITE           First test suite to run allows for restarts
36       -H, --honor           Honor the EXCEPT and ALWAYS_EXCEPT list when --only is used
37       -i, --repeat N        Repeat tests N times (default 1). A new directory
38                             will be created under LOGDIR for each iteration.
39       -k  --no-stop         Don't stop when subtests fail
40       -R, --remount         Remount lustre between tests
41       -r, --reformat        Reformat (during initial configuration if needed)
42       -s  --slow            SLOW=yes
43       -v, --verbose         Verbose mode
44       -l, --send-logs       Send logs to the Maloo database after run
45                               (can be done later by running maloo_upload.sh)
46       -L, --lang            Script language of test suite. Default: bash
47       -N, --no-setup        No setup. Do not setup Lustre prior to executing test suite.
48       -h, --help            This help.
49
50 Suite options
51 These are suite specific options that can be specified after each suite on
52 the command line.
53    suite-name  [options]
54       --only LIST         Run only specific list of subtests
55       --except LIST       Skip list of subtests
56       --start-at SUBTEST  Start testing from subtest
57       --stop-at SUBTEST   Stop testing at subtest
58       --time-limit LIMIT  Don't allow this suite to run longer
59                           than LIMT seconds. [UNIMPLEMENTED]
60
61 Example usage:
62 Run all of sanity and all of replay-single except for 70b with SLOW=y using
63 the default "local" configuration.
64
65   auster -s sanity replay-single --except 70b
66
67 Run all tests in the regression group 5 times using large config.
68
69   auster -f large -g test-groups/regression -i 5
70
71 Run the client-only tests from sanity.
72
73   FSNAME=myfilesystem mgs_HOST=1.2.3.4 auster -C sanity
74
75 EOF
76         exit
77 }
78
79 dry_run=false
80 do_reset=false
81 verbose=false
82 repeat_count=1
83 upload_logs=false
84 reformat=false
85 script_lang=bash
86 test_logs_dir=/tmp/test_logs/$(date +%Y-%m-%d)/$(date +%H%M%S)
87 export HONOR_EXCEPT=
88 export do_setup=true
89 export client_tests_only=false
90 export "${SLOW:=no}"
91 export "${NAME:=local}"
92
93 # Replace long option with corresponding short option
94 for arg in "$@"; do
95         shift
96         case "$arg" in
97                 --config) set -- "$@" '-c';;
98                 --client-only) set -- "$@" '-C';;
99                 --log-dir) set -- "$@" '-d';;
100                 --full-log-dir) set -- "$@" '-D';;
101                 --group) set -- "$@" '-g';;
102                 --suite) set -- "$@" '-S';;
103                 --no-stop) set -- "$@" '-k';;
104                 --verbose) set -- "$@" '-v';;
105                 --honor) set -- "$@" '-H';;
106                 --repeat) set -- "$@" '-i';;
107                 --cfg-name) set -- "$@" '-f';;
108                 --remount) set -- "$@" '-R';;
109                 --reformat) set -- "$@" '-r';;
110                 --slow) set -- "$@" '-s';;
111                 --send-logs) set -- "$@" '-l';;
112                 --lang) set -- "$@" '-L';;
113                 --no-setup) set -- "$@" '-N';;
114                 --help) set -- "$@" '-h';;
115                 *) set -- "$@" "$arg";;
116         esac
117 done
118
119 while getopts "c:Cd:D:nkf:S:g:Hi:rRslL:Nhv" opt
120 do
121         case "$opt" in
122                 c) export CONFIG=$OPTARG;;
123                 C) client_tests_only=true;;
124                 d) test_logs_dir=$OPTARG/$(date +%Y-%m-%d)/$(date +%H%M%S);;
125                 D) test_logs_dir=$OPTARG;;
126                 g) test_group_file=$OPTARG;;
127                 S) FIRST_SUITE=$OPTARG;;
128                 k) export FAIL_ON_ERROR=false;;
129                 n) dry_run=:;;
130                 v) verbose=:;;
131                 H) export HONOR_EXCEPT="y";;
132                 i) repeat_count=$OPTARG;;
133                 f) NAME=$OPTARG;;
134                 R) do_reset=:;;
135                 r) reformat=:;;
136                 s) export SLOW=yes;;
137                 l) upload_logs=true;;
138                 L) script_lang=$OPTARG;;
139                 N) do_setup=false;;
140                 h|\?) usage;;
141         esac
142 done
143
144 # If a test_group_file is specified, then ignore rest of command line
145 if [[ $test_group_file ]]; then
146     export TEST_GROUP=$(basename $test_group_file)
147     set $(sed 's/#.*$//' $test_group_file)
148 else
149     shift $((OPTIND -1))
150 fi
151
152 STARTTIME=`date +%s`
153
154 : ${LUSTRE:=$(cd $(dirname $0)/..; echo $PWD)}
155 . $LUSTRE/tests/test-framework.sh
156 init_test_env
157
158 # Set CLIENTONLY, while trying to discover some common
159 # variables so the test runner doesn't need do this
160 # manually
161 if $client_tests_only; then
162         export CLIENTONLY=true;
163         export FSTYPE=${FSTYPE:-ldiskfs};
164         export MDSCOUNT="$(( $($LFS mdts | wc -l) - 1 ))"
165         export OSTCOUNT="$(( $($LFS osts | wc -l) - 1 ))"
166 fi
167
168 # special return code to stop testing without cleanup
169 # used with the --stop-on-error option
170 export STOP_NOW_RC=111
171
172 if [ $upload_logs = true ] ; then
173     upload_script=$(find_script_in_path maloo_upload.sh $PATH:$LUSTRE/tests)
174     if [[ -z $upload_script ]]; then
175         echo "Can't find maloo_upload.sh script"
176         exit 1
177     fi
178
179     if [ ! -r ~/.maloorc ] ; then
180         echo "A ~/.maloorc file is required in order to upload results."
181         echo "Visit your maloo web interface to download your .maloorc file"
182         exit 1
183     fi
184 fi
185
186 export NAME MOUNT START CLEAN
187 . ${CONFIG:-$LUSTRE/tests/cfg/$NAME.sh}
188
189 # Only need to know where (MOUNT) and how (mgs_HOST) to
190 # mount Lustre for client-side only tests
191 if $client_tests_only; then
192         assert_env mgs_HOST
193 else
194         assert_env mds_HOST
195         assert_env ost_HOST OSTCOUNT
196         assert_env MOUNT2
197 fi
198
199 assert_env FSNAME MOUNT
200
201 echo "Started at `date`"
202 setup_if_needed
203
204 run_suites "$@"
205 RC=$?
206
207 if [[ $RC -eq 0 ]]; then
208     cleanup_if_needed
209 fi
210
211 echo "Finished at `date` in $((`date +%s` - $STARTTIME))s"
212 echo "$0: completed with rc $RC" && exit $RC