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