Whamcloud - gitweb
0709852ec440b5bb27fc1aaff596a3e96f7990cf
[fs/lustre-release.git] / lustre / tests / acceptance-small.sh
1 #!/bin/bash
2 # script which _must_ complete successfully (at minimum) before checkins to
3 # the CVS HEAD are allowed.
4 #set -vx
5 set -e
6
7 export MSKIPPED=0
8 export OSKIPPED=0
9
10 # This is the default set of tests to run.
11 DEFAULT_SUITES="runtests sanity sanity-benchmark sanityn lfsck liblustre
12                 runracer replay-single conf-sanity recovery-small
13                 replay-ost-single replay-dual replay-vbr insanity sanity-quota
14                 sanity-sec sanity-gss performance-sanity large-scale
15                 recovery-mds-scale recovery-double-scale recovery-random-scale
16                 parallel-scale lustre_rsync-test metadata-updates ost-pools
17                 lnet-selftest mmp obdfilter-survey sgpdd-survey"
18
19 if [[ -n $@ ]]; then
20     ACC_SM_ONLY="${ACC_SM_ONLY} $@"
21 fi
22
23 [ "$SIZE" ] || SIZE=$((RAMKB * 2))
24 [ "$RSIZE" ] || RSIZE=512
25 [ "$UID" ] || UID=1000
26 [ "$MOUNT" ] || MOUNT=/mnt/lustre
27 [ "$MOUNT2" ] || MOUNT2=${MOUNT}2
28 [ "$TMP" ] || TMP=/tmp
29 [ "$COUNT" ] || COUNT=1000
30 [ "$DEBUG_LVL" ] || DEBUG_LVL=0
31 [ "$DEBUG_OFF" ] || DEBUG_OFF="eval lctl set_param debug=\"$DEBUG_LVL\""
32 [ "$DEBUG_ON" ] || DEBUG_ON="eval lctl set_param debug=0x33f0484"
33
34 export TF_FAIL=$TMP/tf.fail
35
36 if [ "$ACC_SM_ONLY" ]; then
37     for O in $DEFAULT_SUITES; do
38         O=$(echo $O | tr "-" "_" | tr "[:lower:]" "[:upper:]")
39         export ${O}="no"
40     done
41     for O in $ACC_SM_ONLY; do
42         O=`echo ${O%.sh} | tr "-" "_"`
43         O=`echo $O | tr "[:lower:]" "[:upper:]"`
44         export ${O}="yes"
45     done
46 fi
47
48 STARTTIME=`date +%s`
49
50 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
51 . $LUSTRE/tests/test-framework.sh
52 init_test_env
53
54 if $GSS; then
55     # liblustre doesn't support GSS
56     export LIBLUSTRE=no
57 else
58     export SANITY_GSS="no"
59 fi
60
61 SETUP=${SETUP:-setupall}
62 FORMAT=${FORMAT:-formatall}
63 CLEANUP=${CLEANUP:-stopall}
64
65 setup_if_needed() {
66     nfs_client_mode && return
67
68     local MOUNTED=$(mounted_lustre_filesystems)
69     if $(echo $MOUNTED | grep -w -q $MOUNT); then
70         check_config_clients $MOUNT
71         init_facets_vars
72         init_param_vars
73         return
74     fi
75
76     echo "Lustre is not mounted, trying to do setup SETUP=$SETUP ... "
77     [ "$REFORMAT" ] && $FORMAT
78     $SETUP
79
80     MOUNTED=$(mounted_lustre_filesystems)
81     if ! $(echo $MOUNTED | grep -w -q $MOUNT); then
82         echo "Lustre is not mounted after setup! SETUP=$SETUP"
83         exit 1
84     fi
85 }
86
87 find_in_path() {
88     target=$1
89     for dir in $(tr : " " <<< $PATH); do
90       if [ -e $dir/$target ]; then
91           echo "$dir/$target found in PATH"
92           return 0
93       fi
94     done
95     return 1
96 }
97
98 title() {
99     # update titlebar if stdin is attaached to an xterm
100     if ${UPDATE_TITLEBAR:-false}; then
101         if tty -s; then
102             case $TERM in 
103                 xterm*)
104                     echo -ne "\033]2; acceptance-small: $* \007" >&0
105                     ;;
106             esac
107         fi
108     fi 
109     log "-----============= acceptance-small: "$*" ============----- $(date)"
110 }
111
112 run_suite() {
113     local suite_name=$(echo ${1%.sh} | tr "[:upper:]_" "[:lower:]-" )
114     local suite=$(echo ${suite_name} | tr "[:lower:]-" "[:upper:]_")
115     local suite_only=ONLY # Change to ${suite}_ONLY after fixing YALA
116
117     if is_sanity_benchmark ${suite_name}; then
118         suite_only=suite_name
119         suite_script=$LUSTRE/tests/sanity-benchmark.sh
120     elif [ -e $LUSTRE/tests/${suite_name}.sh ]; then
121         suite_script=$LUSTRE/tests/${suite_name}.sh
122     elif [ -e $LUSTRE/tests/$suite_name ]; then
123         suite_script=$LUSTRE/tests/$suite_name
124     elif find_in_path $suite_name; then
125         suite_script=${suite_name}
126     elif find_in_path ${suite_name}.sh; then
127         suite_script=${suite_name}.sh
128     else
129         echo "Can't find test script for $suite_name"
130         return 1
131     fi
132
133     echo "$suite_script located."
134     if [[ ${!suite} != no ]]; then
135         local rc
136         local status
137         local duration
138         local start_ts=$(date +%s)
139         rm -rf $TF_FAIL
140         title $suite_name
141         log_test $suite_name
142         bash $suite_script ${!suite_only}
143         rc=$?
144         duration=$(($(date +%s) - $start_ts))
145         if [ -f $TF_FAIL -o $rc -ne 0 ]; then
146             status="FAIL"
147         else
148             status="PASS"
149         fi
150         echo "Script: $status"
151         log_test_status $duration $status
152
153         $CLEANUP
154         [ x$suite = xSGPDD_SURVEY ] || $SETUP
155
156         eval ${suite}="done"
157     else
158         echo "Skipping $suite_name"
159     fi
160 }
161
162 run_suites() {
163     for suite in $*; do
164         run_suite $suite
165     done
166 }
167
168 export NAME MOUNT START CLEAN
169 . $LUSTRE/tests/cfg/$NAME.sh
170
171 assert_env mds_HOST MDS_MKFS_OPTS 
172 assert_env ost_HOST OST_MKFS_OPTS OSTCOUNT
173 assert_env FSNAME MOUNT MOUNT2
174
175 setup_if_needed
176 init_logging
177
178 run_suites ${ACC_SM_ONLY:-$DEFAULT_SUITES}
179
180 RC=$?
181 title FINISHED
182 echo "Finished at `date` in $((`date +%s` - $STARTTIME))s"
183 print_summary
184 [ "$MSKIPPED" = 1 ] && log "FAIL: remote MDS tests skipped" && RC=1
185 [ "$OSKIPPED" = 1 ] && log "FAIL: remote OST tests skipped" && RC=1
186 echo "$0: completed with rc $RC" && exit $RC