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