Whamcloud - gitweb
LU-13688 tests: remove duplicate HSM functions 61/38961/5
authorNikitas Angelinas <nikitas.angelinas@hpe.com>
Wed, 17 Jun 2020 11:04:45 +0000 (04:04 -0700)
committerOleg Drokin <green@whamcloud.com>
Thu, 13 Aug 2020 06:02:25 +0000 (06:02 +0000)
Some HSM test framework functions exist in both test-framework.sh and
sanity-hsm.sh. Some of these are also used in PCC tests, so the
sanity-hsm.sh copy can be removed and some are used only in HSM tests,
so the test-framework.sh copy can be removed. The test-framework.sh
copies were introduced by LU-10092 which seems to have used versions
of the functions before they were updated by LU-11742, so update
kill_copytools() to the latest version.

Signed-off-by: Nikitas Angelinas <nikitas.angelinas@hpe.com>
Cray-bug-id: LUS-8913
Change-Id: I8101f748bfcfffb81598f7a5d2d82f2a16696e5c
Reviewed-on: https://review.whamcloud.com/38961
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Ben Evans <beevans@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/tests/sanity-hsm.sh
lustre/tests/test-framework.sh

index 499f96e..15f9551 100755 (executable)
@@ -82,100 +82,11 @@ CLIENT1=${CLIENT1:-$HOSTNAME}
 # Exception is the test which need two separate nodes
 CLIENT2=${CLIENT2:-$CLIENT1}
 
-#
-# In order to test multiple remote HSM agents, a new facet type named "AGT" and
-# the following associated variables are added:
-#
-# AGTCOUNT: number of agents
-# AGTDEV{N}: target HSM mount point (root path of the backend)
-# agt{N}_HOST: hostname of the agent agt{N}
-# SINGLEAGT: facet of the single agent
-#
-# The number of agents is initialized as the number of remote client nodes.
-# By default, only single copytool is started on a remote client/agent. If there
-# was no remote client, then the copytool will be started on the local client.
-#
-init_agt_vars() {
-       local n
-       local agent
-
-       export AGTCOUNT=${AGTCOUNT:-$((CLIENTCOUNT - 1))}
-       [[ $AGTCOUNT -gt 0 ]] || AGTCOUNT=1
-
-       export SHARED_DIRECTORY=${SHARED_DIRECTORY:-$TMP}
-       if [[ $CLIENTCOUNT -gt 1 ]] &&
-               ! check_shared_dir $SHARED_DIRECTORY $CLIENTS; then
-               skip_env "SHARED_DIRECTORY should be accessible"\
-                        "on all client nodes"
-               exit 0
-       fi
-
-       # We used to put the HSM archive in $SHARED_DIRECTORY but that
-       # meant NFS issues could hose sanity-hsm sessions. So now we
-       # use $TMP instead.
-       for n in $(seq $AGTCOUNT); do
-               eval export AGTDEV$n=\$\{AGTDEV$n:-"$TMP/arc$n"\}
-               agent=CLIENT$((n + 1))
-               if [[ -z "${!agent}" ]]; then
-                       [[ $CLIENTCOUNT -eq 1 ]] && agent=CLIENT1 ||
-                               agent=CLIENT2
-               fi
-               eval export agt${n}_HOST=\$\{agt${n}_HOST:-${!agent}\}
-       done
-
-       export SINGLEAGT=${SINGLEAGT:-agt1}
-
-       export HSMTOOL=${HSMTOOL:-"lhsmtool_posix"}
-       export HSMTOOL_VERBOSE=${HSMTOOL_VERBOSE:-""}
-       export HSMTOOL_UPDATE_INTERVAL=${HSMTOOL_UPDATE_INTERVAL:=""}
-       export HSMTOOL_EVENT_FIFO=${HSMTOOL_EVENT_FIFO:=""}
-       export HSMTOOL_TESTDIR
-
-       HSM_ARCHIVE_NUMBER=2
-
-       # The test only support up to 10 MDTs
-       MDT_PREFIX="mdt.$FSNAME-MDT000"
-       HSM_PARAM="${MDT_PREFIX}0.hsm"
-
-       # archive is purged at copytool setup
-       HSM_ARCHIVE_PURGE=true
-
-       # Don't allow copytool error upon start/setup
-       HSMTOOL_NOERROR=false
-}
-
-# Get the backend root path for the given agent facet.
-copytool_device() {
-       local facet=$1
-       local dev=AGTDEV$(facet_number $facet)
-
-       echo -n ${!dev}
-}
-
-get_mdt_devices() {
-       local mdtno
-       # get MDT device for each mdc
-       for mdtno in $(seq 1 $MDSCOUNT); do
-               local idx=$(($mdtno - 1))
-               MDT[$idx]=$($LCTL get_param -n \
-                       mdc.$FSNAME-MDT000${idx}-mdc-*.mds_server_uuid |
-                       awk '{gsub(/_UUID/,""); print $1}' | head -n1)
-       done
-}
-
 search_copytools() {
        local hosts=${1:-$(facet_active_host $SINGLEAGT)}
        do_nodesv $hosts "libtool execute pgrep -x $HSMTOOL"
 }
 
-kill_copytools() {
-       local hosts=${1:-$(facet_active_host $SINGLEAGT)}
-
-       echo "Killing existing copytools on $hosts"
-       do_nodesv $hosts "libtool execute killall -q $HSMTOOL" || true
-       copytool_continue "$hosts"
-}
-
 wait_copytools() {
        local hosts=${1:-$(facet_active_host $SINGLEAGT)}
        local wait_timeout=200
@@ -264,13 +175,6 @@ copytool_suspend() {
        echo "Copytool is suspended on $agents"
 }
 
-copytool_continue() {
-       local agents=${1:-$(facet_active_host $SINGLEAGT)}
-
-       do_nodesv $agents "libtool execute pkill -CONT -x $HSMTOOL" || return 0
-       echo "Copytool is continued on $agents"
-}
-
 copytool_remove_backend() {
        local fid=$1
        local be=$(do_facet $SINGLEAGT find "$(hsm_root)" -name $fid)
index 9f7c655..fd84e2d 100755 (executable)
@@ -10033,7 +10033,6 @@ init_agt_vars() {
        export HSMTOOL_UPDATE_INTERVAL=${HSMTOOL_UPDATE_INTERVAL:=""}
        export HSMTOOL_EVENT_FIFO=${HSMTOOL_EVENT_FIFO:=""}
        export HSMTOOL_TESTDIR
-       export HSMTOOL_BASE=$(basename "$HSMTOOL" | cut -f1 -d" ")
 
        HSM_ARCHIVE_NUMBER=2
 
@@ -10067,44 +10066,19 @@ get_mdt_devices() {
        done
 }
 
-search_copytools() {
-       local hosts=${1:-$(facet_active_host $SINGLEAGT)}
-       do_nodesv $hosts "pgrep -x $HSMTOOL_BASE"
+copytool_continue() {
+       local agents=${1:-$(facet_active_host $SINGLEAGT)}
+
+       do_nodesv $agents "libtool execute pkill -CONT -x $HSMTOOL" || return 0
+       echo "Copytool is continued on $agents"
 }
 
 kill_copytools() {
        local hosts=${1:-$(facet_active_host $SINGLEAGT)}
 
        echo "Killing existing copytools on $hosts"
-       do_nodesv $hosts "killall -q $HSMTOOL_BASE" || true
-}
-
-wait_copytools() {
-       local hosts=${1:-$(facet_active_host $SINGLEAGT)}
-       local wait_timeout=200
-       local wait_start=$SECONDS
-       local wait_end=$((wait_start + wait_timeout))
-       local sleep_time=100000 # 0.1 second
-
-       while ((SECONDS < wait_end)); do
-               if ! search_copytools $hosts; then
-                       echo "copytools stopped in $((SECONDS - wait_start))s"
-                       return 0
-               fi
-
-               echo "copytools still running on $hosts"
-               usleep $sleep_time
-               [ $sleep_time -lt 32000000 ] && # 3.2 seconds
-                       sleep_time=$(bc <<< "$sleep_time * 2")
-       done
-
-       # try to dump Copytool's stack
-       do_nodesv $hosts "echo 1 >/proc/sys/kernel/sysrq ; " \
-                        "echo t >/proc/sysrq-trigger"
-
-       echo "copytools failed to stop in ${wait_timeout}s"
-
-       return 1
+       do_nodesv $hosts "libtool execute killall -q $HSMTOOL" || true
+       copytool_continue "$hosts"
 }
 
 copytool_monitor_cleanup() {