#!/bin/bash
-# -*- mode: Bash; tab-width: 4; indent-tabs-mode: t; -*-
-# vim:shiftwidth=4:softtabstop=4:tabstop=4:
#
# Run select tests by setting ONLY, or as arguments to the script.
# Skip specific tests by setting EXCEPT.
#
-# Run test by setting NOSETUP=true when ltest has setup env for us
set -e
-SRCDIR=`dirname $0`
-export PATH=$PWD/$SRCDIR:$SRCDIR:$PWD/$SRCDIR/../utils:$PATH:/sbin
-
ONLY=${ONLY:-"$*"}
-# bug number for skipped test: LU-4256
-ALWAYS_EXCEPT="$LRSYNC_EXCEPT 2b"
-# UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
-
-[ "$SLOW" = "no" ] && EXCEPT_SLOW=""
-
-[ "$ALWAYS_EXCEPT$EXCEPT" ] &&
- echo "Skipping tests: `echo $ALWAYS_EXCEPT $EXCEPT`"
KILL=/bin/kill
-
-TMP=${TMP:-/tmp}
LREPL_LOG=$TMP/lustre_rsync.log
ORIG_PWD=${PWD}
-LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
+LUSTRE=${LUSTRE:-$(dirname $0)/..}
. $LUSTRE/tests/test-framework.sh
-init_test_env $@
-. ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
+init_test_env "$@"
init_logging
+ALWAYS_EXCEPT="$LRSYNC_EXCEPT "
+# bug number for skipped test: LU-4256
+ALWAYS_EXCEPT+=" 2b"
+# UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
+
+build_test_filter
+
+[ -n "$FILESET" ] && skip "Not functional for FILESET set"
+
check_and_setup_lustre
DIR=${DIR:-$MOUNT}
error "No generic nobody group"
fi
-build_test_filter
-
export LRSYNC=${LRSYNC:-"$LUSTRE/utils/lustre_rsync"}
[ ! -f "$LRSYNC" ] && export LRSYNC=$(which lustre_rsync)
export LRSYNC="$LRSYNC -v -c no -d 2"
rm -rf $TGT2/$tdir $TGT2/d*.lustre_rsync-test 2> /dev/null
rm -rf ${DIR}/$tdir $DIR/d*.lustre_rsync-test ${DIR}/tgt 2> /dev/null
rm -f $LREPL_LOG
- mkdir -p ${DIR}/$tdir || error "Failed to create target: " $DIR/$tdir
+
+ mkdir_on_mdt0 $DIR/$tdir || error "Failed to create target: " $DIR/$tdir
mkdir -p ${TGT}/$tdir || error "Failed to create target: " $TGT/$tdir
mkdir -p ${TGT2}/$tdir || error "Failed to create target: " $TGT2/$tdir
}
# "small" - large xattr is unsupported but small xattr is supported
# "no" - xattr is unsupported
check_xattr() {
- local tgt=$1
- local xattr="no"
+ local tgt=$1
+ local xattr="no"
+
+ touch $tgt
- touch $tgt
+ local val="$(generate_string $(max_xattr_size))"
- local val="$(generate_string $(max_xattr_size))"
- if large_xattr_enabled &&
- setfattr -n user.foo -v $val $tgt 2>/dev/null; then
- xattr="large"
- else
- setfattr -n user.foo -v bar $tgt 2>/dev/null && xattr="small"
- fi
+ if large_xattr_enabled &&
+ setfattr -n user.foo -v $val $tgt 2>/dev/null; then
+ xattr="large"
+ else
+ setfattr -n user.foo -v bar $tgt 2>/dev/null && xattr="small"
+ fi
- rm -f $tgt
- echo $xattr
+ rm -f $tgt
+ echo $xattr
}
check_diff() {
# Test 1A - test basic operations
test_1A() { # was test_1
- init_src
- init_changelog
- local xattr=$(check_xattr $TGT/foo)
+ init_src
+ init_changelog
+ local xattr=$(check_xattr $TGT/foo)
- # Directory create
- mkdir $DIR/$tdir/d1
- mkdir $DIR/$tdir/d2
+ # Directory create
+ mkdir $DIR/$tdir/d1
+ mkdir $DIR/$tdir/d2
- # File create
- touch $DIR/$tdir/file1
- cp /etc/hosts $DIR/$tdir/d1/
- touch $DIR/$tdir/d1/"space in filename"
- touch $DIR/$tdir/d1/file2
+ # File create
+ touch $DIR/$tdir/file1
+ cp /etc/hosts $DIR/$tdir/d1/
+ touch $DIR/$tdir/d1/"space in filename"
+ touch $DIR/$tdir/d1/file2
- # File rename
- mv $DIR/$tdir/d1/file2 $DIR/$tdir/d2/file3
+ # File rename
+ mv $DIR/$tdir/d1/file2 $DIR/$tdir/d2/file3
- # File and directory delete
- touch $DIR/$tdir/d1/file4
- mkdir $DIR/$tdir/d1/del
- touch $DIR/$tdir/d1/del/del1
- touch $DIR/$tdir/d1/del/del2
- rm -rf $DIR/$tdir/d1/del
- rm $DIR/$tdir/d1/file4
+ # File and directory delete
+ touch $DIR/$tdir/d1/file4
+ mkdir $DIR/$tdir/d1/del
+ touch $DIR/$tdir/d1/del/del1
+ touch $DIR/$tdir/d1/del/del2
+ rm -rf $DIR/$tdir/d1/del
+ rm $DIR/$tdir/d1/file4
- #hard and soft links
- cat /etc/hosts > $DIR/$tdir/d1/link1
- ln $DIR/$tdir/d1/link1 $DIR/$tdir/d1/link2
- ln -s $DIR/$tdir/d1/link1 $DIR/$tdir/d1/link3
+ # Hard and soft links
+ cat /etc/hosts > $DIR/$tdir/d1/link1
+ ln $DIR/$tdir/d1/link1 $DIR/$tdir/d1/link2
+ ln -s $DIR/$tdir/d1/link1 $DIR/$tdir/d1/link3
- # Device files
- #mknod $DIR/$tdir/dev1 b 8 1
+ # Device files
+ #mknod $DIR/$tdir/dev1 b 8 1
# Replicate
local LRSYNC_LOG=$(generate_logname "lrsync_log")
$LRSYNC -s $DIR -t $TGT -t $TGT2 -m $MDT0 -u $CL_USER -l $LREPL_LOG \
-D $LRSYNC_LOG
- # Set attributes
- chmod 000 $DIR/$tdir/d2/file3
- chown nobody:$GROUP $DIR/$tdir/d2/file3
+ # Set attributes
+ chmod 000 $DIR/$tdir/d2/file3
+ chown nobody:$GROUP $DIR/$tdir/d2/file3
- # Set xattrs
- if [[ "$xattr" != "no" ]]; then
- local value
- touch $DIR/$tdir/file5
- [[ "$xattr" = "large" ]] &&
- value="$(generate_string $(max_xattr_size))" || value="bar"
- setfattr -n user.foo -v $value $DIR/$tdir/file5
- fi
+ # Set xattrs
+ if [[ "$xattr" != "no" ]]; then
+ local value
+ touch $DIR/$tdir/file5
+ [[ "$xattr" = "large" ]] &&
+ value="$(generate_string $(max_xattr_size))" || value="bar"
+ setfattr -n user.foo -v $value $DIR/$tdir/file5 ||
+ error "setfattr failed"
+ fi
echo "Replication #2"
$LRSYNC -l $LREPL_LOG -D $LRSYNC_LOG
init_changelog
# Directory create
- mkdir $DIR/root-dir
+ mkdir_on_mdt0 $DIR/root-dir
# File create
touch $DIR/root-file
# File and directory delete
touch $DIR/root-file4
- mkdir $DIR/root-dir1
+ mkdir_on_mdt0 $DIR/root-dir1
rm $DIR/root-file4
rm -rf $DIR/root-dir1
init_changelog
# Run dbench
- sh rundbench -C -D $DIR/$tdir 2 -t $DBENCH_TIME || error "dbench failed"
+ bash rundbench -C -D $DIR/$tdir 2 -t $DBENCH_TIME ||
+ error "dbench failed"
local LRSYNC_LOG=$(generate_logname "lrsync_log")
# Replicate the changes to $TGT
init_changelog
# Run dbench
- sh rundbench -C -D $DIR/$tdir 2 -t $DBENCH_TIME &
+ bash rundbench -C -D $DIR/$tdir 2 -t $DBENCH_TIME &
# wait for dbench to start
wait_for_function 'child_pid=$(pgrep dbench)' 360
# let dbench run for a bit
init_changelog
# Run dbench
- sh rundbench -C -D $DIR/$tdir 2 -t $DBENCH_TIME &
+ bash rundbench -C -D $DIR/$tdir 2 -t $DBENCH_TIME &
local LRSYNC_LOG=$(generate_logname "lrsync_log")
# Replicate the changes to $TGT
run_test 9 "Replicate recursive directory removal"
cd $ORIG_PWD
-complete $SECONDS
+complete_test $SECONDS
check_and_cleanup_lustre
exit_status