Whamcloud - gitweb
LU-15210 tests: fix sanity-lnet to handle duplicate IP
[fs/lustre-release.git] / lustre / tests / obdfilter-survey.sh
1 #!/bin/bash
2 set -e
3
4 LUSTRE=${LUSTRE:-$(dirname $0)/..}
5 . $LUSTRE/tests/test-framework.sh
6 init_test_env $@
7 init_logging
8
9 # bug number for skipped test:
10 ALWAYS_EXCEPT="$OBDFILTER_SURVEY_EXCEPT "
11 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
12
13 build_test_filter
14
15 [ "$SLOW" = no ] && { nobjhi=1; thrhi=4; }
16 nobjhi=${nobjhi:-1}
17 thrhi=${thrhi:-16}
18 size=${size:-1024}
19 thrlo=${thrlo:-$(( thrhi / 2))}
20
21 OBDSURVEY=${OBDSURVEY:-$(which obdfilter-survey)}
22
23 check_and_setup_lustre
24
25 # FIXME: the summary file a bit smaller than OSTSIZE, add estimation
26 minsize=$(min_ost_size)
27 if [ $(( size * 1024 )) -ge $minsize  ]; then
28     size=$((minsize * 10 / 1024 / 12 ))
29     echo min kbytesavail: $minsize using size=${size} MBytes per obd instance
30 fi
31
32 get_targets () {
33         local targets
34         local target
35         local dev
36         local nid
37         local osc
38
39         for osc in $($LCTL get_param -N osc.${FSNAME}-*osc-*); do
40                 nid=$($LCTL get_param $osc.import |
41                         awk '/current_connection:/ {sub(/@.*/,""); print $2}')
42                 dev=$(echo $osc | sed -e 's/^osc\.//' -e 's/-osc.*//')
43                 target=$dev
44
45                 # For local disk obdfilter-survey requires target devs w/o nid.
46                 # obdfilter-survey :
47                 # case 1 (local disk):
48                 #    $ nobjhi=2 thrhi=2 size=1024
49                 #      targets="$nid:$FSNAME-OST0000 $nid:$FSNAME-OST0001 ..."
50                 #                 sh obdfilter-survey
51                 local_node && [ "$1" == "disk" ] || target=$nid:$target
52                 targets="$targets $target"
53         done
54         echo $targets
55 }
56
57 obdflter_survey_targets () {
58         local case=$1
59         local targets
60
61         case $case in
62                 disk)    targets=$(get_targets $case);;
63                 netdisk) targets=$(get_targets $case);;
64                 network) targets=$(host_nids_address $(comma_list $(osts_nodes)) $NETTYPE);;
65                 *) error "unknown obdflter-survey case!" ;;
66         esac
67         echo $targets
68 }
69
70 obdflter_survey_run () {
71         local case=$1
72
73         rm -f ${TMP}/obdfilter_survey*
74
75         local targets=$(obdflter_survey_targets $case)
76         local cmd="NETTYPE=$NETTYPE thrlo=$thrlo nobjhi=$nobjhi thrhi=$thrhi size=$size case=$case rslt_loc=${TMP} targets=\"$targets\" $OBDSURVEY"
77         echo + $cmd
78         eval $cmd
79         local rc=$?
80
81         cat ${TMP}/obdfilter_survey*
82         [ $rc = 0 ] || error "$OBDSURVEY failed: $rc"
83 }
84
85 test_1a () {
86         obdflter_survey_run disk
87 }
88 run_test 1a "Object Storage Targets survey"
89
90 test_1b () {
91         local param_file=$TMP/$tfile-params
92
93         do_nodesv $(comma_list $(osts_nodes)) \
94                 $LCTL get_param obdfilter.${FSNAME}-*.sync_journal
95         save_lustre_params $(get_facets OST) \
96                 "obdfilter.${FSNAME}-*.sync_journal" > $param_file
97         do_nodesv $(comma_list $(osts_nodes)) \
98                 $LCTL set_param obdfilter.${FSNAME}-*.sync_journal=0
99
100         local stime=$(date +%s)
101         thrlo=4 nobjhi=1 thrhi=4 obdflter_survey_run disk
102         local etime=$(date +%s)
103         # run time of obd survey
104         local rtime=$((etime - stime))
105
106         echo "obd survey finished in $rtime seconds"
107         restore_lustre_params < $param_file
108
109         rm -f $param_file
110 }
111 run_test 1b "Object Storage Targets survey, async journal"
112
113 test_1c () {
114         nobjlo=1 nobjhi=1 thrlo=32 thrhi=32 rszlo=1024 rszhi=1024 size=8192\
115         obdflter_survey_run disk
116 }
117 run_test 1c "Object Storage Targets survey, big batch"
118
119 test_2a () {
120         obdflter_survey_run netdisk
121 }
122 run_test 2a "Stripe F/S over the Network"
123
124 test_2b () {
125         local param_file=$TMP/$tfile-params
126
127         do_nodesv $(comma_list $(osts_nodes)) \
128                 $LCTL get_param obdfilter.${FSNAME}-*.sync_journal
129         save_lustre_params $(get_facets OST) \
130                 "obdfilter.${FSNAME}-*.sync_journal" > $param_file
131         do_nodesv $(comma_list $(osts_nodes)) \
132                 $LCTL set_param obdfilter.${FSNAME}-*.sync_journal=0
133
134         local stime=$(date +%s)
135         thrlo=4 nobjhi=1 thrhi=4 obdflter_survey_run netdisk
136         local etime=$(date +%s)
137         local rtime=$((etime - stime))
138
139         echo "obd survey finished in $rtime seconds"
140         restore_lustre_params < $param_file
141
142         rm -f $param_file
143 }
144 run_test 2b "Stripe F/S over the Network, async journal"
145
146
147 # README.obdfilter-survey: In network test only automated run is supported.
148 test_3a () {
149         # obdfilter-survey Prerequisite:
150         #    For "network" case  you need to have all
151         #    modules (those llmount.sh loads) loaded in kernel. And the
152         #    'lctl dl' output must be blank.
153         # Skipping test for CLIENTONLY mode because of
154         # cleanupall()->stopall() does not cleanup the servers on this mode.
155         [ "$CLIENTONLY" ] && skip "CLIENTONLY mode"
156
157         remote_servers || skip "Local servers"
158
159         cleanupall
160
161         obdflter_survey_run network
162
163         setupall
164 }
165 run_test 3a "Network survey"
166
167 complete $SECONDS
168 cleanup_echo_devs
169 check_and_cleanup_lustre
170 exit_status