[Ocfs2-test-devel] [PATCH 1/2] Ocfs2-test: Add additional func tests for xattr single-node test.

Tristan Ye tristan.ye at oracle.com
Mon Jan 12 00:26:26 PST 2009


Add additional func tests and several enhancement for xattr-single-run.sh,
added testcases as follows,

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).

7. Inline-data & inline-xattr combination test
   1) Filling-up test: inline-data consume less than (or equal to) max_inline_data - 256,
inline-xattr consume less or equal than  256
   2) Disable inline-xattr test: inline-data consume more than max_inline_data - 256,which cause
inline-xattr disabled.
   3) Disable inline-xattr test: shrink inline-data size to less than(or equal to)  max_inline_data -
256, which re-enable the inline-xattr.
   4) Inline xattr reservation test: add inline-xattr entry first(to reserve the last 256 bytes), then try
to fill the inodes with inline-data to see if inline-xattr will get affected.

Besides these, also improve the tests with a timing measurement and sucess&failure counting.

Signed-off-by: Tristan Ye <tristan.ye at oracle.com>
---
 programs/xattr_tests/xattr-single-run.sh |  680 ++++++++++++++++++++++++++++--
 1 files changed, 646 insertions(+), 34 deletions(-)

diff --git a/programs/xattr_tests/xattr-single-run.sh b/programs/xattr_tests/xattr-single-run.sh
index 4a54caa..87d31dd 100755
--- a/programs/xattr_tests/xattr-single-run.sh
+++ b/programs/xattr_tests/xattr-single-run.sh
@@ -1,6 +1,22 @@
 #!/bin/bash
+#
+# Copyright (C) 2008 Oracle.  All rights reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public
+# License, version 2,  as published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with this program; if not, write to the
+# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 021110-1307, USA.
+#
 # vi: set ts=8 sw=8 autoindent noexpandtab :
-################################################################################
 #
 # File :	xattr-single-run.sh
 #
@@ -12,8 +28,7 @@
 #
 # History:      14 Aug 2008
 #
-# Copyright (C) 2008 Oracle.  All rights reserved.
-#
+
 ################################################################################
 # Global Variables
 ################################################################################
@@ -32,9 +47,11 @@ SUDO="`which sudo` -u root"
 RM="`which rm`"
 MKDIR="`which mkdir`"
 TOUCH_BIN="`which touch`"
+DD_BIN="`which dd`"
 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"
@@ -48,17 +65,27 @@ BLOCKSIZE=
 CLUSTERSIZE=
 BLOCKNUMS=
 
-
 WORKPLACE=
 
-EXECUTE=1
-KILL_TEST=0
-GET_STATUS=0
+TEST_NO=0
+TEST_PASS=0
+
+COMBIN_TEST=
+declare -i MAX_SMALL_INLINE_XATTR
+declare -i MAX_LARGE_INLINE_XATTR
+declare -i MAX_SMALL_BLOCK_XATTR
+declare -i MAX_LARGE_BLOCK_XATTR
+
+declare -i MAX_INLINE_DATA
+declare -i MAX_INLINE_XATTR
+
 declare -i ITERATIONS
 declare -i EA_NUMS
 declare -i EA_NAME_LEN
 declare -i EA_VALUE_SIZE
 
+declare -i i
+
 set -o pipefail
 
 BOOTUP=color
@@ -117,7 +144,8 @@ exit_or_not()
 ################################################################################
 f_usage()
 {
-    echo "usage: `basename ${0}` [-o output_log_dir] <-d <device>> <mountpoint path>"
+    echo "usage: `basename ${0}` [-c] [-o output_log_dir] <-d <device>> <mountpoint path>"
+    echo "	 -c enable the combination test for inline-data and inline-xattr."
     echo "       -o output directory for the logs"
     echo "       -d specify the device which has been formated as an ocfs2 volume."
     echo "       <mountpoint path> path of mountpoint where the ocfs2 volume will be mounted on."
@@ -132,8 +160,9 @@ f_getoptions()
                 exit 1
          fi
 
-	 while getopts "i:x:n:l:s:ko:d:" options; do
+	 while getopts "cho:d:" options; do
                 case $options in
+		c ) COMBIN_TEST="1";;
                 o ) LOG_OUT_DIR="$OPTARG";;
                 d ) OCFS2_DEVICE="$OPTARG";;
                 h ) f_usage
@@ -186,7 +215,11 @@ f_do_mkfs_and_mount()
 {
 	echo -n "Mkfsing device:"|tee -a ${RUN_LOG_FILE}
 
-        echo y|${MKFS_BIN} --fs-features=xattr -b ${BLOCKSIZE} -C ${CLUSTERSIZE} -N 4 ${OCFS2_DEVICE} ${BLOCKNUMS}>>${RUN_LOG_FILE} 2>&1
+	if [ -z "${COMBIN_TEST}" ];then
+		echo y|${MKFS_BIN} --fs-features=xattr -b ${BLOCKSIZE} -C ${CLUSTERSIZE} -N 1 ${OCFS2_DEVICE} ${BLOCKNUMS}>>${RUN_LOG_FILE} 2>&1
+	else
+		echo y|${MKFS_BIN} --fs-features=xattr,inline-data -b ${BLOCKSIZE} -C ${CLUSTERSIZE} -N 1 ${OCFS2_DEVICE} ${BLOCKNUMS}>>${RUN_LOG_FILE} 2>&1
+	fi
         RET=$?
         echo_status ${RET} |tee -a ${RUN_LOG_FILE}
         exit_or_not ${RET}
@@ -218,12 +251,531 @@ 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} ${FILENAME} >>${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} ${FILENAME} >>${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_get_max_inline_size()
+{
+	TMP_FILE=${MOUNT_POINT}/.xattr-inline-data-tmp-file.$$
+	DEBUG_TMP_FILE=/.xattr-inline-data-tmp-file.$$
+
+	${TOUCH_BIN} ${TMP_FILE}
+
+	${DD_BIN} if=/dev/zero of=${TMP_FILE} bs=1 count=1 &>/dev/null
+	sync
+
+	MAX_INLINE_DATA=`${DEBUGFS_BIN} -R "stat ${DEBUG_TMP_FILE}" ${OCFS2_DEVICE} | grep -i inline | grep -i data | grep -i max | awk '{print $4}'`
+
+	${SETXATTR} -n "user.test" -v "test" ${TMP_FILE}
+	sync
+
+	MAX_INLINE_XATTR=`${DEBUGFS_BIN} -R "stat ${DEBUG_TMP_FILE}" ${OCFS2_DEVICE} | grep Xattr | grep Inline | grep -i size | awk '{print $7}'`
+
+	${RM} -rf ${TMP_FILE}
+}
+
+f_combin_test()
+{
+	SUB_TESTNO=1
+	TEST_FILE=${WORKPLACE}/xattr-inline-data-combin-test-file
+	DEBUG_TEST_FILE=/xattr_test_place/xattr-inline-data-combin-test-file
+
+	LARGE_VALUE_LESS_THAN_80="largelargelargelargelargelargelargelargelargelargelargelargelargelargelarge"
+	LARGE_VALUE_MORE_THAN_80="largelargelargelargelargelargelargelargelargelargelargelargelargelargelargelargelarge"
+
+	echo "Test ${SUB_TESTNO}: Inline Data&Xattr Filling Up Test." >>${DETAIL_LOG_FILE}
+	f_get_max_inline_size
+	${TOUCH_BIN} ${TEST_FILE}
+
+	${DD_BIN} if=/dev/zero of=${TEST_FILE} bs=1 count=$((${MAX_INLINE_DATA}-${MAX_INLINE_XATTR})) 2>>${DETAIL_LOG_FILE} >/dev/null
+	exit_or_not $?
+
+	f_insert_xattrs "small" ${TEST_FILE} ${MAX_SMALL_INLINE_XATTR}
+	exit_or_not $?
+
+	# Extend the inline-xattr and inline-data
+	echo "e">>${TEST_FILE}
+	${SETXATTR} -n "user.small" -v "SMALL" ${TEST_FILE}
+	exit_or_not $?
+
+	#Delete last EA entry to shrink.
+	${SETXATTR} -x "user.small" ${TEST_FILE}
+	exit_or_not $?
+
+	#Truncate inline-data to shrink.
+	${DD_BIN} if=/dev/zero of=${TEST_FILE} bs=1 count=$((${MAX_INLINE_DATA}-${MAX_INLINE_XATTR})) 2>>${DETAIL_LOG_FILE} >/dev/null
+	exit_or_not $?
+
+	#Replace last EA entry to extend.
+	XATTR_NAME="user.${i}"
+	${SETXATTR} -n "${XATTR_NAME}" -v "${LARGE_VALUE_LESS_THAN_80}" ${TEST_FILE}
+	exit_or_not $?
+	
+	${RM} -rf ${TEST_FILE}
+	${TOUCH_BIN} ${TEST_FILE}
+	((SUB_TESTNO++))
+
+	echo "Test ${SUB_TESTNO}: Disable&Enable Inline Xattr Test." >>${DETAIL_LOG_FILE}
+	${DD_BIN} if=/dev/zero of=${TEST_FILE} bs=1 count=$((${MAX_INLINE_DATA}-${MAX_INLINE_XATTR}+1)) 2>>${DETAIL_LOG_FILE} >/dev/null
+	${SETXATTR} -n "user.small" -v "SMALL" ${TEST_FILE}
+	exit_or_not $?
+
+	sync
+	${DEBUGFS_BIN} -R "xattr ${DEBUG_TEST_FILE}" ${OCFS2_DEVICE}|grep -qi block || {
+		echo "Xattr entry inserted here should be extended into outside block.">>${DETAIL_LOG_FILE}
+		return 1
+	}
+
+	${DD_BIN} if=/dev/zero of=${TEST_FILE} bs=1 count=$((${MAX_INLINE_DATA}-${MAX_INLINE_XATTR})) 2>>${DETAIL_LOG_FILE} >/dev/null
+	${SETXATTR} -n "user.small" -v "SMALL" ${TEST_FILE}
+	exit_or_not $?
+
+	sync
+	${DEBUGFS_BIN} -R "stat ${DEBUG_TEST_FILE}" ${OCFS2_DEVICE}|grep -qi InlineXattr || {
+		echo "Xattr entry inserted here should be inlined.">>${DETAIL_LOG_FILE}
+		return 1
+	}
+
+	${RM} -rf ${TEST_FILE}
+	${TOUCH_BIN} ${TEST_FILE}
+	((SUB_TESTNO++))
+
+	echo "Test ${SUB_TESTNO}: Inline Xattr Reservation Test." >>${DETAIL_LOG_FILE}
+	# Reserve 256 bytes for inline-xattr
+	${SETXATTR} -n "user.small" -v "SMALL" ${TEST_FILE}
+	exit_or_not $?
+
+	${DD_BIN} if=/dev/zero of=${TEST_FILE} bs=1 count=$((${MAX_INLINE_DATA}-${MAX_INLINE_XATTR})) 2>>${DETAIL_LOG_FILE} >/dev/null
+	echo "a" >> ${TEST_FILE}
+
+	sync
+	${DEBUGFS_BIN} -R "stat ${DEBUG_TEST_FILE}" ${OCFS2_DEVICE}|grep -qi InlineData && {
+		echo "Inline data should not invade reserved inline-xattr space.xxxxx">>${DETAIL_LOG_FILE}
+		return 1
+	}
+
+	${RM} -rf ${TEST_FILE}
+	${TOUCH_BIN} ${TEST_FILE}
+
+	${SETXATTR} -n "user.small" -v "SMALL" ${TEST_FILE}
+	exit_or_not $?
+
+	${SETXATTR} -x "user.small" ${TEST_FILE}
+	exit_or_not $?
+
+	${DD_BIN} if=/dev/zero of=${TEST_FILE} bs=1 count=$((${MAX_INLINE_DATA}-${MAX_INLINE_XATTR}+1)) 2>>${DETAIL_LOG_FILE} >/dev/null
+	exit_or_not $?
+
+	sync
+	${DEBUGFS_BIN} -R "stat ${DEBUG_TEST_FILE}" ${OCFS2_DEVICE}|grep -i InlineData && {
+		echo "Inline data should not invade reserved inline-xattr space.yyyy">>${DETAIL_LOG_FILE}
+		retun 1
+	}
+
+	${RM} -rf ${TEST_FILE}
+	((SUB_TESTNO++))
+
+	return 0
+}
+
+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"
+	
+	${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=$?
+	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}
+	echo "Extension test by small xattr increament.">>${DETAIL_LOG_FILE}
+	f_extend_xattr "small" ${TEST_FILE} "bucket"
+	MAX_SMALL_BLOCK_XATTR=$((${i}-1))
+	exit_or_not $?
+
+	echo "Clean up file">>${DETAIL_LOG_FILE}
+
+	${RM} -rf ${TEST_FILE}
+	${TOUCH_BIN} ${TEST_FILE}
+
+	echo "Extension test by large xattr increament.">>${DETAIL_LOG_FILE}
+	f_extend_xattr "large" ${TEST_FILE} "bucket"
+	MAX_LARGE_BLOCK_XATTR=$((${i}-1))
+	exit_or_not $?
+
+	echo "Clean up file">>${DETAIL_LOG_FILE}
+
+	${RM} -rf ${TEST_FILE}
+	${TOUCH_BIN} ${TEST_FILE}
+
+	# Get very ready to extend block to bucket.
+	echo " Get very ready to extend block to bucket.">>${DETAIL_LOG_FILE}
+
+	f_insert_xattrs "small" ${TEST_FILE} ${MAX_SMALL_BLOCK_XATTR}
+	exit_or_not $?
+
+	# Replace a small entry with a large one,less than 80
+	echo "Replace a small entry with a large one,less than 80">>${DETAIL_LOG_FILE}
+	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 $?
+
+	echo "Clean up file">>${DETAIL_LOG_FILE}
+
+	${RM} -rf ${TEST_FILE}
+	${TOUCH_BIN} ${TEST_FILE}
+
+	echo " Get very ready to extend block to bucket again.">>${DETAIL_LOG_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
+	echo "Replace a small entry with a large one, more than 80">>${DETAIL_LOG_FILE}
+	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 $?
+
+	echo "Clean up file">>${DETAIL_LOG_FILE}
+
+	${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()
 {
+	((TEST_NO++))
 	echo >>${DETAIL_LOG_FILE}
 	echo "==========================================================">>${DETAIL_LOG_FILE}
-	echo -ne "Check Namespace&Filetype of SingleNode Xattr on Ocfs2:"|tee -a ${RUN_LOG_FILE}
-	echo -ne "Check Namespace&Filetype of SingleNode Xattr on Ocfs2:">>${DETAIL_LOG_FILE}
+	echo -ne "[${TEST_NO}] Check Namespace&Filetype of SingleNode Xattr on Ocfs2:"|tee -a ${RUN_LOG_FILE}
+	echo -ne "[${TEST_NO}] Check Namespace&Filetype of SingleNode Xattr on Ocfs2:">>${DETAIL_LOG_FILE}
 	echo >>${DETAIL_LOG_FILE}
 	echo "==========================================================">>${DETAIL_LOG_FILE}
 	for namespace in user trusted
@@ -263,12 +815,45 @@ f_runtest()
 		echo |tee -a ${RUN_LOG_FILE}
 	fi
 	${RM} -rf ${WORKPLACE}/* || exit 1
+	((TEST_PASS++))
 
+	((TEST_NO++))
+	echo >>${DETAIL_LOG_FILE}
+	echo "==========================================================">>${DETAIL_LOG_FILE}
+	echo -ne "[${TEST_NO}] Perform Additional Func Test:"|tee -a ${RUN_LOG_FILE}
+	echo -ne "[${TEST_NO}] 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
+	((TEST_PASS++))
 
+	((TEST_NO++))
+	echo >>${DETAIL_LOG_FILE}
+	echo "==========================================================">>${DETAIL_LOG_FILE}
+	echo -ne "[${TEST_NO}] Perform Inline Data&Xattr Combination Test:"|tee -a ${RUN_LOG_FILE}
+	echo -ne "[${TEST_NO}] Perform Inline Data&Xattr Combination Test::">>${DETAIL_LOG_FILE}
+	echo >>${DETAIL_LOG_FILE}
+	echo "==========================================================">>${DETAIL_LOG_FILE}
+	if [ ! -z "${COMBIN_TEST}" ] && [ ! ${BLOCKSIZE} -eq 512 ];then
+		f_combin_test
+	fi
+	RET=$?
+	echo_status ${RET}|tee -a ${RUN_LOG_FILE}
+	exit_or_not ${RET}
+	${RM} -rf ${WORKPLACE}/* || exit 1
+	((TEST_PASS++))
+
+	((TEST_NO++))
         echo >>${DETAIL_LOG_FILE}
 	echo "==========================================================">>${DETAIL_LOG_FILE}
-	echo -ne "Check Utility of SingleNode Xattr on Ocfs2:"|tee -a ${RUN_LOG_FILE}
-        echo -ne "Check Utility of SingleNode Xattr on Ocfs2:">>${DETAIL_LOG_FILE}
+	echo -ne "[${TEST_NO}] Check Utility of SingleNode Xattr on Ocfs2:"|tee -a ${RUN_LOG_FILE}
+        echo -ne "[${TEST_NO}] Check Utility of SingleNode Xattr on Ocfs2:">>${DETAIL_LOG_FILE}
         echo >>${DETAIL_LOG_FILE}
         echo "==========================================================">>${DETAIL_LOG_FILE}
 	for((i=0;i<10;i++));do
@@ -286,12 +871,14 @@ f_runtest()
 		echo | tee -a ${RUN_LOG_FILE}
 	fi
         ${RM} -rf ${WORKPLACE}/* || exit 1
+	((TEST_PASS++))
 
 
+	((TEST_NO++))
 	echo >>${DETAIL_LOG_FILE}
         echo "==========================================================">>${DETAIL_LOG_FILE}
-        echo -ne "Check Max SingleNode Xattr EA_Name_Length:"|tee -a ${RUN_LOG_FILE}
-        echo -ne "Check Max SingleNode Xattr EA_Name_Length:">>${DETAIL_LOG_FILE}
+        echo -ne "[${TEST_NO}] Check Max SingleNode Xattr EA_Name_Length:"|tee -a ${RUN_LOG_FILE}
+        echo -ne "[${TEST_NO}] Check Max SingleNode Xattr EA_Name_Length:">>${DETAIL_LOG_FILE}
         echo >>${DETAIL_LOG_FILE}
         echo "==========================================================">>${DETAIL_LOG_FILE}
 	echo -e "Testing Binary:\t\t${XATTR_TEST_BIN} -i 1 -x 1 -n user -t normal -l 255 -s 200 ${WORKPLACE}">>${DETAIL_LOG_FILE}
@@ -300,12 +887,14 @@ f_runtest()
         echo_status ${RET} |tee -a ${RUN_LOG_FILE}
         exit_or_not ${RET}
 	${RM} -rf ${WORKPLACE}/* || exit 1
+	((TEST_PASS++))
 
 
+	((TEST_NO++))
 	echo >>${DETAIL_LOG_FILE}
         echo "==========================================================">>${DETAIL_LOG_FILE}
-        echo -ne "Check Max SingleNode Xattr EA_Size:"|tee -a ${RUN_LOG_FILE}
-        echo -ne "Check Max SingleNode Xattr EA_Size:">>${DETAIL_LOG_FILE}
+        echo -ne "[${TEST_NO}] Check Max SingleNode Xattr EA_Size:"|tee -a ${RUN_LOG_FILE}
+        echo -ne "[${TEST_NO}] Check Max SingleNode Xattr EA_Size:">>${DETAIL_LOG_FILE}
         echo >>${DETAIL_LOG_FILE}
         echo "==========================================================">>${DETAIL_LOG_FILE}
         echo -e "Testing Binary:\t\t${XATTR_TEST_BIN} -i 1 -x 1 -n user -t normal -l 50 -s 65536 ${WORKPLACE}">>${DETAIL_LOG_FILE}
@@ -314,12 +903,14 @@ f_runtest()
         echo_status ${RET} |tee -a ${RUN_LOG_FILE}
         exit_or_not ${RET}
         ${RM} -rf ${WORKPLACE}/* || exit 1
+	((TEST_PASS++))
 
 
+	((TEST_NO++))
 	echo >>${DETAIL_LOG_FILE}
         echo "==========================================================">>${DETAIL_LOG_FILE}
-        echo -ne "Check Huge SingleNode Xattr EA_Entry_Nums:"|tee -a ${RUN_LOG_FILE}
-        echo -ne "Check Huge SingleNode Xattr EA_Entry_Nums:">>${DETAIL_LOG_FILE}
+        echo -ne "[${TEST_NO}] Check Huge SingleNode Xattr EA_Entry_Nums:"|tee -a ${RUN_LOG_FILE}
+        echo -ne "[${TEST_NO}] Check Huge SingleNode Xattr EA_Entry_Nums:">>${DETAIL_LOG_FILE}
         echo >>${DETAIL_LOG_FILE}
         echo "==========================================================">>${DETAIL_LOG_FILE}
         echo -e "Testing Binary:\t\t${XATTR_TEST_BIN} -i 1 -x 20000 -n user -t normal -l 20 -s 100 ${WORKPLACE}">>${DETAIL_LOG_FILE}
@@ -328,8 +919,10 @@ f_runtest()
         echo_status ${RET} |tee -a ${RUN_LOG_FILE}
         exit_or_not ${RET}
         ${RM} -rf ${WORKPLACE}/* || exit 1
+	((TEST_PASS++))
 
 
+	((TEST_NO++))
         echo >>${DETAIL_LOG_FILE}
         echo "==========================================================">>${DETAIL_LOG_FILE}
         echo -ne "Check All Max SingleNode Xattr Arguments Together:"|tee -a ${RUN_LOG_FILE}
@@ -346,8 +939,8 @@ f_runtest()
 
         echo >>${DETAIL_LOG_FILE}
         echo "==========================================================">>${DETAIL_LOG_FILE}
-        echo -ne "Launch Random SingleNode Xattr Test on Ocfs2:"|tee -a ${RUN_LOG_FILE}
-        echo -ne "Launch Random SingleNode Xattr Test on Ocfs2:">>${DETAIL_LOG_FILE}
+        echo -ne "[${TEST_NO}] Launch Random SingleNode Xattr Test on Ocfs2:"|tee -a ${RUN_LOG_FILE}
+        echo -ne "[${TEST_NO}] Launch Random SingleNode Xattr Test on Ocfs2:">>${DETAIL_LOG_FILE}
         echo >>${DETAIL_LOG_FILE}
         echo "==========================================================">>${DETAIL_LOG_FILE}
         echo -e "Testing Binary:\t\t${XATTR_TEST_BIN} -i 1 -x 200 -n user -t normal -l 100 -s 4000 -r ${WORKPLACE}">>${DETAIL_LOG_FILE}
@@ -356,12 +949,14 @@ f_runtest()
         echo_status ${RET} |tee -a ${RUN_LOG_FILE}
         exit_or_not ${RET}
         ${RM} -rf ${WORKPLACE}/* || exit 1
+	((TEST_PASS++))
 
 
+	((TEST_NO++))
 	echo >>${DETAIL_LOG_FILE}
         echo "==========================================================">>${DETAIL_LOG_FILE}
-        echo -ne "Launch Concurrent Update/Read SingleNode Xattr Test on Ocfs2:"|tee -a ${RUN_LOG_FILE}
-        echo -ne "Launch Concurrent Update/Read SingleNode Xattr Test on Ocfs2:">>${DETAIL_LOG_FILE}
+        echo -ne "[${TEST_NO}] Launch Concurrent Update/Read SingleNode Xattr Test on Ocfs2:"|tee -a ${RUN_LOG_FILE}
+        echo -ne "[${TEST_NO}] Launch Concurrent Update/Read SingleNode Xattr Test on Ocfs2:">>${DETAIL_LOG_FILE}
         echo >>${DETAIL_LOG_FILE}
         echo "==========================================================">>${DETAIL_LOG_FILE}
         echo -e "Testing Binary:\t\t${XATTR_TEST_BIN} -i 1 -x 2000 -n user -t normal -l 50 -s 1000 -m 2000 -r ${WORKPLACE}">>${DETAIL_LOG_FILE}
@@ -370,12 +965,14 @@ f_runtest()
         echo_status ${RET} |tee -a ${RUN_LOG_FILE}
         exit_or_not ${RET}
         ${RM} -rf ${WORKPLACE}/* || exit 1
+	((TEST_PASS++))
 	
 	
+	((TEST_NO++))
 	echo >>${DETAIL_LOG_FILE}
         echo "==========================================================">>${DETAIL_LOG_FILE}
-        echo -ne "Launch Multiple Files SingleNode Xattr Test on Ocfs2:"|tee -a ${RUN_LOG_FILE}
-        echo -ne "Launch Multiple Files SingleNode Xattr Test on Ocfs2:">>${DETAIL_LOG_FILE}
+        echo -ne "[${TEST_NO}] Launch Multiple Files SingleNode Xattr Test on Ocfs2:"|tee -a ${RUN_LOG_FILE}
+        echo -ne "[${TEST_NO}] Launch Multiple Files SingleNode Xattr Test on Ocfs2:">>${DETAIL_LOG_FILE}
         echo >>${DETAIL_LOG_FILE}
         echo "==========================================================">>${DETAIL_LOG_FILE}
         echo -e "Testing Binary:\t\t${XATTR_TEST_BIN} -i 1 -x 500 -n user -t normal -l 20 -s 800 -f 100 -r ${WORKPLACE}">>${DETAIL_LOG_FILE}
@@ -384,11 +981,14 @@ f_runtest()
         echo_status ${RET} |tee -a ${RUN_LOG_FILE}
         exit_or_not ${RET}
         ${RM} -rf ${WORKPLACE}/* || exit 1
+	((TEST_PASS++))
 
 
+	((TEST_NO++))
 	echo >>${DETAIL_LOG_FILE}
         echo "==========================================================">>${DETAIL_LOG_FILE}
-        echo -ne "Launch Stress Test With Shell Command:"|tee -a ${RUN_LOG_FILE}
+        echo -ne "[${TEST_NO}] Launch Stress Test With Shell Command:"|tee -a ${RUN_LOG_FILE}
+        echo -ne "[${TEST_NO}] Launch Stress Test With Shell Command:">>${DETAIL_LOG_FILE}
         echo -ne "">>${DETAIL_LOG_FILE}
         echo >>${DETAIL_LOG_FILE}
         echo "==========================================================">>${DETAIL_LOG_FILE}
@@ -411,12 +1011,14 @@ f_runtest()
 		exit 1
         fi
         ${RM} -rf ${WORKPLACE}/* || exit 1
+	((TEST_PASS++))
 
 
+	((TEST_NO++))
 	echo >>${DETAIL_LOG_FILE}
         echo "==========================================================">>${DETAIL_LOG_FILE}
-        echo -ne "Launch SingleNode Xattr Stress Test on Ocfs2:"|tee -a ${RUN_LOG_FILE}
-        echo -ne "Launch SingleNode Xattr Stress Test on Ocfs2:">>${DETAIL_LOG_FILE}
+        echo -ne "[${TEST_NO}] Launch SingleNode Xattr Stress Test on Ocfs2:"|tee -a ${RUN_LOG_FILE}
+        echo -ne "[${TEST_NO}] Launch SingleNode Xattr Stress Test on Ocfs2:">>${DETAIL_LOG_FILE}
         echo >>${DETAIL_LOG_FILE}
         echo "==========================================================">>${DETAIL_LOG_FILE}
         echo -e "Testing Binary:\t\t${XATTR_TEST_BIN} -i 100 -x 10000 -n user -t normal -l 200 -s 60000  -r ${WORKPLACE}">>${DETAIL_LOG_FILE}
@@ -425,7 +1027,7 @@ f_runtest()
         echo_status ${RET} |tee -a ${RUN_LOG_FILE}
         exit_or_not ${RET}
         ${RM} -rf ${WORKPLACE}/* || exit 1
-
+	((TEST_PASS++))
 }
 
 f_cleanup()
@@ -442,12 +1044,16 @@ trap ' : ' SIGTERM
 
 f_setup $*
 
-for BLOCKSIZE in 1024 4096
+START_TIME=${SECONDS}
+echo "=====================Single node xattr testing starts: `date`=====================" |tee -a ${RUN_LOG_FILE}
+echo "=====================Single node xattr testing starts: `date`=====================" >> ${DETAIL_LOG_FILE}
+
+for BLOCKSIZE in 512 1024 2048 4096
 do
         for CLUSTERSIZE in 4096 32768 1048576
         do
-                echo "++++++++++Single node xattr test with \"-b ${BLOCKSIZE} -C ${CLUSTERSIZE}\"++++++++++" |tee -a ${RUN_LOG_FILE}
-                echo "++++++++++Single node xattr test with \"-b ${BLOCKSIZE} -C ${CLUSTERSIZE}\"++++++++++">>${DETAIL_LOG_FILE}
+                echo "++++++++++xattr tests with \"-b ${BLOCKSIZE} -C ${CLUSTERSIZE}\"++++++++++" |tee -a ${RUN_LOG_FILE}
+                echo "++++++++++xattr tests with \"-b ${BLOCKSIZE} -C ${CLUSTERSIZE}\"++++++++++">>${DETAIL_LOG_FILE}
                 echo "======================================================================================="
                 f_do_mkfs_and_mount
                 f_runtest
@@ -456,6 +1062,12 @@ do
                 echo -e "\n\n\n">>${DETAIL_LOG_FILE}
         done
 done
-
 f_cleanup
 
+END_TIME=${SECONDS}
+echo "=====================Single node xattr testing ends: `date`=====================" |tee -a ${RUN_LOG_FILE}
+echo "=====================Single node xattr testing ends: `date`=====================" >> ${DETAIL_LOG_FILE}
+
+echo "Time elapsed(s): $((${END_TIME}-${START_TIME}))" |tee -a ${RUN_LOG_FILE}
+echo "Tests total: ${TEST_NO}" |tee -a ${RUN_LOG_FILE}
+echo "Tests passed: ${TEST_PASS}" |tee -a ${RUN_LOG_FILE}
-- 
1.5.5




More information about the Ocfs2-test-devel mailing list