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