From 0bf6cf6dc9c946de6948fdd3631de399fb8b70f1 Mon Sep 17 00:00:00 2001 From: Andrea Luzzardi Date: Wed, 6 May 2015 01:35:54 -0700 Subject: [PATCH] integration helpers: add start_with_busybox starts an engine with a preloaded busybox without pulling (much faster). Signed-off-by: Andrea Luzzardi --- test/integration/helpers.bash | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/integration/helpers.bash b/test/integration/helpers.bash index dca57a68f3..e6a9eb1075 100644 --- a/test/integration/helpers.bash +++ b/test/integration/helpers.bash @@ -27,6 +27,8 @@ BASE_PORT=$(( ( RANDOM % 1000 ) + 5000 )) STORAGE_DRIVER=${STORAGE_DRIVER:-aufs} EXEC_DRIVER=${EXEC_DRIVER:-native} +BUSYBOX_IMAGE="$BATS_TMPDIR/busybox.tgz" + # Join an array with a given separator. function join() { local IFS="$1" @@ -149,6 +151,22 @@ function swarm_join_cleanup() { done } +function start_docker_with_busybox() { + # Preload busybox if not available. + [ "$(docker_host images -q busybox)" ] || docker_host pull busybox + [ -f "$BUSYBOX_IMAGE" ] || docker_host save -o "$BUSYBOX_IMAGE" busybox + + # Start the docker instances. + local current=${#DOCKER_CONTAINERS[@]} + start_docker "$@" + local new=${#DOCKER_CONTAINERS[@]} + + # Load busybox on the new instances. + for ((i=current; i < new; i++)); do + docker -H ${HOSTS[$i]} load -i "$BUSYBOX_IMAGE" + done +} + # Start N docker engines. function start_docker() { local current=${#DOCKER_CONTAINERS[@]}