test: Enable macOS shell testing
* Check and install libvirt with Homebrew
macOS does not have apt, dnf or yum. Add checking for homebrew for
installing libvirt.
* Use platform timeout for tests
* Add timeout detection to test/util.sh
* Use $timeout for shell test requiring timeout
This commit is contained in:
@@ -14,13 +14,14 @@ sudo_command=$(which sudo)
|
|||||||
YUM=`which yum 2>/dev/null`
|
YUM=`which yum 2>/dev/null`
|
||||||
DNF=`which dnf 2>/dev/null`
|
DNF=`which dnf 2>/dev/null`
|
||||||
APT=`which apt-get 2>/dev/null`
|
APT=`which apt-get 2>/dev/null`
|
||||||
|
BREW=`which brew 2>/dev/null`
|
||||||
|
|
||||||
# if DNF is available use it
|
# if DNF is available use it
|
||||||
if [ -x "$DNF" ]; then
|
if [ -x "$DNF" ]; then
|
||||||
YUM=$DNF
|
YUM=$DNF
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$YUM" -a -z "$APT" ]; then
|
if [ -z "$YUM" -a -z "$APT" -a -z "$BREW" ]; then
|
||||||
echo "The package managers can't be found."
|
echo "The package managers can't be found."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@@ -36,6 +37,10 @@ if [ ! -z "$APT" ]; then
|
|||||||
$sudo_command $APT install -y libpcap0.8-dev || true
|
$sudo_command $APT install -y libpcap0.8-dev || true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ ! -z "$BREW" ]; then
|
||||||
|
$BREW install libvirt || true
|
||||||
|
fi
|
||||||
|
|
||||||
if [ $travis -eq 0 ]; then
|
if [ $travis -eq 0 ]; then
|
||||||
if [ ! -z "$YUM" ]; then
|
if [ ! -z "$YUM" ]; then
|
||||||
# some go dependencies are stored in mercurial
|
# some go dependencies are stored in mercurial
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ exit 0
|
|||||||
mkdir -p /tmp/mgmt/a/b/c/
|
mkdir -p /tmp/mgmt/a/b/c/
|
||||||
|
|
||||||
# run empty graph, with prometheus support
|
# run empty graph, with prometheus support
|
||||||
timeout --kill-after=20s 15s ./mgmt run --tmp-prefix --yaml=examples/deep-dirs.yaml &
|
$timeout --kill-after=20s 15s ./mgmt run --tmp-prefix --yaml=examples/deep-dirs.yaml &
|
||||||
pid=$!
|
pid=$!
|
||||||
sleep 5s # let it converge
|
sleep 5s # let it converge
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash -e
|
#!/bin/bash -e
|
||||||
|
|
||||||
# run empty graph, with prometheus support
|
# run empty graph, with prometheus support
|
||||||
timeout --kill-after=20s 15s ./mgmt run --tmp-prefix --prometheus &
|
$timeout --kill-after=20s 15s ./mgmt run --tmp-prefix --prometheus &
|
||||||
pid=$!
|
pid=$!
|
||||||
sleep 5s # let it converge
|
sleep 5s # let it converge
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash -e
|
#!/bin/bash -e
|
||||||
|
|
||||||
# run empty graph, with prometheus support
|
# run empty graph, with prometheus support
|
||||||
timeout --kill-after=20s 15s ./mgmt run --tmp-prefix --prometheus --prometheus-listen :52637 &
|
$timeout --kill-after=20s 15s ./mgmt run --tmp-prefix --prometheus --prometheus-listen :52637 &
|
||||||
pid=$!
|
pid=$!
|
||||||
sleep 5s # let it converge
|
sleep 5s # let it converge
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
set -o errexit
|
set -o errexit
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
timeout --kill-after=3s 1s ./mgmt --help # hello world!
|
$timeout --kill-after=3s 1s ./mgmt --help # hello world!
|
||||||
pid=$!
|
pid=$!
|
||||||
wait $pid # get exit status
|
wait $pid # get exit status
|
||||||
exit $?
|
exit $?
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ if env | grep -q -e '^TRAVIS=true$'; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# run till completion
|
# run till completion
|
||||||
timeout --kill-after=15s 10s ./mgmt run --yaml t2.yaml --converged-timeout=5 --no-watch --tmp-prefix &
|
$timeout --kill-after=15s 10s ./mgmt run --yaml t2.yaml --converged-timeout=5 --no-watch --tmp-prefix &
|
||||||
pid=$!
|
pid=$!
|
||||||
wait $pid # get exit status
|
wait $pid # get exit status
|
||||||
e=$?
|
e=$?
|
||||||
|
|||||||
@@ -10,11 +10,11 @@ fi
|
|||||||
mkdir -p "${MGMT_TMPDIR}"mgmt{A..C}
|
mkdir -p "${MGMT_TMPDIR}"mgmt{A..C}
|
||||||
|
|
||||||
# run till completion
|
# run till completion
|
||||||
timeout --kill-after=15s 10s ./mgmt run --yaml t3-a.yaml --converged-timeout=5 --no-watch --tmp-prefix &
|
$timeout --kill-after=15s 10s ./mgmt run --yaml t3-a.yaml --converged-timeout=5 --no-watch --tmp-prefix &
|
||||||
pid1=$!
|
pid1=$!
|
||||||
timeout --kill-after=15s 10s ./mgmt run --yaml t3-b.yaml --converged-timeout=5 --no-watch --tmp-prefix &
|
$timeout --kill-after=15s 10s ./mgmt run --yaml t3-b.yaml --converged-timeout=5 --no-watch --tmp-prefix &
|
||||||
pid2=$!
|
pid2=$!
|
||||||
timeout --kill-after=15s 10s ./mgmt run --yaml t3-c.yaml --converged-timeout=5 --no-watch --tmp-prefix &
|
$timeout --kill-after=15s 10s ./mgmt run --yaml t3-c.yaml --converged-timeout=5 --no-watch --tmp-prefix &
|
||||||
pid3=$!
|
pid3=$!
|
||||||
|
|
||||||
wait $pid1 # get exit status
|
wait $pid1 # get exit status
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash -e
|
#!/bin/bash -e
|
||||||
|
|
||||||
# should take slightly more than 25s, but fail if we take 35s)
|
# should take slightly more than 25s, but fail if we take 35s)
|
||||||
timeout --kill-after=35s 30s ./mgmt run --yaml t4.yaml --converged-timeout=5 --no-watch --tmp-prefix &
|
$timeout --kill-after=35s 30s ./mgmt run --yaml t4.yaml --converged-timeout=5 --no-watch --tmp-prefix &
|
||||||
pid=$!
|
pid=$!
|
||||||
wait $pid # get exit status
|
wait $pid # get exit status
|
||||||
exit $?
|
exit $?
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash -e
|
#!/bin/bash -e
|
||||||
|
|
||||||
# should take slightly more than 35s, but fail if we take 45s)
|
# should take slightly more than 35s, but fail if we take 45s)
|
||||||
timeout --kill-after=45s 40s ./mgmt run --yaml t5.yaml --converged-timeout=5 --no-watch --tmp-prefix &
|
$timeout --kill-after=45s 40s ./mgmt run --yaml t5.yaml --converged-timeout=5 --no-watch --tmp-prefix &
|
||||||
pid=$!
|
pid=$!
|
||||||
wait $pid # get exit status
|
wait $pid # get exit status
|
||||||
exit $?
|
exit $?
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash -e
|
#!/bin/bash -e
|
||||||
|
|
||||||
# should take slightly more than 35s, but fail if we take 45s)
|
# should take slightly more than 35s, but fail if we take 45s)
|
||||||
timeout --kill-after=45s 40s ./mgmt run --yaml t5.yaml --converged-timeout=5 --no-watch --tmp-prefix &
|
$timeout --kill-after=45s 40s ./mgmt run --yaml t5.yaml --converged-timeout=5 --no-watch --tmp-prefix &
|
||||||
pid=$!
|
pid=$!
|
||||||
wait $pid # get exit status
|
wait $pid # get exit status
|
||||||
exit $?
|
exit $?
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ if env | grep -q -e '^TRAVIS=true$'; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# run till completion
|
# run till completion
|
||||||
timeout --kill-after=20s 15s ./mgmt run --yaml t6.yaml --no-watch --tmp-prefix &
|
$timeout --kill-after=20s 15s ./mgmt run --yaml t6.yaml --no-watch --tmp-prefix &
|
||||||
pid=$!
|
pid=$!
|
||||||
sleep 1s # let it converge
|
sleep 1s # let it converge
|
||||||
test -e /tmp/mgmt/f1
|
test -e /tmp/mgmt/f1
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash -e
|
#!/bin/bash -e
|
||||||
|
|
||||||
# run empty graph
|
# run empty graph
|
||||||
timeout --kill-after=20s 15s ./mgmt run --tmp-prefix &
|
$timeout --kill-after=20s 15s ./mgmt run --tmp-prefix &
|
||||||
pid=$!
|
pid=$!
|
||||||
sleep 5s # let it converge
|
sleep 5s # let it converge
|
||||||
$(sleep 3s && killall -SIGINT mgmt)& # send ^C to exit mgmt
|
$(sleep 3s && killall -SIGINT mgmt)& # send ^C to exit mgmt
|
||||||
|
|||||||
@@ -3,11 +3,11 @@
|
|||||||
exit 0 # XXX: test temporarily disabled till etcd or mgmt regression is fixed.
|
exit 0 # XXX: test temporarily disabled till etcd or mgmt regression is fixed.
|
||||||
|
|
||||||
# run empty graphs, we're just testing etcd clustering
|
# run empty graphs, we're just testing etcd clustering
|
||||||
timeout --kill-after=180s 120s ./mgmt run --hostname h1 --tmp-prefix &
|
$timeout --kill-after=180s 120s ./mgmt run --hostname h1 --tmp-prefix &
|
||||||
pid1=$!
|
pid1=$!
|
||||||
sleep 15s # let it startup
|
sleep 15s # let it startup
|
||||||
|
|
||||||
timeout --kill-after=180s 120s ./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 &
|
$timeout --kill-after=180s 120s ./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 &
|
||||||
pid2=$!
|
pid2=$!
|
||||||
sleep 15s
|
sleep 15s
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
# common settings and functions for test scripts
|
# common settings and functions for test scripts
|
||||||
|
|
||||||
|
if [[ $(uname) == "Darwin" ]] ; then
|
||||||
|
export timeout="gtimeout"
|
||||||
|
else
|
||||||
|
export timeout="timeout"
|
||||||
|
fi
|
||||||
|
|
||||||
fail_test()
|
fail_test()
|
||||||
{
|
{
|
||||||
echo "FAIL: $@"
|
echo "FAIL: $@"
|
||||||
|
|||||||
Reference in New Issue
Block a user