From 784c5e3d73b6148de6fe6fc6954534838fcc50e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C8=98tefan=20Talpalaru?= Date: Thu, 30 Apr 2020 15:59:57 +0200 Subject: [PATCH] Jenkins: add timeouts to testnet finalisation tests (#947) * Jenkins: add timeouts to testnet finalisation tests - add nicer child process management to "launch_local_testnet.sh" - correct a comment in "start.sh" * the Jenkins worker's version of "timeout" doesn't support "-v" --- Jenkinsfile | 4 ++-- scripts/launch_local_testnet.sh | 11 +++++++---- tests/simulation/start.sh | 6 +++--- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 1f90e40a2..1ea500a00 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -31,8 +31,8 @@ def runStages() { } if ("${NODE_NAME}" ==~ /linux.*/) { stage("testnet finalization") { - sh "./scripts/launch_local_testnet.sh --testnet 0 --nodes 4 --log-level INFO --disable-htop -- --verify-finalization --stop-at-epoch=5" - sh "./scripts/launch_local_testnet.sh --testnet 1 --nodes 4 --log-level INFO --disable-htop -- --verify-finalization --stop-at-epoch=5" + sh "timeout -k 20s 10m ./scripts/launch_local_testnet.sh --testnet 0 --nodes 4 --log-level INFO --disable-htop -- --verify-finalization --stop-at-epoch=5" + sh "timeout -k 20s 40m ./scripts/launch_local_testnet.sh --testnet 1 --nodes 4 --log-level INFO --disable-htop -- --verify-finalization --stop-at-epoch=5" } } } diff --git a/scripts/launch_local_testnet.sh b/scripts/launch_local_testnet.sh index 3ed74fd50..3fb1a4c7c 100755 --- a/scripts/launch_local_testnet.sh +++ b/scripts/launch_local_testnet.sh @@ -140,12 +140,15 @@ BOOTSTRAP_IP="127.0.0.1" --bootstrap-port=${BOOTSTRAP_PORT} \ --genesis-offset=5 # Delay in seconds +# 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() { - killall beacon_node &>/dev/null || true + pkill -P $$ beacon_node &>/dev/null || true sleep 2 - killall -9 beacon_node &>/dev/null || true + pkill -9 -P $$ beacon_node &>/dev/null || true } -cleanup +trap 'cleanup' SIGINT SIGTERM EXIT PIDS="" NODES_WITH_VALIDATORS=${NODES_WITH_VALIDATORS:-4} @@ -172,7 +175,7 @@ for NUM_NODE in $(seq 0 $(( ${NUM_NODES} - 1 ))); do done fi - stdbuf -o0 build/beacon_node \ + ./build/beacon_node \ --nat:extip:127.0.0.1 \ --log-level="${LOG_LEVEL}" \ --tcp-port=$(( ${BOOTSTRAP_PORT} + ${NUM_NODE} )) \ diff --git a/tests/simulation/start.sh b/tests/simulation/start.sh index 7d77e22d0..5b81fb739 100755 --- a/tests/simulation/start.sh +++ b/tests/simulation/start.sh @@ -189,9 +189,9 @@ echo Creating grafana dashboards... --in="${SIM_ROOT}/beacon-chain-sim-node0-Grafana-dashboard.json" \ --out="${SIM_ROOT}/beacon-chain-sim-all-nodes-Grafana-dashboard.json" -# Kill child processes on Ctrl-C by sending SIGTERM to the whole process group, -# passing the negative PID of this shell instance to the "kill" command. -# Trap and ignore SIGTERM, so we don't kill this process along with its children. +# 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. if [[ "$USE_MULTITAIL" == "no" && "$USE_TMUX" == "no" ]]; then trap 'pkill -P $$ beacon_node' SIGINT EXIT fi