2018-07-25 14:48:23 +02:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
2021-09-22 10:42:03 +02:00
|
|
|
# Integration Infiniband test using villas node.
|
2018-07-25 14:48:23 +02:00
|
|
|
#
|
|
|
|
# @author Dennis Potter <dennis@dennispotter.eu>
|
2020-01-20 17:17:00 +01:00
|
|
|
# @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
2018-07-25 14:48:23 +02:00
|
|
|
# @license GNU General Public License (version 3)
|
|
|
|
#
|
|
|
|
# VILLASnode
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
##################################################################################
|
|
|
|
|
2018-08-20 18:32:01 +02:00
|
|
|
# Check if tools are present
|
|
|
|
if ! command -v lspci; then
|
2018-12-23 00:09:05 +01:00
|
|
|
echo "'lspci' tool is missing"
|
2018-08-20 18:32:01 +02:00
|
|
|
exit 99
|
|
|
|
fi
|
|
|
|
|
2018-07-25 14:48:23 +02:00
|
|
|
# Check if user is superuser. SU is used for namespace
|
2018-07-25 18:46:33 +02:00
|
|
|
if [[ "$EUID" -ne 0 ]]; then
|
|
|
|
echo "Please run as root"
|
|
|
|
exit 99
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Check if Infiniband card is present
|
2018-07-25 18:50:58 +02:00
|
|
|
if [[ ! $(lspci | grep Infiniband) ]]; then
|
2018-07-26 15:33:15 +02:00
|
|
|
echo "Did not find any Infiniband cards in system"
|
2018-07-25 14:48:23 +02:00
|
|
|
exit 99
|
|
|
|
fi
|
|
|
|
|
2018-07-26 15:33:15 +02:00
|
|
|
|
|
|
|
CONFIG_FILE=$(mktemp /tmp/ib-configuration-XXXX.conf)
|
|
|
|
CONFIG_FILE_TARGET=$(mktemp /tmp/ib-configuration-target-XXXX.conf)
|
2018-07-25 14:48:23 +02:00
|
|
|
INPUT_FILE=$(mktemp)
|
|
|
|
OUTPUT_FILE=$(mktemp)
|
|
|
|
|
2018-07-25 16:31:09 +02:00
|
|
|
NUM_SAMPLES=${NUM_SAMPLES:-10}
|
2018-07-28 16:43:14 +02:00
|
|
|
RC=0
|
2018-07-25 14:48:23 +02:00
|
|
|
|
2018-08-07 17:37:26 +02:00
|
|
|
# Generate test data for RC, UC, and UD test
|
2021-09-22 10:42:03 +02:00
|
|
|
villas signal -l ${NUM_SAMPLES} -n random > ${INPUT_FILE}
|
2018-07-25 18:34:23 +02:00
|
|
|
|
2018-07-26 15:33:15 +02:00
|
|
|
# Set config file with a MODE flag
|
2018-07-25 14:48:23 +02:00
|
|
|
cat > ${CONFIG_FILE} <<EOF
|
2018-08-07 17:37:26 +02:00
|
|
|
logging = {
|
|
|
|
level = 0,
|
|
|
|
facilities = "ib",
|
|
|
|
},
|
|
|
|
|
|
|
|
http = {
|
|
|
|
enabled = false,
|
|
|
|
},
|
|
|
|
|
2018-07-26 15:33:15 +02:00
|
|
|
nodes = {
|
2018-07-25 18:34:23 +02:00
|
|
|
results = {
|
|
|
|
type = "file",
|
|
|
|
uri = "${OUTPUT_FILE}",
|
|
|
|
},
|
|
|
|
|
2018-07-25 14:48:23 +02:00
|
|
|
ib_node_source = {
|
|
|
|
type = "infiniband",
|
|
|
|
|
2018-08-07 17:37:26 +02:00
|
|
|
rdma_port_space = "MODE",
|
2018-07-25 14:48:23 +02:00
|
|
|
|
|
|
|
in = {
|
|
|
|
address = "10.0.0.2:1337",
|
|
|
|
|
|
|
|
max_wrs = 8192,
|
|
|
|
cq_size = 8192,
|
|
|
|
|
|
|
|
poll_mode = "BUSY",
|
|
|
|
buffer_subtraction = 128,
|
|
|
|
},
|
|
|
|
out = {
|
|
|
|
address = "10.0.0.1:1337",
|
|
|
|
resolution_timeout = 1000,
|
|
|
|
|
|
|
|
max_wrs = 8192,
|
|
|
|
cq_size = 256,
|
|
|
|
|
2018-08-02 11:31:11 +02:00
|
|
|
send_inline = true,
|
2018-07-25 14:48:23 +02:00
|
|
|
max_inline_data = 60,
|
2018-08-02 11:31:11 +02:00
|
|
|
|
|
|
|
use_fallback = true,
|
2018-07-25 14:48:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ib_node_target = {
|
|
|
|
type = "infiniband",
|
|
|
|
|
2018-08-07 17:37:26 +02:00
|
|
|
rdma_port_space = "MODE",
|
2018-07-25 14:48:23 +02:00
|
|
|
|
|
|
|
in = {
|
|
|
|
address = "10.0.0.1:1337",
|
|
|
|
|
|
|
|
max_wrs = 8192,
|
|
|
|
cq_size = 8192,
|
|
|
|
|
|
|
|
poll_mode = "BUSY",
|
|
|
|
buffer_subtraction = 128,
|
|
|
|
}
|
2018-07-25 18:34:23 +02:00
|
|
|
}
|
2018-07-25 14:48:23 +02:00
|
|
|
}
|
|
|
|
EOF
|
|
|
|
|
2018-07-26 15:33:15 +02:00
|
|
|
# Set target config file, which is the same for both runs
|
2018-07-25 14:48:23 +02:00
|
|
|
cat > ${CONFIG_FILE_TARGET} <<EOF
|
2018-07-26 15:33:15 +02:00
|
|
|
@include "${CONFIG_FILE//\/tmp\/}"
|
|
|
|
|
2018-07-25 14:48:23 +02:00
|
|
|
paths = (
|
|
|
|
{
|
|
|
|
in = "ib_node_target",
|
2018-07-26 15:33:15 +02:00
|
|
|
out = "results"
|
2018-07-25 14:48:23 +02:00
|
|
|
}
|
|
|
|
)
|
|
|
|
EOF
|
|
|
|
|
2018-07-26 15:33:15 +02:00
|
|
|
# Declare modes
|
2018-08-07 17:37:26 +02:00
|
|
|
MODES=("RC" "UC" "UD")
|
2018-07-25 18:34:23 +02:00
|
|
|
|
2018-07-26 15:33:15 +02:00
|
|
|
# Run through modes
|
|
|
|
for MODE in "${MODES[@]}"
|
|
|
|
do
|
2018-07-25 18:34:23 +02:00
|
|
|
|
2018-07-26 15:33:15 +02:00
|
|
|
echo "#############################"
|
|
|
|
echo "#############################"
|
|
|
|
echo "## START ${MODE} ##"
|
|
|
|
echo "#############################"
|
|
|
|
echo "#############################"
|
2018-07-25 14:48:23 +02:00
|
|
|
|
2018-08-07 17:37:26 +02:00
|
|
|
sed -i -e 's/MODE/'${MODE}'/g' ${CONFIG_FILE}
|
2018-07-25 14:48:23 +02:00
|
|
|
|
2018-07-26 15:33:15 +02:00
|
|
|
# Start receiving node
|
2021-09-22 10:42:03 +02:00
|
|
|
villas node ${CONFIG_FILE_TARGET} &
|
2018-07-26 15:33:15 +02:00
|
|
|
node_proc=$!
|
|
|
|
|
|
|
|
# Wait for node to complete init
|
|
|
|
sleep 1
|
|
|
|
|
|
|
|
# Preprare fifo
|
|
|
|
DATAFIFO=/tmp/datafifo
|
|
|
|
if [[ ! -p ${DATAFIFO} ]]; then
|
|
|
|
mkfifo ${DATAFIFO}
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Start sending pipe
|
2021-09-22 10:42:03 +02:00
|
|
|
ip netns exec namespace0 villas pipe -l ${NUM_SAMPLES} ${CONFIG_FILE} ib_node_source >${OUTPUT_FILE} <${DATAFIFO} &
|
2018-07-26 15:33:15 +02:00
|
|
|
node_pipe=$!
|
|
|
|
|
|
|
|
# Keep pipe alive
|
|
|
|
sleep 5 >${DATAFIFO} &
|
|
|
|
|
|
|
|
# Wait for pipe to connect to node
|
|
|
|
sleep 3
|
|
|
|
|
|
|
|
# Write data to pipe
|
|
|
|
cat ${INPUT_FILE} >${DATAFIFO} &
|
|
|
|
|
|
|
|
# Wait for node to handle samples
|
|
|
|
sleep 2
|
|
|
|
|
|
|
|
# Stop node
|
2018-07-26 15:46:41 +02:00
|
|
|
kill $node_pipe
|
|
|
|
kill $node_proc
|
2018-07-26 15:33:15 +02:00
|
|
|
|
|
|
|
# Compare data
|
2021-09-22 10:42:03 +02:00
|
|
|
villas compare ${INPUT_FILE} ${OUTPUT_FILE}
|
2018-07-26 15:33:15 +02:00
|
|
|
RC=$?
|
2018-07-25 14:48:23 +02:00
|
|
|
|
2018-07-26 15:33:15 +02:00
|
|
|
# Exit, if an error occurs
|
|
|
|
if [[ $RC != 0 ]]; then
|
|
|
|
rm ${CONFIG_FILE} ${CONFIG_FILE_TARGET} ${INPUT_FILE} ${OUTPUT_FILE} ${DATAFIFO}
|
|
|
|
|
2020-09-10 17:32:02 +02:00
|
|
|
exit ${RC}
|
2018-07-26 15:33:15 +02:00
|
|
|
fi
|
2018-07-25 14:48:23 +02:00
|
|
|
|
2018-07-26 15:33:15 +02:00
|
|
|
echo "#############################"
|
|
|
|
echo "#############################"
|
|
|
|
echo "## STOP $MODE ##"
|
|
|
|
echo "#############################"
|
|
|
|
echo "#############################"
|
|
|
|
echo ""
|
2018-07-25 14:48:23 +02:00
|
|
|
|
2018-08-07 17:37:26 +02:00
|
|
|
sed -i -e 's/'${MODE}'/MODE/g' ${CONFIG_FILE}
|
2018-07-26 15:33:15 +02:00
|
|
|
done
|
2018-07-25 14:48:23 +02:00
|
|
|
|
|
|
|
rm ${CONFIG_FILE} ${CONFIG_FILE_TARGET} ${INPUT_FILE} ${OUTPUT_FILE} ${DATAFIFO}
|
|
|
|
|
2020-09-10 17:32:02 +02:00
|
|
|
exit ${RC}
|