Whamcloud - gitweb
LU-4665 tests: support specifying arbitrary OST indices 22/9722/8
authorJian Yu <jian.yu@intel.com>
Sat, 20 Sep 2014 00:05:55 +0000 (20:05 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Thu, 25 Sep 2014 02:42:26 +0000 (02:42 +0000)
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 <jian.yu@intel.com>
Change-Id: Icf5d377d4d10995c2fb501bf7762ec8937466fdc
Reviewed-on: http://review.whamcloud.com/9722
Reviewed-by: James Simmons <uja.ornl@gmail.com>
Tested-by: Jenkins
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
lustre/tests/cfg/local.sh
lustre/tests/test-framework.sh

index 601d7bc..6d16312 100644 (file)
@@ -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)}
index 8028991..0eeaf3c 100755 (executable)
@@ -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})) \