Whamcloud - gitweb
LU-590 tests: obdfilter-survey.sh fails test 2a.
[fs/lustre-release.git] / lustre / tests / test-framework.sh
index 06224d3..15fe46a 100644 (file)
@@ -37,8 +37,13 @@ if [ -f "$EXCEPT_LIST_FILE" ]; then
     . $EXCEPT_LIST_FILE
 fi
 
-[ -z "$MODPROBECONF" -a -f /etc/modprobe.conf ] && MODPROBECONF=/etc/modprobe.conf
-[ -z "$MODPROBECONF" -a -f /etc/modprobe.d/Lustre ] && MODPROBECONF=/etc/modprobe.d/Lustre
+# check config files for options in decreasing order of preference
+[ -z "$MODPROBECONF" -a -f /etc/modprobe.d/lustre.conf ] &&
+    MODPROBECONF=/etc/modprobe.d/lustre.conf
+[ -z "$MODPROBECONF" -a -f /etc/modprobe.d/Lustre ] &&
+    MODPROBECONF=/etc/modprobe.d/Lustre
+[ -z "$MODPROBECONF" -a -f /etc/modprobe.conf ] &&
+    MODPROBECONF=/etc/modprobe.conf
 
 assert_DIR () {
     local failed=""
@@ -607,12 +612,12 @@ set_default_debug_nodes () {
     local nodes=$1
 
     if [[ ,$nodes, = *,$HOSTNAME,* ]]; then
-       nodes=$(exclude_items_from_list "$nodes" "$HOSTNAME")
-       set_default_debug
+        nodes=$(exclude_items_from_list "$nodes" "$HOSTNAME")
+            set_default_debug
     fi
 
     [[ -n $nodes ]] && do_rpc_nodes $nodes set_default_debug \
-       \\\"$PTLDEBUG\\\" \\\"$SUBSYSTEM\\\" $DEBUG_SIZE || true
+        \\\"$PTLDEBUG\\\" \\\"$SUBSYSTEM\\\" $DEBUG_SIZE || true
 }
 
 set_default_debug_facet () {
@@ -1517,6 +1522,14 @@ facet_failover() {
 
     echo "Failing $facet on node $host"
 
+    # Make sure the client data is synced to disk. LU-924
+    #
+    # We don't write client data synchrnously (to avoid flooding sync writes
+    # when there are many clients connecting), so if the server reboots before
+    # the client data reachs disk, the client data will be lost and the client
+    # will be evicted after recovery, which is not what we expected.
+    do_facet $facet "sync; sync; sync"
+
     local affected=$(affected_facets $facet)
 
     shutdown_facet $facet
@@ -3323,7 +3336,7 @@ run_one_logged() {
 
     echo
     log_sub_test_begin test_${1}
-    (run_one $1 "$2") 2>&1 | tee $test_log
+    (run_one $1 "$2") 2>&1 | tee -i $test_log
     local RC=${PIPESTATUS[0]}
 
     [ $RC -ne 0 ] && [ ! -f $LOGDIR/err ] && \
@@ -4777,3 +4790,56 @@ is_sanity_benchmark() {
 min_ost_size () {
     $LCTL get_param -n osc.*.kbytesavail | sort -n | head -n1
 }
+
+# Get the block size of the filesystem.
+get_block_size() {
+    local facet=$1
+    local device=$2
+    local size
+
+    size=$(do_facet $facet "$DUMPE2FS -h $device 2>&1" |
+           awk '/^Block size:/ {print $3}')
+    echo $size
+}
+
+# Check whether the "large_xattr" feature is enabled or not.
+large_xattr_enabled() {
+    local mds_dev=$(mdsdevname ${SINGLEMDS//mds/})
+
+    do_facet $SINGLEMDS "$DUMPE2FS -h $mds_dev 2>&1 | grep -q large_xattr"
+    return ${PIPESTATUS[0]}
+}
+
+# Get the maximum xattr size supported by the filesystem.
+max_xattr_size() {
+    local size
+
+    if large_xattr_enabled; then
+        # include/linux/limits.h: #define XATTR_SIZE_MAX 65536
+        size=65536
+    else
+        local mds_dev=$(mdsdevname ${SINGLEMDS//mds/})
+        local block_size=$(get_block_size $SINGLEMDS $mds_dev)
+
+        # maximum xattr size = size of block - size of header -
+        #                      size of 1 entry - 4 null bytes
+        size=$((block_size - 32 - 32 - 4))
+    fi
+
+    echo $size
+}
+
+# Dump the value of the named xattr from a file.
+get_xattr_value() {
+    local xattr_name=$1
+    local file=$2
+
+    echo "$(getfattr -n $xattr_name --absolute-names --only-values $file)"
+}
+
+# Generate a string with size of $size bytes.
+generate_string() {
+    local size=${1:-1024} # in bytes
+
+    echo "$(head -c $size < /dev/zero | tr '\0' y)"
+}