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