Whamcloud - gitweb
LU-1303 lod: introduce lod device
[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         local rtime=$3
107
108         # last two lines from history
109         # $4: run >= 5000
110         # $8: hndls >= thrhi * 2
111         # display history of rtime/4 before, in case obd cleanup consumes time
112         local tlines=$((rtime / 5 / 4 + 1))
113         local hist=("$(print_jbd history $facet | tail -$tlines | head -1)")
114         echo "$hist"
115         local run=($(echo "${hist[*]}" | awk '{print $4}'))
116         local hndls=($(echo "${hist[*]}" | awk '{print $8}'))
117
118         local rc=0
119         for (( i=0; i<1; i++)); do
120                 [[ ${run[i]} -lt 5000 ]] && \
121                         error "$facet: run expected 5000, have ${run[i]}" && rc=1
122                 [[ ${hndls[i]} -lt $((thrhi * 2)) ]] && \
123                         error "$facet: hndls expected > $((thrhi * 2)), have ${hndls[i]}" && rc=2
124         done
125         return $rc
126 }
127
128 check_jbd_values_facets () {
129         local facets=$1
130         local thrhi=$2
131         local rtime=$3
132         local facet
133         local rc=0
134         for facet in  ${facets//,/ }; do
135                 check_jbd_values $facet $thrhi $rtime || rc=$((rc+$?))
136         done
137         return $rc
138 }
139
140 test_1b () {
141         local param_file=$TMP/$tfile-params
142
143         do_nodesv $(comma_list $(osts_nodes)) lctl get_param obdfilter.${FSNAME}-*.sync_journal
144
145         save_lustre_params $(comma_list $(osts_nodes)) "obdfilter.${FSNAME}-*.sync_journal" >$param_file
146         do_nodesv $(comma_list $(osts_nodes)) lctl set_param obdfilter.${FSNAME}-*.sync_journal=0
147
148         local stime=$(date +%s)
149         thrlo=4 nobjhi=1 thrhi=4 obdflter_survey_run disk
150         local etime=$(date +%s)
151         # run time of obd survey
152         local rtime=$((etime - stime))
153
154         echo "obd survey finished in $rtime seconds"
155         check_jbd_values_facets $(get_facets OST) 4 $rtime || rc=$((rc+$?))
156
157         restore_lustre_params < $param_file
158
159         rm -f $param_file
160         return $rc
161 }
162 run_test 1b "Object Storage Targets survey, async journal"
163
164 test_1c () {
165         nobjlo=1 nobjhi=1 thrlo=128 thrhi=128 rszlo=1024 rszhi=1024 size=8192\
166         obdflter_survey_run disk
167 }
168 run_test 1c "Object Storage Targets survey, big batch"
169
170 test_2a () {
171         obdflter_survey_run netdisk
172 }
173 run_test 2a "Stripe F/S over the Network"
174
175 test_2b () {
176         local param_file=$TMP/$tfile-params
177
178         do_nodesv $(comma_list $(osts_nodes)) lctl get_param obdfilter.${FSNAME}-*.sync_journal
179
180         save_lustre_params $(comma_list $(osts_nodes)) "obdfilter.${FSNAME}-*.sync_journal" >$param_file
181         do_nodesv $(comma_list $(osts_nodes)) lctl set_param obdfilter.${FSNAME}-*.sync_journal=0
182
183         local stime=$(date +%s)
184         thrlo=4 nobjhi=1 thrhi=4 obdflter_survey_run netdisk
185         local etime=$(date +%s)
186         local rtime=$((etime - stime))
187
188         echo "obd survey finished in $rtime seconds"
189         check_jbd_values_facets $(get_facets OST) 4 $rtime || rc=$((rc+$?))
190
191         restore_lustre_params < $param_file
192
193         rm -f $param_file
194         return $rc
195 }
196 run_test 2b "Stripe F/S over the Network, async journal"
197
198
199 # README.obdfilter-survey: In network test only automated run is supported.
200 test_3a () {
201         remote_servers || { skip "Local servers" && return 0; }
202
203         # The Network survey test needs:
204         # Start lctl and check for the device list. The device list must be empty.
205         cleanupall
206
207         obdflter_survey_run network
208
209         setupall
210 }
211 run_test 3a "Network survey"
212
213 complete $(basename $0) $SECONDS
214 cleanup_echo_devs
215 check_and_cleanup_lustre
216 exit_status