Whamcloud - gitweb
LU-11166 tests: remove use of /proc/fs/jbd2/*/history file
[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 # bug number for skipped test:
21 ALWAYS_EXCEPT="$OBDFILTER_SURVEY_EXCEPT"
22 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_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
89 test_1a () {
90         obdflter_survey_run disk
91 }
92 run_test 1a "Object Storage Targets survey"
93
94 test_1b () {
95         local param_file=$TMP/$tfile-params
96
97         do_nodesv $(comma_list $(osts_nodes)) \
98                 $LCTL get_param obdfilter.${FSNAME}-*.sync_journal
99         save_lustre_params $(get_facets OST) \
100                 "obdfilter.${FSNAME}-*.sync_journal" > $param_file
101         do_nodesv $(comma_list $(osts_nodes)) \
102                 $LCTL set_param obdfilter.${FSNAME}-*.sync_journal=0
103
104         local stime=$(date +%s)
105         thrlo=4 nobjhi=1 thrhi=4 obdflter_survey_run disk
106         local etime=$(date +%s)
107         # run time of obd survey
108         local rtime=$((etime - stime))
109
110         echo "obd survey finished in $rtime seconds"
111         restore_lustre_params < $param_file
112
113         rm -f $param_file
114 }
115 run_test 1b "Object Storage Targets survey, async journal"
116
117 test_1c () {
118         nobjlo=1 nobjhi=1 thrlo=32 thrhi=32 rszlo=1024 rszhi=1024 size=8192\
119         obdflter_survey_run disk
120 }
121 run_test 1c "Object Storage Targets survey, big batch"
122
123 test_2a () {
124         obdflter_survey_run netdisk
125 }
126 run_test 2a "Stripe F/S over the Network"
127
128 test_2b () {
129         local param_file=$TMP/$tfile-params
130
131         do_nodesv $(comma_list $(osts_nodes)) \
132                 $LCTL get_param obdfilter.${FSNAME}-*.sync_journal
133         save_lustre_params $(get_facets OST) \
134                 "obdfilter.${FSNAME}-*.sync_journal" > $param_file
135         do_nodesv $(comma_list $(osts_nodes)) \
136                 $LCTL set_param obdfilter.${FSNAME}-*.sync_journal=0
137
138         local stime=$(date +%s)
139         thrlo=4 nobjhi=1 thrhi=4 obdflter_survey_run netdisk
140         local etime=$(date +%s)
141         local rtime=$((etime - stime))
142
143         echo "obd survey finished in $rtime seconds"
144         restore_lustre_params < $param_file
145
146         rm -f $param_file
147 }
148 run_test 2b "Stripe F/S over the Network, async journal"
149
150
151 # README.obdfilter-survey: In network test only automated run is supported.
152 test_3a () {
153         # obdfilter-survey Prerequisite:
154         #    For "network" case  you need to have all
155         #    modules (those llmount.sh loads) loaded in kernel. And the
156         #    'lctl dl' output must be blank.
157         # Skipping test for CLIENTONLY mode because of
158         # cleanupall()->stopall() does not cleanup the servers on this mode.
159         [ "$CLIENTONLY" ] && skip "CLIENTONLY mode"
160
161         remote_servers || skip "Local servers"
162
163         cleanupall
164
165         obdflter_survey_run network
166
167         setupall
168 }
169 run_test 3a "Network survey"
170
171 complete $SECONDS
172 cleanup_echo_devs
173 check_and_cleanup_lustre
174 exit_status