Whamcloud - gitweb
904ff710dfd6c1e91275207bcf47ae5ad047efbc
[fs/lustre-release.git] / lustre / tests / racer.sh
1 #!/bin/bash
2 #set -vx
3 set -e
4
5 ONLY=${ONLY:-"$*"}
6 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
7 . $LUSTRE/tests/test-framework.sh
8 init_test_env $@
9 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
10 init_logging
11
12 racer=$LUSTRE/tests/racer/racer.sh
13 echo racer: $racer with $MDSCOUNT MDTs
14
15 if [ "$SLOW" = "no" ]; then
16     DURATION=${DURATION:-300}
17 else
18     DURATION=${DURATION:-900}
19 fi
20 MOUNT_2=${MOUNT_2:-"yes"}
21
22 build_test_filter
23 check_and_setup_lustre
24
25 CLIENTS=${CLIENTS:-$HOSTNAME}
26 RACERDIRS=${RACERDIRS:-"$DIR $DIR2"}
27 echo RACERDIRS=$RACERDIRS
28
29 if ((MDSCOUNT > 1 &&
30      $(lustre_version_code $SINGLEMDS) >= $(version_code 2.8.0))); then
31         RACER_ENABLE_REMOTE_DIRS=${RACER_ENABLE_REMOTE_DIRS:-true}
32         RACER_ENABLE_STRIPED_DIRS=${RACER_ENABLE_STRIPED_DIRS:-true}
33         RACER_ENABLE_MIGRATION=${RACER_ENABLE_MIGRATION:-true}
34 elif ((MDSCOUNT > 1 &&
35        $(lustre_version_code $SINGLEMDS) >= $(version_code 2.5.0))); then
36         RACER_ENABLE_REMOTE_DIRS=${RACER_ENABLE_REMOTE_DIRS:-true}
37 fi
38
39 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.9.54) ||
40    $(facet_fstype mgs) != zfs ]] && RACER_ENABLE_SNAPSHOT=false
41
42 [[ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.9.55) ]] &&
43         RACER_ENABLE_PFL=false
44
45 [[ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.10.53) ]] &&
46         RACER_ENABLE_DOM=false
47
48 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ]] &&
49         RACER_ENABLE_FLR=false
50
51 RACER_ENABLE_REMOTE_DIRS=${RACER_ENABLE_REMOTE_DIRS:-false}
52 RACER_ENABLE_STRIPED_DIRS=${RACER_ENABLE_STRIPED_DIRS:-false}
53 RACER_ENABLE_MIGRATION=${RACER_ENABLE_MIGRATION:-false}
54 RACER_ENABLE_SNAPSHOT=${RACER_ENABLE_SNAPSHOT:-true}
55 RACER_ENABLE_PFL=${RACER_ENABLE_PFL:-true}
56 RACER_ENABLE_DOM=${RACER_ENABLE_DOM:-true}
57 RACER_ENABLE_FLR=${RACER_ENABLE_FLR:-true}
58
59 check_progs_installed $CLIENTS $racer ||
60         { skip_env "$racer not found" && exit 0; }
61
62 # run racer
63 test_1() {
64         local rrc=0
65         local rc=0
66         local clients=$CLIENTS
67         local RDIRS
68         local i
69
70         for d in ${RACERDIRS}; do
71                 is_mounted $d || continue
72
73                 RDIRS="$RDIRS $d/racer"
74                 mkdir -p $d/racer
75         #       lfs setstripe $d/racer -c -1
76                 if [ $MDSCOUNT -ge 2 ]; then
77                         for i in $(seq $((MDSCOUNT - 1))); do
78                                 RDIRS="$RDIRS $d/racer$i"
79                                 if [ ! -e $d/racer$i ]; then
80                                         $LFS mkdir -i $i $d/racer$i ||
81                                                 error "lfs mkdir $i failed"
82                                 fi
83                         done
84                 fi
85         done
86
87         local rpids=""
88         for rdir in $RDIRS; do
89                 do_nodes $clients "DURATION=$DURATION \
90                         MDSCOUNT=$MDSCOUNT OSTCOUNT=$OSTCOUNT\
91                         RACER_ENABLE_REMOTE_DIRS=$RACER_ENABLE_REMOTE_DIRS \
92                         RACER_ENABLE_STRIPED_DIRS=$RACER_ENABLE_STRIPED_DIRS \
93                         RACER_ENABLE_MIGRATION=$RACER_ENABLE_MIGRATION \
94                         RACER_ENABLE_PFL=$RACER_ENABLE_PFL \
95                         RACER_ENABLE_DOM=$RACER_ENABLE_DOM \
96                         RACER_ENABLE_FLR=$RACER_ENABLE_FLR \
97                         LFS=$LFS \
98                         $racer $rdir $NUM_RACER_THREADS" &
99                 pid=$!
100                 rpids="$rpids $pid"
101         done
102
103         local lss_pids=""
104         if $RACER_ENABLE_SNAPSHOT; then
105                 lss_gen_conf
106
107                 $LUSTRE/tests/racer/lss_create.sh &
108                 pid=$!
109                 lss_pids="$lss_pids $pid"
110
111                 $LUSTRE/tests/racer/lss_destroy.sh &
112                 pid=$!
113                 lss_pids="$lss_pids $pid"
114         fi
115
116         echo racers pids: $rpids
117         for pid in $rpids; do
118                 wait $pid
119                 rc=$?
120                 echo "pid=$pid rc=$rc"
121                 if [ $rc != 0 ]; then
122                     rrc=$((rrc + 1))
123                 fi
124         done
125
126         if $RACER_ENABLE_SNAPSHOT; then
127                 killall -q lss_create.sh
128                 killall -q lss_destroy.sh
129
130                 for pid in $lss_pids; do
131                         wait $pid
132                 done
133
134                 lss_cleanup
135         fi
136
137         return $rrc
138 }
139 run_test 1 "racer on clients: ${CLIENTS:-$(hostname)} DURATION=$DURATION"
140
141 complete $SECONDS
142 check_and_cleanup_lustre
143 exit_status