Whamcloud - gitweb
b=22977 add echoclient async journal regression test to acc-sm obdfilter-survey
[fs/lustre-release.git] / lustre / tests / obdfilter-survey.sh
1 #!/bin/bash
2 #set -x
3 set -e
4
5 LUSTRE=${LUSTRE:-`dirname $0`/..}
6 . $LUSTRE/tests/test-framework.sh
7 init_test_env $@
8
9 nobjhi=${nobjhi:-1}
10 thrhi=${thrhi:-16}
11 size=${size:-1024}
12
13 # the summary file a bit smaller than OSTSIZE
14 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
15
16 [ "$SLOW" = no ] && { nobjhi=1; thrhi=4; }
17 thrlo=${thrlo:-$(( thrhi / 2))}
18
19 # Skip these tests
20 # bug number   23791 23791
21 ALWAYS_EXCEPT="1b    2b    $OBDFILTER_SURVEY_EXCEPT"
22
23 OBDSURVEY=${OBDSURVEY:-$(which obdfilter-survey)}
24
25 build_test_filter
26 check_and_setup_lustre
27
28 min_ost_size () {
29     $LCTL get_param -n osc.*.kbytesavail | sort -n | head -n1
30 }
31
32 # FIXME: the summary file a bit smaller than OSTSIZE, add estimation
33 minsize=$(min_ost_size)
34 if [ $(( size * 1024 )) -ge $minsize  ]; then
35     size=$((minsize * 10 / 1024 / 12 ))
36     echo min kbytesavail: $minsize using size=${size} MBytes per obd instance
37 fi
38
39 get_targets () {
40         local targets
41         local devs
42         local oss
43
44         for oss in $(osts_nodes); do
45                 devs=$(do_node $oss "lctl dl |grep obdfilter |sort" | awk '{print $4}')
46                 for d in $devs; do
47                         # if oss is local -- obdfilter-survey needs dev wo/ host
48                         target=$d
49                         [[ $oss = `hostname` ]] || target=$oss:$target
50                         targets="$targets $target"
51                 done
52         done
53
54         echo $targets
55 }
56
57 obdflter_survey_targets () {
58         local case=$1
59         local targets
60
61         case $case in
62                 disk)    targets=$(get_targets);;
63                 netdisk) targets=$(get_targets);;
64                 network) targets="$(osts_nodes)";;
65                 *) error "unknown obdflter-survey case!" ;;
66         esac
67         echo $targets
68 }
69
70 obdflter_survey_run () {
71         local case=$1
72
73         rm -f ${TMP}/obdfilter_survey*
74
75         local targets=$(obdflter_survey_targets $case)
76         local cmd="NETTYPE=$NETTYPE thrlo=$thrlo nobjhi=$nobjhi thrhi=$thrhi size=$size case=$case rslt_loc=${TMP} targets=\"$targets\" sh $OBDSURVEY"
77         echo + $cmd
78         eval $cmd
79
80         cat ${TMP}/obdfilter_survey*
81 }
82 test_1a () {
83         obdflter_survey_run disk
84 }
85 run_test 1a "Object Storage Targets survey"
86
87 print_jbd () {
88         local file=$1
89         local facet=$2
90         local varsvc=${facet}_svc
91         local dev=$(basename $(do_facet $facet lctl get_param -n *.${!varsvc}.mntdev))
92
93         # ext4: /proc/fs/jbd2/sda1:8/history 
94         # ext3: /proc/fs/jbd/sdb1/history
95
96         do_facet $facet cat /proc/fs/jbd*/${dev}*/$file
97 }
98
99 check_jbd_values () {
100         local facet=$1
101         local thrhi=$2
102
103         # last two lines from history
104         # $4: run >= 5000
105         # $8: hndls >= thrhi * 2
106         local hist=("$(print_jbd history $facet | tail -3 | head -2)")
107         echo "$hist"
108         local run=($(echo "${hist[*]}" | awk '{print $4}'))
109         local hndls=($(echo "${hist[*]}" | awk '{print $8}'))
110
111         local rc=0
112         for (( i=0; i<1; i++)); do
113                 [[ ${run[i]} -lt 5000 ]] && \
114                         error "$facet: run expected 5000, have ${run[i]}" && rc=1
115                 [[ ${hndls[i]} -lt $((thrhi * 2)) ]] && \
116                         error "$facet: hndls expected > $((thrhi * 2)), have ${hndls[i]}" && rc=2
117         done
118         return $rc
119 }
120
121 check_jbd_values_facets () {
122         local facets=$1
123         local thrhi=$2
124         local facet
125         local rc=0
126         for facet in  ${facets//,/ }; do
127                 check_jbd_values $facet $thrhi || rc=$((rc+$?))
128         done
129         return $rc
130 }
131
132 test_1b () {
133         local param_file=$TMP/$tfile-params
134
135         do_nodesv $(comma_list $(osts_nodes)) lctl get_param obdfilter.${FSNAME}-*.sync_journal
136
137         save_lustre_params $(comma_list $(osts_nodes)) "obdfilter.${FSNAME}-*.sync_journal" >$param_file
138         do_nodesv $(comma_list $(osts_nodes)) lctl set_param obdfilter.${FSNAME}-*.sync_journal=0
139
140         thrlo=4 nobjhi=1 thrhi=4 obdflter_survey_run disk
141
142         check_jbd_values_facets $(get_facets OST) 4 || rc=$((rc+$?))
143
144         restore_lustre_params < $param_file
145
146         rm -f $param_file
147         return $rc
148 }
149 run_test 1b "Object Storage Targets survey, async journal"
150
151 test_2a () {
152         obdflter_survey_run netdisk
153 }
154 run_test 2a "Stripe F/S over the Network"
155
156 test_2b () {
157         local param_file=$TMP/$tfile-params
158
159         do_nodesv $(comma_list $(osts_nodes)) lctl get_param obdfilter.${FSNAME}-*.sync_journal
160
161         save_lustre_params $(comma_list $(osts_nodes)) "obdfilter.${FSNAME}-*.sync_journal" >$param_file
162         do_nodesv $(comma_list $(osts_nodes)) lctl set_param obdfilter.${FSNAME}-*.sync_journal=0
163
164         thrlo=4 nobjhi=1 thrhi=4 obdflter_survey_run netdisk
165
166         check_jbd_values_facets $(get_facets OST) 4 || rc=$((rc+$?))
167
168         restore_lustre_params < $param_file
169
170         rm -f $param_file
171         return $rc
172 }
173 run_test 2b "Stripe F/S over the Network, async journal"
174
175
176 # README.obdfilter-survey: In network test only automated run is supported.
177 test_3a () {
178         remote_servers || { skip "Local servers" && return 0; }
179
180         # The Network survey test needs:
181         # Start lctl and check for the device list. The device list must be empty.
182         cleanupall
183
184         obdflter_survey_run network
185
186         setupall
187 }
188 run_test 3a "Network survey"
189
190 equals_msg `basename $0`: test complete, cleaning up
191 cleanup_echo_devs
192 check_and_cleanup_lustre
193 [ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG && grep -q FAIL $TESTSUITELOG && exit 1 || true