Whamcloud - gitweb
b31ddedbc2f8d4c9074ac79fa44cf3883b61affa
[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 insanity sanity-quota sanity-sec
14                 sanity-gss performance-sanity large-scale recovery-mds-scale 
15                 recovery-double-scale recovery-random-scale parallel-scale 
16                 lustre_rsync-test metadata-updates ost-pools lnet-selftest
17                 mmp"
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 if [ "$ACC_SM_ONLY" ]; then
35     for O in $DEFAULT_SUITES; do
36         O=$(echo $O | tr "-" "_" | tr "[:lower:]" "[:upper:]")
37         export ${O}="no"
38     done
39     for O in $ACC_SM_ONLY; do
40         O=`echo ${O%.sh} | tr "-" "_"`
41         O=`echo $O | tr "[:lower:]" "[:upper:]"`
42         export ${O}="yes"
43     done
44 fi
45 LFSCK="no" # bug 13698
46
47 STARTTIME=`date +%s`
48
49 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
50 . $LUSTRE/tests/test-framework.sh
51 init_test_env
52
53 if $GSS; then
54     # liblustre doesn't support GSS
55     export LIBLUSTRE=no
56 else
57     export SANITY_GSS="no"
58 fi
59
60 SETUP=${SETUP:-setupall}
61 FORMAT=${FORMAT:-formatall}
62 CLEANUP=${CLEANUP:-stopall}
63
64 setup_if_needed() {
65     nfs_client_mode && return
66
67     local MOUNTED=$(mounted_lustre_filesystems)
68     if $(echo $MOUNTED | grep -w -q $MOUNT); then
69         check_config_clients $MOUNT
70         init_facets_vars
71         init_param_vars
72         return
73     fi
74
75     echo "Lustre is not mounted, trying to do setup SETUP=$SETUP ... "
76     [ "$REFORMAT" ] && $FORMAT
77     $SETUP
78
79     MOUNTED=$(mounted_lustre_filesystems)
80     if ! $(echo $MOUNTED | grep -w -q $MOUNT); then
81         echo "Lustre is not mounted after setup! SETUP=$SETUP"
82         exit 1
83     fi
84 }
85
86 find_in_path() {
87     target=$1
88     for dir in $(tr : " " <<< $PATH); do
89       if [ -e $dir/$target ]; then
90           echo "$dir/$target found in PATH"
91           return 0
92       fi
93     done
94     return 1
95 }
96
97 title() {
98     # update titlebar if stdin is attaached to an xterm
99     if ${UPDATE_TITLEBAR:-false}; then
100         if tty -s; then
101             case $TERM in 
102                 xterm*)
103                     echo -ne "\033]2; acceptance-small: $* \007" >&0
104                     ;;
105             esac
106         fi
107     fi 
108     log "-----============= acceptance-small: "$*" ============----- `date`"
109 }
110
111 is_sanity_benchmark() {
112     local benchmarks="dbench bonnie iozone fsx"
113     local suite=$1
114     for b in $benchmarks; do
115         if [ "$b" == "$suite" ]; then
116             return 0
117         fi
118     done
119     return 1
120 }
121
122 run_suite() {
123     local suite_name=$(echo ${1%.sh} | tr "[:upper:]_" "[:lower:]-" )
124     local suite=$(echo ${suite_name} | tr "[:lower:]-" "[:upper:]_")
125     local suite_only=ONLY # Change to ${suite}_ONLY after fixing YALA
126
127     if is_sanity_benchmark ${suite_name}; then
128         suite_only=suite_name
129         suite_script=$LUSTRE/tests/sanity-benchmark.sh
130     elif [ -e $LUSTRE/tests/${suite_name}.sh ]; then
131         suite_script=$LUSTRE/tests/${suite_name}.sh
132     elif [ -e $LUSTRE/tests/$suite_name ]; then
133         suite_script=$LUSTRE/tests/$suite_name
134     elif find_in_path $suite_name; then
135         suite_script=${suite_name}
136     elif find_in_path ${suite_name}.sh; then
137         suite_script=${suite_name}.sh
138     else
139         echo "Can't find test script for $suite_name"
140         return 1
141     fi
142
143     echo "$suite_script located."
144     if [[ ${!suite} != no ]]; then
145         title $suite_name
146         log_test $suite_name
147         bash $suite_script ${!suite_only}
148         $CLEANUP
149         $SETUP
150         eval ${suite}="done"
151     else
152         echo "Skipping $suite_name"
153     fi
154 }
155
156 run_suites() {
157     for suite in $*; do
158         run_suite $suite
159     done
160 }
161
162 export NAME MOUNT START CLEAN
163 . $LUSTRE/tests/cfg/$NAME.sh
164
165 assert_env mds_HOST MDS_MKFS_OPTS 
166 assert_env ost_HOST OST_MKFS_OPTS OSTCOUNT
167 assert_env FSNAME MOUNT MOUNT2
168
169 setup_if_needed
170 init_logging
171
172 run_suites ${ACC_SM_ONLY:-$DEFAULT_SUITES}
173
174 RC=$?
175 title FINISHED
176 echo "Finished at `date` in $((`date +%s` - $STARTTIME))s"
177 print_summary
178 [ "$MSKIPPED" = 1 ] && log "FAIL: remote MDS tests skipped" && RC=1
179 [ "$OSKIPPED" = 1 ] && log "FAIL: remote OST tests skipped" && RC=1
180 echo "$0: completed with rc $RC" && exit $RC