1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-23 00:00:01 +01:00
VILLASnode/tests/integration/node-infiniband.sh

227 lines
5.2 KiB
Bash
Raw Normal View History

#!/bin/bash
#
# Integration loopback test using villas-node.
#
# @author Dennis Potter <dennis@dennispotter.eu>
# @copyright 2018, Institute for Automation of Complex Power Systems, EONERC
# @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/>.
##################################################################################
# Check if user is superuser. SU is used for namespace
if [[ "$EUID" -ne 0 ]]; then
echo "Please run as root"
exit 99
fi
# Check if Infiniband card is present
if [[ $(lspci | grep Infiniband) == 0 ]]; then
echo "Found no Infiniband cards in system"
exit 99
fi
SCRIPT=$(realpath $0)
SCRIPTPATH=$(dirname ${SCRIPT})
source ${SCRIPTPATH}/../../tools/integration-tests-helper.sh
CONFIG_FILE=$(mktemp)
CONFIG_FILE_TARGET=$(mktemp)
INPUT_FILE=$(mktemp)
OUTPUT_FILE=$(mktemp)
2018-07-25 16:31:09 +02:00
NUM_SAMPLES=${NUM_SAMPLES:-10}
2018-07-25 18:34:23 +02:00
## Generate test data for TCP and UDP test
VILLAS_LOG_PREFIX=$(colorize "[Signal]") \
villas-signal random -l ${NUM_SAMPLES} -n > ${INPUT_FILE}
echo "#############################"
echo "#############################"
echo "## START TCP ##"
echo "#############################"
echo "#############################"
cat > ${CONFIG_FILE} <<EOF
nodes: {
2018-07-25 18:34:23 +02:00
results = {
type = "file",
uri = "${OUTPUT_FILE}",
},
ib_node_source = {
type = "infiniband",
rdma_port_space = "RDMA_PS_TCP",
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,
send_inline = 1,
max_inline_data = 60,
}
}
ib_node_target = {
type = "infiniband",
rdma_port_space = "RDMA_PS_TCP",
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
}
}
EOF
cat > ${CONFIG_FILE_TARGET} <<EOF
$(<${CONFIG_FILE})
paths = (
{
in = "ib_node_target",
2018-07-25 18:34:23 +02:00
out = "results",
}
)
EOF
2018-07-25 18:34:23 +02:00
# Start receiving node
VILLAS_LOG_PREFIX=$(colorize "[Node] ") \
villas-node ${CONFIG_FILE_TARGET} &
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
VILLAS_LOG_PREFIX=$(colorize "[Pipe] ") \
ip netns exec namespace0 villas-pipe -l ${NUM_SAMPLES} ${CONFIG_FILE} ib_node_source >${OUTPUT_FILE} <${DATAFIFO} &
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
kill -9 $node_pipe
kill -9 $node_proc
# Compare data
villas-test-cmp ${INPUT_FILE} ${OUTPUT_FILE}
RC=$?
if [[ $RC != 0 ]]; then
rm ${CONFIG_FILE} ${CONFIG_FILE_TARGET} ${INPUT_FILE} ${OUTPUT_FILE} ${DATAFIFO}
exit $RC
fi
echo "#############################"
echo "#############################"
echo "## STOP TCP ##"
echo "#############################"
echo "#############################"
echo ""
echo "#############################"
echo "#############################"
echo "## START UDP ##"
echo "#############################"
echo "#############################"
# Set mode to UDP
sed -i -e 's/RDMA_PS_TCP/RDMA_PS_UDP/g' ${CONFIG_FILE}
sed -i -e 's/RDMA_PS_TCP/RDMA_PS_UDP/g' ${CONFIG_FILE_TARGET}
# Start receiving node
VILLAS_LOG_PREFIX=$(colorize "[Node] ") \
villas-node ${CONFIG_FILE_TARGET} &
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
VILLAS_LOG_PREFIX=$(colorize "[Pipe] ") \
ip netns exec namespace0 villas-pipe -l ${NUM_SAMPLES} ${CONFIG_FILE} ib_node_source >${OUTPUT_FILE} <${DATAFIFO} &
2018-07-25 18:34:23 +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-25 18:34:23 +02:00
kill -9 $node_pipe
kill -9 $node_proc
# Compare data
villas-test-cmp ${INPUT_FILE} ${OUTPUT_FILE}
RC=$?
rm ${CONFIG_FILE} ${CONFIG_FILE_TARGET} ${INPUT_FILE} ${OUTPUT_FILE} ${DATAFIFO}
2018-07-25 18:34:23 +02:00
echo "#############################"
echo "#############################"
echo "## STOP UDP ##"
echo "#############################"
echo "#############################"
exit $RC