Whamcloud - gitweb
LU-16399 tests: add subtests setup/cleanup records 82/49582/45
authorAlex Deiter <alex.deiter@gmail.com>
Mon, 9 Jan 2023 16:19:26 +0000 (20:19 +0400)
committerOleg Drokin <green@whamcloud.com>
Tue, 20 Jun 2023 05:20:16 +0000 (05:20 +0000)
* Added setup/cleanup records for subtests

Change-Id: Icb203a864fa8785e423a073b4ee0f02ea3d3ac77
Signed-off-by: Alex Deiter <adeiter@tintri.com>
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/49582
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Jian Yu <yujian@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/tests/conf-sanity.sh
lustre/tests/functions.sh
lustre/tests/sanity-pcc.sh
lustre/tests/test-framework.sh

index 11e6a55..09a9b36 100644 (file)
@@ -3075,7 +3075,7 @@ run_test 33b "Drop cancel during umount"
 
 test_34a() {
        setup
-       do_facet client "sh runmultiop_bg_pause $DIR/file O_c"
+       do_facet client "bash runmultiop_bg_pause $DIR/file O_c"
        manual_umount_client
        rc=$?
        do_facet client killall -USR1 multiop
index f25817d..d0771f2 100644 (file)
@@ -578,7 +578,7 @@ run_connectathon() {
        fi
        echo "tests: $tests"
        for test in $tests; do
-               local cmd="sh ./runtests -N $cnt_NRUN $test -f $testdir"
+               local cmd="bash ./runtests -N $cnt_NRUN $test -f $testdir"
                local rc=0
 
                log "$cmd"
index b0a28aa..6b9e74d 100644 (file)
@@ -1584,7 +1584,7 @@ test_101a() {
        # File is owned by root, make it accessible to RUNAS user
        chmod a+rw $DIR/$tdir/$tfile.shell
        stack_trap 'rm -f $DIR/$tdir/$tfile.shell' EXIT
-       do_facet $SINGLEAGT nsenter -t $PID -U -m "sh $DIR/$tdir/$tfile.shell"
+       do_facet $SINGLEAGT nsenter -t $PID -U -m "bash $DIR/$tdir/$tfile.shell"
        do_facet $SINGLEAGT nsenter -t $PID -U -m $LFS pcc attach -i $HSM_ARCHIVE_NUMBER \
                $file || error "RW-PCC attach $file failed"
        check_lpcc_state $file "readwrite"
index 242cb5d..1f0e350 100755 (executable)
@@ -4289,7 +4289,7 @@ do_node_vp() {
        shift
 
        if [[ "$host" == "$HOSTNAME" ]]; then
-               sh -c "$(printf -- ' %q' "$@")"
+               bash -c "$(printf -- ' %q' "$@")"
                return $?
        fi
 
@@ -5771,7 +5771,9 @@ set_pools_quota () {
        done
 }
 
-check_and_setup_lustre() {
+do_check_and_setup_lustre() {
+       echo "=== $TESTSUITE: start setup $(date +'%H:%M:%S (%s)') ==="
+
        sanitize_parameters
        nfs_client_mode && return
        cifs_client_mode && return
@@ -5850,6 +5852,7 @@ check_and_setup_lustre() {
        if [ -n "$fs_STRIPEPARAMS" ]; then
                setstripe_getstripe $MOUNT $fs_STRIPEPARAMS
        fi
+
        if $GSS_SK; then
                set_flavor_all null
        elif $GSS; then
@@ -5859,6 +5862,7 @@ check_and_setup_lustre() {
        if $DELETE_OLD_POOLS; then
                destroy_all_pools
        fi
+
        if [[ -n "$FS_POOL" ]]; then
                create_pools $FS_POOL $FS_POOL_NOSTS
        fi
@@ -5866,11 +5870,44 @@ check_and_setup_lustre() {
        if [[ -n "$POOLS_QUOTA_USERS_SET" ]]; then
                set_pools_quota
        fi
-       if [ "$ONLY" == "setup" ]; then
+
+       echo "=== $TESTSUITE: finish setup $(date +'%H:%M:%S (%s)') ==="
+
+       if [[ "$ONLY" == "setup" ]]; then
                exit 0
        fi
 }
 
+check_and_setup_lustre() {
+       local start_stamp=$(date +%s)
+       local saved_umask=$(umask)
+       local log=$TESTLOG_PREFIX.test_setup.test_log.$(hostname -s).log
+       local status='PASS'
+       local stop_stamp=0
+       local duration=0
+       local error=''
+       local rc=0
+
+       umask 0022
+
+       log_sub_test_begin test_setup
+
+       if ! do_check_and_setup_lustre 2>&1 > >(tee -i $log); then
+               error=$(tail -1 $log)
+               status='FAIL'
+               rc=1
+       fi
+
+       stop_stamp=$(date +%s)
+       duration=$((stop_stamp - start_stamp))
+
+       log_sub_test_end "$status" "$duration" "$rc" "$error"
+
+       umask $saved_umask
+
+       return $rc
+}
+
 restore_mount () {
        local clients=${CLIENTS:-$HOSTNAME}
        local mntpt=$1
@@ -5886,14 +5923,16 @@ cleanup_mount () {
 }
 
 cleanup_and_setup_lustre() {
-       if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
+       if [[ "$ONLY" == "cleanup" ]] || grep -q "$MOUNT" /proc/mounts; then
                lctl set_param debug=0 || true
                cleanupall
-               if [ "$ONLY" == "cleanup" ]; then
+
+               if [[ "$ONLY" == "cleanup" ]]; then
                        exit 0
                fi
        fi
-       check_and_setup_lustre
+
+       do_check_and_setup_lustre
 }
 
 # Run e2fsck on MDT or OST device.
@@ -6033,34 +6072,68 @@ log_zfs_info() {
        fi
 }
 
-check_and_cleanup_lustre() {
-       if [ "$LFSCK_ALWAYS" = "yes" -a "$TESTSUITE" != "sanity-lfsck" -a \
-            "$TESTSUITE" != "sanity-scrub" ]; then
+do_check_and_cleanup_lustre() {
+       echo "=== $TESTSUITE: start cleanup $(date +'%H:%M:%S (%s)') ==="
+
+       if [[ "$LFSCK_ALWAYS" == "yes" && "$TESTSUITE" != "sanity-lfsck" && \
+             "$TESTSUITE" != "sanity-scrub" ]]; then
                run_lfsck
        fi
 
        if is_mounted $MOUNT; then
                if $DO_CLEANUP; then
-                       [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-9]* ||
+                       [[ -n "$DIR" ]] && rm -rf $DIR/[Rdfs][0-9]* ||
                                error "remove sub-test dirs failed"
                else
                        echo "skip cleanup"
                fi
-               [ "$ENABLE_QUOTA" ] && restore_quota || true
+               [[ -n "$ENABLE_QUOTA" ]] && restore_quota || true
        fi
 
-       if [ "$I_UMOUNTED2" = "yes" ]; then
+       if [[ "$I_UMOUNTED2" == "yes" ]]; then
                restore_mount $MOUNT2 || error "restore $MOUNT2 failed"
        fi
 
-       if [ "$I_MOUNTED2" = "yes" ]; then
+       if [[ "$I_MOUNTED2" == "yes" ]]; then
                cleanup_mount $MOUNT2
        fi
 
-       if [[ "$I_MOUNTED" = "yes" ]] && ! $AUSTER_CLEANUP; then
+       if [[ "$I_MOUNTED" == "yes" ]] && ! $AUSTER_CLEANUP; then
                cleanupall -f || error "cleanup failed"
                unset I_MOUNTED
        fi
+
+       echo "=== $TESTSUITE: finish cleanup $(date +'%H:%M:%S (%s)') ==="
+}
+
+check_and_cleanup_lustre() {
+       local start_stamp=$(date +%s)
+       local saved_umask=$(umask)
+       local log=$TESTLOG_PREFIX.test_cleanup.test_log.$(hostname -s).log
+       local status='PASS'
+       local stop_stamp=0
+       local duration=0
+       local error=''
+       local rc=0
+
+       umask 0022
+
+       log_sub_test_begin test_cleanup
+
+       if ! do_check_and_cleanup_lustre 2>&1 > >(tee -i $log); then
+               error=$(tail -1 $log)
+               status='FAIL'
+               rc=1
+       fi
+
+       stop_stamp=$(date +%s)
+       duration=$((stop_stamp - start_stamp))
+
+       log_sub_test_end "$status" "$duration" "$rc" "$error"
+
+       umask $saved_umask
+
+       return $rc
 }
 
 #######