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>
|
|
|
|
# @copyright 2017, Institute for Automation of Complex Power Systems, EONERC
|
|
|
|
# @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-05-05 19:24:16 +00:00
|
|
|
#
|
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-05-05 19:24:16 +00:00
|
|
|
#
|
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
|
|
|
|
2017-08-27 17:07:04 +02:00
|
|
|
SCRIPT=$(realpath $0)
|
|
|
|
SCRIPTPATH=$(dirname ${SCRIPT})
|
2017-04-02 12:56:46 +02:00
|
|
|
|
2017-08-27 17:07:04 +02:00
|
|
|
LOCAL_CONF=${SCRIPTPATH}/../../etc/loopback.json
|
2017-03-27 12:39:29 +02:00
|
|
|
|
2017-04-02 12:56:46 +02:00
|
|
|
FETCHED_CONF=$(mktemp)
|
2017-03-27 12:39:29 +02:00
|
|
|
|
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 file://${LOCAL_CONF} &
|
|
|
|
|
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
|
2017-08-20 10:54:34 +02:00
|
|
|
curl -sX POST --data '{ "action" : "config", "id" : "'${ID}'" }' http://localhost/api/v1 > ${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
|
2017-08-20 10:54:34 +02:00
|
|
|
diff -u <(jq -S .response < ${FETCHED_CONF}) <(jq -S . < ${LOCAL_CONF})
|
2017-03-27 12:39:29 +02:00
|
|
|
RC=$?
|
|
|
|
|
2017-08-31 17:25:23 +02:00
|
|
|
rm -f ${FETCHED_CONF}
|
2017-03-27 12:39:29 +02:00
|
|
|
|
|
|
|
exit $RC
|