2024-02-29 20:03:12 +01:00
|
|
|
#!/usr/bin/env bash
|
2017-08-10 17:58:01 +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-08-10 17:58:01 +02:00
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
DIR=$(mktemp -d)
|
|
|
|
pushd ${DIR}
|
2018-12-02 03:57:40 +01: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-12-02 03:06:19 +01:00
|
|
|
{
|
2024-02-29 21:54:10 +01:00
|
|
|
"http": {
|
|
|
|
"port": 8080
|
|
|
|
}
|
2018-12-02 03:57:40 +01:00
|
|
|
}
|
2018-12-02 03:06:19 +01:00
|
|
|
EOF
|
2017-08-10 17:58:01 +02:00
|
|
|
|
2018-12-02 03:57:40 +01:00
|
|
|
# Start without a configuration
|
2021-09-22 10:42:03 +02:00
|
|
|
timeout -s SIGKILL 3 \
|
2024-02-29 20:03:12 +01:00
|
|
|
villas node config.json &
|
2018-12-02 03:57:40 +01:00
|
|
|
|
2017-08-10 17:58:01 +02:00
|
|
|
# Wait for node to complete init
|
|
|
|
sleep 1
|
|
|
|
|
|
|
|
# Restart with configuration
|
2020-08-17 17:06:40 +02:00
|
|
|
curl -sX POST http://localhost:8080/api/v2/shutdown
|
2017-08-10 17:58:01 +02:00
|
|
|
|
2021-09-22 10:42:03 +02:00
|
|
|
# Wait returns the return code of villas node
|
2017-08-10 17:58:01 +02:00
|
|
|
# which will be 0 (success) in case of normal shutdown
|
|
|
|
# or <>0 (fail) in case the 3 second timeout was reached
|
2018-12-02 03:06:19 +01:00
|
|
|
wait $!
|