[Ocfs2-tools-devel] [Ocfs2-test-devel] [PATCH 1/6] New set of inline-data testing tools:Add shell wrapper for single-node inline-data testing.

Tao Ma tao.ma at oracle.com
Sun Aug 31 19:52:24 PDT 2008


Hi Tristan,
	We have moved ocfs2-test to git version control.
You can see information about the new Git repository at
http://oss.oracle.com/projects/ocfs2-test/source.html

So could you please resend them based on git next round?

tristan.ye wrote:
> This patch aims at creating a shell wrapper to schedule the testcases
> for single-node inline-data testing,which helps to make things easier to
> go by automating testing.
> 
> Signed-off-by: Tristan Ye <tristan.ye at oracle.com>
> ---
> 
> Index: ocfs2-test/programs/inline-data/single-inline-run.sh
> ===================================================================
> --- ocfs2-test/programs/inline-data/single-inline-run.sh	(revision 0)
> +++ ocfs2-test/programs/inline-data/single-inline-run.sh	(revision 0)
> @@ -0,0 +1,372 @@
> +#!/bin/bash
> +# vi: set ts=8 sw=8 autoindent noexpandtab :
> +################################################################################
> +#
> +# File :        single-inline-run.sh
> +#
> +# Description:  The wrapper script help to run the inline-data test for
> both files and
> +#		dirs.
> +#       
> +#
> +# Author:       Tristan Ye,     tristan.ye at oracle.com
> +#
> +# History:      25 Aug 2008
> +#
> +
> +################################################################################
> +# Global Variables
> +################################################################################
> +PATH=$PATH:/sbin      # Add /sbin to the path for ocfs2 tools
> +export PATH=$PATH:.
> +RM="`which rm`"
> +MKDIR="`which mkdir`"
> +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`"
> +INLINE_DATA_BIN=`which single-inline-data`
> +INLINE_DIRS_BIN=`which single-inline-dirs`
> +DEFAULT_LOG="single-inline-data-test-logs"
> +LOG_OUT_DIR=
> +DATA_LOG_FILE=
> +DIRS_LOG_FILE=
> +RUN_LOG_FILE=
> +MOUNT_POINT=
> +OCFS2_DEVICE=
> +
> +BLOCKSIZE=
> +CLUSTERSIZE=
> +BLOCKNUMS=
> +
> +
> +set -o pipefail
> +
> +BOOTUP=color
> +RES_COL=80
> +MOVE_TO_COL="echo -en \\033[${RES_COL}G"
> +SETCOLOR_SUCCESS="echo -en \\033[1;32m"
> +SETCOLOR_FAILURE="echo -en \\033[1;31m"
> +SETCOLOR_WARNING="echo -en \\033[1;33m"
> +SETCOLOR_NORMAL="echo -en \\033[0;39m"
> +LOGLEVEL=1
> +
> +echo_success()
> +{
> +  [ "$BOOTUP" = "color" ] && $MOVE_TO_COL
> +  echo -n "["
> +  [ "$BOOTUP" = "color" ] && $SETCOLOR_SUCCESS
> +  echo -n $" PASS "
> +  [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
> +  echo -n "]"
> +  return 0
> +}
> +
> +echo_failure()
> +{
> +  [ "$BOOTUP" = "color" ] && $MOVE_TO_COL
> +  echo -n "["
> +  [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
> +  echo -n $"FAILED"
> +  [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
> +  echo -n "]"
> +  return 1
> +}
> +
> +echo_status()
> +{
> +	if [ "${1}" == "0" ];then
> +		echo_success
> +		echo
> +	else
> +		echo_failure
> +		echo
> +		exit 1
> +	fi
> +
> +	
> +}
> +
> +exit_or_not()
> +{
> +	if [ "${1}" != "0" ];then
> +		exit 1;
> +	fi
> +}
> +
> +################################################################################
> +# Utility Functions
> +################################################################################
> +f_usage()
> +{
> +    echo "usage: `basename ${0}` [-o output] <-d <device>> <mountpoint
> path>"
> +    echo "       -o output directory for the logs"
> +    echo "       -d device name used for ocfs2 volume"
> +    echo "       <mountpoint path> path of mountpoint where the ocfs2
> volume will be mounted on."
> +    exit 1;
> +
> +}
> +
> +f_getoptions()
> +{
> +         if [ $# -eq 0 ]; then
> +                f_usage;
> +                exit 1
> +         fi
> +
> +         while getopts "o:hd:" options; do
> +                case $options in
> +                o ) LOG_OUT_DIR="$OPTARG";;
> +                d ) OCFS2_DEVICE="$OPTARG";;
> +                h ) f_usage
> +                    exit 1;;
> +                * ) f_usage
> +                   exit 1;;
> +                esac
> +        done
> +        shift $(($OPTIND -1))
> +        MOUNT_POINT=${1}
> +
> +}
> +
> +f_setup()
> +{
> +        f_getoptions $*
> +
> +        if [ -z "${MOUNT_POINT}" ];then
> +                f_usage
> +        fi
> +
> +        LOG_OUT_DIR=${LOG_OUT_DIR:-$DEFAULT_LOG}
> +
> +        ${MKDIR} -p ${LOG_OUT_DIR} || exit 1
> +
> +
> +        LOG_POSTFIX=$(date +%Y%m%d-%H%M%S)
> +        DATA_LOG_FILE="`dirname ${LOG_OUT_DIR}`/`basename
> ${LOG_OUT_DIR}`/single-inline-data-test-${LOG_POSTFIX}.log"
> +        DIRS_LOG_FILE="`dirname ${LOG_OUT_DIR}`/`basename
> ${LOG_OUT_DIR}`/single-inline-dirs-test-${LOG_POSTFIX}.log"
> +        RUN_LOG_FILE="`dirname ${LOG_OUT_DIR}`/`basename
> ${LOG_OUT_DIR}`/run-${LOG_POSTFIX}.log"
> +
> +}
> +
> +f_do_mkfs_and_mount()
> +{
> +	echo -n "Mkfsing device:"|tee -a ${RUN_LOG_FILE}
> +
> +	echo y|${MKFS_BIN} --fs-features=inline-data -b ${BLOCKSIZE} -C
> ${CLUSTERSIZE} -N 4 ${OCFS2_DEVICE} ${BLOCKNUMS}>>${RUN_LOG_FILE} 2>&1
> +	RET=$?
> +	echo_status ${RET} |tee -a ${RUN_LOG_FILE}
> +	exit_or_not ${RET}
> +
> +	echo -n "Mounting device to ${MOUNT_POINT}:"|tee -a ${RUN_LOG_FILE}
> +
> +	${MOUNT_BIN} -t ocfs2 ${OCFS2_DEVICE}  ${MOUNT_POINT}>>${RUN_LOG_FILE}
> 2>&1
> +
> +	RET=$?
> +        echo_status ${RET} |tee -a ${RUN_LOG_FILE}
> +        exit_or_not ${RET}
> +} 
> +
> +f_run_data_test()
> +{
> +	echo >>${DATA_LOG_FILE}
> +        echo
> "==========================================================">>${DATA_LOG_FILE}
> +        echo -ne "Functionality Test For Regular File:"|tee -a
> ${RUN_LOG_FILE}
> +        echo -ne "Functionality Test For Regular File:">>
> ${DATA_LOG_FILE}
> +        echo >>${DATA_LOG_FILE}
> +        echo
> "==========================================================">>${DATA_LOG_FILE}
> +	echo -e "Testing Binary:\t\t${INLINE_DATA_BIN} -i 1 -d ${OCFS2_DEVICE}
> ${MOUNT_POINT}">>${DATA_LOG_FILE}
> +
> +	${INLINE_DATA_BIN} -i 1 -d ${OCFS2_DEVICE}
> ${MOUNT_POINT}>>${DATA_LOG_FILE} 2>&1
I think maybe you can add 2 user parameters for data_bin and dir_bin so 
that the user can give them directly to your script if they want to use 
other similar programs.

btw, I haven't run your program yet, maybe try it when you send a git 
format one.

Regards,
Tao



More information about the Ocfs2-tools-devel mailing list