1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

tests: add new testcase for websockets, add perfixes and several bug fixes

This commit is contained in:
Steffen Vogel 2017-08-27 17:07:04 +02:00
parent ec692d7d72
commit fcb90ae5c9
8 changed files with 252 additions and 78 deletions

View file

@ -22,9 +22,10 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
##################################################################################
set -e
SCRIPT=$(realpath $0)
SCRIPTPATH=$(dirname ${SCRIPT})
LOCAL_CONF=${SRCDIR}/etc/loopback.json
LOCAL_CONF=${SCRIPTPATH}/../../etc/loopback.json
FETCHED_CONF=$(mktemp)
FETCHED_JSON_CONF=$(mktemp)

View file

@ -22,6 +22,10 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
##################################################################################
SCRIPT=$(realpath $0)
SCRIPTPATH=$(dirname ${SCRIPT})
source ${SCRIPTPATH}/../../tools/integration-tests-helper.sh
CONFIG_FILE=$(mktemp)
INPUT_FILE=$(mktemp)
OUTPUT_FILE=$(mktemp)
@ -29,42 +33,40 @@ OUTPUT_FILE=$(mktemp)
NUM_SAMPLES=${NUM_SAMPLES:-10}
cat > ${CONFIG_FILE} <<EOF
nodes = {
node1 = {
type = "socket";
layer = "udp";
local = "*:12000";
remote = "127.0.0.1:12001"
}
node2 = {
type = "socket";
layer = "udp";
local = "*:12001";
remote = "127.0.0.1:12000"
}
{
"nodes": {
"node1": {
"type": "socket",
"layer": "udp",
"local": "*:12000",
"remote": "127.0.0.1:12001"
},
"node2": {
"type": "socket",
"layer": "udp",
"local": "*:12001",
"remote": "127.0.0.1:12000"
}
},
"paths": [
{ "in": "node1", "out": "node1" }
]
}
paths = (
{
in = "node1",
out = "node1"
}
)
EOF
# Generate test data
VILLAS_LOG_PREFIX=$(colorize "[Signal]") \
villas-signal random -l ${NUM_SAMPLES} -n > ${INPUT_FILE}
# Start node
VILLAS_LOG_PREFIX=$(colorize "[Node] ") \
villas-node ${CONFIG_FILE} &
# Wait for node to complete init
sleep 1
# Send / Receive data to node
VILLAS_LOG_PREFIX=$(colorize "[Pipe] ") \
villas-pipe -l ${NUM_SAMPLES} ${CONFIG_FILE} node2 > ${OUTPUT_FILE} < ${INPUT_FILE}
# Wait for node to handle samples

View file

@ -22,6 +22,10 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
##################################################################################
SCRIPT=$(realpath $0)
SCRIPTPATH=$(dirname ${SCRIPT})
source ${SCRIPTPATH}/../../tools/integration-tests-helper.sh
CONFIG_FILE=$(mktemp)
INPUT_FILE=$(mktemp)
OUTPUT_FILE=$(mktemp)
@ -35,36 +39,29 @@ URI=https://1Nrd46fZX8HbggT:badpass@rwth-aachen.sciebo.de/public.php/webdav/node
cat > ${CONFIG_FILE} <<EOF
{
"nodes" : {
"remote_file_out" : {
"remote_file" : {
"type" : "file",
"out" : {
"uri" : "${URI}",
"mode" : "w+",
"flush" : false
}
},
"remote_file_in" : {
"type" : "file",
"in" : {
"uri" : "${URI}",
"mode" : "r",
"epoch_mode" : "original",
"eof" : "exit"
}
"uri" : "${URI}",
"flush" : false,
"epoch_mode" : "original",
"eof" : "exit"
}
}
}
EOF
# Delete old file
curl -X DELETE ${URI}
curl -X DELETE ${URI} > /dev/null
VILLAS_LOG_PREFIX=$(colorize "[Signal] ") \
villas-signal random -n -l ${NUM_SAMPLES} > ${INPUT_FILE}
villas-pipe -s ${CONFIG_FILE} remote_file_out < ${INPUT_FILE}
VILLAS_LOG_PREFIX=$(colorize "[Send] ") \
villas-pipe -s ${CONFIG_FILE} remote_file < ${INPUT_FILE}
villas-pipe -r ${CONFIG_FILE} remote_file_in > ${OUTPUT_FILE}
VILLAS_LOG_PREFIX=$(colorize "[Recv] ") \
villas-pipe -r -l ${NUM_SAMPLES} ${CONFIG_FILE} remote_file > ${OUTPUT_FILE}
villas-test-cmp ${INPUT_FILE} ${OUTPUT_FILE}
RC=$?

View file

@ -35,18 +35,12 @@ cat > ${CONFIG_FILE} << EOF
"node1" : {
"type" : "file",
"in" : {
"uri" : "${NODE_FILE}",
"mode" : "w+",
"uri" : "${NODE_FILE}",
"mode" : "w+",
"epoch_mode" : "original",
"eof" : "wait"
},
"out" : {
"uri" : "${NODE_FILE}",
"mode" : "w+",
"flush" : true
}
"epoch_mode" : "original",
"eof" : "wait",
"flush" : true
}
}
}
@ -58,10 +52,14 @@ villas-signal random -l ${NUM_SAMPLES} -n > ${INPUT_FILE}
# We delay EOF of the INPUT_FILE by 1 second in order to wait for incoming data to be received
villas-pipe -l ${NUM_SAMPLES} ${CONFIG_FILE} node1 > ${OUTPUT_FILE} < ${INPUT_FILE}
# Comapre data
# Compare data
villas-test-cmp ${INPUT_FILE} ${OUTPUT_FILE}
RC=$?
cat ${OUTPUT_FILE}
echo
cat ${INPUT_FILE}
rm ${OUTPUT_FILE} ${INPUT_FILE} ${CONFIG_FILE} ${NODE_FILE}
exit $RC

View file

@ -22,17 +22,38 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
##################################################################################
SCRIPT=$(realpath $0)
SCRIPTPATH=$(dirname ${SCRIPT})
source ${SCRIPTPATH}/../../tools/integration-tests-helper.sh
CONFIG_FILE=$(mktemp)
INPUT_FILE=$(mktemp)
OUTPUT_FILE=$(mktemp)
NUM_SAMPLES=${NUM_SAMPLES:-10}
NUM_SAMPLES=${NUM_SAMPLES:-100}
# Generate test data
villas-signal random -l ${NUM_SAMPLES} -n > ${INPUT_FILE}
for FORMAT in csv json villas csv msg gtnet-fake raw-flt32 gtnet-fake; do
VECTORIZES="1"
# The raw format does not support vectors
if villas_format_supports_vectorize ${FORMAT}; then
VECTORIZES="${VECTORIZES} 10"
fi
for VECTORIZE in ${VECTORIZES}; do
cat > ${CONFIG_FILE} << EOF
{
"nodes" : {
"node1" : {
"type" : "nanomsg",
"format" : "${FORMAT}",
"vectorize" : ${VECTORIZE},
"subscribe" : "tcp://127.0.0.1:12000",
"publish" : "tcp://127.0.0.1:12000"
@ -41,20 +62,32 @@ cat > ${CONFIG_FILE} << EOF
}
EOF
# Generate test data
villas-signal random -l ${NUM_SAMPLES} -n > ${INPUT_FILE}
# We delay EOF of the INPUT_FILE by 1 second in order to wait for incoming data to be received
villas-pipe -l ${NUM_SAMPLES} ${CONFIG_FILE} node1 > ${OUTPUT_FILE} < ${INPUT_FILE}
cat ${INPUT_FILE}
echo
cat ${OUTPUT_FILE}
# Ignore timestamp and seqeunce no if in raw format
if villas_format_supports_header ${FORMAT}; then
CMPFLAGS=-ts
fi
# Comapre data
villas-test-cmp ${INPUT_FILE} ${OUTPUT_FILE}
# Compare data
villas-test-cmp ${CMPFLAGS} ${INPUT_FILE} ${OUTPUT_FILE}
RC=$?
if (( ${RC} != 0 )); then
echo "=========== Sub-test failed for: format=${FORMAT}, vectorize=${VECTORIZE}"
cat ${CONFIG_FILE}
echo
cat ${INPUT_FILE}
echo
cat ${OUTPUT_FILE}
exit ${RC}
else
echo "=========== Sub-test succeeded for: format=${FORMAT}, vectorize=${VECTORIZE}"
fi
done; done
rm ${OUTPUT_FILE} ${INPUT_FILE} ${CONFIG_FILE}
exit $RC

View file

@ -22,20 +22,34 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
##################################################################################
SCRIPT=$(realpath $0)
SCRIPTPATH=$(dirname ${SCRIPT})
source ${SCRIPTPATH}/../../tools/integration-tests-helper.sh
CONFIG_FILE=$(mktemp)
INPUT_FILE=$(mktemp)
OUTPUT_FILE=$(mktemp)
THEORIES=$(mktemp)
NUM_SAMPLES=${NUM_SAMPLES:-10}
NUM_SAMPLES=${NUM_SAMPLES:-100}
# Generate test data
villas-signal random -l ${NUM_SAMPLES} -n > ${INPUT_FILE}
for FORMAT in csv json villas csv msg gtnet-fake raw-flt32 gtnet-fake; do
for LAYER in udp ip eth; do
for HEADER in none default; do
for ENDIAN in big little; do
for VERIFY_SOURCE in true false; do
VECTORIZES="1"
# The raw format does not support vectors
if villas_format_supports_vectorize ${FORMAT}; then
VECTORIZES="${VECTORIZES} 10"
fi
for VECTORIZE in ${VECTORIZES}; do
case ${LAYER} in
udp)
@ -54,15 +68,16 @@ case ${LAYER} in
LOCAL="00:00:00:00:00:00%lo:34997"
REMOTE="00:00:00:00:00:00%lo:34997"
;;
esac
esac
cat > ${CONFIG_FILE} << EOF
{
"nodes" : {
"node1" : {
"type" : "socket",
"vectorize" : ${VECTORIZE},
"format" : "${FORMAT}",
"layer" : "${LAYER}",
"header" : "${HEADER}",
"endian" : "${ENDIAN}",
@ -78,12 +93,17 @@ EOF
# We delay EOF of the INPUT_FILE by 1 second in order to wait for incoming data to be received
villas-pipe -l ${NUM_SAMPLES} ${CONFIG_FILE} node1 > ${OUTPUT_FILE} < ${INPUT_FILE}
# Ignore timestamp and seqeunce no if in raw format
if ! villas_format_supports_header $FORMAT; then
CMPFLAGS=-ts
fi
# Compare data
villas-test-cmp ${INPUT_FILE} ${OUTPUT_FILE}
RC:$?
villas-test-cmp ${CMPFLAGS} ${INPUT_FILE} ${OUTPUT_FILE}
RC=$?
if (( ${RC} != 0 )); then
echo "=========== Sub-test failed for: layer=${LAYER}, header=${HEADER}, endian=${ENDIAN}, verify_source=${VERIFY_SOURCE}"
echo "=========== Sub-test failed for: format=${FORMAT}, layer=${LAYER}, header=${HEADER}, endian=${ENDIAN}, verify_source=${VERIFY_SOURCE}, vectorize=${VECTORIZE}"
cat ${CONFIG_FILE}
echo
cat ${INPUT_FILE}
@ -91,10 +111,10 @@ if (( ${RC} != 0 )); then
cat ${OUTPUT_FILE}
exit ${RC}
else
echo "=========== Sub-test succeeded for: layer=${LAYER}, header=${HEADER}, endian=${ENDIAN}, verify_source=${VERIFY_SOURCE}"
echo "=========== Sub-test succeeded for: format=${FORMAT}, layer=${LAYER}, header=${HEADER}, endian=${ENDIAN}, verify_source=${VERIFY_SOURCE}, vectorize=${VECTORIZE}"
fi
done; done; done; done
done; done; done; done; done; done
rm ${OUTPUT_FILE} ${INPUT_FILE} ${CONFIG_FILE} ${THEORIES}

View file

@ -0,0 +1,87 @@
#!/bin/bash
#
# Integration loopback test for villas-pipe.
#
# @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
# @copyright 2017, 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/>.
##################################################################################
SCRIPT=$(realpath $0)
SCRIPTPATH=$(dirname ${SCRIPT})
source ${SCRIPTPATH}/../../tools/integration-tests-helper.sh
CONFIG_FILE=$(mktemp)
CONFIG_FILE2=$(mktemp)
INPUT_FILE=$(mktemp)
OUTPUT_FILE=$(mktemp)
NUM_SAMPLES=${NUM_SAMPLES:-10}
cat > ${CONFIG_FILE} << EOF
{
"nodes" : {
"node1" : {
"type" : "websocket",
"destinations" : [
"ws://127.0.0.1:81/node2"
]
}
}
}
EOF
cat > ${CONFIG_FILE2} << EOF
{
"http" : {
"port" : 81
},
"nodes" : {
"node2" : {
"type" : "websocket"
}
}
}
EOF
# Generate test data
VILLAS_LOG_PREFIX=$(colorize "[Signal]") \
villas-signal random -l ${NUM_SAMPLES} -n > ${INPUT_FILE}
VILLAS_LOG_PREFIX=$(colorize "[Recv] ") \
villas-pipe -r -d 15 -l ${NUM_SAMPLES} ${CONFIG_FILE2} node2 > ${OUTPUT_FILE} &
PID=$!
VILLAS_LOG_PREFIX=$(colorize "[Send] ") \
villas-pipe -s -d 15 ${CONFIG_FILE} node1 < ${INPUT_FILE}
wait ${PID}
cat ${OUTPUT_FILE}
echo
cat ${INPUT_FILE}
# Compare data
villas-test-cmp ${INPUT_FILE} ${OUTPUT_FILE}
RC=$?
rm ${OUTPUT_FILE} ${INPUT_FILE} ${CONFIG_FILE} ${CONFIG_FILE2}
exit $RC

View file

@ -22,18 +22,38 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
##################################################################################
SCRIPT=$(realpath $0)
SCRIPTPATH=$(dirname ${SCRIPT})
source ${SCRIPTPATH}/../../tools/integration-tests-helper.sh
CONFIG_FILE=$(mktemp)
INPUT_FILE=$(mktemp)
OUTPUT_FILE=$(mktemp)
NUM_SAMPLES=${NUM_SAMPLES:-10}
# Generate test data
villas-signal random -l ${NUM_SAMPLES} -n -v 10 > ${INPUT_FILE}
for FORMAT in csv json villas csv msg gtnet-fake raw-flt32 gtnet-fake; do
VECTORIZES="1"
# The raw format does not support vectors
if villas_format_supports_vectorize ${FORMAT}; then
VECTORIZES="${VECTORIZES} 10"
fi
for VECTORIZE in ${VECTORIZES}; do
cat > ${CONFIG_FILE} << EOF
{
"nodes" : {
"node1" : {
"type" : "zeromq",
"format" : "${FORMAT}",
"vectorize" : ${VECTORIZE},
"pattern" : "pubsub",
"subscribe" : "tcp://127.0.0.1:12000",
"publish" : "tcp://127.0.0.1:12000"
@ -42,16 +62,32 @@ cat > ${CONFIG_FILE} << EOF
}
EOF
# Generate test data
villas-signal random -l ${NUM_SAMPLES} -n > ${INPUT_FILE}
# We delay EOF of the INPUT_FILE by 1 second in order to wait for incoming data to be received
villas-pipe -l ${NUM_SAMPLES} ${CONFIG_FILE} node1 > ${OUTPUT_FILE} < ${INPUT_FILE}
# Comapre data
villas-test-cmp ${INPUT_FILE} ${OUTPUT_FILE}
# Ignore timestamp and seqeunce no if in raw format
if villas_format_supports_header ${FORMAT}; then
CMPFLAGS=-ts
fi
# Compare data
villas-test-cmp ${CMPFLAGS} ${INPUT_FILE} ${OUTPUT_FILE}
RC=$?
if (( ${RC} != 0 )); then
echo "=========== Sub-test failed for: format=${FORMAT}, vectorize=${VECTORIZE}"
cat ${CONFIG_FILE}
echo
cat ${INPUT_FILE}
echo
cat ${OUTPUT_FILE}
exit ${RC}
else
echo "=========== Sub-test succeeded for: format=${FORMAT}, vectorize=${VECTORIZE}"
fi
done; done
rm ${OUTPUT_FILE} ${INPUT_FILE} ${CONFIG_FILE}
exit $RC