From 0d0d48d9f62fce28663c2603c29f6709a3bb0214 Mon Sep 17 00:00:00 2001 From: James Shubin Date: Fri, 22 Feb 2019 06:15:10 -0500 Subject: [PATCH] test: Shell tests should use unified timeout command --- test/shell/augeas-1.sh | 4 +++- test/shell/clustersize.sh | 14 +++++++------- test/shell/env0.sh | 6 +++--- test/shell/etcd-three-hosts.sh | 8 +++++--- test/shell/etcd-two-hosts.sh | 6 ++++-- test/shell/exchange.sh | 12 ++++++------ test/shell/exec-fail.sh | 5 ++++- test/shell/exec-usergroup.sh | 4 +++- test/shell/file-mode.sh | 6 +++--- test/shell/file-move-upper-dir.sh | 4 +++- test/shell/file-move.sh | 4 +++- test/shell/file-owner.sh | 4 +++- test/shell/file-source.sh | 4 +++- test/shell/graph-exit1.sh | 4 +++- test/shell/graph-exit2.sh | 4 +++- test/shell/graph-fanin-1.sh | 4 +++- test/shell/ipv6-localhost.sh | 6 +++--- test/shell/libmgmt-change1.sh | 4 +++- test/shell/libmgmt-change2.sh | 4 +++- test/shell/load0.sh | 6 +++--- test/shell/net.sh | 6 ++++-- test/shell/no-network.sh | 6 +++--- test/shell/prometheus-1.sh | 4 +++- test/shell/prometheus-2.sh | 4 +++- test/shell/prometheus-3.sh | 4 +++- test/shell/prometheus-4.sh | 4 +++- test/shell/sema-1.sh | 4 +++- test/shell/sema-2.sh | 4 +++- test/shell/t1.sh | 4 +++- test/shell/t2.sh | 4 +++- test/shell/t3.sh | 8 +++++--- test/shell/t5.sh | 4 +++- test/shell/t5b.sh | 4 +++- test/shell/t6.sh | 4 +++- test/shell/t7.sh | 4 +++- test/shell/yaml-change1.sh | 4 +++- test/util.sh | 2 ++ 37 files changed, 124 insertions(+), 63 deletions(-) diff --git a/test/shell/augeas-1.sh b/test/shell/augeas-1.sh index 7294cdcf..fde2108c 100755 --- a/test/shell/augeas-1.sh +++ b/test/shell/augeas-1.sh @@ -1,9 +1,11 @@ #!/bin/bash -e +. "$(dirname "$0")/../util.sh" + mkdir -p "${MGMT_TMPDIR}" echo > "${MGMT_TMPDIR}"sshd_config -$timeout --kill-after=360s 300s "$MGMT" run --tmp-prefix yaml --yaml=augeas-1.yaml & +$TIMEOUT "$MGMT" run --tmp-prefix yaml --yaml=augeas-1.yaml & pid=$! # kill server on error diff --git a/test/shell/clustersize.sh b/test/shell/clustersize.sh index c239941c..3d7cd50e 100755 --- a/test/shell/clustersize.sh +++ b/test/shell/clustersize.sh @@ -1,5 +1,7 @@ #!/bin/bash +. "$(dirname "$0")/../util.sh" + set -o errexit set -o pipefail @@ -8,24 +10,22 @@ if ! command -v etcdctl >/dev/null; then exit 0 fi -. "$(dirname "$0")/../util.sh" - mkdir /tmp/mgmt/{A..E} # kill servers on error/exit trap 'pkill -9 mgmt' EXIT -"$MGMT" run --hostname h1 --tmp-prefix --no-pgp empty & -"$MGMT" run --hostname h2 --tmp-prefix --no-pgp --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2381 --server-urls http://127.0.0.1:2382 empty & -"$MGMT" run --hostname h3 --tmp-prefix --no-pgp --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2383 --server-urls http://127.0.0.1:2384 empty & +$TIMEOUT "$MGMT" run --hostname h1 --tmp-prefix --no-pgp empty & +$TIMEOUT "$MGMT" run --hostname h2 --tmp-prefix --no-pgp --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2381 --server-urls http://127.0.0.1:2382 empty & +$TIMEOUT "$MGMT" run --hostname h3 --tmp-prefix --no-pgp --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2383 --server-urls http://127.0.0.1:2384 empty & # wait for everything to converge sleep 30s ETCDCTL_API=3 etcdctl --endpoints 127.0.0.1:2379 put /_mgmt/idealClusterSize 3 -"$MGMT" run --hostname h4 --tmp-prefix --no-pgp --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2385 --server-urls http://127.0.0.1:2386 empty & -"$MGMT" run --hostname h5 --tmp-prefix --no-pgp --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2387 --server-urls http://127.0.0.1:2388 empty & +$TIMEOUT "$MGMT" run --hostname h4 --tmp-prefix --no-pgp --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2385 --server-urls http://127.0.0.1:2386 empty & +$TIMEOUT "$MGMT" run --hostname h5 --tmp-prefix --no-pgp --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2387 --server-urls http://127.0.0.1:2388 empty & # wait for everything to converge sleep 30s diff --git a/test/shell/env0.sh b/test/shell/env0.sh index 4793650d..f10370ee 100755 --- a/test/shell/env0.sh +++ b/test/shell/env0.sh @@ -1,10 +1,10 @@ #!/bin/bash -e +. "$(dirname "$0")/../util.sh" + set -o errexit set -o pipefail -. ../util.sh - # these values represent environment variable values below or defaults set in test/shell/env0.mcl regex="123,,:123,321,:true,false:123" @@ -14,7 +14,7 @@ if [[ ! "$tmpdir" =~ "/tmp" ]]; then exit 99 fi -env TMPDIR="${tmpdir}" TEST=123 EMPTY="" $timeout --kill-after=360s 300s "$MGMT" run --tmp-prefix --converged-timeout=5 lang --lang env0.mcl +env TMPDIR="${tmpdir}" TEST=123 EMPTY="" $TIMEOUT "$MGMT" run --tmp-prefix --converged-timeout=5 lang --lang env0.mcl e=$? egrep "$regex" "$tmpdir/environ" || fail_test "Could not match '$(cat "$tmpdir/environ")' in '$tmpdir/environ' to '$regex'." diff --git a/test/shell/etcd-three-hosts.sh b/test/shell/etcd-three-hosts.sh index 242fd3fe..b3f6ddb6 100755 --- a/test/shell/etcd-three-hosts.sh +++ b/test/shell/etcd-three-hosts.sh @@ -1,15 +1,17 @@ #!/bin/bash -e +. "$(dirname "$0")/../util.sh" + # run empty graphs, we're just testing etcd clustering -$timeout --kill-after=360s 300s "$MGMT" run --hostname h1 --tmp-prefix empty & +$TIMEOUT "$MGMT" run --hostname h1 --tmp-prefix empty & pid1=$! sleep 15s # let it startup -$timeout --kill-after=360s 300s "$MGMT" run --hostname h2 --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2381 --server-urls http://127.0.0.1:2382 --tmp-prefix empty & +$TIMEOUT "$MGMT" run --hostname h2 --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2381 --server-urls http://127.0.0.1:2382 --tmp-prefix empty & pid2=$! sleep 15s -$timeout --kill-after=360s 300s "$MGMT" run --hostname h3 --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2383 --server-urls http://127.0.0.1:2384 --tmp-prefix empty & +$TIMEOUT "$MGMT" run --hostname h3 --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2383 --server-urls http://127.0.0.1:2384 --tmp-prefix empty & pid3=$! sleep 15s diff --git a/test/shell/etcd-two-hosts.sh b/test/shell/etcd-two-hosts.sh index 04b7bcce..3dcb2038 100755 --- a/test/shell/etcd-two-hosts.sh +++ b/test/shell/etcd-two-hosts.sh @@ -1,11 +1,13 @@ #!/bin/bash -e +. "$(dirname "$0")/../util.sh" + # run empty graphs, we're just testing etcd clustering -$timeout --kill-after=360s 300s "$MGMT" run --hostname h1 --tmp-prefix empty & +$TIMEOUT "$MGMT" run --hostname h1 --tmp-prefix empty & pid1=$! sleep 15s # let it startup -$timeout --kill-after=360s 300s "$MGMT" run --hostname h2 --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2381 --server-urls http://127.0.0.1:2382 --tmp-prefix empty & +$TIMEOUT "$MGMT" run --hostname h2 --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2381 --server-urls http://127.0.0.1:2382 --tmp-prefix empty & pid2=$! sleep 15s diff --git a/test/shell/exchange.sh b/test/shell/exchange.sh index cab3bc95..3ac9a951 100755 --- a/test/shell/exchange.sh +++ b/test/shell/exchange.sh @@ -1,14 +1,14 @@ #!/bin/bash +. "$(dirname "$0")/../util.sh" + set -o errexit set -o pipefail -. "$(dirname "$0")/../util.sh" - -"$MGMT" run --hostname h1 --ideal-cluster-size 1 --tmp-prefix --no-pgp lang --lang exchange0.mcl & -"$MGMT" run --hostname h2 --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2381 --server-urls http://127.0.0.1:2382 --tmp-prefix --no-pgp lang --lang exchange0.mcl & -"$MGMT" run --hostname h3 --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2383 --server-urls http://127.0.0.1:2384 --tmp-prefix --no-pgp lang --lang exchange0.mcl & -"$MGMT" run --hostname h4 --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2385 --server-urls http://127.0.0.1:2386 --tmp-prefix --no-pgp lang --lang exchange0.mcl & +$TIMEOUT "$MGMT" run --hostname h1 --ideal-cluster-size 1 --tmp-prefix --no-pgp lang --lang exchange0.mcl & +$TIMEOUT "$MGMT" run --hostname h2 --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2381 --server-urls http://127.0.0.1:2382 --tmp-prefix --no-pgp lang --lang exchange0.mcl & +$TIMEOUT "$MGMT" run --hostname h3 --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2383 --server-urls http://127.0.0.1:2384 --tmp-prefix --no-pgp lang --lang exchange0.mcl & +$TIMEOUT "$MGMT" run --hostname h4 --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2385 --server-urls http://127.0.0.1:2386 --tmp-prefix --no-pgp lang --lang exchange0.mcl & # kill servers on error/exit trap 'pkill -9 mgmt' EXIT diff --git a/test/shell/exec-fail.sh b/test/shell/exec-fail.sh index 4fd12852..3a2b019b 100755 --- a/test/shell/exec-fail.sh +++ b/test/shell/exec-fail.sh @@ -1,9 +1,12 @@ #!/bin/bash -e +. "$(dirname "$0")/../util.sh" + # should take a few seconds plus converged timeout, and test we don't hang! # TODO: should we return a different exit code if the resources fail? # TODO: should we be converged if one of the resources has permanently failed? -$timeout --kill-after=360s 300s "$MGMT" run --converged-timeout=15 --no-watch --no-pgp --tmp-prefix yaml --yaml exec-fail.yaml & +$TIMEOUT "$MGMT" run --converged-timeout=15 --no-watch --no-pgp --tmp-prefix yaml --yaml exec-fail.yaml & + pid=$! wait $pid # get exit status exit $? diff --git a/test/shell/exec-usergroup.sh b/test/shell/exec-usergroup.sh index 14a2440e..dd17f448 100755 --- a/test/shell/exec-usergroup.sh +++ b/test/shell/exec-usergroup.sh @@ -1,5 +1,7 @@ #!/bin/bash +. "$(dirname "$0")/../util.sh" + set -x set -o pipefail @@ -38,7 +40,7 @@ function run_usergroup_test() { setup # run till completion - sudo -A timeout --kill-after=360s 300s "$MGMT" run --converged-timeout=15 --no-watch --tmp-prefix yaml --yaml ./exec-usergroup/${graph} & + sudo -A $TIMEOUT "$MGMT" run --converged-timeout=15 --no-watch --tmp-prefix yaml --yaml ./exec-usergroup/${graph} & pid=$! wait $pid # get exit status e=$? diff --git a/test/shell/file-mode.sh b/test/shell/file-mode.sh index b0d0f066..010b13e5 100755 --- a/test/shell/file-mode.sh +++ b/test/shell/file-mode.sh @@ -1,11 +1,11 @@ #!/bin/bash -e +. "$(dirname "$0")/../util.sh" + set -x -. ../util.sh - # run till completion -$timeout --kill-after=360s 300s "$MGMT" run --converged-timeout=5 --no-watch --tmp-prefix yaml --yaml file-mode.yaml & +$TIMEOUT "$MGMT" run --converged-timeout=5 --no-watch --tmp-prefix yaml --yaml file-mode.yaml & pid=$! wait $pid # get exit status e=$? diff --git a/test/shell/file-move-upper-dir.sh b/test/shell/file-move-upper-dir.sh index a495ea4f..7de580c4 100755 --- a/test/shell/file-move-upper-dir.sh +++ b/test/shell/file-move-upper-dir.sh @@ -4,10 +4,12 @@ exit 0 +. "$(dirname "$0")/../util.sh" + mkdir -p /tmp/mgmt/a/b/c/ # run empty graph, with prometheus support -$timeout --kill-after=360s 300s "$MGMT" run --tmp-prefix yaml --yaml=examples/deep-dirs.yaml & +$TIMEOUT "$MGMT" run --tmp-prefix yaml --yaml=examples/deep-dirs.yaml & pid=$! sleep 10s # let it converge diff --git a/test/shell/file-move.sh b/test/shell/file-move.sh index 62879ec6..a90b73c5 100755 --- a/test/shell/file-move.sh +++ b/test/shell/file-move.sh @@ -1,10 +1,12 @@ #!/bin/bash -e +. "$(dirname "$0")/../util.sh" + mkdir -p /tmp/mgmt/ rm /tmp/mgmt/f1 &>/dev/null || true # run empty graph, with prometheus support -$timeout --kill-after=360s 300s "$MGMT" run --tmp-prefix yaml --yaml=file-move.yaml 2>&1 | tee /tmp/mgmt/file-move.log & +$TIMEOUT "$MGMT" run --tmp-prefix yaml --yaml=file-move.yaml 2>&1 | tee /tmp/mgmt/file-move.log & pid=$! sleep 5s # let it converge diff --git a/test/shell/file-owner.sh b/test/shell/file-owner.sh index a6825bb9..37e68aa2 100755 --- a/test/shell/file-owner.sh +++ b/test/shell/file-owner.sh @@ -1,6 +1,8 @@ #!/bin/bash -e # vim: noet:ts=8:sts=8:sw=8 +. "$(dirname "$0")/../util.sh" + set -x if ! timeout 1s sudo -A true; then @@ -9,7 +11,7 @@ if ! timeout 1s sudo -A true; then fi # run till completion -$timeout --kill-after=360s 300s sudo -A "$MGMT" run --converged-timeout=5 --no-watch --tmp-prefix yaml --yaml file-owner.yaml & +$TIMEOUT sudo -A "$MGMT" run --converged-timeout=5 --no-watch --tmp-prefix yaml --yaml file-owner.yaml & pid=$! wait $pid # get exit status e=$? diff --git a/test/shell/file-source.sh b/test/shell/file-source.sh index 71b1825b..95862231 100755 --- a/test/shell/file-source.sh +++ b/test/shell/file-source.sh @@ -1,6 +1,8 @@ #!/bin/bash -e # vim: noet:ts=8:sts=8:sw=8 +. "$(dirname "$0")/../util.sh" + set -x if ! timeout 1s sudo -A true; then @@ -9,7 +11,7 @@ if ! timeout 1s sudo -A true; then fi # run till completion -$timeout --kill-after=360s 300s sudo -A "$MGMT" run --converged-timeout=5 --no-watch --tmp-prefix lang --lang file-source.mcl & +$TIMEOUT sudo -A "$MGMT" run --converged-timeout=5 --no-watch --tmp-prefix lang --lang file-source.mcl & pid=$! wait $pid # get exit status e=$? diff --git a/test/shell/graph-exit1.sh b/test/shell/graph-exit1.sh index 785a1f8e..26979ee5 100755 --- a/test/shell/graph-exit1.sh +++ b/test/shell/graph-exit1.sh @@ -1,9 +1,11 @@ #!/bin/bash -e +. "$(dirname "$0")/../util.sh" + # should take 15 seconds for longest resources plus startup time to shutdown # we don't want the ^C to allow the rest of the graph to continue executing! # this is a test of mgmt exiting quickly via a fast pause after it sees a ^C -$timeout --kill-after=60s 55s "$MGMT" run --no-watch --no-pgp --tmp-prefix yaml --yaml graph-exit1.yaml & +$TIMEOUT "$MGMT" run --no-watch --no-pgp --tmp-prefix yaml --yaml graph-exit1.yaml & pid=$! sleep 5s # let the initial resources start to run... killall -SIGINT mgmt # send ^C to exit mgmt diff --git a/test/shell/graph-exit2.sh b/test/shell/graph-exit2.sh index a72ddb60..04293f13 100755 --- a/test/shell/graph-exit2.sh +++ b/test/shell/graph-exit2.sh @@ -1,8 +1,10 @@ #!/bin/bash -e +. "$(dirname "$0")/../util.sh" + # should take 15 seconds for longest resources plus startup time to shutdown # we don't want the ^C to allow the rest of the graph to continue executing! -$timeout --kill-after=65s 55s "$MGMT" run --no-watch --no-pgp --tmp-prefix yaml --yaml graph-exit2.yaml & +$TIMEOUT "$MGMT" run --no-watch --no-pgp --tmp-prefix yaml --yaml graph-exit2.yaml & pid=$! sleep 10s # let the initial resources start to run... killall -SIGINT mgmt # send ^C to exit mgmt diff --git a/test/shell/graph-fanin-1.sh b/test/shell/graph-fanin-1.sh index 22c44a0b..86be03ea 100755 --- a/test/shell/graph-fanin-1.sh +++ b/test/shell/graph-fanin-1.sh @@ -1,7 +1,9 @@ #!/bin/bash -e +. "$(dirname "$0")/../util.sh" + # should take more than 25s plus overhead -$timeout --kill-after=360s 300s "$MGMT" run --converged-timeout=5 --no-watch --tmp-prefix --no-pgp yaml --yaml graph-fanin-1.yaml & +$TIMEOUT "$MGMT" run --converged-timeout=5 --no-watch --tmp-prefix --no-pgp yaml --yaml graph-fanin-1.yaml & pid=$! wait $pid # get exit status exit $? diff --git a/test/shell/ipv6-localhost.sh b/test/shell/ipv6-localhost.sh index 9195ecec..daff5b9c 100755 --- a/test/shell/ipv6-localhost.sh +++ b/test/shell/ipv6-localhost.sh @@ -1,5 +1,7 @@ #!/bin/bash +. "$(dirname "$0")/../util.sh" + set -o errexit set -o pipefail @@ -8,12 +10,10 @@ if ! ifconfig lo | grep 'inet6 ::1' >/dev/null; then exit 0 fi -. "$(dirname "$0")/../util.sh" - tmpdir="$($mktemp --tmpdir -d tmp.XXX)" # run empty graph listing only to IPv6 addresses -"$MGMT" run --client-urls "http://[::1]:2379" --server-urls "http://[::1]:2380" --tmp-prefix empty & +$TIMEOUT "$MGMT" run --client-urls "http://[::1]:2379" --server-urls "http://[::1]:2380" --tmp-prefix empty & pid=$! # kill server on error/exit diff --git a/test/shell/libmgmt-change1.sh b/test/shell/libmgmt-change1.sh index a5fdd90a..9eb15299 100755 --- a/test/shell/libmgmt-change1.sh +++ b/test/shell/libmgmt-change1.sh @@ -1,11 +1,13 @@ #!/bin/bash -e +. "$(dirname "$0")/../util.sh" + # XXX: this has not been updated to latest GAPI/Deploy API. Patches welcome! exit 0 go build -i -o libmgmt libmgmt-change1.go # this example should change graphs frequently, and then shutdown... -$timeout --kill-after=30s 20s ./libmgmt & +$TIMEOUT ./libmgmt & pid=$! wait $pid # get exit status e=$? diff --git a/test/shell/libmgmt-change2.sh b/test/shell/libmgmt-change2.sh index 58d9f5b2..0554d412 100755 --- a/test/shell/libmgmt-change2.sh +++ b/test/shell/libmgmt-change2.sh @@ -1,11 +1,13 @@ #!/bin/bash -e +. "$(dirname "$0")/../util.sh" + # XXX: this has not been updated to latest GAPI/Deploy API. Patches welcome! exit 0 go build -i -o libmgmt libmgmt-change2.go # this example should change graphs frequently, and then shutdown... -$timeout --kill-after=30s 20s ./libmgmt & +$TIMEOUT ./libmgmt & pid=$! wait $pid # get exit status e=$? diff --git a/test/shell/load0.sh b/test/shell/load0.sh index e104eb25..08541081 100755 --- a/test/shell/load0.sh +++ b/test/shell/load0.sh @@ -1,12 +1,12 @@ #!/bin/bash -e +. "$(dirname "$0")/../util.sh" + # TODO: do loadavg calls work properly on macOS in travis? set -o errexit set -o pipefail -. ../util.sh - # Expected load average values eg: load average: 1.64306640625, 1.8076171875, 1.82958984375 # High precision results are preferred (more than the 2 digits in /proc/loadavg at least). # Precision varies (eg: 4, 9 or 11 digits). Hence no strict check for precision but @@ -36,7 +36,7 @@ file "${tmpdir}/loadavg" { } EOF -$timeout --kill-after=360s 300s "$MGMT" run --tmp-prefix --converged-timeout=5 lang --lang "$tmpdir/load0.mcl" & +$TIMEOUT "$MGMT" run --tmp-prefix --converged-timeout=5 lang --lang "$tmpdir/load0.mcl" & pid=$! wait $pid # get exit status e=$? diff --git a/test/shell/net.sh b/test/shell/net.sh index f20162c6..f22f9ece 100755 --- a/test/shell/net.sh +++ b/test/shell/net.sh @@ -1,5 +1,7 @@ #!/bin/bash -e +. "$(dirname "$0")/../util.sh" + set -x set -o pipefail @@ -44,7 +46,7 @@ sudo mkdir -p /etc/systemd/network sudo ip link add $IFACE type dummy || true # run mgmt net res with $IFACE and $ADDR set as above -sudo -A $timeout --kill-after=360s 300s "$MGMT" run --converged-timeout=5 --tmp-prefix lang --lang ./net0.mcl & +sudo -A $TIMEOUT "$MGMT" run --converged-timeout=5 --tmp-prefix lang --lang ./net0.mcl & pid1=$! # give the engine time to start up @@ -85,7 +87,7 @@ wait $pid1 e1=$? # run mgmt net res with $IFACE state => "down" -sudo -A $timeout --kill-after=360s 300s "$MGMT" run --converged-timeout=5 --tmp-prefix lang --lang ./net1.mcl & +sudo -A $TIMEOUT "$MGMT" run --converged-timeout=5 --tmp-prefix lang --lang ./net1.mcl & # give the engine time to start up sleep 5 diff --git a/test/shell/no-network.sh b/test/shell/no-network.sh index 180d7be7..dea6f582 100755 --- a/test/shell/no-network.sh +++ b/test/shell/no-network.sh @@ -1,15 +1,15 @@ #!/bin/bash +. "$(dirname "$0")/../util.sh" + # Tests the behaviour of the --no-network set -o errexit set -o pipefail -. "$(dirname "$0")/../util.sh" - tmpdir="$($mktemp --tmpdir -d tmp.XXX)" # run empty graph, with standalone enabled -"$MGMT" run --no-network --prefix "$tmpdir" empty & +$TIMEOUT "$MGMT" run --no-network --prefix "$tmpdir" empty & pid=$! # kill server on error/exit diff --git a/test/shell/prometheus-1.sh b/test/shell/prometheus-1.sh index 79330ea4..d20ea927 100755 --- a/test/shell/prometheus-1.sh +++ b/test/shell/prometheus-1.sh @@ -1,7 +1,9 @@ #!/bin/bash -e +. "$(dirname "$0")/../util.sh" + # run empty graph, with prometheus support -$timeout --kill-after=360s 300s "$MGMT" run --tmp-prefix --prometheus empty & +$TIMEOUT "$MGMT" run --tmp-prefix --prometheus empty & pid=$! sleep 5s # let it converge diff --git a/test/shell/prometheus-2.sh b/test/shell/prometheus-2.sh index fc7dd2ff..989c60e8 100755 --- a/test/shell/prometheus-2.sh +++ b/test/shell/prometheus-2.sh @@ -1,7 +1,9 @@ #!/bin/bash -e +. "$(dirname "$0")/../util.sh" + # run empty graph, with prometheus support -$timeout --kill-after=360s 300s "$MGMT" run --tmp-prefix --prometheus --prometheus-listen :52637 empty & +$TIMEOUT "$MGMT" run --tmp-prefix --prometheus --prometheus-listen :52637 empty & pid=$! sleep 5s # let it converge diff --git a/test/shell/prometheus-3.sh b/test/shell/prometheus-3.sh index d538b886..9ea16fc8 100755 --- a/test/shell/prometheus-3.sh +++ b/test/shell/prometheus-3.sh @@ -1,9 +1,11 @@ #!/bin/bash -e +. "$(dirname "$0")/../util.sh" + exit 0 # XXX: temporarily disabled until prometheus is added back post refactor # run a graph, with prometheus support -$timeout --kill-after=360s 300s "$MGMT" run --tmp-prefix --no-pgp --prometheus yaml --yaml prometheus-3.yaml & +$TIMEOUT "$MGMT" run --tmp-prefix --no-pgp --prometheus yaml --yaml prometheus-3.yaml & pid=$! sleep 10s # let it converge diff --git a/test/shell/prometheus-4.sh b/test/shell/prometheus-4.sh index 4a3ea3c4..5d3df310 100755 --- a/test/shell/prometheus-4.sh +++ b/test/shell/prometheus-4.sh @@ -1,9 +1,11 @@ #!/bin/bash -xe +. "$(dirname "$0")/../util.sh" + exit 0 # XXX: temporarily disabled until prometheus is added back post refactor # run a graph, with prometheus support -$timeout --kill-after=360s 300s "$MGMT" run --tmp-prefix --no-pgp --prometheus yaml --yaml prometheus-4.yaml & +$TIMEOUT "$MGMT" run --tmp-prefix --no-pgp --prometheus yaml --yaml prometheus-4.yaml & pid=$! sleep 15s # let it converge diff --git a/test/shell/sema-1.sh b/test/shell/sema-1.sh index 835439bd..14d01e1b 100755 --- a/test/shell/sema-1.sh +++ b/test/shell/sema-1.sh @@ -1,8 +1,10 @@ #!/bin/bash -e +. "$(dirname "$0")/../util.sh" + # should take at least 55s, but fail if we block this # TODO: it would be nice to make sure this test doesn't exit too early! -$timeout --kill-after=360s 300s "$MGMT" run --sema 2 --converged-timeout=5 --no-watch --no-pgp --tmp-prefix yaml --yaml sema-1.yaml & +$TIMEOUT "$MGMT" run --sema 2 --converged-timeout=5 --no-watch --no-pgp --tmp-prefix yaml --yaml sema-1.yaml & pid=$! wait $pid # get exit status exit $? diff --git a/test/shell/sema-2.sh b/test/shell/sema-2.sh index 2a54a7ce..79275042 100755 --- a/test/shell/sema-2.sh +++ b/test/shell/sema-2.sh @@ -1,8 +1,10 @@ #!/bin/bash -e +. "$(dirname "$0")/../util.sh" + # should take at least 55s, but fail if we block this # TODO: it would be nice to make sure this test doesn't exit too early! -$timeout --kill-after=360s 300s "$MGMT" run --converged-timeout=5 --no-watch --no-pgp --tmp-prefix lang --lang sema-2.mcl & +$TIMEOUT "$MGMT" run --converged-timeout=5 --no-watch --no-pgp --tmp-prefix lang --lang sema-2.mcl & pid=$! wait $pid # get exit status exit $? diff --git a/test/shell/t1.sh b/test/shell/t1.sh index 4464a6da..de005634 100755 --- a/test/shell/t1.sh +++ b/test/shell/t1.sh @@ -6,10 +6,12 @@ # * it is recommended that you run mgmt --converged-timeout= # * you can run mgmt with --max-runtime= in special scenarios +. "$(dirname "$0")/../util.sh" + set -o errexit set -o pipefail -$timeout --kill-after=360s 300s "$MGMT" --help # hello world! +$TIMEOUT "$MGMT" --help # hello world! pid=$! wait $pid # get exit status exit $? diff --git a/test/shell/t2.sh b/test/shell/t2.sh index c7641f0f..a0cd3327 100755 --- a/test/shell/t2.sh +++ b/test/shell/t2.sh @@ -1,7 +1,9 @@ #!/bin/bash -e +. "$(dirname "$0")/../util.sh" + # run till completion -$timeout --kill-after=360s 300s "$MGMT" run --converged-timeout=5 --no-watch --tmp-prefix yaml --yaml t2.yaml & +$TIMEOUT "$MGMT" run --converged-timeout=5 --no-watch --tmp-prefix yaml --yaml t2.yaml & pid=$! wait $pid # get exit status e=$? diff --git a/test/shell/t3.sh b/test/shell/t3.sh index 41c3db66..25b34041 100755 --- a/test/shell/t3.sh +++ b/test/shell/t3.sh @@ -1,5 +1,7 @@ #!/bin/bash -e +. "$(dirname "$0")/../util.sh" + if env | grep -q -e '^TRAVIS=true$'; then # inotify doesn't seem to work properly on travis echo "Travis and Jenkins give wonky results here, skipping test!" @@ -10,11 +12,11 @@ fi mkdir -p "${MGMT_TMPDIR}"mgmt{A..C} # run till completion -$timeout --kill-after=360s 300s "$MGMT" run --converged-timeout=5 --no-watch --tmp-prefix yaml --yaml t3-a.yaml & +$TIMEOUT "$MGMT" run --converged-timeout=5 --no-watch --tmp-prefix yaml --yaml t3-a.yaml & pid1=$! -$timeout --kill-after=360s 300s "$MGMT" run --converged-timeout=5 --no-watch --tmp-prefix yaml --yaml t3-b.yaml & +$TIMEOUT "$MGMT" run --converged-timeout=5 --no-watch --tmp-prefix yaml --yaml t3-b.yaml & pid2=$! -$timeout --kill-after=360s 300s "$MGMT" run --converged-timeout=5 --no-watch --tmp-prefix yaml --yaml t3-c.yaml & +$TIMEOUT "$MGMT" run --converged-timeout=5 --no-watch --tmp-prefix yaml --yaml t3-c.yaml & pid3=$! wait $pid1 # get exit status diff --git a/test/shell/t5.sh b/test/shell/t5.sh index 335ecd05..a789eb91 100755 --- a/test/shell/t5.sh +++ b/test/shell/t5.sh @@ -1,7 +1,9 @@ #!/bin/bash -e +. "$(dirname "$0")/../util.sh" + # should take slightly more than 35s, but fail if we take much longer) -$timeout --kill-after=360s 300s "$MGMT" run --converged-timeout=5 --no-watch --no-pgp --tmp-prefix yaml --yaml t5.yaml & +$TIMEOUT "$MGMT" run --converged-timeout=5 --no-watch --no-pgp --tmp-prefix yaml --yaml t5.yaml & pid=$! wait $pid # get exit status exit $? diff --git a/test/shell/t5b.sh b/test/shell/t5b.sh index 4f859786..286b8cac 100755 --- a/test/shell/t5b.sh +++ b/test/shell/t5b.sh @@ -1,7 +1,9 @@ #!/bin/bash -e +. "$(dirname "$0")/../util.sh" + # should take slightly more than 35s, but fail if we take much longer) -$timeout --kill-after=360s 300s "$MGMT" run --converged-timeout=5 --no-watch --no-pgp --tmp-prefix yaml --yaml t5b.yaml & +$TIMEOUT "$MGMT" run --converged-timeout=5 --no-watch --no-pgp --tmp-prefix yaml --yaml t5b.yaml & pid=$! wait $pid # get exit status exit $? diff --git a/test/shell/t6.sh b/test/shell/t6.sh index 933b2c36..acbefc16 100755 --- a/test/shell/t6.sh +++ b/test/shell/t6.sh @@ -1,7 +1,9 @@ #!/bin/bash -e +. "$(dirname "$0")/../util.sh" + # run till completion -$timeout --kill-after=360s 300s "$MGMT" run --no-watch --tmp-prefix yaml --yaml t6.yaml & +$TIMEOUT "$MGMT" run --no-watch --tmp-prefix yaml --yaml t6.yaml & pid=$! sleep 10s # let it converge test -e /tmp/mgmt/f1 diff --git a/test/shell/t7.sh b/test/shell/t7.sh index 1877fe08..df8fa73f 100755 --- a/test/shell/t7.sh +++ b/test/shell/t7.sh @@ -1,7 +1,9 @@ #!/bin/bash -e +. "$(dirname "$0")/../util.sh" + # run empty graph -$timeout --kill-after=360s 300s "$MGMT" run --tmp-prefix --no-pgp empty & +$TIMEOUT "$MGMT" run --tmp-prefix --no-pgp empty & pid=$! sleep 10s # let it converge $(sleep 3s && killall -SIGINT mgmt)& # send ^C to exit mgmt diff --git a/test/shell/yaml-change1.sh b/test/shell/yaml-change1.sh index 1699761f..63d5f833 100755 --- a/test/shell/yaml-change1.sh +++ b/test/shell/yaml-change1.sh @@ -1,5 +1,7 @@ #!/bin/bash -e +. "$(dirname "$0")/../util.sh" + exit 0 # TODO: this test needs to be update to use deploys instead #if env | grep -q -e '^TRAVIS=true$'; then @@ -14,7 +16,7 @@ fi # set the config file cp -a yaml-change1a.yaml /tmp/mgmt/yaml-change.yaml -$timeout --kill-after=360s 300s "$MGMT" run --tmp-prefix yaml --yaml /tmp/mgmt/yaml-change.yaml & +$TIMEOUT "$MGMT" run --tmp-prefix yaml --yaml /tmp/mgmt/yaml-change.yaml & pid=$! sleep 5s # let it converge grep -q 'hello world' /tmp/mgmt/change1 # check contents are correct diff --git a/test/util.sh b/test/util.sh index ec815515..e4613172 100755 --- a/test/util.sh +++ b/test/util.sh @@ -18,6 +18,8 @@ else export STAT="stat" fi +TIMEOUT="$timeout --kill-after=360s --signal=QUIT 300s" + fail_test() { echo -e "FAIL: $@"