mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
added integration tests
This commit is contained in:
parent
f28dd96c30
commit
eb4cb081f1
13 changed files with 340 additions and 109 deletions
|
@ -2,6 +2,9 @@
|
|||
|
||||
tests: unit-tests
|
||||
|
||||
run-tests: run-unit-tests
|
||||
run-tests: run-unit-tests run-integration-tests
|
||||
|
||||
run-integration-tests: src tools
|
||||
@$(SRCDIR)/tests/integration-tests.sh
|
||||
|
||||
.PHONY: tests run-tests
|
||||
.PHONY: tests run-tests run-integration-tests
|
||||
|
|
81
tests/integration-tests.sh
Executable file
81
tests/integration-tests.sh
Executable file
|
@ -0,0 +1,81 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Run integration tests
|
||||
#
|
||||
# @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
# @copyright 2017, Institute for Automation of Complex Power Systems, EONERC
|
||||
##################################################################################
|
||||
|
||||
SCRIPT=$(realpath ${BASH_SOURCE[0]})
|
||||
SCRIPTPATH=$(dirname $SCRIPT)
|
||||
|
||||
export SRCDIR=$(realpath ${SCRIPTPATH}/..)
|
||||
export BUILDDIR=${SRCDIR}/build/release
|
||||
export LOGDIR=${BUILDDIR}/tests/integration
|
||||
export PATH=${BUILDDIR}:${PATH}
|
||||
|
||||
# Default values
|
||||
VERBOSE=0
|
||||
FILTER='*'
|
||||
|
||||
export NUM_SAMPLES=100
|
||||
|
||||
# Parse command line arguments
|
||||
while getopts ":f:v" OPT; do
|
||||
case ${OPT} in
|
||||
f)
|
||||
FILTER=${OPTARG}
|
||||
;;
|
||||
v)
|
||||
VERBOSE=1
|
||||
;;
|
||||
\?)
|
||||
echo "Invalid option: -${OPTARG}" >&2
|
||||
;;
|
||||
:)
|
||||
echo "Option -$OPTARG requires an argument." >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
TESTS=${SRCDIR}/tests/integration/${FILTER}.sh
|
||||
|
||||
# Preperations
|
||||
mkdir -p ${LOGDIR}
|
||||
|
||||
NUM_PASS=0
|
||||
NUM_FAIL=0
|
||||
|
||||
# Preamble
|
||||
echo -e "Starting integration tests for VILLASnode/fpga:\n"
|
||||
|
||||
for TEST in ${TESTS}; do
|
||||
TESTNAME=$(basename -s .sh ${TEST})
|
||||
|
||||
# Run test
|
||||
if (( ${VERBOSE} == 0 )); then
|
||||
${TEST} &> ${LOGDIR}/${TESTNAME}.log
|
||||
else
|
||||
${TEST}
|
||||
fi
|
||||
|
||||
RC=$?
|
||||
|
||||
if (( $RC != 0 )); then
|
||||
echo -e "\e[31m[Fail] \e[39m ${TESTNAME} with code $RC"
|
||||
NUM_FAIL=$((${NUM_FAIL} + 1))
|
||||
else
|
||||
echo -e "\e[32m[Pass] \e[39m ${TESTNAME}"
|
||||
NUM_PASS=$((${NUM_PASS} + 1))
|
||||
fi
|
||||
done
|
||||
|
||||
# Show summary
|
||||
if (( ${NUM_FAIL} > 0 )); then
|
||||
echo -e "\nSummary: ${NUM_FAIL} of $((${NUM_FAIL} + ${NUM_PASS})) tests failed."
|
||||
exit 1
|
||||
else
|
||||
echo -e "\nSummary: all tests passed!"
|
||||
exit 0
|
||||
fi
|
|
@ -1,35 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
SCRIPT=$(realpath ${BASH_SOURCE[0]})
|
||||
SCRIPTPATH=$(dirname $SCRIPT)
|
||||
|
||||
TOPDIR=$(realpath ${SCRIPTPATH}/..)
|
||||
BUILDDIR=${TOPDIR}/build/release
|
||||
PATH=${BUILDDIR}:${PATH}
|
||||
|
||||
CONFIGFILE=$(mktemp)
|
||||
DATAFILE_ORIG=$(mktemp)
|
||||
DATAFILE_LOOP=$(mktemp)
|
||||
|
||||
cat > ${CONFIGFILE} <<- EOM
|
||||
nodes = {
|
||||
node1 = {
|
||||
type = "socket";
|
||||
layer = "udp";
|
||||
|
||||
local = "*:12000";
|
||||
remote = "localhost:12000"
|
||||
}
|
||||
}
|
||||
EOM
|
||||
|
||||
# Generate test data
|
||||
villas-signal random -l 10 -r 100 > ${DATAFILE_ORIG}
|
||||
|
||||
villas-pipe ${CONFIGFILE} node1 < ${DATAFILE_ORIG} > ${DATAFILE_LOOP}
|
||||
|
||||
diff -u ${DATAFILE_ORIG} ${DATAFILE_LOOP}
|
||||
|
||||
rm ${DATAFILE_ORIG}
|
||||
rm ${DATAFILE_LOOP}
|
||||
rm ${CONFIGFILE}
|
26
tests/integration/api-config.sh
Executable file
26
tests/integration/api-config.sh
Executable file
|
@ -0,0 +1,26 @@
|
|||
#!/bin/bash
|
||||
|
||||
LOCAL_CONF=${SRCDIR}/etc/loopback.conf
|
||||
FETCHED_CONF=$(mktemp)
|
||||
|
||||
echo ${CONF}
|
||||
|
||||
# Start VILLASnode instance with local config (via advio)
|
||||
villas-node file://${LOCAL_CONF} &
|
||||
|
||||
sleep 1
|
||||
|
||||
# Fetch config via API
|
||||
curl -sX POST --data '{ "command" : "config" }' http://localhost/api/v1 2>/dev/null > ${FETCHED_CONF}
|
||||
|
||||
# Shutdown VILLASnode
|
||||
kill $!
|
||||
|
||||
# Compare local config with the fetched one
|
||||
diff -u <(cat ${LOCAL_CONF} | conf2json | jq -S .) <(cat ${FETCHED_CONF} | jq -S .config)
|
||||
|
||||
RC=$?
|
||||
|
||||
rm -f ${FETCHED_CONF}
|
||||
|
||||
exit $RC
|
42
tests/integration/hook-convert.sh
Executable file
42
tests/integration/hook-convert.sh
Executable file
|
@ -0,0 +1,42 @@
|
|||
#!/bin/bash
|
||||
|
||||
INPUT_FILE=$(mktemp)
|
||||
OUTPUT_FILE=$(mktemp)
|
||||
EXPECT_FILE=$(mktemp)
|
||||
|
||||
cat <<EOF > ${INPUT_FILE}
|
||||
1490500399.776379108(0) 0.000000 0.000000 0.000000 0.000000
|
||||
1490500399.876379108(1) 0.587785 0.587785 0.587785 0.587785
|
||||
1490500399.976379108(2) 0.951057 0.951057 0.951057 0.951057
|
||||
1490500400.076379108(3) 0.951057 0.951057 0.951057 0.951057
|
||||
1490500400.176379108(4) 0.587785 0.587785 0.587785 0.587785
|
||||
1490500400.276379108(5) 0.000000 0.000000 0.000000 0.000000
|
||||
1490500400.376379108(6) -0.587785 -0.587785 -0.587785 -0.587785
|
||||
1490500400.476379108(7) -0.951057 -0.951057 -0.951057 -0.951057
|
||||
1490500400.576379108(8) -0.951057 -0.951057 -0.951057 -0.951057
|
||||
1490500400.676379108(9) -0.587785 -0.587785 -0.587785 -0.587785
|
||||
EOF
|
||||
|
||||
cat <<EOF > ${EXPECT_FILE}
|
||||
1490500399.776379108(0) 0.000000 0 0 0.000000
|
||||
1490500399.876379108(1) 0.587785 58 58 0.587785
|
||||
1490500399.976379108(2) 0.951057 95 95 0.951057
|
||||
1490500400.076379108(3) 0.951057 95 95 0.951057
|
||||
1490500400.176379108(4) 0.587785 58 58 0.587785
|
||||
1490500400.276379108(5) 0.000000 0 0 0.000000
|
||||
1490500400.376379108(6) -0.587785 -58 -58 -0.587785
|
||||
1490500400.476379108(7) -0.951057 -95 -95 -0.951057
|
||||
1490500400.576379108(8) -0.951057 -95 -95 -0.951057
|
||||
1490500400.676379108(9) -0.587785 -58 -58 -0.587785
|
||||
EOF
|
||||
|
||||
villas-hook convert 'mode="fixed" scale=100 mask=0x6' < ${INPUT_FILE} > ${OUTPUT_FILE}
|
||||
|
||||
# Compare only the data values
|
||||
diff -u <(cut -f2- ${OUTPUT_FILE}) <(cut -f2- ${EXPECT_FILE})
|
||||
|
||||
RC=$?
|
||||
|
||||
rm -f ${INPUT_FILE} ${OUTPUT_FILE} ${EXPECT_FILE}
|
||||
|
||||
exit $RC
|
36
tests/integration/hook-decimate.sh
Executable file
36
tests/integration/hook-decimate.sh
Executable file
|
@ -0,0 +1,36 @@
|
|||
#!/bin/bash
|
||||
|
||||
INPUT_FILE=$(mktemp)
|
||||
OUTPUT_FILE=$(mktemp)
|
||||
EXPECT_FILE=$(mktemp)
|
||||
|
||||
cat <<EOF > ${INPUT_FILE}
|
||||
1490500399.776379108(0) 0.000000 0.000000 0.000000 0.000000
|
||||
1490500399.876379108(1) 0.587785 0.587785 0.587785 0.587785
|
||||
1490500399.976379108(2) 0.951057 0.951057 0.951057 0.951057
|
||||
1490500400.076379108(3) 0.951057 0.951057 0.951057 0.951057
|
||||
1490500400.176379108(4) 0.587785 0.587785 0.587785 0.587785
|
||||
1490500400.276379108(5) 0.000000 0.000000 0.000000 0.000000
|
||||
1490500400.376379108(6) -0.587785 -0.587785 -0.587785 -0.587785
|
||||
1490500400.476379108(7) -0.951057 -0.951057 -0.951057 -0.951057
|
||||
1490500400.576379108(8) -0.951057 -0.951057 -0.951057 -0.951057
|
||||
1490500400.676379108(9) -0.587785 -0.587785 -0.587785 -0.587785
|
||||
EOF
|
||||
|
||||
cat <<EOF > ${EXPECT_FILE}
|
||||
1490500399.776379108(0) 0.000000 0.000000 0.000000 0.000000
|
||||
1490500400.076379108(3) 0.951057 0.951057 0.951057 0.951057
|
||||
1490500400.376379108(6) -0.587785 -0.587785 -0.587785 -0.587785
|
||||
1490500400.676379108(9) -0.587785 -0.587785 -0.587785 -0.587785
|
||||
EOF
|
||||
|
||||
villas-hook decimate 'ratio=3' < ${INPUT_FILE} > ${OUTPUT_FILE}
|
||||
|
||||
# Compare only the data values
|
||||
diff -u <(cut -f2- ${OUTPUT_FILE}) <(cut -f2- ${EXPECT_FILE})
|
||||
|
||||
RC=$?
|
||||
|
||||
rm -f ${INPUT_FILE} ${OUTPUT_FILE} ${EXPECT_FILE}
|
||||
|
||||
exit $RC
|
42
tests/integration/hook-drop.sh
Executable file
42
tests/integration/hook-drop.sh
Executable file
|
@ -0,0 +1,42 @@
|
|||
#!/bin/bash
|
||||
|
||||
INPUT_FILE=$(mktemp)
|
||||
OUTPUT_FILE=$(mktemp)
|
||||
EXPECT_FILE=$(mktemp)
|
||||
|
||||
cat <<EOF > ${INPUT_FILE}
|
||||
1490500399.776379108(0) 0.000000 0.000000 0.000000 0.000000
|
||||
1490500399.876379108(1) 0.587785 0.587785 0.587785 0.587785
|
||||
1490500399.976379108(2) 0.951057 0.951057 0.951057 0.951057
|
||||
1490500399.976379108(2) 0.951057 0.951057 0.951057 0.951057
|
||||
1490500399.976379108(2) 0.951057 0.951057 0.951057 0.951057
|
||||
1490500400.076379108(3) 0.951057 0.951057 0.951057 0.951057
|
||||
1490500400.176379108(4) 0.587785 0.587785 0.587785 0.587785
|
||||
1490500400.476379108(7) -0.951057 -0.951057 -0.951057 -0.951057
|
||||
1490500400.276379108(5) 0.000000 0.000000 0.000000 0.000000
|
||||
1490500400.576379108(8) -0.951057 -0.951057 -0.951057 -0.951057
|
||||
1490500400.376379108(6) -0.587785 -0.587785 -0.587785 -0.587785
|
||||
1490500400.676379108(9) -0.587785 -0.587785 -0.587785 -0.587785
|
||||
EOF
|
||||
|
||||
cat <<EOF > ${EXPECT_FILE}
|
||||
1490500399.776379108(0) 0.000000 0.000000 0.000000 0.000000
|
||||
1490500399.876379108(1) 0.587785 0.587785 0.587785 0.587785
|
||||
1490500399.976379108(2) 0.951057 0.951057 0.951057 0.951057
|
||||
1490500400.076379108(3) 0.951057 0.951057 0.951057 0.951057
|
||||
1490500400.176379108(4) 0.587785 0.587785 0.587785 0.587785
|
||||
1490500400.476379108(7) -0.951057 -0.951057 -0.951057 -0.951057
|
||||
1490500400.576379108(8) -0.951057 -0.951057 -0.951057 -0.951057
|
||||
1490500400.676379108(9) -0.587785 -0.587785 -0.587785 -0.587785
|
||||
EOF
|
||||
|
||||
villas-hook drop < ${INPUT_FILE} > ${OUTPUT_FILE}
|
||||
|
||||
# Compare only the data values
|
||||
diff -u <(cut -f2- ${OUTPUT_FILE}) <(cut -f2- ${EXPECT_FILE})
|
||||
|
||||
RC=$?
|
||||
|
||||
rm -f ${INPUT_FILE} ${OUTPUT_FILE} ${EXPECT_FILE}
|
||||
|
||||
exit $RC
|
42
tests/integration/hook-map.sh
Executable file
42
tests/integration/hook-map.sh
Executable file
|
@ -0,0 +1,42 @@
|
|||
#!/bin/bash
|
||||
|
||||
INPUT_FILE=$(mktemp)
|
||||
OUTPUT_FILE=$(mktemp)
|
||||
EXPECT_FILE=$(mktemp)
|
||||
|
||||
cat <<EOF > ${INPUT_FILE}
|
||||
1490500399.776379108(0) 0.000000 0.000000 0.000000 0.000000
|
||||
1490500399.876379108(1) 0.587785 0.587785 0.587785 0.587785
|
||||
1490500399.976379108(2) 0.951057 0.951057 0.951057 0.951057
|
||||
1490500400.076379108(3) 0.951057 0.951057 0.951057 0.951057
|
||||
1490500400.176379108(4) 0.587785 0.587785 0.587785 0.587785
|
||||
1490500400.276379108(5) 0.000000 0.000000 0.000000 0.000000
|
||||
1490500400.376379108(6) -0.587785 -0.587785 -0.587785 -0.587785
|
||||
1490500400.476379108(7) -0.951057 -0.951057 -0.951057 -0.951057
|
||||
1490500400.576379108(8) -0.951057 -0.951057 -0.951057 -0.951057
|
||||
1490500400.676379108(9) -0.587785 -0.587785 -0.587785 -0.587785
|
||||
EOF
|
||||
|
||||
cat <<EOF > ${EXPECT_FILE}
|
||||
1490500399.776379108(0) 0.000000 0 1490500399 776379108 0.000000 0.000000
|
||||
1490500399.876379108(1) 0.587785 1 1490500399 876379108 0.587785 0.587785
|
||||
1490500399.976379108(2) 0.951057 2 1490500399 976379108 0.951057 0.951057
|
||||
1490500400.076379108(3) 0.951057 3 1490500400 76379108 0.951057 0.951057
|
||||
1490500400.176379108(4) 0.587785 4 1490500400 176379108 0.587785 0.587785
|
||||
1490500400.276379108(5) 0.000000 5 1490500400 276379108 0.000000 0.000000
|
||||
1490500400.376379108(6) -0.587785 6 1490500400 376379108 -0.587785 -0.587785
|
||||
1490500400.476379108(7) -0.951057 7 1490500400 476379108 -0.951057 -0.951057
|
||||
1490500400.576379108(8) -0.951057 8 1490500400 576379108 -0.951057 -0.951057
|
||||
1490500400.676379108(9) -0.587785 9 1490500400 676379108 -0.587785 -0.587785
|
||||
EOF
|
||||
|
||||
villas-hook map 'mapping = [ "data[3]", "hdr.sequence", "ts.origin", "data[1-2]" ]' < ${INPUT_FILE} > ${OUTPUT_FILE}
|
||||
|
||||
# Compare only the data values
|
||||
diff -u <(cut -f2- ${OUTPUT_FILE}) <(cut -f2- ${EXPECT_FILE})
|
||||
|
||||
RC=$?
|
||||
|
||||
rm -f ${INPUT_FILE} ${OUTPUT_FILE} ${EXPECT_FILE}
|
||||
|
||||
exit $RC
|
18
tests/integration/hook-shift_seq.sh
Executable file
18
tests/integration/hook-shift_seq.sh
Executable file
|
@ -0,0 +1,18 @@
|
|||
#!/bin/bash
|
||||
|
||||
OUTPUT_FILE=$(mktemp)
|
||||
|
||||
OFFSET=100
|
||||
|
||||
villas-signal random -l ${NUM_SAMPLES} -n | villas-hook shift_seq offset=${OFFSET} > ${OUTPUT_FILE}
|
||||
|
||||
# Compare shifted sequence no
|
||||
diff -u \
|
||||
<(sed -re 's/^[0-9]+\.[0-9]+([\+\-][0-9]+\.[0-9]+(e[\+\-][0-9]+)?)?\(([0-9]+)\).*/\3/g' ${OUTPUT_FILE}) \
|
||||
<(seq ${OFFSET} $((${NUM_SAMPLES}+${OFFSET}-1)))
|
||||
|
||||
RC=$?
|
||||
|
||||
rm -f ${OUTPUT_FILE}
|
||||
|
||||
exit $RC
|
18
tests/integration/hook-shift_ts.sh
Executable file
18
tests/integration/hook-shift_ts.sh
Executable file
|
@ -0,0 +1,18 @@
|
|||
#!/bin/bash
|
||||
|
||||
STATS_FILE=$(mktemp)
|
||||
|
||||
OFFSET=10
|
||||
EPSILON=0.05
|
||||
|
||||
villas-signal sine -l 10 -r 10 | villas-hook shift_ts offset=${OFFSET} | villas-hook stats format=\"json\" output=\"${STATS_FILE}\" > /dev/null
|
||||
|
||||
#jq .owd ${STATS_FILE}
|
||||
|
||||
jq -e ".owd.mean - ${OFFSET} | length < ${EPSILON}" ${STATS_FILE} > /dev/null
|
||||
|
||||
RC=$?
|
||||
|
||||
rm ${STATS_FILE}
|
||||
|
||||
exit $RC
|
16
tests/integration/hook-skip_first.sh
Executable file
16
tests/integration/hook-skip_first.sh
Executable file
|
@ -0,0 +1,16 @@
|
|||
#!/bin/bash
|
||||
|
||||
OUTPUT_FILE=$(mktemp)
|
||||
|
||||
SKIP=10
|
||||
|
||||
echo ${OUTPUT_FILE}
|
||||
|
||||
villas-signal random -r 1 -l ${NUM_SAMPLES} -n | villas-hook skip_first seconds=${SKIP} > ${OUTPUT_FILE}
|
||||
|
||||
LINES=$(wc -l < ${OUTPUT_FILE})
|
||||
|
||||
rm ${OUTPUT_FILE}
|
||||
|
||||
# Test condition
|
||||
(( ${LINES} == ${NUM_SAMPLES} - ${SKIP} ))
|
14
tests/integration/hook-skip_first2.sh
Executable file
14
tests/integration/hook-skip_first2.sh
Executable file
|
@ -0,0 +1,14 @@
|
|||
#!/bin/bash
|
||||
|
||||
OUTPUT_FILE=$(mktemp)
|
||||
|
||||
SKIP=50
|
||||
|
||||
villas-signal random -r 1 -l ${NUM_SAMPLES} -n | villas-hook skip_first samples=${SKIP} > ${OUTPUT_FILE}
|
||||
|
||||
LINES=$(wc -l < ${OUTPUT_FILE})
|
||||
|
||||
rm ${OUTPUT_FILE}
|
||||
|
||||
# Test condition
|
||||
(( ${LINES} == ${NUM_SAMPLES} - ${SKIP} ))
|
|
@ -1,72 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
# Configuration
|
||||
|
||||
HOST=$(hostname -s)
|
||||
|
||||
#LOCAL_IP=10.10.12.2
|
||||
LOCAL_IP=127.0.0.1
|
||||
LOCAL_PORT=12001
|
||||
|
||||
#REMOTE_IP=10.10.12.3
|
||||
REMOTE_IP=127.0.0.1
|
||||
REMOTE_PORT=12002
|
||||
|
||||
#LOCAL_DIR=/villas/server/
|
||||
#REMOTE_DIR=/villas/server/
|
||||
LOCAL_DIR=/home/stv0g/workspace/rwth/acs/villas/server
|
||||
REMOTE_DIR=$LOCAL_DIR
|
||||
######################### End of Configuration ################################
|
||||
# There's no need to change something below this line
|
||||
|
||||
SSH="ssh -T $REMOTE_IP"
|
||||
|
||||
TEST_CONFIG="
|
||||
affinity = 0x02; # Mask of cores the server should run on
|
||||
priority = 50; # Scheduler priority for the server
|
||||
debug = 10; # The level of verbosity for debug messages
|
||||
stats = 3; # The interval in seconds fo path statistics
|
||||
|
||||
nodes = {
|
||||
remote = {
|
||||
type = \"udp\";
|
||||
local = \"$LOCAL_IP:$LOCAL_PORT\";
|
||||
remote = \"$REMOTE_IP:$REMOTE_PORT\";
|
||||
}
|
||||
};
|
||||
"
|
||||
|
||||
|
||||
REMOTE_CONFIG="
|
||||
affinity = 0x02; # Mask of cores the server should run on
|
||||
priority = 50; # Scheduler priority for the server
|
||||
debug = 0; # The level of verbosity for debug messages
|
||||
stats = 0; # The interval in seconds fo path statistics
|
||||
|
||||
nodes = {
|
||||
remote = {
|
||||
type = \"udp\";
|
||||
local = \"$REMOTE_IP:$REMOTE_PORT\";
|
||||
remote = \"$LOCAL_IP:$LOCAL_PORT\";
|
||||
},
|
||||
};
|
||||
|
||||
paths = ({
|
||||
in = \"remote\";
|
||||
out = \"remote\";
|
||||
});
|
||||
"
|
||||
|
||||
# Start remote server
|
||||
$SSH -n "echo '$REMOTE_CONFIG' | sudo $REMOTE_DIR/server -" &
|
||||
REMOTE_PID=$!
|
||||
echo "Started remote server with pid: $REMOTE_PID"
|
||||
|
||||
# Start tests
|
||||
echo "$TEST_CONFIG" | $LOCAL_DIR/test - rtt -f 3 -c 100000 3>> test_output
|
||||
|
||||
# Stop remote server
|
||||
$SSH sudo kill $REMOTE_PID
|
||||
echo "Stopped remote server with pid: $REMOTE_PID"
|
Loading…
Add table
Reference in a new issue