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/api-config.sh

65 lines
1.6 KiB
Bash
Raw Permalink Normal View History

2017-03-27 12:39:29 +02:00
#!/bin/bash
2017-04-27 13:08:17 +02:00
#
# Integration test for remote API
#
# @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-04-27 13:08:17 +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.
#
2017-04-27 13:08:17 +02:00
# 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.
#
2017-04-27 13:08:17 +02:00
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
##################################################################################
2017-03-27 12:39:29 +02:00
SCRIPT=$(realpath $0)
SCRIPTPATH=$(dirname ${SCRIPT})
2017-04-02 12:56:46 +02:00
CONFIG_FILE=$(mktemp)
2017-04-02 12:56:46 +02:00
FETCHED_CONF=$(mktemp)
2017-03-27 12:39:29 +02:00
cat > ${CONFIG_FILE} <<EOF
{
"http" : {
"port" : 8080
},
"nodes" : {
"node1" : {
"type" : "loopback"
}
}
}
EOF
2017-08-20 10:54:34 +02:00
ID=$(uuidgen)
2017-03-27 12:39:29 +02:00
# Start VILLASnode instance with local config (via advio)
villas-node ${CONFIG_FILE} &
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
curl -s http://localhost:8080/api/v2/config > ${FETCHED_CONF}
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
diff -u <(jq -S . < ${FETCHED_CONF}) <(jq -S . < ${CONFIG_FILE})
2017-03-27 12:39:29 +02:00
RC=$?
rm -f ${FETCHED_CONF} ${CONFIG_FILE}
2017-03-27 12:39:29 +02:00
exit ${RC}