From 9bcb52a5bd5eab66c16c284bd27eec942867d751 Mon Sep 17 00:00:00 2001 From: Sonia Date: Tue, 9 May 2017 16:24:45 -0700 Subject: [PATCH] LU-8576 test: Fix hard-coded NETTYPE in test-framework.sh In test-frameowrk.sh, h2o2ib() and h2tcp() hard-codes the network type value to o2ib or tcp respectively. With this patch, h2nettype() is defined which replaces h2o2ib(), h2tcp(), h2ptl() and h2elan(). Function h2nettype() uses value of NETTYPE parameter passed from user instead of any hard-coded value. With this patch, NETTYPE value is used as network name instead of network type. Test-Parameters: trivial testlist=conf-sanity, sanity, sanity-sec Change-Id: If0fe16a1f6aade4d7f784243c75f70764280ea88 Signed-off-by: Sonia Sharma Reviewed-on: https://review.whamcloud.com/27027 Tested-by: Jenkins Reviewed-by: Andreas Dilger Reviewed-by: Dmitry Eremin Tested-by: Maloo --- lustre/tests/cfg/local.sh | 2 +- lustre/tests/conf-sanity.sh | 14 +++---- lustre/tests/sanity-sec.sh | 2 +- lustre/tests/sanity.sh | 10 ++--- lustre/tests/test-framework.sh | 92 ++++++++++++++++-------------------------- 5 files changed, 49 insertions(+), 71 deletions(-) diff --git a/lustre/tests/cfg/local.sh b/lustre/tests/cfg/local.sh index baa7d18..dc0c6cb 100644 --- a/lustre/tests/cfg/local.sh +++ b/lustre/tests/cfg/local.sh @@ -75,7 +75,7 @@ OST_INDEX_LIST=${OST_INDEX_LIST:-} # More specific ones override more general ones. See facet_index(). NETTYPE=${NETTYPE:-tcp} -MGSNID=${MGSNID:-$(h2$NETTYPE $mgs_HOST)} +MGSNID=${MGSNID:-$(h2nettype $mgs_HOST)} # # Back end file system type(s) of facets can be specified with these diff --git a/lustre/tests/conf-sanity.sh b/lustre/tests/conf-sanity.sh index ac29af6..525d436 100755 --- a/lustre/tests/conf-sanity.sh +++ b/lustre/tests/conf-sanity.sh @@ -1367,7 +1367,7 @@ test_32newtarball() { chown $T32_QID.$T32_QID $tmp/src/t32_qf_old # format ost with comma-separated NIDs to verify LU-4460 - local failnid="$(h2$NETTYPE 1.2.3.4),$(h2$NETTYPE 4.3.2.1)" + local failnid="$(h2nettype 1.2.3.4),$(h2nettype 4.3.2.1)" MGSNID="$MGSNID,$MGSNID" OSTOPT="--failnode=$failnid" formatall setupall @@ -2480,9 +2480,9 @@ test_35a() { # bug 12459 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1) do_facet mgs "$LCTL conf_param \ - ${device}.failover.node=$(h2$NETTYPE $FAKENID)" || + ${device}.failover.node=$(h2nettype $FAKENID)" || error "Setting ${device}.failover.node=\ - $(h2$NETTYPE $FAKENID) failed." + $(h2nettype $FAKENID) failed." log "Wait for RECONNECT_INTERVAL seconds (10s)" sleep 10 @@ -2538,9 +2538,9 @@ test_35b() { # bug 18674 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1) do_facet mgs "$LCTL conf_param \ - ${device}.failover.node=$(h2$NETTYPE $FAKENID)" || + ${device}.failover.node=$(h2nettype $FAKENID)" || error "Set ${device}.failover.node=\ - $(h2$NETTYPE $FAKENID) failed" + $(h2nettype $FAKENID) failed" local at_max_saved=0 # adaptive timeouts may prevent seeing the issue @@ -3224,7 +3224,7 @@ test_43b() { # LU-5690 local client_ip=$(host_nids_address $HOSTNAME $NETTYPE) local host=${client_ip//*./} local net=${client_ip/%$host/} - local nosquash_nids=$(h2$NETTYPE $net[$host,$host,$host]) + local nosquash_nids=$(h2nettype $net[$host,$host,$host]) add $fs2mgs $(mkfs_opts mgs $fs2mgsdev) --fsname=$fsname \ --param mdt.root_squash=$RUNAS_ID:$RUNAS_ID \ @@ -5381,7 +5381,7 @@ test_77() { # LU-3445 local fs2ostvdev=$(ostvdevname 1_2) local fsname=test1234 local mgsnid - local failnid="$(h2$NETTYPE 1.2.3.4),$(h2$NETTYPE 4.3.2.1)" + local failnid="$(h2nettype 1.2.3.4),$(h2nettype 4.3.2.1)" combined_mgs_mds || stop_mgs || error "stopping MGS service failed" diff --git a/lustre/tests/sanity-sec.sh b/lustre/tests/sanity-sec.sh index 3a710b0..5df8e27 100755 --- a/lustre/tests/sanity-sec.sh +++ b/lustre/tests/sanity-sec.sh @@ -922,7 +922,7 @@ create_fops_nodemaps() { local client for client in $clients; do local client_ip=$(host_nids_address $client $NETTYPE) - local client_nid=$(h2$NETTYPE $client_ip) + local client_nid=$(h2nettype $client_ip) do_facet mgs $LCTL nodemap_add c${i} || return 1 do_facet mgs $LCTL nodemap_add_range \ --name c${i} --range $client_nid || return 1 diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 863eba0..a436192 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -6563,13 +6563,13 @@ run_test 99f "cvs commit =======================================" test_100() { [ $PARALLEL == "yes" ] && skip "skip parallel run" && return - [ "$NETTYPE" = tcp ] || \ - { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" && \ + [[ "$NETTYPE" =~ tcp ]] || + { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" && return ; } remote_ost_nodsh && skip "remote OST with nodsh" && return remote_mds_nodsh && skip "remote MDS with nodsh" && return - remote_servers || \ + remote_servers || { skip "useless for local single node setup" && return; } netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do @@ -12892,8 +12892,8 @@ test_217() { # bug 22430 for node in $(nodes_list); do nid=$(host_nids_address $node $NETTYPE) if [[ $nid = *-* ]] ; then - echo "lctl ping $nid@$NETTYPE" - lctl ping $nid@$NETTYPE + echo "lctl ping $(h2nettype $nid)" + lctl ping $(h2nettype $nid) else echo "skipping $node (no hyphen detected)" fi diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh index 0143715..1c0533e 100755 --- a/lustre/tests/test-framework.sh +++ b/lustre/tests/test-framework.sh @@ -581,14 +581,18 @@ load_modules_local() { set_default_debug load_module ../lnet/lnet/lnet - case $NETTYPE in - o2ib) - LNETLND="o2iblnd/ko2iblnd" - ;; - *) - ;; - esac - LNETLND=${LNETLND:-"socklnd/ksocklnd"} + + LNDPATH=${LNDPATH:-"../lnet/klnds"} + if [ -z "$LNETLND" ]; then + case $NETTYPE in + o2ib*) LNETLND="o2iblnd/ko2iblnd" ;; + tcp*) LNETLND="socklnd/ksocklnd" ;; + *) local lnd="${NETTYPE%%[0-9]}lnd" + [ -f "$LNDPATH/$lnd/k$lnd.ko" ] && + LNETLND="$lnd/k$lnd" || + LNETLND="socklnd/ksocklnd" + esac + fi load_module ../lnet/klnds/$LNETLND load_module obdclass/obdclass load_module ptlrpc/ptlrpc @@ -2753,21 +2757,11 @@ fail_abort() { clients_up || error "post-failover stat: $?" } -do_lmc() { - echo There is no lmc. This is mountconf, baby. - exit 1 -} - host_nids_address() { - local nodes=$1 - local kind=$2 + local nodes=$1 + local net=${2:-"."} - if [ -n "$kind" ]; then - nids=$(do_nodes $nodes "$LCTL list_nids | grep $kind | cut -f 1 -d '@'") - else - nids=$(do_nodes $nodes "$LCTL list_nids all | cut -f 1 -d '@'") - fi - echo $nids + do_nodes $nodes "$LCTL list_nids | grep $net | cut -f 1 -d @" } h2name_or_ip() { @@ -2776,40 +2770,34 @@ h2name_or_ip() { fi } -h2ptl() { - if [ "$1" = "'*'" ]; then echo \'*\'; else - ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | \ - awk '{print $1}'` - if [ -z "$ID" ]; then - echo "Could not get a ptl id for $1..." - exit 1 - fi - echo $ID"@ptl" +h2nettype() { + if [[ -v NETTYPE ]]; then + h2name_or_ip "$1" "$NETTYPE" + else + h2name_or_ip "$1" "$2" fi } -declare -fx h2ptl +declare -fx h2nettype +# Wrapper function to print the deprecation warning h2tcp() { - h2name_or_ip "$1" "tcp" -} -declare -fx h2tcp - -h2elan() { - if [ "$1" = "'*'" ]; then echo \'*\'; else - if type __h2elan >/dev/null 2>&1; then - ID=$(__h2elan $1) - else - ID=`echo $1 | sed 's/[^0-9]*//g'` - fi - echo $ID"@elan" + echo "h2tcp: deprecated, use h2nettype instead" 1>&2 + if [[ -v NETTYPE ]]; then + h2nettype "$@" + else + h2nettype "$1" "tcp" fi } -declare -fx h2elan +# Wrapper function to print the deprecation warning h2o2ib() { - h2name_or_ip "$1" "o2ib" + echo "h2o2ib: deprecated, use h2nettype instead" 1>&2 + if [[ -v NETTYPE ]]; then + h2nettype "$@" + else + h2nettype "$1" "o2ib" + fi } -declare -fx h2o2ib # This enables variables in cfg/"setup".sh files to support the pdsh HOSTLIST # expressions format. As a bonus we can then just pass in those variables @@ -3554,7 +3542,7 @@ mkfs_opts() { var=${facet}failover_HOST if [ -n "${!var}" ] && [ ${!var} != $(facet_host $facet) ]; then - opts+=" --failnode=$(h2$NETTYPE ${!var})" + opts+=" --failnode=$(h2nettype ${!var})" fi opts+=${TIMEOUT:+" --param=sys.timeout=$TIMEOUT"} @@ -4094,20 +4082,10 @@ check_config_client () { return 0 fi - local myMGS_host=$mgs_HOST - if [ "$NETTYPE" = "ptl" ]; then - myMGS_host=$(h2ptl $mgs_HOST | sed -e s/@ptl//) - fi - echo Checking config lustre mounted on $mntpt local mgshost=$(mount | grep " $mntpt " | awk -F@ '{print $1}') mgshost=$(echo $mgshost | awk -F: '{print $1}') -# if [ "$mgshost" != "$myMGS_host" ]; then -# log "Bad config file: lustre is mounted with mgs $mgshost, but mgs_HOST=$mgs_HOST, NETTYPE=$NETTYPE -# Please use correct config or set mds_HOST correctly!" -# fi - } check_config_clients () { -- 1.8.3.1