From 71180f97e700ff854901fc8a7c55efa1f69aea60 Mon Sep 17 00:00:00 2001 From: Marc CARRE Date: Mon, 19 Dec 2016 14:25:31 +0000 Subject: [PATCH 1/2] Parallelise setup.sh. --- test/setup.sh | 43 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/test/setup.sh b/test/setup.sh index 374a6518..cc8ef884 100755 --- a/test/setup.sh +++ b/test/setup.sh @@ -11,27 +11,52 @@ cd "$(dirname "${BASH_SOURCE[0]}")" echo "Copying weave images, scripts, and certificates to hosts, and" echo " prefetch test images" +exists_on() { + docker_on $1 inspect --format=" " $2 >/dev/null 2>&1 +} + +pull_if_missing() { + if ! exists_on "$1" "$2" ; then + echo "Pulling $2 on $1..." + docker_on $1 pull $2 > /dev/null + fi +} + setup_host() { - HOST=$1 - docker_on $HOST load -i ../weave.tar.gz + local HOST=$1 + docker_on $HOST load -i ../weave.tar.gz & + local pids="$!" + DANGLING_IMAGES="$(docker_on $HOST images -q -f dangling=true)" [ -n "$DANGLING_IMAGES" ] && docker_on $HOST rmi $DANGLING_IMAGES 1>/dev/null 2>&1 || true run_on $HOST mkdir -p bin - upload_executable $HOST ../bin/docker-ns - upload_executable $HOST ../weave - rsync -az -e "$SSH" --exclude=tls ./tls/ $HOST:~/tls + + upload_executable $HOST ../bin/docker-ns & + local pids="$pids $!" + + upload_executable $HOST ../weave & + local pids="$pids $!" + + rsync -az -e "$SSH" --exclude=tls ./tls/ $HOST:~/tls & + local pids="$pids $!" + for IMG in $TEST_IMAGES ; do - docker_on $HOST inspect --format=" " $IMG >/dev/null 2>&1 || docker_on $HOST pull $IMG + pull_if_missing "$HOST" "$IMG" + local pids="$pids $!" done + for pid in $pids; do wait $pid; done } +ppids="" for HOST in $HOSTS; do setup_host $HOST & - pids="$pids $!" + ppids="$ppids $!" done # Wait individually for tasks so we fail-exit on any non-zero return code # ('wait' on its own always returns 0) -for pid in $pids; do - wait $pid; +for ppid in $ppids; do + wait $ppid; done + +echo "Setup completed successfully." From 89e116961c53c296df922f5b714c95a9f0d7709a Mon Sep 17 00:00:00 2001 From: Marc CARRE Date: Mon, 19 Dec 2016 14:49:05 +0000 Subject: [PATCH 2/2] Now measure time spent in setup. --- test/setup.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/setup.sh b/test/setup.sh index cc8ef884..97a2e377 100755 --- a/test/setup.sh +++ b/test/setup.sh @@ -2,6 +2,7 @@ set -e +begin=$(date +%s) cd "$(dirname "${BASH_SOURCE[0]}")" . "$(dirname "$0")/config.sh" @@ -59,4 +60,4 @@ for ppid in $ppids; do wait $ppid; done -echo "Setup completed successfully." +echo "Setup completed successfully in $(date -u -d @$(($(date +%s)-$begin)) +"%T")."