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