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