Whamcloud - gitweb
LU-14707 tests: Bashify scripts for Ubuntu et. al.
[fs/lustre-release.git] / lustre / tests / sanityn.sh
index d433294..c1ead99 100755 (executable)
@@ -283,7 +283,7 @@ test_11() {
 run_test 11 "execution of file opened for write should return error ===="
 
 test_12() {
-       DIR=$DIR DIR2=$DIR2 sh lockorder.sh
+       DIR=$DIR DIR2=$DIR2 bash lockorder.sh
 }
 run_test 12 "test lock ordering (link, stat, unlink)"
 
@@ -361,7 +361,7 @@ run_test 14d "chmod of executing file is still possible ========"
 
 test_15() {    # bug 974 - ENOSPC
        echo "PATH=$PATH"
-       sh oos2.sh $MOUNT1 $MOUNT2
+       bash oos2.sh $MOUNT1 $MOUNT2
        wait_delete_completed
        grant_error=$(dmesg | grep "< tot_grant")
        [ -z "$grant_error" ] || error "$grant_error"
@@ -822,7 +822,7 @@ run_test 28 "read/write/truncate file with lost stripes"
 test_30() { #b=11110, LU-2523
        test_mkdir $DIR1/$tdir
        cp -f /bin/bash $DIR1/$tdir/bash
-       /bin/sh -c 'sleep 1; rm -f $DIR2/$tdir/bash; cp /bin/bash $DIR2/$tdir' &
+       bash -c 'sleep 1; rm -f $DIR2/$tdir/bash; cp /bin/bash $DIR2/$tdir' &
        $DIR1/$tdir/bash -c 'sleep 2;
                openfile -f O_RDONLY /proc/$$/exe >& /dev/null; echo $?'
        wait
@@ -866,6 +866,30 @@ test_31b() {
 }
 run_test 31b "voluntary OST cancel / blocking ast race=============="
 
+#LU-14949 - multi-client version of the test 31r in sanity.
+test_31r() {
+       touch $DIR/$tfile.target
+       touch $DIR/$tfile.source
+
+       ls -l $DIR/$tfile.target # cache it for sure
+
+       #OBD_FAIL_LLITE_OPEN_DELAY 0x1419
+       $LCTL set_param fail_loc=0x1419 fail_val=3
+       cat $DIR/$tfile.target &
+       CATPID=$!
+
+       # Guarantee open is waiting before we get here
+       sleep 1
+       mv $DIR2/$tfile.source $DIR2/$tfile.target
+
+       wait $CATPID
+       RC=$?
+       if [[ $RC -ne 0 ]]; then
+               error "open with cat failed, rc=$RC"
+       fi
+}
+run_test 31r "open-rename(replace) race"
+
 test_32b() { # bug 11270
        remote_ost_nodsh && skip "remote OST with nodsh" && return
 
@@ -921,22 +945,23 @@ test_32b() { # bug 11270
 #run_test 32b "lockless i/o"
 
 print_jbd_stat () {
-    local dev
-    local mdts=$(get_facets MDS)
-    local varcvs
-    local mds
-
-    local stat=0
-    for mds in ${mdts//,/ }; do
-        varsvc=${mds}_svc
-        dev=$(basename $(do_facet $mds "lctl get_param -n osd*.${!varsvc}.mntdev|\
-               xargs readlink -f" ))
-       val=$(do_facet $mds "cat /proc/fs/jbd*/${dev}{,:*,-*}/info 2>/dev/null |
-               head -n1")
-        val=${val%% *};
-        stat=$(( stat + val))
-    done
-    echo $stat
+       local mdts=$(get_facets MDS)
+       local stat=0
+       local varsvc
+       local dev
+       local mds
+
+       for mds in ${mdts//,/ }; do
+               varsvc=${mds}_svc
+
+               dev=$(basename $(do_facet $mds "lctl get_param -n \
+                       osd*.${!varsvc}.mntdev | xargs readlink -f"))
+               val=$(do_facet $mds "cat /proc/fs/jbd*/${dev}{,:*,-*}/info \
+                       2>/dev/null | head -n1")
+               val=${val%% *};
+               stat=$((stat + val))
+       done
+       echo $stat
 }
 
 # commit on sharing tests
@@ -1098,9 +1123,9 @@ op_trigger_cos() {
 
        # trigger CoS twice in case transaction commit before unlock
        for i in 1 2; do
-               sh -c "$1"
+               bash -c "$1"
                do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
-               sh -c "$2"
+               bash -c "$2"
                commit_nr=$(do_nodes $nodes \
                        "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
                total=$((total + commit_nr));
@@ -4392,6 +4417,77 @@ test_77n() { #LU-10802
 }
 run_test 77n "check wildcard support for TBF JobID NRS policy"
 
+test_77o() {
+       (( $OST1_VERSION > $(version_code 2.14.54) )) ||
+               skip "need OST > 2.14.54"
+
+       do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_policies="tbf\ nid"
+       do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="start\ name\ nid={192.168.*.*@tcp}\ rate=10000"
+       do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="start\ name1\ nid={192.168.*.*@tcp}\ rate=10000"
+       do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="change\ name1\ rank=name"
+       do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="stop\ name"
+       do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_policies="fifo"
+}
+run_test 77o "Changing rank should not panic"
+
+test_77q() {
+       local i
+
+       (( $MDS1_VERSION > $(version_code 2.14.54) )) ||
+               skip "need MDS >= 2.14.54"
+
+       do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_policies="tbf"
+       stack_trap "do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_policies=fifo"
+
+       for i in {1..50}; do
+               local pid1 pid2
+
+               do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="'start rule77q_1 uid={500}&gid={500} rate=100'" &
+               pid1=$!
+               do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="'start rule77q_2 uid={1000}&gid={1000} rate=100'" &
+               pid2=$!
+               wait $pid1 || error "$i: Fail to start TBF rule 'rule77q_1'"
+               wait $pid2 || error "$i: Fail to start TBF rule 'rule77q_2'"
+
+               do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="'stop rule77q_1'" &
+               pid1=$!
+               do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="'stop rule77q_2'" &
+               pid2=$!
+               wait $pid1 || error "$i: Fail to stop TBF rule 'rule77q_1'"
+               wait $pid2 || error "$i: Fail to stop TBF rule 'rule77q_2'"
+       done
+}
+run_test 77q "Parallel TBF rule definitions should not panic"
+
+test_77p() {
+       local c
+       local -a spec_chars=(
+               '@' '.' '~' '#' '/' '^' '%' '*' ';' ',' '?' '<' '>' ':'
+               '+' '=' ')' '(' '{' '}' '|' '[' ']' '!' '&' '\$' '\`' '\\')
+
+       (( $MDS1_VERSION > $(version_code 2.14.54) )) ||
+               skip "need MDS >= 2.14.54"
+
+       do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_policies="tbf"
+       stack_trap "do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_policies=fifo"
+
+       # TBF rule name size is 16 bytes
+       do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="start\ test_77p_overflo\ uid={500}\ rate=500" &&
+               error "The length of tbf rule name is not checked" || true
+       do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="start\ \ uid={500}\ rate=500" &&
+               error "The server should not accept empty tbf rule name" || true
+       do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="start\ test_77p_empty" &&
+               error "The server should not accept 'start <tbf_rule_name>' without an expression" || true
+
+       # Test with special chars
+       for c in "${spec_chars[@]}"; do
+               do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="'start test77p${c}spec uid={500} rate=500'" &&
+               error "Special char '${c}' should not be accepted in a tbf rule name" || true
+       done
+
+}
+run_test 77p "Check validity of rule names for TBF policies"
+
 test_78() { #LU-6673
        local rc
 
@@ -4450,6 +4546,7 @@ test_80a() {
        local file
        local pid
 
+       mkdir_on_mdt0 $DIR1/$tdir
        mkdir -p $DIR1/$tdir/dir
        createmany -o $DIR1/$tdir/dir/f 10 ||
                error "create files under remote dir failed $i"
@@ -5677,6 +5774,37 @@ test_111() {
 }
 run_test 111 "A racy rename/link an open file should not cause fs corruption"
 
+test_112() {
+       (( MDSCOUNT >= 2 )) ||
+               skip "We need at least 2 MDTs for this test"
+
+       (( MDS1_VERSION >= $(version_code 2.14.54) )) ||
+               skip "Need server version at least 2.14.54"
+
+       local rr
+       local count
+
+       rr=$($LCTL get_param -n lmv.*.qos_threshold_rr | head -n1)
+       rr=${rr%%%}
+       stack_trap "$LCTL set_param lmv.*.qos_threshold_rr=$rr > /dev/null"
+
+       mkdir -p $DIR1/$tdir/s1/s2 || error "mkdir s2 failed"
+       $LFS mkdir -i 0 $DIR1/$tdir/s1/s2/s3 || error "mkdir s3 failed"
+       $LFS setdirstripe -D -i -1 --max-inherit-rr=0 $DIR1/$tdir/s1/s2/s3 ||
+               error "setdirstripe s3 failed"
+       $LCTL set_param lmv.*.qos_threshold_rr=90
+       mkdir $DIR2/$tdir/s1/s2/s3/d{1..64}
+       count=$($LFS getstripe -m $DIR2/$tdir/s1/s2/s3/d* | grep ^0 | wc -l)
+       (( count == 64 )) || error "only $count subdirs created on MDT0"
+
+       $LFS setdirstripe -D -i -1 --max-inherit-rr=3 $DIR1/$tdir/s1/s2/s3 ||
+               error "setdirstripe s3 failed"
+       mkdir $DIR2/$tdir/s1/s2/s3/s{1..64}
+       count=$($LFS getstripe -m $DIR2/$tdir/s1/s2/s3/s* | grep ^0 | wc -l)
+       (( count == 64 / MDSCOUNT )) || error "$count subdirs created on MDT0"
+}
+run_test 112 "update max-inherit in default LMV"
+
 log "cleanup: ======================================================"
 
 # kill and wait in each test only guarentee script finish, but command in script