Whamcloud - gitweb
LU-10997 build: add files to .gitignore
[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_targets () {
37         local targets
38         local target
39         local dev
40         local nid
41         local osc
42
43         for osc in $($LCTL get_param -N osc.${FSNAME}-*osc-*); do
44                 nid=$($LCTL get_param $osc.import |
45                         awk '/current_connection:/ {sub(/@.*/,""); print $2}')
46                 dev=$(echo $osc | sed -e 's/^osc\.//' -e 's/-osc.*//')
47                 target=$dev
48
49                 # For local disk obdfilter-survey requires target devs w/o nid.
50                 # obdfilter-survey :
51                 # case 1 (local disk):
52                 #    $ nobjhi=2 thrhi=2 size=1024
53                 #         targets="lustre-OST0000 lustre-OST0001 ..."
54                 #                 sh obdfilter-survey
55                 local_node && [ "$1" == "disk" ] || target=$nid:$target
56                 targets="$targets $target"
57         done
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         local rc=$?
84
85         cat ${TMP}/obdfilter_survey*
86         [ $rc = 0 ] || error "$OBDSURVEY failed: $rc"
87 }
88 test_1a () {
89         obdflter_survey_run disk
90 }
91 run_test 1a "Object Storage Targets survey"
92
93 print_jbd () {
94         local file=$1
95         local facet=$2
96         local varsvc=${facet}_svc
97         local dev=$(ldiskfs_canon "*.${!varsvc}.mntdev" $facet)
98
99         # ext4: /proc/fs/jbd2/sda1:8/history
100         # ext3: /proc/fs/jbd/sdb1/history
101
102         do_facet $facet cat /proc/fs/jbd*/${dev}*/$file
103 }
104
105 check_jbd_values () {
106         local facet=$1
107         local thrhi=$2
108         local rtime=$3
109
110         # last two lines from history
111         # $4: run >= 5000
112         # $8: hndls >= thrhi * 2
113         # display history of rtime/4 before, in case obd cleanup consumes time
114         local tlines=$((rtime / 5 / 4 + 1))
115         local hist=("$(print_jbd history $facet | tail -$tlines | head -n1)")
116         echo "$hist"
117         local run=($(echo "${hist[*]}" | awk '{print $4}'))
118         local hndls=($(echo "${hist[*]}" | awk '{print $8}'))
119
120         local rc=0
121         for (( i=0; i<1; i++)); do
122                 [[ ${run[i]} -lt 5000 ]] && \
123                         error "$facet: run expected 5000, have ${run[i]}" && rc=1
124                 [[ ${hndls[i]} -lt $((thrhi * 2)) ]] && \
125                         error "$facet: hndls expected > $((thrhi * 2)), have ${hndls[i]}" && rc=2
126         done
127         return $rc
128 }
129
130 check_jbd_values_facets () {
131         local facets=$1
132         local thrhi=$2
133         local rtime=$3
134         local facet
135         local rc=0
136         for facet in  ${facets//,/ }; do
137                 check_jbd_values $facet $thrhi $rtime || rc=$((rc+$?))
138         done
139         return $rc
140 }
141
142 test_1b () {
143         local param_file=$TMP/$tfile-params
144
145         do_nodesv $(comma_list $(osts_nodes)) \
146                 $LCTL get_param obdfilter.${FSNAME}-*.sync_journal
147         save_lustre_params $(get_facets OST) \
148                 "obdfilter.${FSNAME}-*.sync_journal" > $param_file
149         do_nodesv $(comma_list $(osts_nodes)) \
150                 $LCTL set_param obdfilter.${FSNAME}-*.sync_journal=0
151
152         local stime=$(date +%s)
153         thrlo=4 nobjhi=1 thrhi=4 obdflter_survey_run disk
154         local etime=$(date +%s)
155         # run time of obd survey
156         local rtime=$((etime - stime))
157
158         echo "obd survey finished in $rtime seconds"
159         check_jbd_values_facets $(get_facets OST) 4 $rtime || rc=$((rc+$?))
160
161         restore_lustre_params < $param_file
162
163         rm -f $param_file
164         return $rc
165 }
166 run_test 1b "Object Storage Targets survey, async journal"
167
168 test_1c () {
169         nobjlo=1 nobjhi=1 thrlo=32 thrhi=32 rszlo=1024 rszhi=1024 size=8192\
170         obdflter_survey_run disk
171 }
172 run_test 1c "Object Storage Targets survey, big batch"
173
174 test_2a () {
175         obdflter_survey_run netdisk
176 }
177 run_test 2a "Stripe F/S over the Network"
178
179 test_2b () {
180         local param_file=$TMP/$tfile-params
181
182         do_nodesv $(comma_list $(osts_nodes)) \
183                 $LCTL get_param obdfilter.${FSNAME}-*.sync_journal
184         save_lustre_params $(get_facets OST) \
185                 "obdfilter.${FSNAME}-*.sync_journal" > $param_file
186         do_nodesv $(comma_list $(osts_nodes)) \
187                 $LCTL set_param obdfilter.${FSNAME}-*.sync_journal=0
188
189         local stime=$(date +%s)
190         thrlo=4 nobjhi=1 thrhi=4 obdflter_survey_run netdisk
191         local etime=$(date +%s)
192         local rtime=$((etime - stime))
193
194         echo "obd survey finished in $rtime seconds"
195         check_jbd_values_facets $(get_facets OST) 4 $rtime || rc=$((rc+$?))
196
197         restore_lustre_params < $param_file
198
199         rm -f $param_file
200         return $rc
201 }
202 run_test 2b "Stripe F/S over the Network, async journal"
203
204
205 # README.obdfilter-survey: In network test only automated run is supported.
206 test_3a () {
207         # obdfilter-survey Prerequisite:
208         #    For "network" case  you need to have all
209         #    modules (those llmount.sh loads) loaded in kernel. And the
210         #    'lctl dl' output must be blank.
211         # Skipping test for CLIENTONLY mode because of
212         # cleanupall()->stopall() does not cleanup the servers on this mode.
213         [ "$CLIENTONLY" ] && skip "CLIENTONLY mode" && return
214
215         remote_servers || { skip "Local servers" && return 0; }
216
217         cleanupall
218
219         obdflter_survey_run network
220
221         setupall
222 }
223 run_test 3a "Network survey"
224
225 complete $SECONDS
226 cleanup_echo_devs
227 check_and_cleanup_lustre
228 exit_status