Whamcloud - gitweb
LU-11636 tests: fix test_mkdir() to work with old severs 11/33611/11
authorElena Gryaznova <c17455@cray.com>
Mon, 11 Feb 2019 13:52:35 +0000 (16:52 +0300)
committerOleg Drokin <green@whamcloud.com>
Mon, 8 Apr 2019 05:35:11 +0000 (05:35 +0000)
Patch fixes the following test_mkdir() defects:
- test_mkdir() always creates striped dir, this breaks interop
  testing with non DNEII servers. For old servers stripe count
  is supposed to be set to 1. The tests which call
  test_mkdir() -c <value>, where <value> is greater than 1 should
  take care about interop with old servers and be skipped for
  such servers.
- test_mkdir() creates the striped dir with -c2 only, this limits
  the testing on MDSCOUNT > 2 config.
Patch adds the possibilities:
- to specify the exact stripe count if DIRSTRIPE_COUNT set;
  default is random and does not depend on the test number now.
- to specify the exact stripe index if DIRSTRIPE_INDEX set;
  default is not changed (random).
- set stripe count to 1 for servers without DNE2 (< 2.8.0).

Patch moves get_lustre_env call (added by LU-11607) from sanity.sh,
conf-sanity.sh and sanity-quota.sh to init_logging(). This allows
$MDS1_VERSION to be used in test_mkdir() instead of having to add
get_lustre_env() to every test script test_mkdir() is used in.

Patch does fix sanity 120a(), 120f() to operate with predictable
MDT index. We did not see this failure before test_mkdir()
improvements because tests were never run with mdt_index other
than equal to 0: the randomization
  mdt_index=$((test_num % MDSCOUNT))
  had set mdt_index equal to 0 for MDSCOUNT {1..6} for these tests.

Patch fixes sanity-scrub.sh:scrub_prep() to create $nfiles on mds$n
and sanity-scrub.sh:test_11() to create $CREATED files on each mds.

Signed-off-by: Elena Gryaznova <c17455@cray.com>
Cray-bug-id: LUS-6434, LUS-5500, LUS-6697
Reviewed-by: Vladimir Saveliev <c17830@cray.com>
Reviewed-by: Alexander Boyko <c17825@cray.com>
Change-Id: I3e6362a0b7c1d3987a289e492c8e9ad090f394d4
Reviewed-on: https://review.whamcloud.com/33611
Tested-by: Jenkins
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Alexandr Boyko <c17825@cray.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/tests/conf-sanity.sh
lustre/tests/sanity-hsm.sh
lustre/tests/sanity-quota.sh
lustre/tests/sanity-scrub.sh
lustre/tests/sanity.sh
lustre/tests/test-framework.sh

index 1971070..ca26bd6 100644 (file)
@@ -30,7 +30,6 @@ export MULTIOP=${MULTIOP:-multiop}
 . $LUSTRE/tests/test-framework.sh
 init_test_env $@
 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
-get_lustre_env
 
 # use small MDS + OST size to speed formatting time
 # do not use too small MDSSIZE/OSTSIZE, which affect the default journal size
index 69e3ac3..eefb8ec 100755 (executable)
@@ -33,7 +33,6 @@ OPENFILE=${OPENFILE:-openfile}
 MMAP_CAT=${MMAP_CAT:-mmap_cat}
 MOUNT_2=${MOUNT_2:-"yes"}
 FAIL_ON_ERROR=false
-MDS_VERSION_CODE=$(lustre_version_code $SINGLEMDS)
 
 # script only handles up to 10 MDTs (because of MDT_PREFIX)
 [ $MDSCOUNT -gt 9 ] &&
@@ -41,7 +40,7 @@ MDS_VERSION_CODE=$(lustre_version_code $SINGLEMDS)
 
 check_and_setup_lustre
 
-if [[ $MDS_VERSION_CODE -lt $(version_code 2.4.53) ]]; then
+if [[ $MDS1_VERSION -lt $(version_code 2.4.53) ]]; then
        skip_env "Need MDS version at least 2.4.53"
 fi
 
index 921f67e..54e1bf6 100755 (executable)
@@ -34,7 +34,7 @@ LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
 . $LUSTRE/tests/test-framework.sh
 init_test_env $@
 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
-get_lustre_env
+
 init_logging
 DIRECTIO=${DIRECTIO:-$LUSTRE/tests/directio}
 
index 16cac0b..92c913a 100644 (file)
@@ -100,7 +100,7 @@ scrub_prep() {
        echo "preparing... $(date)"
        for n in $(seq $MDSCOUNT); do
                echo "creating $nfiles files on mds$n"
-               test_mkdir -i $((n - 1)) $DIR/$tdir/mds$n ||
+               test_mkdir -i $((n - 1)) -c1 $DIR/$tdir/mds$n ||
                        error "Failed to create directory mds$n"
                cp $LUSTRE/tests/*.sh $DIR/$tdir/mds$n ||
                        error "Failed to copy files to mds$n"
@@ -1025,7 +1025,7 @@ test_11() {
        check_mount_and_prep
 
        for n in $(seq $MDSCOUNT); do
-               test_mkdir -i $((n - 1)) $DIR/$tdir/mds$n ||
+               test_mkdir -i $((n - 1)) -c1 $DIR/$tdir/mds$n ||
                        error "(1) Fail to mkdir $DIR/$tdir/mds$n"
 
                createmany -o $DIR/$tdir/mds$n/f $CREATED ||
index 531b149..bdc08f2 100755 (executable)
@@ -70,7 +70,7 @@ LUSTRE_TESTS_API_DIR=${LUSTRE_TESTS_API_DIR:-${LUSTRE}/tests/clientapi}
 . $LUSTRE/tests/test-framework.sh
 init_test_env $@
 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
-get_lustre_env
+
 init_logging
 
 #                                  5          12          (min)"
@@ -9682,7 +9682,7 @@ run_test 119d "The DIO path should try to send a new rpc once one is completed"
 test_120a() {
        [ $PARALLEL == "yes" ] && skip "skip parallel run"
        remote_mds_nodsh && skip "remote MDS with nodsh"
-       test_mkdir $DIR/$tdir
+       test_mkdir -i0 -c1 $DIR/$tdir
        $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
                skip_env "no early lock cancel on server"
 
@@ -9693,13 +9693,13 @@ test_120a() {
        cancel_lru_locks osc
 
        stat $DIR/$tdir > /dev/null
-       can1=$(do_facet $SINGLEMDS \
+       can1=$(do_facet mds1 \
               "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
               awk '/ldlm_cancel/ {print $2}')
        blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
               awk '/ldlm_bl_callback/ {print $2}')
-       test_mkdir -c1 $DIR/$tdir/d1
-       can2=$(do_facet $SINGLEMDS \
+       test_mkdir -i0 -c1 $DIR/$tdir/d1
+       can2=$(do_facet mds1 \
               "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
               awk '/ldlm_cancel/ {print $2}')
        blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
@@ -9743,24 +9743,24 @@ run_test 120b "Early Lock Cancel: create test"
 test_120c() {
        [ $PARALLEL == "yes" ] && skip "skip parallel run"
        remote_mds_nodsh && skip "remote MDS with nodsh"
-       test_mkdir -c1 $DIR/$tdir
+       test_mkdir -i0 -c1 $DIR/$tdir
        $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
                skip "no early lock cancel on server"
 
        lru_resize_disable mdc
        lru_resize_disable osc
-       test_mkdir -c1 $DIR/$tdir/d1
-       test_mkdir -c1 $DIR/$tdir/d2
+       test_mkdir -i0 -c1 $DIR/$tdir/d1
+       test_mkdir -i0 -c1 $DIR/$tdir/d2
        touch $DIR/$tdir/d1/f1
        cancel_lru_locks mdc
        stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
-       can1=$(do_facet $SINGLEMDS \
+       can1=$(do_facet mds1 \
               "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
               awk '/ldlm_cancel/ {print $2}')
        blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
               awk '/ldlm_bl_callback/ {print $2}')
        ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
-       can2=$(do_facet $SINGLEMDS \
+       can2=$(do_facet mds1 \
               "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
               awk '/ldlm_cancel/ {print $2}')
        blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
@@ -9775,7 +9775,7 @@ run_test 120c "Early Lock Cancel: link test"
 test_120d() {
        [ $PARALLEL == "yes" ] && skip "skip parallel run"
        remote_mds_nodsh && skip "remote MDS with nodsh"
-       test_mkdir -c1 $DIR/$tdir
+       test_mkdir -i0 -c1 $DIR/$tdir
        $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
                skip_env "no early lock cancel on server"
 
@@ -9784,13 +9784,13 @@ test_120d() {
        touch $DIR/$tdir
        cancel_lru_locks mdc
        stat $DIR/$tdir > /dev/null
-       can1=$(do_facet $SINGLEMDS \
+       can1=$(do_facet mds1 \
               "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
               awk '/ldlm_cancel/ {print $2}')
        blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
               awk '/ldlm_bl_callback/ {print $2}')
        chmod a+x $DIR/$tdir
-       can2=$(do_facet $SINGLEMDS \
+       can2=$(do_facet mds1 \
               "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
               awk '/ldlm_cancel/ {print $2}')
        blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
@@ -9810,7 +9810,7 @@ test_120e() {
 
        local dlmtrace_set=false
 
-       test_mkdir -c1 $DIR/$tdir
+       test_mkdir -i0 -c1 $DIR/$tdir
        lru_resize_disable mdc
        lru_resize_disable osc
        ! $LCTL get_param debug | grep -q dlmtrace &&
@@ -9824,14 +9824,14 @@ test_120e() {
        # during unlink (LU-4206), so cancel osc lock now.
        sleep 2
        cancel_lru_locks osc
-       can1=$(do_facet $SINGLEMDS \
+       can1=$(do_facet mds1 \
               "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
               awk '/ldlm_cancel/ {print $2}')
        blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
               awk '/ldlm_bl_callback/ {print $2}')
        unlink $DIR/$tdir/f1
        sleep 5
-       can2=$(do_facet $SINGLEMDS \
+       can2=$(do_facet mds1 \
               "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
               awk '/ldlm_cancel/ {print $2}')
        blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
@@ -9852,11 +9852,11 @@ test_120f() {
                skip_env "no early lock cancel on server"
        remote_mds_nodsh && skip "remote MDS with nodsh"
 
-       test_mkdir -c1 $DIR/$tdir
+       test_mkdir -i0 -c1 $DIR/$tdir
        lru_resize_disable mdc
        lru_resize_disable osc
-       test_mkdir -c1 $DIR/$tdir/d1
-       test_mkdir -c1 $DIR/$tdir/d2
+       test_mkdir -i0 -c1 $DIR/$tdir/d1
+       test_mkdir -i0 -c1 $DIR/$tdir/d2
        dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
        dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
        cancel_lru_locks mdc
@@ -9868,14 +9868,14 @@ test_120f() {
        # during rename (LU-4206), so cancel osc lock now.
        sleep 2
        cancel_lru_locks osc
-       can1=$(do_facet $SINGLEMDS \
+       can1=$(do_facet mds1 \
               "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
               awk '/ldlm_cancel/ {print $2}')
        blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
               awk '/ldlm_bl_callback/ {print $2}')
        mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
        sleep 5
-       can2=$(do_facet $SINGLEMDS \
+       can2=$(do_facet mds1 \
               "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
               awk '/ldlm_cancel/ {print $2}')
        blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
index 03f5af0..fb831e1 100755 (executable)
@@ -7944,6 +7944,8 @@ init_logging() {
                    do_facet $SINGLEMDS $LCTL --version)"
        log "OSS: $(do_facet ost1 $LCTL lustre_build_version 2> /dev/null ||
                    do_facet ost1 $LCTL --version)"
+
+       get_lustre_env
 }
 
 log_test() {
@@ -8350,14 +8352,14 @@ generate_logname() {
 test_mkdir() {
        local path
        local p_option
-       local stripe_count=2
-       local stripe_index=-1
+       local dirstripe_count=${DIRSTRIPE_COUNT:-"-1"}
+       local dirstripe_index=${DIRSTRIPE_INDEX:-"-1"}
        local OPTIND=1
 
        while getopts "c:i:p" opt; do
                case $opt in
-                       c) stripe_count=$OPTARG;;
-                       i) stripe_index=$OPTARG;;
+                       c) dirstripe_count=$OPTARG;;
+                       i) dirstripe_index=$OPTARG;;
                        p) p_option="-p";;
                        \?) error "only support -i -c -p";;
                esac
@@ -8380,17 +8382,25 @@ test_mkdir() {
        if [ $MDSCOUNT -le 1 ]; then
                mkdir $path || error "mkdir '$path' failed"
        else
-               local test_num=$(echo $testnum | sed -e 's/[^0-9]*//g')
                local mdt_index
 
-               if [ $stripe_index -eq -1 ]; then
-                       mdt_index=$((test_num % MDSCOUNT))
+               if [ $dirstripe_index -eq -1 ]; then
+                       mdt_index=$((RANDOM % MDSCOUNT))
+               else
+                       mdt_index=$dirstripe_index
+               fi
+
+               if (($MDS1_VERSION >= $(version_code 2.8.0))); then
+                       if [ $dirstripe_count -eq -1 ]; then
+                               dirstripe_count=$((RANDOM % MDSCOUNT + 1))
+                       fi
                else
-                       mdt_index=$stripe_index
+                       dirstripe_count=1
                fi
-               echo "striped dir -i$mdt_index -c$stripe_count $path"
-               $LFS mkdir -i$mdt_index -c$stripe_count $path ||
-                       error "mkdir -i $mdt_index -c$stripe_count $path failed"
+
+               echo "striped dir -i$mdt_index -c$dirstripe_count $path"
+               $LFS mkdir -i$mdt_index -c$dirstripe_count $path ||
+                       error "mkdir -i $mdt_index -c$dirstripe_count $path failed"
        fi
 }