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

93 lines
2 KiB
Bash
Raw Permalink Normal View History

2017-09-05 01:07:11 +02:00
#!/bin/bash
#
# Integration loopback test using villas-node.
#
# @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
2020-01-20 17:17:00 +01:00
# @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
2017-09-05 01:07:11 +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/>.
##################################################################################
SCRIPT=$(realpath $0)
SCRIPTPATH=$(dirname ${SCRIPT})
2019-02-17 22:24:49 +01:00
source ${SCRIPTPATH}/../../tools/villas-helper.sh
2017-09-05 01:07:11 +02:00
CONFIG_FILE=$(mktemp)
2019-02-17 22:24:49 +01:00
STATS_LOG=$(mktemp)
RATE="33.0"
2017-09-05 01:07:11 +02:00
cat > ${CONFIG_FILE} <<EOF
{
"nodes": {
"stats_1": {
"type": "stats",
"node": "signal_1",
2019-02-17 22:24:49 +01:00
"rate": 10.0,
"in": {
"signals": [
{ "name": "gap", "stats": "signal_1.gap_sent.mean" },
2019-02-17 22:24:49 +01:00
{ "name": "total", "stats": "signal_1.owd.total" }
]
}
2017-09-05 01:07:11 +02:00
},
"signal_1": {
"type": "signal",
"limit": 100,
"signal": "sine",
2019-02-17 22:24:49 +01:00
"rate": ${RATE},
2018-08-20 18:32:01 +02:00
"in" : {
"hooks": [
{ "type": "stats", "verbose": true }
]
}
2019-02-17 22:24:49 +01:00
},
"stats_log_1": {
"type": "file",
"format": "json",
"uri": "${STATS_LOG}"
2017-09-05 01:07:11 +02:00
}
},
"paths": [
{
2019-02-17 22:24:49 +01:00
"in": "signal_1"
2017-09-05 01:07:11 +02:00
},
{
"in": "stats_1",
2019-02-17 22:24:49 +01:00
"out": "stats_log_1"
2017-09-05 01:07:11 +02:00
}
]
}
EOF
# Start node
VILLAS_LOG_PREFIX=$(colorize "[Node] ") \
2019-02-17 22:24:49 +01:00
villas-node ${CONFIG_FILE} &
PID=$!
sleep 5
kill ${PID}
wait ${PID}
2019-02-17 22:24:49 +01:00
tail -n1 ${STATS_LOG} | jq -e "(.data[0] - 1/${RATE} | length) < 1e-4 and .data[1] == 99" > /dev/null
RC=$?
rm ${STATS_LOG} ${CONFIG_FILE}
exit ${RC}