From add8789e231838864a3099fc40071b2ec5feba97 Mon Sep 17 00:00:00 2001 From: Dennis Potter Date: Wed, 25 Jul 2018 14:48:23 +0200 Subject: [PATCH] Added first version of integration test for Infiniband node --- tests/integration/node-infiniband.sh | 180 +++++++++++++++++++++++++++ 1 file changed, 180 insertions(+) create mode 100755 tests/integration/node-infiniband.sh diff --git a/tests/integration/node-infiniband.sh b/tests/integration/node-infiniband.sh new file mode 100755 index 000000000..ec3786a47 --- /dev/null +++ b/tests/integration/node-infiniband.sh @@ -0,0 +1,180 @@ +#!/bin/bash +# +# Integration loopback test using villas-node. +# +# @author Dennis Potter +# @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 . +################################################################################## + +# Check if user is superuser. SU is used for namespace +if [ "$EUID" -ne 0 ] + then echo "Please run as root" + 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) + +NUM_SAMPLES=${NUM_SAMPLES:-100} + +cat > ${CONFIG_FILE} < ${CONFIG_FILE_TARGET} < ${INPUT_FILE} + +# 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} & + +# 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 %1 +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} + +exit $RC