Blame IbaTools/opacabletest/opacabletest.sh

Packit 857059
#!/bin/bash
Packit 857059
# BEGIN_ICS_COPYRIGHT8 ****************************************
Packit 857059
# 
Packit 857059
# Copyright (c) 2015-2017, Intel Corporation
Packit 857059
# 
Packit 857059
# Redistribution and use in source and binary forms, with or without
Packit 857059
# modification, are permitted provided that the following conditions are met:
Packit 857059
# 
Packit 857059
#     * Redistributions of source code must retain the above copyright notice,
Packit 857059
#       this list of conditions and the following disclaimer.
Packit 857059
#     * Redistributions in binary form must reproduce the above copyright
Packit 857059
#       notice, this list of conditions and the following disclaimer in the
Packit 857059
#       documentation and/or other materials provided with the distribution.
Packit 857059
#     * Neither the name of Intel Corporation nor the names of its contributors
Packit 857059
#       may be used to endorse or promote products derived from this software
Packit 857059
#       without specific prior written permission.
Packit 857059
# 
Packit 857059
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Packit 857059
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Packit 857059
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Packit 857059
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
Packit 857059
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Packit 857059
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Packit 857059
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Packit 857059
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Packit 857059
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Packit 857059
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Packit 857059
# 
Packit 857059
# END_ICS_COPYRIGHT8   ****************************************
Packit 857059
Packit 857059
# [ICS VERSION STRING: unknown]
Packit 857059
Packit 857059
# start and stop HFI-SW and/or ISL cable Bit Error Rate tests
Packit 857059
Packit 857059
# optional override of defaults
Packit 857059
if [ -f /etc/opa/opafastfabric.conf ]
Packit 857059
then
Packit 857059
	. /etc/opa/opafastfabric.conf
Packit 857059
fi
Packit 857059
Packit 857059
. /usr/lib/opa/tools/opafastfabric.conf.def
Packit 857059
Packit 857059
. /usr/lib/opa/tools/ff_funcs
Packit 857059
Packit 857059
tempfile="$(mktemp)"
Packit 857059
trap "rm -f $tempfile; exit 1" SIGHUP SIGTERM SIGINT
Packit 857059
trap "rm -f $tempfile" EXIT
Packit 857059
Packit 857059
Usage_full()
Packit 857059
{
Packit 857059
		echo "Usage: opacabletest [-C|-A] [-c file] [-f hostfile] [-h 'hosts'] [-n numprocs]" >&2
Packit 857059
	echo "                     [-t portsfile] [-p ports]" >&2
Packit 857059
	echo "                     [start|start_fi|start_isl|stop|stop_fi|stop_isl] ..." >&2
Packit 857059
	echo "              or" >&2
Packit 857059
	echo "       opacabletest --help" >&2
Packit 857059
	echo "   --help - produce full help text" >&2
Packit 857059
	echo "   -C - clear error counters" >&2
Packit 857059
	echo "   -A - force clear of hw error counters" >&2
Packit 857059
	echo "        implies -C" >&2
Packit 857059
	echo "   -c file - error thresholds config file" >&2
Packit 857059
	echo "             default is $CONFIG_DIR/opa/opamon.si.conf" >&2
Packit 857059
	echo "             only used if -C or -A specified" >&2
Packit 857059
	echo "   -f hostfile - file with hosts to include in HFI-SW test," >&2
Packit 857059
	echo "                 default is $CONFIG_DIR/opa/hosts" >&2
Packit 857059
	echo "   -h hosts - list of hosts to include in HFI-SW test" >&2
Packit 857059
	echo "   -n numprocs - number of processes per host for HFI-SW test" >&2
Packit 857059
	echo "   -t portsfile - file with list of local HFI ports used to access fabric(s)" >&2
Packit 857059
	echo "                  when clearing counters, default is $CONFIG_DIR/opa/ports" >&2
Packit 857059
	echo "   -p ports - list of local HFI ports used to access fabric(s) for counter clear" >&2
Packit 857059
	echo "              default is 1st active port" >&2
Packit 857059
	echo "              This is specified as hfi:port" >&2
Packit 857059
	echo "                 0:0 = 1st active port in system" >&2
Packit 857059
	echo "                 0:y = port y within system" >&2
Packit 857059
	echo "                 x:0 = 1st active port on HFI x" >&2
Packit 857059
	echo "                 x:y = HFI x, port y" >&2
Packit 857059
	echo "              The first HFI in the system is 1.  The first port on an HFI is 1." >&2
Packit 857059
	echo "   start - start the HFI-SW and ISL tests" >&2
Packit 857059
	echo "   start_fi - start the HFI-SW test" >&2
Packit 857059
	echo "   start_isl - start the ISL test" >&2
Packit 857059
	echo "   stop - stop the HFI-SW and ISL tests" >&2
Packit 857059
	echo "   stop_fi - stop the HFI-SW test" >&2
Packit 857059
	echo "   stop_isl - stop the ISL test" >&2
Packit 857059
	echo >&2
Packit 857059
	echo "The HFI-SW cabletest requires that FF_MPI_APPS_DIR be set and contains" >&2
Packit 857059
	echo "a prebuilt copy of Intel mpi_apps for an appropriate MPI" >&2
Packit 857059
	echo >&2
Packit 857059
	echo "The ISL cabletest as started by this tool assumes the master HSM is running" >&2
Packit 857059
	echo "on this host.  If using ESM or a different host is master FM, ISL cabletest" >&2
Packit 857059
	echo "will have to be controlled by the switch CLI or by FastFabric on the master FM" >&2
Packit 857059
	echo "respectively" >&2
Packit 857059
	echo >&2
Packit 857059
	echo " Environment:" >&2
Packit 857059
	echo "   HOSTS - list of hosts, used if -h option not supplied" >&2
Packit 857059
	echo "   HOSTS_FILE - file containing list of hosts, used in absence of -f and -h" >&2
Packit 857059
	echo "   PORTS - list of ports, used in absence of -t and -p" >&2
Packit 857059
	echo "   PORTS_FILE - file containing list of ports, used in absence of -t and -p" >&2
Packit 857059
	echo "   FF_MAX_PARALLEL - maximum concurrent operations" >&2
Packit 857059
	echo "example:">&2
Packit 857059
	echo "   opacabletest -A start" >&2
Packit 857059
	echo "   opacabletest -f good -A start" >&2
Packit 857059
	echo "   opacabletest -h 'arwen elrond' start_fi" >&2
Packit 857059
	echo "   HOSTS='arwen elrond' opacabletest stop" >&2
Packit 857059
	echo "   opacabletest -A" >&2
Packit 857059
	rm -f $tempfile
Packit 857059
	exit 0
Packit 857059
}
Packit 857059
Packit 857059
Usage()
Packit 857059
{
Packit 857059
	echo "Usage: opacabletest [-C|-A] [-n numprocs] [-f hostfile]" >&2
Packit 857059
	echo "                 [start|start_fi|start_isl|stop|stop_fi|stop_isl] ..." >&2
Packit 857059
	echo "              or" >&2
Packit 857059
	echo "       opacabletest --help" >&2
Packit 857059
	echo "   --help - produce full help text" >&2
Packit 857059
	echo "   -C - clear error counters" >&2
Packit 857059
	echo "   -A - force clear of hw error counters" >&2
Packit 857059
	echo "        implies -C" >&2
Packit 857059
	echo "   -f hostfile - file with hosts to include in HFI-SW test," >&2
Packit 857059
	echo "                 default is $CONFIG_DIR/opa/hosts" >&2
Packit 857059
	echo "   -n numprocs - number of processes per host for HFI-SW test" >&2
Packit 857059
	echo >&2
Packit 857059
	echo "   start - start the HFI-SW and ISL tests" >&2
Packit 857059
	echo "   start_fi - start the HFI-SW test" >&2
Packit 857059
	echo "   start_isl - start the ISL test" >&2
Packit 857059
	echo "   stop - stop the HFI-SW and ISL tests" >&2
Packit 857059
	echo "   stop_fi - stop the HFI-SW test" >&2
Packit 857059
	echo "   stop_isl - stop the ISL test" >&2
Packit 857059
	echo >&2
Packit 857059
	echo "The HFI-SW cabletest requires that FF_MPI_APPS_DIR be set and contains" >&2
Packit 857059
	echo "a prebuilt copy of Intel mpi_apps for an appropriate MPI" >&2
Packit 857059
	echo >&2
Packit 857059
	echo "The ISL cabletest as started by this tool assumes the master HSM is running" >&2
Packit 857059
	echo "on this host.  If using ESM or a different host is master FM, ISL cabletest" >&2
Packit 857059
	echo "will have to be controlled by the switch CLI or by FastFabric on the master FM" >&2
Packit 857059
	echo "respectively" >&2
Packit 857059
	echo >&2
Packit 857059
	echo " Environment:" >&2
Packit 857059
	echo "   FF_MAX_PARALLEL - maximum concurrent operations" >&2
Packit 857059
	echo "example:">&2
Packit 857059
	echo "   opacabletest -f good -A start" >&2
Packit 857059
	echo "   opacabletest stop" >&2
Packit 857059
	echo "   opacabletest -A" >&2
Packit 857059
	rm -f $tempfile
Packit 857059
	exit 2
Packit 857059
}
Packit 857059
Packit 857059
if [ x"$1" = "x--help" ]
Packit 857059
then
Packit 857059
	Usage_full
Packit 857059
fi
Packit 857059
Packit 857059
clear=n
Packit 857059
clearhw=n
Packit 857059
numprocs=3
Packit 857059
config_file="$CONFIG_DIR/opa/opamon.si.conf"
Packit 857059
while getopts CAf:h:n:t:p:c: param
Packit 857059
do
Packit 857059
	case $param in
Packit 857059
	C)
Packit 857059
		clear=y;;
Packit 857059
	A)
Packit 857059
		clear=y; clearhw=y;;
Packit 857059
	h)
Packit 857059
		HOSTS="$OPTARG";;
Packit 857059
	f)
Packit 857059
		HOSTS_FILE="$OPTARG";;
Packit 857059
	n)
Packit 857059
		numprocs="$OPTARG";;
Packit 857059
	t)
Packit 857059
		PORTS_FILE="$OPTARG";;
Packit 857059
	p)
Packit 857059
		PORTS="$OPTARG";;
Packit 857059
	c)
Packit 857059
		config_file="$OPTARG";;
Packit 857059
	?)
Packit 857059
		Usage;;
Packit 857059
	esac
Packit 857059
done
Packit 857059
shift $((OPTIND -1))
Packit 857059
Packit 857059
check_host_args opacabletest
Packit 857059
# HOSTS now lists all the hosts, pass it along to the commands below via env
Packit 857059
export HOSTS
Packit 857059
unset HOSTS_FILE
Packit 857059
Packit 857059
if [ $clear = y ]
Packit 857059
then
Packit 857059
	check_ports_args opacabletest
Packit 857059
	# PORTS now lists all the ports, pass it along to the commands below via env
Packit 857059
	export PORTS
Packit 857059
	unset PORTS_FILE
Packit 857059
fi
Packit 857059
Packit 857059
if [ $clear = y ]
Packit 857059
then
Packit 857059
	opareports -C -c "$config_file" -o none
Packit 857059
	if [ $clearhw = y ]
Packit 857059
	then
Packit 857059
		opareports -M -C -c "$config_file" -o none
Packit 857059
	fi
Packit 857059
fi
Packit 857059
Packit 857059
get_fmconfig()
Packit 857059
{
Packit 857059
	FM_CONFIG_DIR=/etc
Packit 857059
	FM_CONFIG_FILE=$CONFIG_DIR/opafm.xml
Packit 857059
	IFS_FM_BASE=/usr/lib/opa-fm # default
Packit 857059
}
Packit 857059
Packit 857059
start_fi()
Packit 857059
{
Packit 857059
	if [ ! -e $FF_MPI_APPS_DIR/run_batch_cabletest ]
Packit 857059
	then
Packit 857059
		echo "opacabletest: Invalid FF_MPI_APPS_DIR: $FF_MPI_APPS_DIR" >&2
Packit 857059
		exit 1
Packit 857059
	fi
Packit 857059
	if [ ! -x $FF_MPI_APPS_DIR/groupstress/mpi_groupstress ]
Packit 857059
	then
Packit 857059
		echo "opacabletest: FF_MPI_APPS_DIR ($FF_MPI_APPS_DIR) not compiled" >&2
Packit 857059
		rm -f $tempfile
Packit 857059
		exit 1
Packit 857059
	fi
Packit 857059
	ff_var_to_stdout "$HOSTS" > $tempfile
Packit 857059
	cd $FF_MPI_APPS_DIR
Packit 857059
	MPI_HOSTS=$tempfile ./run_batch_cabletest -n $numprocs infinite
Packit 857059
}
Packit 857059
Packit 857059
start_isl()
Packit 857059
{
Packit 857059
	(
Packit 857059
		get_fmconfig
Packit 857059
		if [ ! -x $IFS_FM_BASE/bin/fm_cmdall ]
Packit 857059
		then
Packit 857059
			echo "opacabletest: Error: $IFS_FM_BASE/bin/fm_cmdall not found" >&2
Packit 857059
			rm -f $tempfile
Packit 857059
			exit 1
Packit 857059
		fi
Packit 857059
		$IFS_FM_BASE/bin/fm_cmdall smLooptestFastModeStart
Packit 857059
	)
Packit 857059
	res=$?
Packit 857059
	[ $res -ne 0 ] && exit $res
Packit 857059
}
Packit 857059
Packit 857059
start()
Packit 857059
{
Packit 857059
	start_fi
Packit 857059
	start_isl
Packit 857059
}
Packit 857059
Packit 857059
stop_fi()
Packit 857059
{
Packit 857059
	# we use patterns so the pkill doesn't kill this script or opacmdall itself
Packit 857059
	# use an echo at end so exit status is good
Packit 857059
	/usr/sbin/opacmdall -p -T 60 "pkill -9 -f '[m]pi_groupstress'; echo -n"
Packit 857059
}
Packit 857059
Packit 857059
stop_isl()
Packit 857059
{
Packit 857059
	(
Packit 857059
		get_fmconfig
Packit 857059
		if [ ! -x $IFS_FM_BASE/bin/fm_cmdall ]
Packit 857059
		then
Packit 857059
			echo "opacabletest: Error: $IFS_FM_BASE/bin/fm_cmdall not found" >&2
Packit 857059
			rm -f $tempfile
Packit 857059
			exit 1
Packit 857059
		fi
Packit 857059
		$IFS_FM_BASE/bin/fm_cmdall smLooptestStop
Packit 857059
	)
Packit 857059
	res=$?
Packit 857059
	[ $res -ne 0 ] && exit $res
Packit 857059
}
Packit 857059
Packit 857059
stop()
Packit 857059
{
Packit 857059
	stop_fi
Packit 857059
	stop_isl
Packit 857059
}
Packit 857059
Packit 857059
while [ $# -ne 0 ]
Packit 857059
do
Packit 857059
	case "$1" in
Packit 857059
	start) start;;
Packit 857059
	start_fi) start_fi;;
Packit 857059
	start_isl) start_isl;;
Packit 857059
	stop) stop;;
Packit 857059
	stop_fi) stop_fi;;
Packit 857059
	stop_isl) stop_isl;;
Packit 857059
	*)	Usage;;
Packit 857059
	esac
Packit 857059
	shift
Packit 857059
done
Packit 857059
Packit 857059
rm -f $tempfile