Whamcloud - gitweb
LU-2040 tests: interop test failure on mds-survey
[fs/lustre-release.git] / lustre / tests / mds-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 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
9 init_logging
10
11 file_count=${file_count:-150000}
12 dir_count=${dir_count:-4}
13 thrhi=${thrhi:-8}
14 thrlo=${thrlo:-1}
15
16 [ "$SLOW" = no ] && { file_count=50000; dir_count=2; thrhi=4; }
17
18 # Skip these tests
19 ALWAYS_EXCEPT="$MDS_SURVEY_EXCEPT"
20
21 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
22 if [ -z ${MDSSURVEY} ]; then
23     skip_env "mds-survey not found" && exit
24 fi
25
26 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.51) ]; then
27         skip_env "Need MDS version at least 2.3.51" && exit
28 fi
29
30 build_test_filter
31 check_and_setup_lustre
32
33 adjust_inode() {
34     local require_inode=0
35     local avail_mdt_inode=0
36     local avail_ost_inode=0
37
38     require_inode=$((file_count * thrhi))
39     # get available inode for mdt
40     avail_mdt_inode=$($LFS df -i $MOUNT | grep "filesystem summary:"  | \
41         awk '{print $5}')
42     avail_mdt_inode=$((avail_mdt_inode * 9 / 10))
43
44     # get available inode for ost
45     for i in $($LFS df -i | grep ${FSNAME}-OST | awk '{print $4}'); do
46         avail_ost_inode=$((avail_ost_inode + i))
47     done
48     avail_ost_inode=$((avail_ost_inode * 9 / 10))
49
50     ((require_inode > avail_mdt_inode)) && require_inode=$avail_mdt_inode
51     ((require_inode > avail_ost_inode)) && require_inode=$avail_ost_inode
52
53     if ((require_inode == 0)); then
54         error "Fail to get the inode count"
55     fi
56     # convert it back to per thread inode
57     require_inode=$((require_inode / thrhi))
58
59     echo $require_inode
60 }
61
62
63 file_count=$(adjust_inode)
64 ost_count=$($LCTL dl | grep -c osc)
65
66 # first unmount all the lustre clients
67 cleanup_mount $MOUNT
68 cleanup_mount $MOUNT2
69
70 get_target() {
71     local mds=$(facet_host $SINGLEMDS)
72     echo $(do_nodes $mds 'lctl dl' | \
73         awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
74 }
75
76 mds_survey_run() {
77     local layer=${1:-mdd}
78     local stripe_count=${2:-0}
79     local mds=$(facet_host $SINGLEMDS)
80     local rc=0
81
82     rm -f ${TMP}/mds_survey*
83
84     local target=$(get_target)
85     local cmd="file_count=$file_count thrlo=$thrlo thrhi=$thrhi"
86     local cmd+=" dir_count=$dir_count layer=$layer stripe_count=$stripe_count"
87     local cmd+=" rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
88
89     echo + $cmd
90     eval $cmd || rc=$?
91     cat ${TMP}/mds_survey*
92     rm -f ${TMP}/mds_survey*
93     ((rc == 0)) || error "mds-survey failed"
94 }
95
96 test_1() {
97     mds_survey_run "mdd" "0"
98 }
99 run_test 1 "Metadata survey with zero-stripe"
100
101 test_2() {
102     if [ $ost_count -eq 0 ]; then
103         skip_env "Need to mount OST to test" && return
104     fi
105     mds_survey_run "mdd" "1"
106 }
107 run_test 2 "Metadata survey with stripe_count = 1"
108
109 # remount the clients
110 restore_mount $MOUNT
111
112 complete $(basename $0) $SECONDS
113 cleanup_echo_devs
114 check_and_cleanup_lustre
115 exit_status