From d0ae0079d747d05f74f733fb594d8edb512f8b16 Mon Sep 17 00:00:00 2001 From: Alex Deiter Date: Mon, 9 Jan 2023 20:19:26 +0400 Subject: [PATCH] LU-16399 tests: add subtests setup/cleanup records * Added setup/cleanup records for subtests Change-Id: Icb203a864fa8785e423a073b4ee0f02ea3d3ac77 Signed-off-by: Alex Deiter Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/49582 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Jian Yu Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin --- lustre/tests/conf-sanity.sh | 2 +- lustre/tests/functions.sh | 2 +- lustre/tests/sanity-pcc.sh | 2 +- lustre/tests/test-framework.sh | 101 +++++++++++++++++++++++++++++++++++------ 4 files changed, 90 insertions(+), 17 deletions(-) diff --git a/lustre/tests/conf-sanity.sh b/lustre/tests/conf-sanity.sh index 11e6a55..09a9b36 100644 --- a/lustre/tests/conf-sanity.sh +++ b/lustre/tests/conf-sanity.sh @@ -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 diff --git a/lustre/tests/functions.sh b/lustre/tests/functions.sh index f25817d..d0771f2 100644 --- a/lustre/tests/functions.sh +++ b/lustre/tests/functions.sh @@ -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" diff --git a/lustre/tests/sanity-pcc.sh b/lustre/tests/sanity-pcc.sh index b0a28aa..6b9e74d 100644 --- a/lustre/tests/sanity-pcc.sh +++ b/lustre/tests/sanity-pcc.sh @@ -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" diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh index 242cb5d..1f0e350 100755 --- a/lustre/tests/test-framework.sh +++ b/lustre/tests/test-framework.sh @@ -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 } ####### -- 1.8.3.1