Whamcloud - gitweb
LU-7372 mgs: reprocess all locks at device fini
[fs/lustre-release.git] / lustre / tests / test-framework.sh
index e4a7ec8..7776af0 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/bash
 
-trap 'print_summary && touch $TF_FAIL && \
+trap 'print_summary && print_stack_trace | tee $TF_FAIL && \
     echo "$TESTSUITE: FAIL: test-framework exiting on error"' ERR
 set -e
 #set -x
@@ -1776,14 +1776,24 @@ zconf_mount_clients() {
        fi
 
        do_nodes $clients "
-running=\\\$(mount | grep -c $mnt' ');
-rc=0;
-if [ \\\$running -eq 0 ] ; then
-    mkdir -p $mnt;
-    $MOUNT_CMD $flags $opts $device $mnt;
-    rc=\\\$?;
-fi;
-exit \\\$rc" || return ${PIPESTATUS[0]}
+               running=\\\$(mount | grep -c $mnt' ');
+               rc=0;
+               if [ \\\$running -eq 0 ] ; then
+                       mkdir -p $mnt;
+                       $MOUNT_CMD $flags $opts $device $mnt;
+                       rc=\\\$?;
+               else
+                       lustre_mnt_count=\\\$(mount | grep $mnt' ' | \
+                               grep 'type lustre' | wc -l);
+                       if [ \\\$running -ne \\\$lustre_mnt_count ] ; then
+                               echo zconf_mount_clients FAILED: \
+                                       mount count \\\$running, not matching \
+                                       with mount count of 'type lustre' \
+                                       \\\$lustre_mnt_count;
+                               rc=1;
+                       fi;
+               fi;
+       exit \\\$rc" || return ${PIPESTATUS[0]}
 
        echo "Started clients $clients: "
        do_nodes $clients "mount | grep $mnt' '"
@@ -2430,10 +2440,10 @@ wait_osts_up() {
        wait_update $HOSTNAME "eval $cmd" $OSTCOUNT ||
                error "wait_update OSTs up on client failed"
 
-       cmd="$LCTL get_param -n lod.$FSNAME-MDT*-*.target_obd | sort -u |
-            awk 'BEGIN {c = 0} /ACTIVE/{c += 1} END {printf \\\"%d\\\", c}'"
+       cmd="$LCTL get_param osp.$FSNAME-OST*-MDT0000.prealloc_last_id |
+            awk '/=[1-9][0-9]/ { c += 1 } END { printf \\\"%d\\\", c }'"
        wait_update_facet $SINGLEMDS "eval $cmd" $OSTCOUNT ||
-               error "wait_update OSTs up on MDT failed"
+               error "wait_update OSTs up on MDT0000 failed"
 }
 
 wait_destroy_complete () {
@@ -2771,7 +2781,7 @@ h2name_or_ip() {
 }
 
 h2nettype() {
-       if [[ -v NETTYPE ]]; then
+       if [[ -n "$NETTYPE" ]]; then
                h2name_or_ip "$1" "$NETTYPE"
        else
                h2name_or_ip "$1" "$2"
@@ -2782,7 +2792,7 @@ declare -fx h2nettype
 # Wrapper function to print the deprecation warning
 h2tcp() {
        echo "h2tcp: deprecated, use h2nettype instead" 1>&2
-       if [[ -v NETTYPE ]]; then
+       if [[ -n "$NETTYPE" ]]; then
                h2nettype "$@"
        else
                h2nettype "$1" "tcp"
@@ -2792,7 +2802,7 @@ h2tcp() {
 # Wrapper function to print the deprecation warning
 h2o2ib() {
        echo "h2o2ib: deprecated, use h2nettype instead" 1>&2
-       if [[ -v NETTYPE ]]; then
+       if [[ -n "$NETTYPE" ]]; then
                h2nettype "$@"
        else
                h2nettype "$1" "o2ib"
@@ -3636,6 +3646,34 @@ check_ost_indices() {
        done
 }
 
+__touch_device()
+{
+       local facet_type=$1 # mgs || mds || ost
+       local facet_num=$2
+       local facet=${1}${2}
+       local device
+
+       case "$(facet_fstype $facet)" in
+       ldiskfs)
+               device=$(${facet_type}devname $facet_num)
+               ;;
+       zfs)
+               device=$(${facet_type}vdevname $facet_num)
+               ;;
+       *)
+               error "Unhandled filesystem type"
+               ;;
+       esac
+
+       do_facet $facet "[ -e \"$device\" ]" && return
+
+       # Note: the following check only works with absolute paths
+       [[ ! "$device" =~ ^/dev/ ]] || [[ "$device" =~ ^/dev/shm/ ]] ||
+               error "$facet: device '$device' does not exist"
+
+       do_facet $facet "touch \"${device}\""
+}
+
 format_mgs() {
        local quiet
 
@@ -3644,6 +3682,12 @@ format_mgs() {
        fi
        echo "Format mgs: $(mgsdevname)"
        reformat_external_journal mgs
+
+       # touch "device" in case it is a loopback file for testing and needs to
+       # be created. mkfs.lustre doesn't do this to avoid accidentally writing
+       # to non-existent files in /dev if the admin made a typo during setup
+       __touch_device mgs
+
        add mgs $(mkfs_opts mgs $(mgsdevname)) $(mountfs_opts mgs) --reformat \
                $(mgsdevname) $(mgsvdevname) ${quiet:+>/dev/null} || exit 10
 }
@@ -3657,6 +3701,9 @@ format_mdt() {
        fi
        echo "Format mds$num: $(mdsdevname $num)"
        reformat_external_journal mds$num
+
+       __touch_device mds $num
+
        add mds$num $(mkfs_opts mds$num $(mdsdevname ${num})) \
                $(mountfs_opts mds$num) --reformat $(mdsdevname $num) \
                $(mdsvdevname $num) ${quiet:+>/dev/null} || exit 10
@@ -3670,6 +3717,9 @@ format_ost() {
        fi
        echo "Format ost$num: $(ostdevname $num)"
        reformat_external_journal ost$num
+
+       __touch_device ost $num
+
        add ost$num $(mkfs_opts ost$num $(ostdevname ${num})) \
                $(mountfs_opts ost$num) --reformat $(ostdevname $num) \
                $(ostvdevname ${num}) ${quiet:+>/dev/null} || exit 10
@@ -7097,7 +7147,7 @@ is_sanity_benchmark() {
 }
 
 min_ost_size () {
-    $LCTL get_param -n osc.*.kbytesavail | sort -n | head -n1
+       $LFS df | grep OST | awk '{print $4}' | sort -un | head -1
 }
 
 #