[Ocfs2-test-devel] [PATCH 1/1] Ocfs2-tests: Add additional func tests for xattr.
Tao Ma
tao.ma at oracle.com
Fri Dec 5 00:55:34 PST 2008
Tristan,
Glad to see you complete my test plan so quickly. The result is cool.
But Since this is based on tiger's temporary debugfs patch, I would
suggest to defer its commit after Tiger's patch is committed to
ocfs2-tools first so that we won't give the user an uncompleted one.
Regards,
Tao
Tristan Ye wrote:
> Thanks to tiger's patch set for debugfs.ocfs2 to make these
> extreme boundary tests become a reality. Currently it includes
> following testcases suggested by Tao's testplan.
>
> 1. Non-xattr test.
> 2. Simple in-inode-xattr test(it will include set a small xattr, a large
> xattr).
> 3. In-inode-xattr-extension test. it will fill up the in-inode space and
> then extend the xattr to an outside xattr block. you need to test t4
> scenarios at least.
> 1) insert a small xattr.
> 2) insert a large xattr.
> 3) replace a small xattr in-inode to a large one(value_size>80)(which
> will remove the old in-inode xattr and add it in outside block).
> 4) replace a small xattr in-inode to a large one(value_size<80).
> 4. Outside-xattr-block test.
> 1) insert a small xattr.
> 2) insert a large xattr.
> 3) replace xattr to a small one((value_size<80)) which then can be
> inserted into in-inode and deleted from xattr block.
> 4) replace xattr to a value(value_size>80) but the old one has a size
> of(48~80).
> 5. Basic bucket-extension test.
> 1) insert a small xattr.
> 2) insert a large xattr.
> 3) replace a small xattr in-inode to a large one(value_size>80)(which
> will remove the old in-inode xattr and add it in outside bucket).
> 4) replace a small xattr in-inode to a large one(value_size<80).
> 6. Basic bucket insert test.
> 1) insert a small xattr.
> 2) insert a large xattr.
> 3) replace xattr to a small one((value_size<80)) which then can be
> inserted into in-inode and deleted from xattr bucket.
> 4) replace xattr to a value(value_size>80) but the old one has a size
> of(48~80).
>
> Actually, the above testcases have exposed the bugs 1052,1054 and 1055 on
> bugzilla. We're also planning testcases of combination-test for inline-xattr
> and inline-data.
>
> Signed-off-by: Tristan Ye <tristan.ye at oracle.com>
> ---
> programs/xattr_tests/xattr-single-run.sh | 408 +++++++++++++++++++++++++++++-
> 1 files changed, 407 insertions(+), 1 deletions(-)
>
> diff --git a/programs/xattr_tests/xattr-single-run.sh b/programs/xattr_tests/xattr-single-run.sh
> index 4a54caa..bfc370b 100755
> --- a/programs/xattr_tests/xattr-single-run.sh
> +++ b/programs/xattr_tests/xattr-single-run.sh
> @@ -35,6 +35,7 @@ TOUCH_BIN="`which touch`"
> MOUNT_BIN="`which sudo` -u root `which mount`"
> UMOUNT_BIN="`which sudo` -u root `which umount`"
> MKFS_BIN="`which sudo` -u root `which mkfs.ocfs2`"
> +DEBUGFS_BIN="`which sudo` -u root `which debugfs.ocfs2`"
> XATTR_TEST_BIN="`which sudo` -u root ${BINDIR}/xattr-test"
>
> DEFAULT_LOG="xattr-test-logs"
> @@ -59,6 +60,8 @@ declare -i EA_NUMS
> declare -i EA_NAME_LEN
> declare -i EA_VALUE_SIZE
>
> +declare -i i
> +
> set -o pipefail
>
> BOOTUP=color
> @@ -111,7 +114,6 @@ exit_or_not()
> fi
> }
>
> -
> ################################################################################
> # Utility Functions
> ################################################################################
> @@ -218,6 +220,396 @@ f_do_umount()
> exit_or_not ${RET}
> }
>
> +f_is_xattr_inlined()
> +{
> + #${1} is test file
> + #${2} is target volume
> +
> + ${DEBUGFS_BIN} -R "xattr ${1}" ${2}|grep -qi "block" || {
> + return 0
> + }
> +
> + return 1
> +}
> +
> +f_is_xattr_bucketed()
> +{
> + #${1} is test file
> + #${2} is target volume
> +
> + ${DEBUGFS_BIN} -R "xattr ${1}" ${2}|grep -qi "bucket" || {
> + return 0
> + }
> +
> + return 1
> +}
> +
> +#
> +# Insert xattr entries with given number and mode
> +# ${1} specify entry type(small or large)
> +# ${2} specify file name
> +# ${3} specify entry number
> +#
> +f_insert_xattrs()
> +{
> + local XATTR_NAME_PREFIX=
> + local XATTR_VALUE_PREFIX=
> + local FILENAME=${2}
> + local ENTRY_NUM=${3}
> + local XATTR_NAME=
> + local XATTR_VALUE=
> + local LARGE_VALUE_LESS_THAN_80="largelargelargelargelargelargelargelargelargelargelargelargelargelargelarge."
> +
> +
> + if [ "x${1}" = "xsmall" ];then
> + XATTR_NAME_PREFIX="user."
> + XATTR_VALUE_PREFIX=""
> + else
> + XATTR_NAME_PREFIX="user.large."
> + XATTR_VALUE_PREFIX=${LARGE_VALUE_LESS_THAN_80}
> +
> + fi
> +
> + for i in $(seq ${ENTRY_NUM});do
> + XATTR_NAME="${XATTR_NAME_PREFIX}${i}"
> + XATTR_VALUE="${XATTR_VALUE_PREFIX}${i}"
> + ${SETXATTR} -n ${XATTR_NAME} -v ${XATTR_VALUE} ${TEST_FILE} >>${DETAIL_LOG_FILE} 2>&1
> + exit_or_not $?
> + done
> +
> + return $?
> +
> +}
> +
> +#
> +# Make inline-xattr firstly extented with small or large files increasing.
> +# ${1} stands for entry type(small or large)
> +# ${2} stands for file name
> +# ${3} should be block or bucket
> +# block: extend inlined xattr to block.
> +# xattr: extend block to bucket.
> +#
> +f_extend_xattr()
> +{
> + local XATTR_NAME_PREFIX=
> + local XATTR_VALUE_PREFIX=
> + local FILENAME=${2}
> + local EXTEND_TYPE=${3}
> + local XATTR_NAME=
> + local XATTR_VALUE=
> + local LARGE_VALUE_LESS_THAN_80="largelargelargelargelargelargelargelargelargelargelargelargelargelargelarge."
> +
> +
> + if [ "x${1}" = "xsmall" ];then
> + XATTR_NAME_PREFIX="user."
> + XATTR_VALUE_PREFIX=""
> + else
> + XATTR_NAME_PREFIX="user.large."
> + XATTR_VALUE_PREFIX=${LARGE_VALUE_LESS_THAN_80}
> +
> + fi
> +
> + i=1
> + while : ;do
> + XATTR_NAME="${XATTR_NAME_PREFIX}${i}"
> + XATTR_VALUE="${XATTR_VALUE_PREFIX}${i}"
> + ${SETXATTR} -n ${XATTR_NAME} -v ${XATTR_VALUE} ${TEST_FILE} >>${DETAIL_LOG_FILE} 2>&1
> + exit_or_not $?
> + sync
> +
> + if [ "x${EXTEND_TYPE}" = "xblock" ];then
> + f_is_xattr_inlined ${DEBUG_TEST_FILE} ${OCFS2_DEVICE} || {
> + break
> + }
> + else
> +
> + f_is_xattr_bucketed ${DEBUG_TEST_FILE} ${OCFS2_DEVICE} || {
> + break
> + }
> +
> + fi
> +
> + ((i++))
> + done
> +
> + return $?
> +}
> +
> +f_add_func_test()
> +{
> + SUB_TESTNO=1
> + TEST_FILE=${WORKPLACE}/additional-func-test-file
> + DEBUG_TEST_FILE=/xattr_test_place/additional-func-test-file
> + LARGE_VALUE_LESS_THAN_80="largelargelargelargelargelargelargelargelargelargelargelargelargelargelarge"
> + LARGE_VALUE_MORE_THAN_80="largelargelargelargelargelargelargelargelargelargelargelargelargelargelargelargelarge"
> + declare -i MAX_SMALL_INLINE_XATTR
> + declare -i MAX_LARGE_INLINE_XATTR
> + declare -i MAX_SMALL_BLOCK_XATTR
> + declare -i MAX_LARGE_BLOCK_XATTR
> +
> + ${TOUCH_BIN} ${TEST_FILE}
> +
> + echo "Test ${SUB_TESTNO}: None Xattr Test.">>${DETAIL_LOG_FILE}
> +
> + DUMMY_NAME="user.dummy"
> + EMPTY_NAME=" "
> + INVALID_NAME="user."
> +
> + for ea_name in ${DUMMY_NAME} ${EMPTY_NAME} ${INVALID_NAME};do
> + ${GETXATTR} -n ${ea_name} ${TEST_FILE} >>${DETAIL_LOG_FILE} 2>&1
> + RET=$?
> + #if [ "${RET}" = "0" ];then
> + # echo "Should not get a entry from a None-xattr file.">>${DETAIL_LOG_FILE} 2>&1
> + # echo_failure | tee -a ${RUN_LOG_FILE}
> + # echo | tee -a ${RUN_LOG_FILE}
> + # exit 1
> +
> + #fi
> + done;
> +
> + ((SUB_TESTNO++))
> +
> + echo "Test ${SUB_TESTNO}: Simple In-inode-xattr Test.">>${DETAIL_LOG_FILE}
> + # Add a small ea in inode
> + XATTR_NAME="user.small"
> + XATTR_VALUE="smallvalue"
> +
> + ${SETXATTR} -n ${XATTR_NAME} -v ${XATTR_VALUE} ${TEST_FILE} >>${DETAIL_LOG_FILE} 2>&1
> + exit_or_not $?
> +
> + ${SETXATTR} -x ${XATTR_NAME} ${TEST_FILE} >>${DETAIL_LOG_FILE} 2>&1
> + exit_or_not $?
> +
> + # Add a large ea in inode
> + XATTR_NAME="user.large"
> + XATTR_VALUE=${LARGE_VALUE_LESS_THAN_80}
> +
> + ${SETXATTR} -n ${XATTR_NAME} -v ${XATTR_VALUE} ${TEST_FILE} >>${DETAIL_LOG_FILE} 2>&1
> + exit_or_not $?
> +
> + ${SETXATTR} -x ${XATTR_NAME} ${TEST_FILE} >>${DETAIL_LOG_FILE} 2>&1
> + exit_or_not $?
> +
> + ((SUB_TESTNO++))
> +
> + echo "Test ${SUB_TESTNO}: In inode EA extension test.">>${DETAIL_LOG_FILE}
> + # Get very ready for extension after a small ea insertion
> + f_extend_xattr "small" ${TEST_FILE} "block"
> + MAX_SMALL_INLINE_XATTR=$((${i}-1))
> + exit_or_not $?
> +
> + ${RM} -rf ${TEST_FILE}
> + ${TOUCH_BIN} ${TEST_FILE}
> +
> + # Get very ready for extension after a large ea insertion
> + f_extend_xattr "large" ${TEST_FILE} "block"
> + MAX_LARGE_INLINE_XATTR=$((${i}-1))
> + exit_or_not $?
> +
> + ${RM} -rf ${TEST_FILE}
> + ${TOUCH_BIN} ${TEST_FILE}
> +
> + # Replace a small ea to a large one to extend
> + f_extend_xattr "small" ${TEST_FILE} "block"
> + exit_or_not $?
> +
> + XATTR_NAME="user.${i}"
> +
> + ${SETXATTR} -x ${XATTR_NAME} ${TEST_FILE} >>${DETAIL_LOG_FILE} 2>&1
> + exit_or_not $?
> +
> + #Large xattr value less than 80
> + XATTR_VALUE=${LARGE_VALUE_LESS_THAN_80}${i}
> +
> + ${SETXATTR} -n ${XATTR_NAME} -v ${XATTR_VALUE} ${TEST_FILE} >>${DETAIL_LOG_FILE} 2>&1
> + exit_or_not $?
> +
> + ${RM} -rf ${TEST_FILE}
> + ${TOUCH_BIN} ${TEST_FILE}
> +
> + f_extend_xattr "small" ${TEST_FILE} "block"
> + exit_or_not $?
> +
> + XATTR_NAME="user.${i}"
> +
> + ${SETXATTR} -x ${XATTR_NAME} ${TEST_FILE} >>${DETAIL_LOG_FILE} 2>&1
> + exit_or_not $?
> +
> + #Large xattr value more than 80
> + XATTR_VALUE=${LARGE_VALUE_MORE_THAN_80}${i}
> + ${SETXATTR} -n ${XATTR_NAME} -v ${XATTR_VALUE} ${TEST_FILE} >>${DETAIL_LOG_FILE} 2>&1
> + exit_or_not $?
> +
> + ${RM} -rf ${TEST_FILE}
> + ${TOUCH_BIN} ${TEST_FILE}
> +
> + ((SUB_TESTNO++))
> +
> + echo "Test ${SUB_TESTNO}: Outside Xattr Shrink Test.">>${DETAIL_LOG_FILE}
> + f_extend_xattr "small" ${TEST_FILE} "block"
> + exit_or_not $?
> +
> + # Add a small ea in external block
> + XATTR_NAME="user.small"
> + XATTR_VALUE="SMALL"
> +
> + ${SETXATTR} -n ${XATTR_NAME} -v ${XATTR_VALUE} ${TEST_FILE} >>${DETAIL_LOG_FILE} 2>&1
> + exit_or_not $?
> +
> + # Add a large ea in external block
> + XATTR_NAME="user.large"
> + XATTR_VALUE=${LARGE_VALUE_LESS_THAN_80}
> +
> + ${SETXATTR} -n ${XATTR_NAME} -v ${XATTR_VALUE} ${TEST_FILE} >>${DETAIL_LOG_FILE} 2>&1
> + exit_or_not $?
> +
> + ${RM} -rf ${TEST_FILE}
> + ${TOUCH_BIN} ${TEST_FILE}
> +
> + # Replace a large entry with a small one to shrink
> + f_extend_xattr "large" ${TEST_FILE} "block"
> +
> + # Here we verify a bug when updating a boundary entry without shrinking.
> + XATTR_NAME="user.large.${i}"
> + XATTR_VALUE="${LARGE_VALUE_LESS_THAN_80}.${i}"
> +
> + ${SETXATTR} -n ${XATTR_NAME} -v ${XATTR_VALUE} ${TEST_FILE} >>${DETAIL_LOG_FILE} 2>&1
> + exit_or_not $?
> +
> + XATTR_NAME="user.large.${i}"
> + XATTR_VALUE="${i}"
> +
> + ${SETXATTR} -n ${XATTR_NAME} -v ${XATTR_VALUE} ${TEST_FILE} >>${DETAIL_LOG_FILE} 2>&1
> + exit_or_not $?
> +
> + ${RM} -rf ${TEST_FILE}
> + ${TOUCH_BIN} ${TEST_FILE}
> +
> + # Replace a large entry with also a large one(value size > 80) to shrink
> + # Since it should reserve the space on inode more the 48 bytes, we need more elaborate operations.
> + ${SETXATTR} -n "user.1" -v "1" ${TEST_FILE}
> + ${SETXATTR} -n "user.2" -v "2" ${TEST_FILE}
> + ${SETXATTR} -n "user.large.1" -v ${LARGE_VALUE_LESS_THAN_80} ${TEST_FILE}
> + ${SETXATTR} -n "user.large.2" -v ${LARGE_VALUE_LESS_THAN_80} ${TEST_FILE}
> + exit_or_not $?
> +
> + XATTR_NAME="user.large.2"
> + # Make value size more than 80 here
> + XATTR_VALUE=${LARGE_VALUE_MORE_THAN_80}
> +
> + ${SETXATTR} -n ${XATTR_NAME} -v ${XATTR_VALUE} ${TEST_FILE} >>${DETAIL_LOG_FILE} 2>&1
> + exit_or_not $?
> +
> + ${RM} -rf ${TEST_FILE}
> + ${TOUCH_BIN} ${TEST_FILE}
> +
> + ((SUB_TESTNO++))
> +
> + echo "Test ${SUB_TESTNO}: Basic Bucket Extension Test.">>${DETAIL_LOG_FILE}
> + f_extend_xattr "small" ${TEST_FILE} "bucket"
> + MAX_SMALL_BLOCK_XATTR=$((${i}-1))
> + exit_or_not $?
> +
> + ${RM} -rf ${TEST_FILE}
> + ${TOUCH_BIN} ${TEST_FILE}
> +
> + f_extend_xattr "large" ${TEST_FILE} "bucket"
> + MAX_LARGE_BLOCK_XATTR=$((${i}-1))
> + exit_or_not $?
> +
> + ${RM} -rf ${TEST_FILE}
> + ${TOUCH_BIN} ${TEST_FILE}
> +
> + # Get very ready to extend block to bucket.
> + f_insert_xattrs "small" ${TEST_FILE} ${MAX_SMALL_BLOCK_XATTR}
> + exit_or_not $?
> +
> + # Replace a small entry with a large one,less than 80
> + XATTR_NAME=user.${i}
> + XATTR_VALUE=${LARGE_VALUE_LESS_THAN_80}
> +
> + ${SETXATTR} -n ${XATTR_NAME} -v ${XATTR_VALUE} ${TEST_FILE} >>${DETAIL_LOG_FILE} 2>&1
> + exit_or_not $?
> +
> + ${RM} -rf ${TEST_FILE}
> + ${TOUCH_BIN} ${TEST_FILE}
> +
> + f_insert_xattrs "small" ${TEST_FILE} ${MAX_SMALL_BLOCK_XATTR}
> + exit_or_not $?
> +
> + # Replace a small entry with a large one, more than 80
> + XATTR_NAME=user.${i}
> + XATTR_VALUE=${LARGE_VALUE_MORE_THAN_80}
> +
> + ${SETXATTR} -n ${XATTR_NAME} -v ${XATTR_VALUE} ${TEST_FILE} >>${DETAIL_LOG_FILE} 2>&1
> + exit_or_not $?
> +
> + ${RM} -rf ${TEST_FILE}
> + ${TOUCH_BIN} ${TEST_FILE}
> +
> + ((SUB_TESTNO++))
> +
> + echo "Test ${SUB_TESTNO}: Basic Bucket Insert & Shrink Test.">>${DETAIL_LOG_FILE}
> +
> + f_extend_xattr "small" ${TEST_FILE} "bucket"
> + exit_or_not $?
> +
> + XATTR_NAME="user.small"
> + XATTR_VALUE="SMALL"
> +
> + ${SETXATTR} -n ${XATTR_NAME} -v ${XATTR_VALUE} ${TEST_FILE} >>${DETAIL_LOG_FILE} 2>&1
> + exit_or_not $?
> +
> + XATTR_NAME="user.large"
> + XATTR_VALUE=${LARGE_VALUE_LESS_THAN_80}
> +
> + ${SETXATTR} -n ${XATTR_NAME} -v ${XATTR_VALUE} ${TEST_FILE} >>${DETAIL_LOG_FILE} 2>&1
> + exit_or_not $?
> +
> + ${RM} -rf ${TEST_FILE}
> + ${TOUCH_BIN} ${TEST_FILE}
> +
> + f_extend_xattr "large" ${TEST_FILE} "bucket"
> + exit_or_not $?
> +
> + # Remove one random entry in inode-block to leave space for further replacing
> + RANDOM_SLOT=$((${RANDOM}%${MAX_LARGE_INLINE_XATTR}+1))
> + XATTR_NAME=user.large.${RANDOM_SLOT}
> +
> + ${SETXATTR} -x ${XATTR_NAME} ${TEST_FILE} >>${DETAIL_LOG_FILE} 2>&1
> + exit_or_not $?
> +
> + # Replace a large xattr with small one in bucket to make it stored in inode-block.
> + RANDOM_SLOT=$((${RANDOM}%$((${MAX_LARGE_BLOCK_XATTR}-${MAX_LARGE_INLINE_XATTR}+1))+${MAX_LARGE_INLINE_XATTR}))
> + XATTR_NAME=user.large.${RANDOM_SLOT}
> + XATTR_VALUE="SMALL"
> +
> + ${SETXATTR} -n ${XATTR_NAME} -v ${XATTR_VALUE} ${TEST_FILE} >>${DETAIL_LOG_FILE} 2>&1
> + exit_or_not $?
> +
> + ${RM} -rf ${TEST_FILE}
> + ${TOUCH_BIN} ${TEST_FILE}
> +
> + f_extend_xattr "large" ${TEST_FILE} "bucket"
> + exit_or_not $?
> +
> + RANDOM_SLOT=$((${RANDOM}%${MAX_LARGE_INLINE_XATTR}+1))
> + XATTR_NAME=user.large.${RANDOM_SLOT}
> +
> + ${SETXATTR} -x ${XATTR_NAME} ${TEST_FILE} >>${DETAIL_LOG_FILE} 2>&1
> + exit_or_not $?
> +
> + # Replace a large xattr with large one(more than 80) in bucket to make it stored in inode-block.
> + RANDOM_SLOT=$((${RANDOM}%$((${MAX_LARGE_BLOCK_XATTR}-${MAX_LARGE_INLINE_XATTR}+1))+${MAX_LARGE_INLINE_XATTR}))
> + XATTR_NAME=user.large.${RANDOM_SLOT}
> + XATTR_VALUE=${LARGE_VALUE_MORE_THAN_80}
> +
> + ${SETXATTR} -n ${XATTR_NAME} -v ${XATTR_VALUE} ${TEST_FILE} >>${DETAIL_LOG_FILE} 2>&1
> + exit_or_not $?
> +
> + return $?
> +}
> +
> f_runtest()
> {
> echo >>${DETAIL_LOG_FILE}
> @@ -265,6 +657,20 @@ f_runtest()
> ${RM} -rf ${WORKPLACE}/* || exit 1
>
>
> + echo >>${DETAIL_LOG_FILE}
> + echo "==========================================================">>${DETAIL_LOG_FILE}
> + echo -ne "Perform Additional Func Test:"|tee -a ${RUN_LOG_FILE}
> + echo -ne "Perform Additional Func Test::">>${DETAIL_LOG_FILE}
> + echo >>${DETAIL_LOG_FILE}
> + echo "==========================================================">>${DETAIL_LOG_FILE}
> + if [ ! ${BLOCKSIZE} -eq 512 ];then
> + f_add_func_test
> + fi
> + RET=$?
> + echo_status ${RET} |tee -a ${RUN_LOG_FILE}
> + exit_or_not ${RET}
> + ${RM} -rf ${WORKPLACE}/* || exit 1
> +
> echo >>${DETAIL_LOG_FILE}
> echo "==========================================================">>${DETAIL_LOG_FILE}
> echo -ne "Check Utility of SingleNode Xattr on Ocfs2:"|tee -a ${RUN_LOG_FILE}
More information about the Ocfs2-test-devel
mailing list