From de0b4231c2b57d1517ea19de5cb224aa275cbdd8 Mon Sep 17 00:00:00 2001 From: "John L. Hammond" Date: Wed, 3 Apr 2013 17:39:56 -0500 Subject: [PATCH] LU-3072 test: add more operations to racer Add chown, chmod, truncate, delxattr, getxattr, setxattr, and mknod to racer. In lustre/utils/truncate.c print errors to stderr. Add a default definition for MCREATE to init_test_env() in test-framework.sh and remove definitions of MCREATE in various tests. Test-Parameters: testlist=racer Test-Parameters: testlist=racer Test-Parameters: testlist=racer Signed-off-by: John L. Hammond Change-Id: Ic366ac8e397035cd68cee5ebeda8408252a2c388 Reviewed-on: http://review.whamcloud.com/5936 Tested-by: Jenkins Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Doug Oucharek Reviewed-by: Oleg Drokin --- lustre/tests/racer/file_chmod.sh | 10 ++++++++++ lustre/tests/racer/file_chown.sh | 9 +++++++++ lustre/tests/racer/file_delxattr.sh | 10 ++++++++++ lustre/tests/racer/file_getxattr.sh | 9 +++++++++ lustre/tests/racer/file_mknod.sh | 9 +++++++++ lustre/tests/racer/file_setxattr.sh | 11 +++++++++++ lustre/tests/racer/file_truncate.sh | 9 +++++++++ lustre/tests/racer/racer.sh | 3 ++- lustre/tests/runtests | 2 -- lustre/tests/sanity-hsm.sh | 1 - lustre/tests/sanity-lfsck.sh | 1 - lustre/tests/sanity.sh | 1 - lustre/tests/sanityn.sh | 1 - lustre/tests/test-framework.sh | 1 + lustre/tests/truncate.c | 38 ++++++++++++++++++++++--------------- 15 files changed, 93 insertions(+), 22 deletions(-) create mode 100755 lustre/tests/racer/file_chmod.sh create mode 100755 lustre/tests/racer/file_chown.sh create mode 100755 lustre/tests/racer/file_delxattr.sh create mode 100755 lustre/tests/racer/file_getxattr.sh create mode 100755 lustre/tests/racer/file_mknod.sh create mode 100755 lustre/tests/racer/file_setxattr.sh create mode 100755 lustre/tests/racer/file_truncate.sh diff --git a/lustre/tests/racer/file_chmod.sh b/lustre/tests/racer/file_chmod.sh new file mode 100755 index 0000000..585c155 --- /dev/null +++ b/lustre/tests/racer/file_chmod.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +DIR=$1 +MAX=$2 + +while true; do + file=$DIR/$((RANDOM % MAX)) + mode=$(printf '%o' $((RANDOM % 010000))) + chmod $mode $file 2> /dev/null +done diff --git a/lustre/tests/racer/file_chown.sh b/lustre/tests/racer/file_chown.sh new file mode 100755 index 0000000..d5de24b --- /dev/null +++ b/lustre/tests/racer/file_chown.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +DIR=$1 +MAX=$2 + +while true; do + file=$DIR/$((RANDOM % MAX)) + chown $RANDOM:$RANDOM $file 2> /dev/null +done diff --git a/lustre/tests/racer/file_delxattr.sh b/lustre/tests/racer/file_delxattr.sh new file mode 100755 index 0000000..b38e515 --- /dev/null +++ b/lustre/tests/racer/file_delxattr.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +DIR=$1 +MAX=$2 + +while true; do + file=$DIR/$((RANDOM % MAX)) + attr=user.$((RANDOM % MAX)) + setfattr -x $attr $file 2>/dev/null +done diff --git a/lustre/tests/racer/file_getxattr.sh b/lustre/tests/racer/file_getxattr.sh new file mode 100755 index 0000000..0171ae4 --- /dev/null +++ b/lustre/tests/racer/file_getxattr.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +DIR=$1 +MAX=$2 + +while true; do + file=$DIR/$((RANDOM % MAX)) + getfattr -d -m- $file &> /dev/null +done diff --git a/lustre/tests/racer/file_mknod.sh b/lustre/tests/racer/file_mknod.sh new file mode 100755 index 0000000..25992d9 --- /dev/null +++ b/lustre/tests/racer/file_mknod.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +DIR=$1 +MAX=$2 + +while true; do + file=$DIR/$((RANDOM % MAX)) + $MCREATE $file 2> /dev/null +done diff --git a/lustre/tests/racer/file_setxattr.sh b/lustre/tests/racer/file_setxattr.sh new file mode 100755 index 0000000..eb17ead --- /dev/null +++ b/lustre/tests/racer/file_setxattr.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +DIR=$1 +MAX=$2 + +while true; do + file=$DIR/$((RANDOM % MAX)) + attr=user.$((RANDOM % MAX)) + value=$RANDOM$RANDOM$RANDOM$RANDOM$RANDOM$RANDOM$RANDOM$RANDOM$RANDOM + setfattr -n $attr -v $value $file 2> /dev/null +done diff --git a/lustre/tests/racer/file_truncate.sh b/lustre/tests/racer/file_truncate.sh new file mode 100755 index 0000000..1c85e6f --- /dev/null +++ b/lustre/tests/racer/file_truncate.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +DIR=$1 +MAX=$2 + +while true; do + file=$DIR/$((RANDOM % MAX)) + $TRUNCATE $file $RANDOM 2> /dev/null +done diff --git a/lustre/tests/racer/racer.sh b/lustre/tests/racer/racer.sh index 1da6465..deef18e 100755 --- a/lustre/tests/racer/racer.sh +++ b/lustre/tests/racer/racer.sh @@ -13,7 +13,8 @@ NUM_THREADS=${NUM_THREADS:-3} mkdir -p $DIR RACER_PROGS="file_create dir_create file_rm file_rename file_link file_symlink \ -file_list file_concat file_exec" +file_list file_concat file_exec file_chown file_chmod file_mknod file_truncate \ +file_delxattr file_getxattr file_setxattr" if [ $MDSCOUNT -gt 1 ]; then RACER_PROGS="${RACER_PROGS} dir_remote dir_migrate" diff --git a/lustre/tests/runtests b/lustre/tests/runtests index b722aca..758d7de 100755 --- a/lustre/tests/runtests +++ b/lustre/tests/runtests @@ -19,8 +19,6 @@ RUNTESTS_SRC=${RUNTESTS_SRC:-"/etc /bin"} [ "$COUNT" ] || COUNT=10000 [ "$SLOW" = "no" ] && COUNT=1000 -[ "$MCREATE" ] || MCREATE=mcreate - [ "$MKDIRMANY" ] || MKDIRMANY="createmany -d" [ "$RMDIRMANY" ] || RMDIRMANY="unlinkmany -d" diff --git a/lustre/tests/sanity-hsm.sh b/lustre/tests/sanity-hsm.sh index aa7ac3b..1b34cc5 100755 --- a/lustre/tests/sanity-hsm.sh +++ b/lustre/tests/sanity-hsm.sh @@ -28,7 +28,6 @@ init_logging MULTIOP=${MULTIOP:-multiop} OPENFILE=${OPENFILE:-openfile} -MCREATE=${MCREATE:-mcreate} MOUNT_2=${MOUNT_2:-"yes"} FAIL_ON_ERROR=false diff --git a/lustre/tests/sanity-lfsck.sh b/lustre/tests/sanity-lfsck.sh index 29c768f..64cf16b 100644 --- a/lustre/tests/sanity-lfsck.sh +++ b/lustre/tests/sanity-lfsck.sh @@ -19,7 +19,6 @@ init_logging require_dsh_mds || exit 0 -MCREATE=${MCREATE:-mcreate} SAVED_MDSSIZE=${MDSSIZE} SAVED_OSTSIZE=${OSTSIZE} SAVED_OSTCOUNT=${OSTCOUNT} diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 057be2a..8a91ebd 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -45,7 +45,6 @@ LFS=${LFS:-lfs} LFIND=${LFIND:-"$LFS find"} LVERIFY=${LVERIFY:-ll_dirstripe_verify} LCTL=${LCTL:-lctl} -MCREATE=${MCREATE:-mcreate} OPENFILE=${OPENFILE:-openfile} OPENUNLINK=${OPENUNLINK:-openunlink} export MULTIOP=${MULTIOP:-multiop} diff --git a/lustre/tests/sanityn.sh b/lustre/tests/sanityn.sh index 2bab077..6edb104 100644 --- a/lustre/tests/sanityn.sh +++ b/lustre/tests/sanityn.sh @@ -19,7 +19,6 @@ PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH SIZE=${SIZE:-40960} CHECKSTAT=${CHECKSTAT:-"checkstat -v"} -MCREATE=${MCREATE:-mcreate} OPENFILE=${OPENFILE:-openfile} OPENUNLINK=${OPENUNLINK:-openunlink} export MULTIOP=${MULTIOP:-multiop} diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh index 421a4e4..3df2e4c 100755 --- a/lustre/tests/test-framework.sh +++ b/lustre/tests/test-framework.sh @@ -226,6 +226,7 @@ init_test_env() { [ ! -f "$LST" ] && export LST=$(which lst) export SGPDDSURVEY=${SGPDDSURVEY:-"$LUSTRE/../lustre-iokit/sgpdd-survey/sgpdd-survey")} [ ! -f "$SGPDDSURVEY" ] && export SGPDDSURVEY=$(which sgpdd-survey) + export MCREATE=${MCREATE:-mcreate} # Ubuntu, at least, has a truncate command in /usr/bin # so fully path our truncate command. export TRUNCATE=${TRUNCATE:-$LUSTRE/tests/truncate} diff --git a/lustre/tests/truncate.c b/lustre/tests/truncate.c index 91e309d..d62d174 100644 --- a/lustre/tests/truncate.c +++ b/lustre/tests/truncate.c @@ -34,27 +34,35 @@ * Lustre is a trademark of Sun Microsystems, Inc. */ -#include -#include #include -#include +#include #include +#include +#include +#include int main(int argc, char **argv) { - unsigned long long off; - int err; + const char *path; + off_t length; + int rc; + + if (argc != 3) { + fprintf(stderr, "Usage: %s PATH LENGTH\n", + program_invocation_short_name); + exit(EXIT_FAILURE); + } - if (argc != 3) { - printf("usage %s file bytes\n", argv[0]); - return 1; - } + path = argv[1]; + length = strtoull(argv[2], NULL, 0); - off = strtoull(argv[2], NULL, 0); - err = truncate64(argv[1], off); - if (err) - printf("Error truncating %s to %lld: %s\n", argv[1], off, - strerror(errno)); + rc = truncate(path, length); + if (rc < 0) { + fprintf(stderr, "%s: cannot truncate '%s' to length %lld: %s\n", + program_invocation_short_name, path, (long long)length, + strerror(errno)); + exit(EXIT_FAILURE); + } - return err; + exit(EXIT_SUCCESS); } -- 1.8.3.1