A system test to exercise the rpc stop command (#4573)
Introduce a systest case for rpc stop command
This commit is contained in:
parent
401d61c24c
commit
274c6714ca
2 changed files with 23 additions and 0 deletions
|
|
@ -50,6 +50,7 @@ void nano::rpc::start ()
|
||||||
logger.critical (nano::log::type::rpc, "Error while binding for RPC on port: {} ({})", endpoint.port (), ec.message ());
|
logger.critical (nano::log::type::rpc, "Error while binding for RPC on port: {} ({})", endpoint.port (), ec.message ());
|
||||||
throw std::runtime_error (ec.message ());
|
throw std::runtime_error (ec.message ());
|
||||||
}
|
}
|
||||||
|
logger.info (nano::log::type::rpc, "RPC listening address: {}", fmt::streamed (acceptor.local_endpoint ()));
|
||||||
acceptor.listen ();
|
acceptor.listen ();
|
||||||
accept ();
|
accept ();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
22
systest/rpc_stop.sh
Executable file
22
systest/rpc_stop.sh
Executable file
|
|
@ -0,0 +1,22 @@
|
||||||
|
#!/bin/bash
|
||||||
|
set -eux
|
||||||
|
|
||||||
|
DATADIR=$(mktemp -d)
|
||||||
|
|
||||||
|
# Start the node in daemon mode in the background
|
||||||
|
$NANO_NODE_EXE --daemon --network dev --data_path $DATADIR --config rpc.enable=true --rpcconfig enable_control=true &
|
||||||
|
NODE_PID=$!
|
||||||
|
|
||||||
|
# Allow some time for the node to start up completely
|
||||||
|
sleep 10
|
||||||
|
|
||||||
|
# Send the stop rpc command
|
||||||
|
curl -g -d '{ "action": "stop" }' '[::1]:45000'
|
||||||
|
|
||||||
|
# Check if the process has stopped using a timeout to avoid infinite waiting
|
||||||
|
if wait $NODE_PID; then
|
||||||
|
echo "Node stopped successfully"
|
||||||
|
else
|
||||||
|
echo "Node did not stop as expected"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
Loading…
Add table
Add a link
Reference in a new issue