2024-02-29 20:03:12 +01:00
|
|
|
#!/usr/bin/env bash
|
2017-04-27 13:08:17 +02:00
|
|
|
#
|
|
|
|
# Integration test for remote API
|
|
|
|
#
|
2022-03-15 09:18:01 -04:00
|
|
|
# Author: Steffen Vogel <post@steffenvogel.de>
|
2022-03-15 09:28:57 -04:00
|
|
|
# SPDX-FileCopyrightText: 2014-2023 Institute for Automation of Complex Power Systems, RWTH Aachen University
|
2022-07-04 18:20:03 +02:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
2017-03-27 12:39:29 +02:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
set -e
|
2017-04-02 12:56:46 +02:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
DIR=$(mktemp -d)
|
|
|
|
pushd ${DIR}
|
2017-03-27 12:39:29 +02:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
function finish {
|
2024-02-29 21:54:10 +01:00
|
|
|
popd
|
|
|
|
rm -rf ${DIR}
|
2021-08-10 10:12:48 -04:00
|
|
|
}
|
|
|
|
trap finish EXIT
|
|
|
|
|
|
|
|
cat > config.json <<EOF
|
2018-10-21 19:07:58 +01:00
|
|
|
{
|
2024-02-29 21:54:10 +01:00
|
|
|
"http": {
|
|
|
|
"port": 8080
|
|
|
|
},
|
|
|
|
"nodes": {
|
|
|
|
"node1": {
|
|
|
|
"type": "loopback"
|
|
|
|
}
|
|
|
|
}
|
2018-10-21 19:07:58 +01:00
|
|
|
}
|
|
|
|
EOF
|
|
|
|
|
2017-08-20 10:54:34 +02:00
|
|
|
ID=$(uuidgen)
|
|
|
|
|
2021-02-16 14:15:14 +01:00
|
|
|
# Start VILLASnode instance with local config
|
2021-08-10 10:12:48 -04:00
|
|
|
villas node config.json &
|
2017-03-27 12:39:29 +02:00
|
|
|
|
2017-04-02 12:56:46 +02:00
|
|
|
# Wait for node to complete init
|
2017-03-27 12:39:29 +02:00
|
|
|
sleep 1
|
|
|
|
|
|
|
|
# Fetch config via API
|
2021-08-10 10:12:48 -04:00
|
|
|
curl -s http://localhost:8080/api/v2/config > fetched.json
|
2017-03-27 12:39:29 +02:00
|
|
|
|
|
|
|
# Shutdown VILLASnode
|
|
|
|
kill $!
|
|
|
|
|
2017-04-02 12:56:46 +02:00
|
|
|
# Compare local config with the fetched one
|
2021-08-10 10:12:48 -04:00
|
|
|
diff -u <(jq -S . < fetched.json) <(jq -S . < config.json)
|