From f777a0a7390dfae4a49555d27416c898bde010f6 Mon Sep 17 00:00:00 2001 From: Jian Yu Date: Mon, 10 Jan 2022 00:37:25 -0800 Subject: [PATCH] EX-4052 tests: use stack_trap within a subtest in sanity-lipe Trap in a subshell is handled differently across bash versions. This patch moves stack_trap into subtests to make them work reliably. Test-Parameters: trivial clientdistro=el7.9 testlist=sanity-lipe Test-Parameters: trivial clientdistro=el8.4 testlist=sanity-lipe Lustre-change: https://review.whamcloud.com/45889 Lustre-commit: db8e16fd8434651ed6102a6be79828346775f87e Change-Id: I00eac5a8cf9511c8e1e531eb54f52ce443e5f77e Signed-off-by: Jian Yu Reviewed-by: John L. Hammond Reviewed-on: https://review.whamcloud.com/46026 Tested-by: jenkins Tested-by: Maloo --- lustre/tests/sanity-lipe.sh | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/lustre/tests/sanity-lipe.sh b/lustre/tests/sanity-lipe.sh index 6f02c69..6894eaa 100644 --- a/lustre/tests/sanity-lipe.sh +++ b/lustre/tests/sanity-lipe.sh @@ -49,13 +49,17 @@ build_test_filter check_and_setup_lustre # mount Lustre clients on MDS node(s) -LIPE_MDS_NODE=$(exclude_items_from_list $(comma_list $(all_mdts_nodes)) \ - $HOSTNAME) -if [[ -n $LIPE_MDS_NODE ]]; then - zconf_mount_clients $LIPE_MDS_NODE $MOUNT || - error "failed to mount Lustre client on MDS node $LIPE_MDS_NODE" - stack_trap "zconf_umount_clients $LIPE_MDS_NODE $MOUNT" -fi +mount_client_on_mds() { + local mds_nodes + + mds_nodes=$(exclude_items_from_list $(comma_list $(all_mdts_nodes)) \ + $HOSTNAME) + if [[ -n $mds_nodes ]]; then + zconf_mount_clients $mds_nodes $MOUNT || + error "failed to mount client on MDS node $mds_nodes" + stack_trap "zconf_umount_clients $mds_nodes $MOUNT" + fi +} # choose a random MDS and return its facet lipe_get_random_mds() { @@ -438,6 +442,7 @@ test_5() { local saved_LIPE_FIND_USE_MOUNT=$LIPE_FIND_USE_MOUNT LIPE_FIND_USE_MOUNT=true stack_trap "LIPE_FIND_USE_MOUNT=$saved_LIPE_FIND_USE_MOUNT" + mount_client_on_mds mkdir_on_mdt -i $index $td || error "$LFS mkdir '$td' failed" create_lipe_find_files $tf @@ -1130,6 +1135,7 @@ test_17() { local saved_LIPE_FIND_USE_MOUNT=$LIPE_FIND_USE_MOUNT LIPE_FIND_USE_MOUNT=true stack_trap "LIPE_FIND_USE_MOUNT=$saved_LIPE_FIND_USE_MOUNT" + mount_client_on_mds mkdir_on_mdt -i $index $td || error "$LFS mkdir '$td' failed" mkdir_on_mdt -i $index $td-1 || error "$LFS mkdir '$td-1' failed" @@ -1366,6 +1372,7 @@ test_22() { local saved_LIPE_FIND_USE_MOUNT=$LIPE_FIND_USE_MOUNT LIPE_FIND_USE_MOUNT=true stack_trap "LIPE_FIND_USE_MOUNT=$saved_LIPE_FIND_USE_MOUNT" + mount_client_on_mds mkdir_on_mdt -i $index $td || error "$LFS mkdir '$td' failed" create_lipe_find_files $tf @@ -1443,6 +1450,7 @@ test_23() { local saved_LIPE_FIND_USE_MOUNT=$LIPE_FIND_USE_MOUNT LIPE_FIND_USE_MOUNT=true stack_trap "LIPE_FIND_USE_MOUNT=$saved_LIPE_FIND_USE_MOUNT" + mount_client_on_mds mkdir_on_mdt -i $index $td || error "$LFS mkdir '$td' failed" create_lipe_find_files $tf @@ -1531,6 +1539,8 @@ test_201() { sync cancel_lru_locks mdc + mount_client_on_mds + attrs=$(do_lipe_scan2_facet $facet --client-mount="$MOUNT" \ --print-json=fid,paths | jq --arg FID "$fid" 'select(.fid == $FID)') -- 1.8.3.1