From 70f87b667557ea29011d9ed02824724118122e20 Mon Sep 17 00:00:00 2001 From: Jian Yu Date: Fri, 19 Sep 2014 20:05:55 -0400 Subject: [PATCH] LU-4665 tests: support specifying arbitrary OST indices This patch improves Lustre test framework to support specifying arbitrary OST indices via OST_INDEX_LIST or OSTINDEX${num}. For example, OSTINDEX1="1" OSTINDEX2="2" OSTINDEX3="4" ...... or OST_INDEX_LIST="[1,2,4-6,8]" #[n-m,l-k,...], where n < m and l < k The default index of an individual OST is its facet number minus 1. Function facet_index() is added to get index for a facet. Test-Parameters: alwaysuploadlogs \ envdefinitions=OST_INDEX_LIST=[0-5] ostcount=7 \ testlist=sanity,conf-sanity Signed-off-by: Jian Yu Change-Id: Icf5d377d4d10995c2fb501bf7762ec8937466fdc Reviewed-on: http://review.whamcloud.com/9722 Reviewed-by: James Simmons Tested-by: Jenkins Reviewed-by: Andreas Dilger Tested-by: Maloo --- lustre/tests/cfg/local.sh | 12 ++++++++++++ lustre/tests/test-framework.sh | 41 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/lustre/tests/cfg/local.sh b/lustre/tests/cfg/local.sh index 601d7bc..6d16312 100644 --- a/lustre/tests/cfg/local.sh +++ b/lustre/tests/cfg/local.sh @@ -43,6 +43,7 @@ OSTSIZE=${OSTSIZE:-200000} OSTOPT=${OSTOPT:-} OST_FS_MKFS_OPTS=${OST_FS_MKFS_OPTS:-} OST_MOUNT_OPTS=${OST_MOUNT_OPTS:-} +OST_INDEX_LIST=${OST_INDEX_LIST:-} # Can specify individual ost devs with # OSTDEV1="/dev/sda" # on specific hosts with @@ -51,6 +52,17 @@ OST_MOUNT_OPTS=${OST_MOUNT_OPTS:-} # For ZFS, ost devices can be specified via either or both of the following: # OSTZFSDEV1="${FSNAME}-ost1/ost1" # OSTDEV1="/dev/sdb1" +# +# OST indices can be specified as follows: +# OSTINDEX1="1" +# OSTINDEX2="2" +# OSTINDEX3="4" +# ...... +# or +# OST_INDEX_LIST="[1,2,4-6,8]" # [n-m,l-k,...], where n < m and l < k, etc. +# +# The default index value of an individual OST is its facet number minus 1. +# More specific ones override more general ones. See facet_index(). NETTYPE=${NETTYPE:-tcp} MGSNID=${MGSNID:-$(h2$NETTYPE $mgs_HOST)} diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh index 8028991..0eeaf3cf 100755 --- a/lustre/tests/test-framework.sh +++ b/lustre/tests/test-framework.sh @@ -816,6 +816,25 @@ node_fstypes() { echo -n $fstypes } +facet_index() { + local facet=$1 + local num=$(facet_number $facet) + local index + + if [[ $(facet_type $facet) = OST ]]; then + index=OSTINDEX${num} + if [[ -n "${!index}" ]]; then + echo -n ${!index} + return + fi + + index=${OST_INDICES[num - 1]} + fi + + [[ -n "$index" ]] || index=$((num - 1)) + echo -n $index +} + devicelabel() { local facet=$1 local dev=$2 @@ -3258,7 +3277,7 @@ mkfs_opts() { local dev=$2 local fsname=${3:-"$FSNAME"} local type=$(facet_type $facet) - local index=$(($(facet_number $facet) - 1)) + local index=$(facet_index $facet) local fstype=$(facet_fstype $facet) local host=$(facet_host $facet) local opts @@ -3344,6 +3363,24 @@ mkfs_opts() { echo -n "$opts" } +check_ost_indices() { + local index_count=${#OST_INDICES[@]} + [[ $index_count -eq 0 || $OSTCOUNT -le $index_count ]] && return 0 + + # OST count is greater than the index count in $OST_INDEX_LIST. + # We need check whether there are duplicate indices. + local i + local j + local index + for i in $(seq $((index_count + 1)) $OSTCOUNT); do + index=$(facet_index ost$i) + for j in $(seq 0 $((index_count - 1))); do + [[ $index -ne ${OST_INDICES[j]} ]] || + error "ost$i has the same index $index as ost$((j+1))" + done + done +} + formatall() { local quiet @@ -3370,6 +3407,8 @@ formatall() { ${quiet:+>/dev/null} || exit 10 done + export OST_INDICES=($(hostlist_expand "$OST_INDEX_LIST")) + check_ost_indices for num in $(seq $OSTCOUNT); do echo "Format ost$num: $(ostdevname $num)" add ost$num $(mkfs_opts ost$num $(ostdevname ${num})) \ -- 1.8.3.1