properly wait for server shutdown in CI
This commit is contained in:
parent
20df158917
commit
2ff1291b09
|
|
@ -44,6 +44,7 @@ pass_count=0
|
||||||
client="../bin/dcd-client"
|
client="../bin/dcd-client"
|
||||||
server="../bin/dcd-server"
|
server="../bin/dcd-server"
|
||||||
tcp=""
|
tcp=""
|
||||||
|
server_pid=""
|
||||||
|
|
||||||
function startServer()
|
function startServer()
|
||||||
{
|
{
|
||||||
|
|
@ -57,6 +58,24 @@ function startServer()
|
||||||
sleep 1
|
sleep 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function waitShutdown()
|
||||||
|
{
|
||||||
|
if [[ -z "$server_pid" ]]; then
|
||||||
|
sleep 0.5 # not owned by us
|
||||||
|
else
|
||||||
|
( sleep 15 ; echo 'Waiting for shutdown timed out'; kill $server_pid ) &
|
||||||
|
killerPid=$!
|
||||||
|
|
||||||
|
wait $server_pid
|
||||||
|
status=$?
|
||||||
|
(kill -0 $killerPid && kill $killerPid) || true
|
||||||
|
|
||||||
|
server_pid=""
|
||||||
|
|
||||||
|
return $status
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Make sure that the server is shut down
|
# Make sure that the server is shut down
|
||||||
echo "Shutting down currently-running server..."
|
echo "Shutting down currently-running server..."
|
||||||
"$client" --shutdown 2>/dev/null > /dev/null
|
"$client" --shutdown 2>/dev/null > /dev/null
|
||||||
|
|
@ -64,7 +83,7 @@ echo "Shutting down currently-running server..."
|
||||||
|
|
||||||
for socket in $SOCKETMODES; do # supported: unix tcp
|
for socket in $SOCKETMODES; do # supported: unix tcp
|
||||||
# allow some time for server to shutdown
|
# allow some time for server to shutdown
|
||||||
sleep 0.5;
|
waitShutdown
|
||||||
|
|
||||||
if [[ $socket == "tcp" ]]; then
|
if [[ $socket == "tcp" ]]; then
|
||||||
tcp="--tcp"
|
tcp="--tcp"
|
||||||
|
|
@ -119,6 +138,8 @@ for socket in $SOCKETMODES; do # supported: unix tcp
|
||||||
echo "Shutting down server..."
|
echo "Shutting down server..."
|
||||||
"$client" --shutdown "$tcp" 2>/dev/null > /dev/null
|
"$client" --shutdown "$tcp" 2>/dev/null > /dev/null
|
||||||
|
|
||||||
|
waitShutdown
|
||||||
|
|
||||||
# Report
|
# Report
|
||||||
if [[ $fail_count -eq 0 ]]; then
|
if [[ $fail_count -eq 0 ]]; then
|
||||||
echo -e "${GREEN}${pass_count} tests passed and ${fail_count} failed.${NORMAL}"
|
echo -e "${GREEN}${pass_count} tests passed and ${fail_count} failed.${NORMAL}"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue