From 563b643c089cc651d12e82e4af84e1ff8c643b6b Mon Sep 17 00:00:00 2001 From: James Nunez Date: Thu, 21 Dec 2017 14:23:40 -0700 Subject: [PATCH] LU-10350 tests: make parsing routines pattern aware 'lfs getstripe' now returns the pattern for each component of a directory and files. The routines that parse parameters, parse_layout_param() and parse_plain_param(), need to look for the component pattern when parsing the output of 'lfs getstripe'. Lustre-change: https://review.whamcloud.com/30636 Lustre-commit: 503a78bde8a59e176356a02b2d078332e3201575 Test-Parameters: trivial testlist=sanity-pfl,ost-pools Signed-off-by: James Nunez Change-Id: Iab605f58e9c8f501fa0889806c511e3310cb6dd7 Reviewed-on: https://review.whamcloud.com/30636 Tested-by: Jenkins Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Lai Siyao Reviewed-by: Oleg Drokin (cherry picked from commit 503a78bde8a59e176356a02b2d078332e3201575) Reviewed-on: https://review.whamcloud.com/32048 Reviewed-by: Wei Liu Reviewed-by: John L. Hammond --- lustre/tests/sanity-pfl.sh | 1 + lustre/tests/test-framework.sh | 84 +++++++++++++++++++++++++++--------------- 2 files changed, 56 insertions(+), 29 deletions(-) diff --git a/lustre/tests/sanity-pfl.sh b/lustre/tests/sanity-pfl.sh index cc4d01e..0b77357 100644 --- a/lustre/tests/sanity-pfl.sh +++ b/lustre/tests/sanity-pfl.sh @@ -375,6 +375,7 @@ component_dump() { test_10() { local parent=$DIR/$tdir local root_layout=$(get_layout_param $MOUNT) + echo "$MOUNT layout: $root_layout" rm -rf $parent $LFS setstripe -d $MOUNT || error "clear root layout" diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh index 095fa26..3f13415 100755 --- a/lustre/tests/test-framework.sh +++ b/lustre/tests/test-framework.sh @@ -8355,6 +8355,30 @@ lss_gen_conf() do_facet mgs "cat $LSNAPSHOT_CONF" } +# Parse 'lfs getstripe -d ' for non-composite dir +parse_plain_dir_param() +{ + local invalues=($1) + local param="" + + if [[ ${invalues[0]} =~ "stripe_count:" ]]; then + param="-c ${invalues[1]}" + fi + if [[ ${invalues[2]} =~ "stripe_size:" ]]; then + param="$param -S ${invalues[3]}" + fi + if [[ ${invalues[4]} =~ "pattern:" ]]; then + if [[ ${invalues[5]} =~ "stripe_offset:" ]]; then + param="$param -i ${invalues[6]}" + else + param="$param -L ${invalues[5]} -i ${invalues[7]}" + fi + elif [[ ${invalues[4]} =~ "stripe_offset:" ]]; then + param="$param -i ${invalues[5]}" + fi + echo "$param" +} + parse_plain_param() { local line=$1 @@ -8366,6 +8390,8 @@ parse_plain_param() echo "-S $val" elif [[ $line =~ ^"lmm_stripe_offset:" ]]; then echo "-i $val" + elif [[ $line =~ ^"lmm_pattern:" ]]; then + echo "-L $val" fi } @@ -8376,39 +8402,39 @@ parse_layout_param() local param="" while read line; do - if [[ -z $mode ]]; then - if [[ $line =~ ^"stripe_count:" ]]; then - mode="plain_dir" - elif [[ $line =~ ^"lmm_stripe_count:" ]]; then - mode="plain_file" - elif [[ $line =~ ^"lcm_layout_gen:" ]]; then - mode="pfl" + if [[ ! -z $line ]]; then + if [[ -z $mode ]]; then + if [[ $line =~ ^"stripe_count:" ]]; then + mode="plain_dir" + elif [[ $line =~ ^"lmm_stripe_count:" ]]; then + mode="plain_file" + elif [[ $line =~ ^"lcm_layout_gen:" ]]; then + mode="pfl" + fi fi - fi - if [[ $mode = "plain_dir" ]]; then - param=$(echo $line | - awk '{printf("-c %d -S %d -i %d",$2,$4,$6)}') - elif [[ $mode = "plain_file" ]]; then - val=$(parse_plain_param "$line") - [[ ! -z $val ]] && param="$param $val" - elif [[ $mode = "pfl" ]]; then - val=$(echo $line | awk '{print $2}') - if [[ $line =~ ^"lcme_extent.e_end:" ]]; then - if [[ $val = "EOF" ]]; then - param="$param -E -1" - else - param="$param -E $val" - fi - elif [[ $line =~ ^"stripe_count:" ]]; then - # pfl dir - val=$(echo $line | - awk '{printf("-c %d -S %d -i %d",$2,$4,$6)}') - param="$param $val" - else - #pfl file + if [[ $mode = "plain_dir" ]]; then + param=$(parse_plain_dir_param "$line") + elif [[ $mode = "plain_file" ]]; then val=$(parse_plain_param "$line") [[ ! -z $val ]] && param="$param $val" + elif [[ $mode = "pfl" ]]; then + val=$(echo $line | awk '{print $2}') + if [[ $line =~ ^"lcme_extent.e_end:" ]]; then + if [[ $val = "EOF" ]]; then + param="$param -E -1" + else + param="$param -E $val" + fi + elif [[ $line =~ ^"stripe_count:" ]]; then + # pfl dir + val=$(parse_plain_dir_param "$line") + param="$param $val" + else + #pfl file + val=$(parse_plain_param "$line") + [[ ! -z $val ]] && param="$param $val" + fi fi fi done -- 1.8.3.1