Whamcloud - gitweb
c994e1e75a93716d64cd69af022b3ddb0298c103
[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
16 [ "$SLOW" = no ] && { nobjhi=1; thrhi=4; }
17
18 # Skip these tests
19 ALWAYS_EXCEPT="$OBDFILTER_SURVEY_EXCEPT"
20
21 OBDSURVEY=${OBDSURVEY:-$(which obdfilter-survey)}
22
23 build_test_filter
24 check_and_setup_lustre
25
26 min_ost_size () {
27     $LCTL get_param -n osc.*.kbytesavail | sort -n | head -n1
28 }
29
30 # FIXME: the summary file a bit smaller than OSTSIZE, add estimation
31 minsize=$(min_ost_size)
32 if [ $(( size * 1024 )) -ge $minsize  ]; then
33     size=$((minsize * 10 / 1024 / 12 ))
34     echo min kbytesavail: $minsize using size=${size} MBytes per obd instance
35 fi
36
37 get_targets () {
38         local targets
39         local devs
40         local oss
41
42         for oss in $(osts_nodes); do
43                 devs=$(do_node $oss "lctl dl |grep obdfilter |sort" | awk '{print $4}')
44                 for d in $devs; do
45                         # if oss is local -- obdfilter-survey needs dev wo/ host
46                         target=$d
47                         [[ $oss = `hostname` ]] || target=$oss:$target
48                         targets="$targets $target"
49                 done
50         done
51
52         echo $targets
53 }
54
55 test_1 () {
56         rm -f ${TMP}/obdfilter_survey*
57
58         local targets=$(get_targets)
59         local cmd="nobjhi=$nobjhi thrhi=$thrhi size=$size case=disk rslt_loc=${TMP} targets=\"$targets\" sh $OBDSURVEY"
60         echo + $cmd
61         eval $cmd
62
63         cat ${TMP}/obdfilter_survey*
64 }
65 run_test 1 "Object Storage Targets survey"
66
67 test_2 () {
68         rm -f ${TMP}/obdfilter_survey*
69
70         local targets=$(get_targets)
71         local cmd="nobjhi=$nobjhi thrhi=$thrhi size=$size rslt_loc=${TMP} case=netdisk targets=\"$targets\" sh $OBDSURVEY"
72         echo + $cmd
73         eval $cmd
74
75         cat ${TMP}/obdfilter_survey*
76 }
77 run_test 2 "Stripe F/S over the Network"
78
79 # README.obdfilter-survey: In network test only automated run is supported.
80 test_3 () {
81         remote_servers || { skip "Local servers" && return 0; }
82
83
84         rm -f ${TMP}/obdfilter_survey*
85         # The Network survey test needs:
86         # Start lctl and check for the device list. The device list must be empty.
87         cleanupall
88
89         local cmd="nobjhi=2 thrhi=4 size=$size targets="$(osts_nodes)" case=network sh $OBDSURVEY"
90         echo + $cmd
91         eval $cmd
92
93         cat ${TMP}/obdfilter_survey*
94         setupall
95 }
96 run_test 3 "Network survey"
97
98 equals_msg `basename $0`: test complete, cleaning up
99 cleanup_echo_devs
100 check_and_cleanup_lustre
101 [ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG || true