From 07b271c0972757772a129e9a6370dbb163f16a06 Mon Sep 17 00:00:00 2001 From: Elena Gryaznova Date: Mon, 11 Feb 2019 16:52:35 +0300 Subject: [PATCH] LU-11636 tests: fix test_mkdir() to work with old severs 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 , where 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 Cray-bug-id: LUS-6434, LUS-5500, LUS-6697 Reviewed-by: Vladimir Saveliev Reviewed-by: Alexander Boyko Change-Id: I3e6362a0b7c1d3987a289e492c8e9ad090f394d4 Reviewed-on: https://review.whamcloud.com/33611 Tested-by: Jenkins Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Alexandr Boyko Reviewed-by: Oleg Drokin --- lustre/tests/conf-sanity.sh | 1 - lustre/tests/sanity-hsm.sh | 3 +-- lustre/tests/sanity-quota.sh | 2 +- lustre/tests/sanity-scrub.sh | 4 ++-- lustre/tests/sanity.sh | 42 +++++++++++++++++++++--------------------- lustre/tests/test-framework.sh | 32 +++++++++++++++++++++----------- 6 files changed, 46 insertions(+), 38 deletions(-) diff --git a/lustre/tests/conf-sanity.sh b/lustre/tests/conf-sanity.sh index 1971070..ca26bd6 100644 --- a/lustre/tests/conf-sanity.sh +++ b/lustre/tests/conf-sanity.sh @@ -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 diff --git a/lustre/tests/sanity-hsm.sh b/lustre/tests/sanity-hsm.sh index 69e3ac3..eefb8ec 100755 --- a/lustre/tests/sanity-hsm.sh +++ b/lustre/tests/sanity-hsm.sh @@ -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 diff --git a/lustre/tests/sanity-quota.sh b/lustre/tests/sanity-quota.sh index 921f67e..54e1bf6 100755 --- a/lustre/tests/sanity-quota.sh +++ b/lustre/tests/sanity-quota.sh @@ -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} diff --git a/lustre/tests/sanity-scrub.sh b/lustre/tests/sanity-scrub.sh index 16cac0b..92c913a 100644 --- a/lustre/tests/sanity-scrub.sh +++ b/lustre/tests/sanity-scrub.sh @@ -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 || diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 531b149..bdc08f2 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -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 | diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh index 03f5af0..fb831e1 100755 --- a/lustre/tests/test-framework.sh +++ b/lustre/tests/test-framework.sh @@ -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 } -- 1.8.3.1