Whamcloud - gitweb
bz=23673 add "updates" dir to lustre-modules location.
[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 obdflter_survey_targets () {
56         local case=$1
57         local targets
58
59         case $case in
60                 disk)    targets=$(get_targets);;
61                 netdisk) targets=$(get_targets);;
62                 network) targets="$(osts_nodes)";;
63                 *) error "unknown obdflter-survey case!" ;;
64         esac
65         echo $targets
66 }
67
68 obdflter_survey_run () {
69         local case=$1
70
71         rm -f ${TMP}/obdfilter_survey*
72
73         local targets=$(obdflter_survey_targets $case)
74         local cmd="NETTYPE=$NETTYPE thrlo=$thrlo nobjhi=$nobjhi thrhi=$thrhi size=$size case=$case rslt_loc=${TMP} targets=\"$targets\" sh $OBDSURVEY"
75         echo + $cmd
76         eval $cmd
77
78         cat ${TMP}/obdfilter_survey*
79 }
80 test_1a () {
81         obdflter_survey_run disk
82 }
83 run_test 1a "Object Storage Targets survey"
84
85 test_2a () {
86         obdflter_survey_run netdisk
87 }
88 run_test 2a "Stripe F/S over the Network"
89
90 # README.obdfilter-survey: In network test only automated run is supported.
91 test_3a () {
92         remote_servers || { skip "Local servers" && return 0; }
93
94         # The Network survey test needs:
95         # Start lctl and check for the device list. The device list must be empty.
96         cleanupall
97
98         obdflter_survey_run network
99
100         setupall
101 }
102 run_test 3a "Network survey"
103
104 equals_msg `basename $0`: test complete, cleaning up
105 cleanup_echo_devs
106 check_and_cleanup_lustre
107 [ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG && grep -q FAIL $TESTSUITELOG && exit 1 || true