Whamcloud - gitweb
059694e5c7c7d31a48eb4aaa3597a5c7d4098f9b
[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                 #                 ./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                 network) targets=$(host_nids_address $(comma_list $(osts_nodes)) $NETTYPE);;
64                 *) error "unknown obdflter-survey case!" ;;
65         esac
66         echo $targets
67 }
68
69 obdflter_survey_run () {
70         local case=$1
71
72         rm -f ${TMP}/obdfilter_survey*
73
74         local targets=$(obdflter_survey_targets $case)
75         local cmd="NETTYPE=$NETTYPE thrlo=$thrlo nobjhi=$nobjhi thrhi=$thrhi size=$size case=$case rslt_loc=${TMP} targets=\"$targets\" $OBDSURVEY"
76         echo + $cmd
77         eval $cmd
78         local rc=$?
79
80         cat ${TMP}/obdfilter_survey*
81         [ $rc = 0 ] || error "$OBDSURVEY failed: $rc"
82 }
83
84 test_1a () {
85         obdflter_survey_run disk
86 }
87 run_test 1a "Object Storage Targets survey"
88
89 test_1b () {
90         local param_file=$TMP/$tfile-params
91
92         do_nodesv $(comma_list $(osts_nodes)) \
93                 $LCTL get_param obdfilter.${FSNAME}-*.sync_journal
94         save_lustre_params $(get_facets OST) \
95                 "obdfilter.${FSNAME}-*.sync_journal" > $param_file
96         do_nodesv $(comma_list $(osts_nodes)) \
97                 $LCTL set_param obdfilter.${FSNAME}-*.sync_journal=0
98
99         local stime=$(date +%s)
100         thrlo=4 nobjhi=1 thrhi=4 obdflter_survey_run disk
101         local etime=$(date +%s)
102         # run time of obd survey
103         local rtime=$((etime - stime))
104
105         echo "obd survey finished in $rtime seconds"
106         restore_lustre_params < $param_file
107
108         rm -f $param_file
109 }
110 run_test 1b "Object Storage Targets survey, async journal"
111
112 test_1c () {
113         nobjlo=1 nobjhi=1 thrlo=32 thrhi=32 rszlo=1024 rszhi=1024 size=8192\
114         obdflter_survey_run disk
115 }
116 run_test 1c "Object Storage Targets survey, big batch"
117
118 test_2a () {
119         skip "netdisk was removed"
120 }
121 run_test 2a "Stripe F/S over the Network"
122
123 test_2b () {
124         skip "netdisk was removed"
125 }
126 run_test 2b "Stripe F/S over the Network, async journal"
127
128
129 # README.obdfilter-survey: In network test only automated run is supported.
130 test_3a () {
131         # obdfilter-survey Prerequisite:
132         #    For "network" case  you need to have all
133         #    modules (those llmount.sh loads) loaded in kernel. And the
134         #    'lctl dl' output must be blank.
135         # Skipping test for CLIENTONLY mode because of
136         # cleanupall()->stopall() does not cleanup the servers on this mode.
137         [ "$CLIENTONLY" ] && skip "CLIENTONLY mode"
138
139         remote_servers || skip "Local servers"
140
141         cleanupall
142
143         obdflter_survey_run network
144
145         setupall
146 }
147 run_test 3a "Network survey"
148
149 complete $SECONDS
150 cleanup_echo_devs
151 check_and_cleanup_lustre
152 exit_status