Whamcloud - gitweb
LU-2420 tests: Have POSIX testing on b2_1
authorEmoly Liu <emoly.liu@intel.com>
Fri, 7 Dec 2012 07:29:55 +0000 (15:29 +0800)
committerOleg Drokin <green@whamcloud.com>
Mon, 10 Dec 2012 21:40:22 +0000 (16:40 -0500)
Have POSIX testing automated on b2_1 as it is on master.
LU-2274 port is included to change the baseline filesystem to ext3
for POSIX testing on SLES distro.

Test-Parameters: envdefinitions=SLOW=yes clientdistro=sles11 testlist=posix
Signed-off-by: Liu Ying <emoly.liu@intel.com>
Change-Id: If20262a37d77053bda3a1e143d74c4ebd11b7ec5
Reviewed-on: http://review.whamcloud.com/4731
Reviewed-by: Jian Yu <jian.yu@intel.com>
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/tests/Makefile.am
lustre/tests/posix.sh [new file with mode: 0755]
lustre/tests/posix/posix.cfg [new file with mode: 0644]

index a7f32c5..3ec40c3 100644 (file)
@@ -27,7 +27,7 @@ noinst_SCRIPTS += lustre-rsync-test.sh ost-pools.sh rpc.sh yaml.sh liblustre.sh
 noinst_SCRIPTS += lnet-selftest.sh obdfilter-survey.sh mmp.sh mmp_mark.sh
 noinst_SCRIPTS += sgpdd-survey.sh maloo_upload.sh auster setup-nfs.sh
 noinst_SCRIPTS += parallel-scale-nfsv3.sh parallel-scale-nfsv4.sh
-noinst_SCRIPTS += parallel-scale-nfs.sh
+noinst_SCRIPTS += parallel-scale-nfs.sh posix.sh
 nobase_noinst_SCRIPTS = cfg/local.sh
 nobase_noinst_SCRIPTS += test-groups/regression test-groups/regression-mpi
 nobase_noinst_SCRIPTS += acl/make-tree acl/run cfg/ncli.sh
@@ -35,6 +35,7 @@ nobase_noinst_SCRIPTS += racer/dir_create.sh racer/file_create.sh racer/file_lis
 nobase_noinst_SCRIPTS += racer/file_rm.sh racer/racer.sh racer/file_concat.sh racer/file_exec.sh
 nobase_noinst_SCRIPTS += racer/file_link.sh racer/file_rename.sh racer/file_symlink.sh
 nobase_noinst_SCRIPTS += rmtacl/make-tree rmtacl/run
+nobase_noinst_SCRIPTS += posix/posix.cfg
 nobase_noinst_DATA = acl/cp.test acl/getfacl-noacl.test acl/inheritance.test
 nobase_noinst_DATA += acl/misc.test acl/permissions.test acl/setfacl.test
 nobase_noinst_DATA += rmtacl/misc.test rmtacl/permissions.test
diff --git a/lustre/tests/posix.sh b/lustre/tests/posix.sh
new file mode 100755 (executable)
index 0000000..e2bb173
--- /dev/null
@@ -0,0 +1,122 @@
+#!/bin/bash
+#set -vx
+set -e
+
+LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
+. $LUSTRE/tests/test-framework.sh
+init_test_env $@
+. ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
+init_logging
+
+build_test_filter
+check_and_setup_lustre
+
+POSIX_DIR=${POSIX_DIR:-"$LUSTRE/tests/posix"}
+POSIX_SRC=${POSIX_SRC:-"/usr/src/posix"}
+BASELINE_FS=${BASELINE_FS:-"ext4"}
+
+# SLES does not support read-write access to an ext4 file system by default
+[[ -e /etc/SuSE-release ]] && BASELINE_FS=ext3
+
+cleanup_loop_dev() {
+    local mnt=$1
+    local dev=$2
+    local file=$3
+
+    # if we only have 1 arg, we will search for dev
+    if [[ $# = 1 ]]; then
+        dev=$(losetup -a | grep "$mnt" | cut -d: -f1)
+        [[ -n $dev ]] && losetup -d $dev
+    else # we need all args
+        [[ -z $mnt ]] || [[ -z $dev ]] || [[ -z $file ]] &&
+            error "Can't cleanup loop device"
+        umount -f $mnt
+        losetup -d $dev && rm -rf $mnt
+        rm -f $file
+    fi
+}
+
+setup_loop_dev() {
+       local mnt=$1
+       local dev=$2
+       local file=$3
+       local rc=0
+
+       echo "Make a loop file system with $file on $dev"
+       dd if=/dev/zero of=$file bs=1024k count=500 > /dev/null
+       if ! losetup $dev $file; then
+               rc=$?
+               echo "can't set up $dev for $file"
+               return $rc
+       fi
+       if ! eval mkfs.$BASELINE_FS $dev; then
+               rc=$?
+               echo "mkfs.$BASELINE_FS on $dev failed"
+               return $rc
+       fi
+       mkdir -p $mnt
+       if ! mount -t $BASELINE_FS $dev $mnt; then
+               rc=$?
+               echo "mount $BASELINE_FS failed"
+               return $rc
+       fi
+       echo
+       return $rc
+}
+
+test_1() {
+       local allnodes="$(comma_list $(nodes_list))"
+       local tfile="$TMP/$BASELINE_FS-file"
+       local mntpnt=$POSIX_SRC/$BASELINE_FS
+       local loopbase
+       local loopdev
+       local rc=0
+
+    # We start at loop1 because posix build uses loop0
+    [ -b /dev/loop/1 ] && loopbase=/dev/loop/
+    [ -b /dev/loop1 ] && loopbase=/dev/loop
+    [ -z "$loopbase" ] && error "/dev/loop/1 and /dev/loop1 gone?"
+
+    for i in `seq 1 7`; do
+        losetup $loopbase$i > /dev/null 2>&1 && continue || true
+        loopdev=$loopbase$i
+        break
+    done
+
+    [ -z "$loopdev" ] && error "Can not find loop device"
+
+    if ! setup_loop_dev $mntpnt $loopdev $tfile; then
+        cleanup_loop_dev "$mntpnt" "$loopdev" "$tfile"
+        error "Setup loop device failed"
+    fi
+
+    # copy the source over to ext mount point
+    if ! cp -af ${POSIX_SRC}/*.* $mntpnt; then
+        cleanup_loop_dev "$mntpnt" "$loopdev" "$tfile"
+        error "Copy POSIX test suite failed"
+    fi
+    export POSIX_SRC=$mntpnt
+    . $POSIX_DIR/posix.cfg
+
+    setup_posix_users $allnodes
+    if ! setup_posix; then
+        delete_posix_users $allnodes
+        cleanup_loop_dev "$POSIX_SRC"
+        cleanup_loop_dev "$mntpnt" "$loopdev" "$tfile"
+        error "Setup POSIX test suite failed"
+    fi
+
+    log "Run POSIX test against lustre filesystem"
+    run_posix $MOUNT compare || \
+        error_noexit "Run POSIX testsuite on $MOUNT failed"
+
+    [[ -d "$MOUNT/TESTROOT" ]] && rm -fr $MOUNT/TESTROOT
+    delete_posix_users $allnodes
+    cleanup_loop_dev "$POSIX_SRC"
+    cleanup_loop_dev "$mntpnt" "$loopdev" "$tfile"
+}
+run_test 1 "install, build, run posix on $BASELINE_FS and lustre, then compare"
+
+complete $(basename $0) $SECONDS
+check_and_cleanup_lustre
+exit_status
diff --git a/lustre/tests/posix/posix.cfg b/lustre/tests/posix/posix.cfg
new file mode 100644 (file)
index 0000000..1f1408c
--- /dev/null
@@ -0,0 +1,190 @@
+#!/bin/bash
+#
+# This file contains the global variables and common functions
+# used in the posix test scripts.
+set -e
+
+LUSTRE=${LUSTRE:-$(cd $(dirname $0)/../..; echo $PWD)}
+. $LUSTRE/tests/test-framework.sh
+
+#************************ Initialize Global Variables *************************#
+export POSIX_SRC=${POSIX_SRC:-"/usr/src/posix"}
+export POSIX_RUN=${POSIX_RUN:-"$POSIX_SRC/run_posix_suite.pl"}
+export TEST_BIN="$POSIX_SRC/TESTROOT-gcc$(gcc -v 2>&1 | tail -1 |
+                cut -d' ' -f3)-$(uname -m).tgz"
+
+# Root directory of the POSIX test suite installation.
+export INSTALL_DIR=${INSTALL_DIR:-"$POSIX_SRC/tet"}
+
+# Root directory from which the testsets will be executed.
+export TESTEXEC_DIR=${TESTEXEC_DIR:-"$POSIX_SRC/TESTROOT"}
+
+# Test results directory.
+export RESULT_DIR=${RESULT_DIR:-"$INSTALL_DIR/test_sets/results"}
+
+# Test groups for POSIX compliance test suite.
+USER_GROUPS="vsxg0,vsxg1,vsxg2"
+
+for i in $(seq 31); do
+       SUPP_GROUPS="$SUPP_GROUPS,supp$i"
+done
+SUPP_GROUPS=${SUPP_GROUPS#,}
+
+export GROUP_ID=${GROUP_ID:-"2000000000"}
+export USER_ID=${USER_ID:-"2000000000"}
+
+#***************************** Common Functions *******************************#
+# Remove users and groups for running the POSIX test suite.
+delete_posix_users() {
+    local node=${1:-$(hostname)}
+
+    do_nodes $node "
+        for i in 0 1 2; do
+            userdel vsx\\\$i;
+        done;
+        for group in ${SUPP_GROUPS//,/ } ${USER_GROUPS//,/ }; do
+            groupdel \\\$group;
+        done" 2>&1 | dshbak -c
+    return ${PIPESTATUS[0]}
+}
+
+# Setup users and groups for running the POSIX test suite.
+setup_posix_users() {
+       local node=${1:-$HOSTNAME}
+       # consistent with install.sh in LSB Test Suite
+       local gid=$((GROUP_ID + 1))
+       local uid=$USER_ID
+       local user group
+       local home
+       local opts
+       local i
+
+       for group in ${USER_GROUPS//,/ } ${SUPP_GROUPS//,/ }; do
+               if ! do_rpc_nodes $node add_group $gid $group; then
+                       delete_posix_users $node
+                       return 1
+               fi
+               gid=$((gid + 1))
+       done
+
+       for i in 0 1 2; do
+               user=vsx$i
+               group=vsxg$i
+
+               if [[ "$user" = "vsx0" ]]; then
+                       home=$INSTALL_DIR/test_sets
+                       opts="-G $SUPP_GROUPS"
+               else
+                       home=$INSTALL_DIR
+                       opts=""
+               fi
+
+               if ! do_rpc_nodes $node add_user $uid $user $group $home $opts
+               then
+                       delete_posix_users $node
+                       return 2
+               fi
+               uid=$((uid + 1))
+       done
+
+       return 0
+}
+
+prep() {
+    if [[ ! -d $POSIX_SRC ]]; then
+        echo "Missing POSIX testsuite source"
+        return 1
+    fi
+    [[ -f $TEST_BIN ]] && rm -f $TEST_BIN
+    [[ -d $INSTALL_DIR ]] && rm -rf $INSTALL_DIR
+
+    if grep -q " 6." /etc/issue; then
+        [[ -d /usr/include/bits ]] || mkdir -p /usr/include/bits
+        [[ -d /usr/include/sys ]] || mkdir -p /usr/include/sys
+        [[ -s /usr/include/stropts.h ]] || \
+            ln -s /usr/lib/x86_64-redhat-linux5E/include/stropts.h \
+            /usr/include/stropts.h
+        [[ -s /usr/include/bits/stropts.h ]] || \
+            ln -s /usr/lib/x86_64-redhat-linux5E/include/bits/stropts.h \
+            /usr/include/bits/stropts.h
+        [[ -s /usr/include/bits/xtitypes.h ]] || \
+            ln -s /usr/lib/x86_64-redhat-linux5E/include/bits/xtitypes.h \
+            /usr/include/bits/xtitypes.h
+        [[ -s /usr/include/sys/stropts.h ]] || \
+            ln -s /usr/lib/x86_64-redhat-linux5E/include/sys/stropts.h \
+            /usr/include/sys/stropts.h
+    fi
+
+    pushd $POSIX_SRC > /dev/null
+
+    if [[ -f install.sh ]]; then
+        [[ ! -x install.sh ]] && chmod +x install.sh
+    else
+        popd > /dev/null
+        echo "install.sh does not exist in $POSIX_SRC."
+        return 1
+    fi
+
+    popd > /dev/null
+}
+
+install() {
+    pushd $POSIX_SRC > /dev/null
+
+    log "Installing POSIX test suite"
+    # Install the POSIX test suite source files
+    expect -f install-posix.exp $INSTALL_DIR $TESTEXEC_DIR
+
+    popd > /dev/null
+}
+
+build() {
+    pushd $POSIX_SRC > /dev/null
+
+    log "Building POSIX test suite"
+    # Build testsets
+    expect -f build-posix.exp $INSTALL_DIR $TESTEXEC_DIR $POSIX_SRC
+
+    popd > /dev/null
+}
+
+cleanup() {
+    if [[ -f $TEST_BIN ]]; then
+        rm -fr $TESTEXEC_DIR
+        echo "Install and build POSIX test suite successfully!"
+        return 0
+    else
+        echo "failed to build POSIX test suite."
+        return 1
+    fi
+}
+
+run_posix() {
+    local MNTPNT=$1
+    local COMPARE=${2}
+    local compare=""
+    local rc=0
+    local cmd
+
+    [[ "x$COMPARE" != "x" ]] && compare="--compare-result"
+    # command to run posix test suite
+    cmd="TMP=/tmp/vsx0 TMPDIR=/tmp/vsx0 $POSIX_RUN --mountpt=$MNTPNT \
+        --posix-src=$POSIX_SRC --install-dir=$INSTALL_DIR \
+        --results-dir=$RESULT_DIR $compare 2>&1"
+
+    # run posix test suite
+    echo $cmd
+    if ! eval $cmd; then
+        rc=${PIPESTATUS[0]}
+    fi
+
+    return $rc
+}
+
+setup_posix() {
+    log "Setting up POSIX test suite from $POSIX_SRC"
+    prep || return $?
+    install
+    build
+    cleanup
+}