Whamcloud - gitweb
LU-10698 obdclass: allow specifying complex jobids
[fs/lustre-release.git] / lustre / tests / sanity.sh
index c8a880d..c42f169 100755 (executable)
@@ -69,11 +69,10 @@ if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
        [ "$SLOW" = "no" ] && EXCEPT_SLOW="$EXCEPT_SLOW 51b"
 fi
 
-# Get the SLES version so we can make decisions on if a test should be run
+# Get the SLES distro version
 #
 # Returns a version string that should only be used in comparing
 # strings returned by version_code()
-
 sles_version_code()
 {
        local version=$(grep VERSION_ID /etc/os-release | cut -d'"' -f2)
@@ -83,6 +82,8 @@ sles_version_code()
        version_code $sles_version
 }
 
+# Check if we are running on Ubuntu or SLES so we can make decisions on
+# what tests to run
 if [ -r /etc/SuSE-release ]; then
        sles_version=$(sles_version_code)
        [ $sles_version -lt $(version_code 11.4.0) ] &&
@@ -91,6 +92,21 @@ if [ -r /etc/SuSE-release ]; then
        [ $sles_version -lt $(version_code 12.0.0) ] &&
                # bug number for skipped test: LU-3703
                ALWAYS_EXCEPT="$ALWAYS_EXCEPT  234"
+elif [ -r /etc/os-release ]; then
+       if grep -qi ubuntu /etc/os-release; then
+               ubuntu_version=$(version_code $(sed -n -e 's/"//g' \
+                                               -e 's/^VERSION=//p' \
+                                               /etc/os-release |
+                                               awk '{ print $1 }'))
+
+               if [[ $ubuntu_version -gt $(version_code 16.0.0) ]]; then
+                       # bug number for skipped test:
+                       #                LU-10334 LU-10335 LU-10335 LU-10335
+                       ALWAYS_EXCEPT+=" 103a     130a     130b     130c"
+                       #                LU-10335 LU-10335 LU-10365 LU-10366
+                       ALWAYS_EXCEPT+=" 130d     130e     400a     410"
+               fi
+       fi
 fi
 
 FAIL_ON_ERROR=false
@@ -652,6 +668,7 @@ test_17m() {
        df $MOUNT > /dev/null 2>&1
        [ $rc -eq 0 ] ||
                error "e2fsck detected error for short/long symlink: rc=$rc"
+       rm -f $wdir/*
 }
 run_test 17m "run e2fsck against MDT which contains short/long symlink"
 
@@ -6312,6 +6329,7 @@ test_64d() {
                skip "OST < 2.10.55 doesn't limit grants enough" && return 0
 
        local tgt=$($LCTL dl | grep "0000-osc-[^mM]" | awk '{print $4}')
+       local file=$DIR/$tfile
 
        [[ $($LCTL get_param osc.${tgt}.import |
                    grep "connect_flags:.*grant_param") ]] || \
@@ -6322,9 +6340,10 @@ test_64d() {
        $LCTL set_param debug="$OLDDEBUG" 2> /dev/null || true
 
        local max_cur_granted=$(($(want_grant $tgt) + $(grant_chunk $tgt)))
+       stack_trap "rm -f $file" EXIT
 
-       $SETSTRIPE $DIR/$tfile -i 0 -c 1
-       dd if=/dev/zero of=$DIR/$tfile bs=1M count=1000 &
+       $SETSTRIPE $file -i 0 -c 1
+       dd if=/dev/zero of=$file bs=1M count=1000 &
        ddpid=$!
 
        while true
@@ -6998,11 +7017,14 @@ test_77g() { # bug 10889
 
        [ ! -f $F77_TMP ] && setup_f77
 
-       $SETSTRIPE -c 1 -i 0 $DIR/$tfile
+       local file=$DIR/$tfile
+       stack_trap "rm -f $file" EXIT
+
+       $SETSTRIPE -c 1 -i 0 $file
        #define OBD_FAIL_OST_CHECKSUM_RECEIVE       0x21a
        do_facet ost1 lctl set_param fail_loc=0x8000021a
        set_checksums 1
-       dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ ||
+       dd if=$F77_TMP of=$file bs=1M count=$F77SZ ||
                error "write error: rc=$?"
        do_facet ost1 lctl set_param fail_loc=0
        set_checksums 0
@@ -7011,7 +7033,7 @@ test_77g() { # bug 10889
        #define OBD_FAIL_OST_CHECKSUM_SEND          0x21b
        do_facet ost1 lctl set_param fail_loc=0x8000021b
        set_checksums 1
-       cmp $F77_TMP $DIR/$tfile || error "file compare failed"
+       cmp $F77_TMP $file || error "file compare failed"
        do_facet ost1 lctl set_param fail_loc=0
        set_checksums 0
 }
@@ -7214,6 +7236,7 @@ run_test 82 "Basic grouplock test"
 
 test_83() {
        local sfile="/boot/System.map-$(uname -r)"
+       [ ! -f $sfile ] && skip "No $sfile found" && return
        # define OBD_FAIL_LLITE_PTASK_IO_FAIL 0x140d
        $LCTL set_param fail_loc=0x140d
        cp $sfile $DIR/$tfile || error "write failed"
@@ -7582,6 +7605,7 @@ run_test 101f "check mmap read performance"
 test_101g_brw_size_test() {
        local mb=$1
        local pages=$((mb * 1048576 / $(page_size)))
+       local file=$DIR/$tfile
 
        $LCTL set_param osc.*.max_pages_per_rpc=${mb}M ||
                { error "unable to set max_pages_per_rpc=${mb}M"; return 1; }
@@ -7590,14 +7614,15 @@ test_101g_brw_size_test() {
                        return 2
        done
 
+       stack_trap "rm -f $file" EXIT
        $LCTL set_param -n osc.*.rpc_stats=0
 
        # 10 RPCs should be enough for the test
        local count=10
-       dd if=/dev/zero of=$DIR/$tfile bs=${mb}M count=$count ||
+       dd if=/dev/zero of=$file bs=${mb}M count=$count ||
                { error "dd write ${mb} MB blocks failed"; return 3; }
        cancel_lru_locks osc
-       dd of=/dev/null if=$DIR/$tfile bs=${mb}M count=$count ||
+       dd of=/dev/null if=$file bs=${mb}M count=$count ||
                { error "dd write ${mb} MB blocks failed"; return 4; }
 
        # calculate number of full-sized read and write RPCs
@@ -8245,7 +8270,37 @@ test_103a() {
                fi
        done
 }
-run_test 103a "acl test ========================================="
+run_test 103a "acl test"
+
+test_103b() {
+       local U
+
+       for U in {0..511}; do
+               {
+               local O=$(printf "%04o" $U)
+
+               umask $(printf "%04o" $((511 ^ $O)))
+               $LFS setstripe -c 1 $DIR/$tfile.s$O
+               local S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.s$O))
+
+               (( $S == ($O & 0666) )) ||
+                       error "lfs setstripe $DIR/$tfile.s$O '$S' != '$O'"
+
+               $LFS setstripe -E16M -c 1 -E1G -S4M $DIR/$tfile.p$O
+               S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.p$O))
+               (( $S == ($O & 0666) )) ||
+                       error "lfs setstripe -E $DIR/$tfile.p$O '$S' != '$O'"
+
+               $LFS setstripe -N2 -c 1 $DIR/$tfile.m$O
+               S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.m$O))
+               (( $S == ($O & 0666) )) ||
+                       error "lfs setstripe -N2 $DIR/$tfile.m$O '$S' != '$O'"
+               rm -f $DIR/$tfile.[smp]$0
+               } &
+       done
+       wait
+}
+run_test 103b "umask lfs setstripe"
 
 test_103c() {
        mkdir -p $DIR/$tdir
@@ -13170,6 +13225,7 @@ else
                JOBENV=FAKE_JOBID
        fi
 fi
+LUSTRE_JOBID_SIZE=31 # plus NUL terminator
 
 verify_jobstats() {
        local cmd=($1)
@@ -13188,16 +13244,16 @@ verify_jobstats() {
        [ "$JOBENV" = "FAKE_JOBID" ] &&
                FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
 
-       JOBVAL=${!JOBENV}
+       JOBVAL=${!JOBENV:0:$LUSTRE_JOBID_SIZE}
 
        [ "$JOBENV" = "nodelocal" ] && {
-               FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
+               FAKE_JOBID=id.$testnum.%e.$RANDOM
                $LCTL set_param jobid_name=$FAKE_JOBID
-               JOBVAL=$FAKE_JOBID
+               JOBVAL=${FAKE_JOBID/\%e/$(basename ${cmd[0]})}
        }
 
        log "Test: ${cmd[*]}"
-       log "Using JobID environment variable $JOBENV=$JOBVAL"
+       log "Using JobID environment $($LCTL get_param -n jobid_var)=$JOBVAL"
 
        if [ $JOBENV = "FAKE_JOBID" ]; then
                FAKE_JOBID=$JOBVAL ${cmd[*]}
@@ -13208,8 +13264,10 @@ verify_jobstats() {
        # all files are created on OST0000
        for facet in $facets; do
                local stats="*.$(convert_facet2label $facet).job_stats"
+
+               # strip out libtool wrappers for in-tree executables
                if [ $(do_facet $facet lctl get_param $stats |
-                      grep -c $JOBVAL) -ne 1 ]; then
+                      sed -e 's/\.lt-/./' | grep -c $JOBVAL) -ne 1 ]; then
                        do_facet $facet lctl get_param $stats
                        error "No jobstats for $JOBVAL found on $facet::$stats"
                fi
@@ -13237,11 +13295,9 @@ test_205() { # Job stats
        [[ $JOBID_VAR = disable ]] && skip "jobstats is disabled" && return
 
        local old_jobenv=$($LCTL get_param -n jobid_var)
-       if [ $old_jobenv != $JOBENV ]; then
-               jobstats_set $JOBENV
-               stack_trap "do_facet mgs \
-                       $LCTL conf_param $FSNAME.sys.jobid_var=$old_jobenv" EXIT
-       fi
+       [ $old_jobenv != $JOBENV ] && jobstats_set $JOBENV
+       stack_trap "do_facet mgs \
+               $LCTL conf_param $FSNAME.sys.jobid_var=$old_jobenv" EXIT
 
        changelog_register
 
@@ -13318,6 +13374,12 @@ test_205() { # Job stats
                [ $jobids -eq 0 ] ||
                        error "Unexpected jobids when jobid_var=$JOBENV"
        fi
+
+       lctl set_param jobid_var=USER jobid_name="S.%j.%e.%u.%h.E"
+       JOBENV="JOBCOMPLEX"
+       JOBCOMPLEX="S.$USER.touch.$(id -u).$(hostname).E"
+
+       verify_jobstats "touch $DIR/$tfile" $SINGLEMDS
 }
 run_test 205 "Verify job stats"