1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00
VILLASnode/tests/integration/node-stats.sh
Steffen Vogel bc24676138 Use spaces for indention of shell scripts
Signed-off-by: Steffen Vogel <post@steffenvogel.de>
2024-02-29 23:18:47 +01:00

71 lines
1.5 KiB
Bash
Executable file

#!/usr/bin/env bash
#
# Integration loopback test using villas node.
#
# Author: Steffen Vogel <post@steffenvogel.de>
# SPDX-FileCopyrightText: 2014-2023 Institute for Automation of Complex Power Systems, RWTH Aachen University
# SPDX-License-Identifier: Apache-2.0
set -e
DIR=$(mktemp -d)
pushd ${DIR}
function finish {
popd
rm -rf ${DIR}
}
trap finish EXIT
RATE="33.0"
cat > config.json <<EOF
{
"nodes": {
"stats_1": {
"type": "stats",
"node": "signal_1",
"rate": 10.0,
"in": {
"signals": [
{ "name": "gap", "stats": "signal_1.gap_sent.mean" },
{ "name": "total", "stats": "signal_1.owd.total" }
]
}
},
"signal_1": {
"type": "signal",
"limit": 100,
"signal": "sine",
"rate": ${RATE},
"in": {
"hooks": [
{ "type": "stats", "verbose": true }
]
}
},
"stats_log_1": {
"type": "file",
"format": "json",
"uri": "stats.json"
}
},
"paths": [
{
"in": "signal_1"
},
{
"in": "stats_1",
"out": "stats_log_1"
}
]
}
EOF
timeout --preserve-status -k 15s 5s \
villas node config.json
[ -s stats.json ] # check that file exists
tail -n1 stats.json | jq -e "(.data[0] - 1/${RATE} | length) < 1e-4 and .data[1] == 99" > /dev/null