1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

tests: fix api-restart and api-shutdown tests

This commit is contained in:
Steffen Vogel 2018-12-02 03:57:40 +01:00
parent 5b3cba5bef
commit 3a53e27bde
2 changed files with 24 additions and 8 deletions

View file

@ -24,6 +24,7 @@
set -e
BASE_CONF=$(mktemp)
LOCAL_CONF=$(mktemp)
FETCHED_CONF=$(mktemp)
@ -57,20 +58,28 @@ cat <<EOF > ${LOCAL_CONF}
}
EOF
# Start without a configuration
villas-node &
cat <<EOF > ${BASE_CONF}
{
"http" : {
"port" : 8080
}
}
EOF
# Start with base configuration
villas-node ${BASE_CONF} &
# Wait for node to complete init
sleep 0.2
sleep 1
# Restart with configuration
curl -sX POST --data '{ "action" : "restart", "request" : { "config": "'${LOCAL_CONF}'" }, "id" : "5a786626-fbc6-4c04-98c2-48027e68c2fa" }' http://localhost:8080/api/v1
# Wait for node to complete init
sleep 1
sleep 2
# Fetch config via API
curl -sX POST --data '{ "action" : "config", "id" : "5a786626-fbc6-4c04-98c2-48027e68c2fa" }' http://localhost/api/v1 > ${FETCHED_CONF}
curl -sX POST --data '{ "action" : "config", "id" : "5a786626-fbc6-4c04-98c2-48027e68c2fa" }' http://localhost:8080/api/v1 > ${FETCHED_CONF}
# Shutdown VILLASnode
kill %%
@ -79,6 +88,6 @@ kill %%
diff -u <(jq -S .response < ${FETCHED_CONF}) <(jq -S . < ${LOCAL_CONF})
RC=$?
rm -f ${LOCAL_CONF} ${FETCHED_CONF}
rm -f ${LOCAL_CONF} ${FETCHED_CONF} ${BASE_CONF}
exit $RC

View file

@ -24,20 +24,27 @@
set -e
# Start without a configuration
timeout -s SIGKILL 3 villas-node & <<EOF
CONFIG_FILE=$(mktemp)
cat > ${CONFIG_FILE} <<EOF
{
"http" : {
"port" : 8080
}
}
EOF
# Start without a configuration
timeout -s SIGKILL 3 villas-node ${CONFIG_FILE} &
# Wait for node to complete init
sleep 1
# Restart with configuration
curl -sX POST --data '{ "action" : "shutdown", "id" : "5a786626-fbc6-4c04-98c2-48027e68c2fa" }' http://localhost:8080/api/v1
rm ${CONFIG_FILE}
# Wait returns the return code of villas-node
# which will be 0 (success) in case of normal shutdown
# or <>0 (fail) in case the 3 second timeout was reached