restapi.sh: cleanup on exit (#3328)
also rename a confusing option/var combo
This commit is contained in:
parent
5dd362fc6e
commit
d5a2c75963
|
@ -49,7 +49,7 @@ def runStages() {
|
||||||
set -e
|
set -e
|
||||||
./tests/simulation/restapi.sh --data-dir resttest0_data --base-port \$(( 9100 + EXECUTOR_NUMBER * 100 )) \
|
./tests/simulation/restapi.sh --data-dir resttest0_data --base-port \$(( 9100 + EXECUTOR_NUMBER * 100 )) \
|
||||||
--base-rest-port \$(( 7100 + EXECUTOR_NUMBER * 100 )) --base-metrics-port \
|
--base-rest-port \$(( 7100 + EXECUTOR_NUMBER * 100 )) --base-metrics-port \
|
||||||
\$(( 8108 + EXECUTOR_NUMBER * 100 )) --sleep-timeout 30 --kill-old-processes
|
\$(( 8108 + EXECUTOR_NUMBER * 100 )) --resttest-delay 30 --kill-old-processes
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ set -e
|
||||||
BASE_PORT="49000"
|
BASE_PORT="49000"
|
||||||
BASE_METRICS_PORT="48008"
|
BASE_METRICS_PORT="48008"
|
||||||
BASE_REST_PORT="47000"
|
BASE_REST_PORT="47000"
|
||||||
TIMEOUT_DURATION="30"
|
RESTTEST_DELAY="30"
|
||||||
TEST_DIRNAME="resttest0_data"
|
TEST_DIRNAME="resttest0_data"
|
||||||
KILL_OLD_PROCESSES="0"
|
KILL_OLD_PROCESSES="0"
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ if [ ${PIPESTATUS[0]} != 4 ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
OPTS="h"
|
OPTS="h"
|
||||||
LONGOPTS="help,data-dir:,base-port:,base-rest-port:,base-metrics-port:,sleep-timeout:,kill-old-processes"
|
LONGOPTS="help,data-dir:,base-port:,base-rest-port:,base-metrics-port:,resttest-delay:,kill-old-processes"
|
||||||
|
|
||||||
print_help() {
|
print_help() {
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
|
@ -39,7 +39,7 @@ Usage: $(basename "$0") [OPTIONS] -- [BEACON NODE OPTIONS]
|
||||||
--base-port bootstrap node's Eth2 traffic port (default: ${BASE_PORT})
|
--base-port bootstrap node's Eth2 traffic port (default: ${BASE_PORT})
|
||||||
--base-rest-port bootstrap node's REST port (default: ${BASE_REST_PORT})
|
--base-rest-port bootstrap node's REST port (default: ${BASE_REST_PORT})
|
||||||
--base-metrics-port bootstrap node's metrics server port (default: ${BASE_METRICS_PORT})
|
--base-metrics-port bootstrap node's metrics server port (default: ${BASE_METRICS_PORT})
|
||||||
--sleep-timeout timeout in seconds (default: ${TIMEOUT_DURATION} seconds)
|
--resttest-delay resttest delay in seconds (default: ${RESTTEST_DELAY} seconds)
|
||||||
--kill-old-processes if any process is found listening on a port we use, kill it (default: disabled)
|
--kill-old-processes if any process is found listening on a port we use, kill it (default: disabled)
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
@ -74,8 +74,8 @@ while true; do
|
||||||
BASE_METRICS_PORT="$2"
|
BASE_METRICS_PORT="$2"
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
--sleep-timeout)
|
--resttest-delay)
|
||||||
TIMEOUT_DURATION="$2"
|
RESTTEST_DELAY="$2"
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
--kill-old-processes)
|
--kill-old-processes)
|
||||||
|
@ -177,6 +177,18 @@ fi
|
||||||
build_if_missing nimbus_beacon_node
|
build_if_missing nimbus_beacon_node
|
||||||
build_if_missing resttest
|
build_if_missing resttest
|
||||||
|
|
||||||
|
# Kill child processes on Ctrl-C/SIGTERM/exit, passing the PID of this shell
|
||||||
|
# instance as the parent and the target process name as a pattern to the
|
||||||
|
# "pkill" command.
|
||||||
|
cleanup() {
|
||||||
|
pkill -f -P $$ nimbus_beacon_node &>/dev/null || true
|
||||||
|
pkill -f -P $$ resttest &>/dev/null || true
|
||||||
|
sleep 2
|
||||||
|
pkill -f -9 -P $$ nimbus_beacon_node &>/dev/null || true
|
||||||
|
pkill -f -9 -P $$ resttest &>/dev/null || true
|
||||||
|
}
|
||||||
|
trap 'cleanup' SIGINT SIGTERM EXIT
|
||||||
|
|
||||||
if [[ ! -f "${SNAPSHOT_FILE}" ]]; then
|
if [[ ! -f "${SNAPSHOT_FILE}" ]]; then
|
||||||
echo "Creating testnet genesis..."
|
echo "Creating testnet genesis..."
|
||||||
${NIMBUS_BEACON_NODE_BIN} \
|
${NIMBUS_BEACON_NODE_BIN} \
|
||||||
|
@ -236,7 +248,7 @@ if [[ ${BEACON_NODE_STATUS} -eq 0 ]]; then
|
||||||
BEACON_NODE_PID="$(jobs -p)"
|
BEACON_NODE_PID="$(jobs -p)"
|
||||||
|
|
||||||
${RESTTEST_BIN} \
|
${RESTTEST_BIN} \
|
||||||
--delay=${TIMEOUT_DURATION} \
|
--delay=${RESTTEST_DELAY} \
|
||||||
--timeout=60 \
|
--timeout=60 \
|
||||||
--skip-topic=slow \
|
--skip-topic=slow \
|
||||||
--connections=4 \
|
--connections=4 \
|
||||||
|
|
Loading…
Reference in New Issue