diff --git a/test/850_plugin_v2_cross_hosts_2_test.sh b/test/850_plugin_v2_cross_hosts_2_test.sh new file mode 100755 index 00000000..3c8bab54 --- /dev/null +++ b/test/850_plugin_v2_cross_hosts_2_test.sh @@ -0,0 +1,133 @@ +#! /bin/bash + +. "$(dirname "$0")/config.sh" + +PLUGIN_NAME="weave-ci-registry:5000/weaveworks/plugin-v2" +HOST1_IP=$($SSH $HOST1 getent ahosts $HOST1 | grep "RAW" | cut -d' ' -f1) +SERVICE="weave-850-service" +NETWORK="weave-850-network" + +setup_master() { + # Setup Docker image registry on $HOST1 + docker_on $HOST1 run -p 5000:5000 -d registry:2 + + # Build plugin-v2 on $HOST1, because Circle "CI" runs only ancient + # version of Docker which does not support v2 plugins. + build_plugin_img="buildpluginv2-ci" + rsync -az -e "$SSH" "$(dirname $0)/../prog/plugin-v2" $HOST1:~/ + $SSH $HOST1</dev/null + docker plugin disable $PLUGIN_NAME >/dev/null + docker plugin remove $PLUGIN_NAME 2>/dev/null + + WORK_DIR=$(mktemp -d) + mkdir -p \${WORK_DIR}/rootfs + + docker create --name=$build_plugin_img weaveworks/plugin true + docker export $build_plugin_img | tar -x -C \${WORK_DIR}/rootfs + cp \${HOME}/plugin-v2/launch.sh \${WORK_DIR}/rootfs/home/weave/launch.sh + cp \${HOME}/plugin-v2/config.json \${WORK_DIR} + docker plugin create $PLUGIN_NAME \${WORK_DIR} + + echo "$HOST1_IP weave-ci-registry" | sudo tee -a /etc/hosts + docker plugin push $PLUGIN_NAME + + # Start Swarm Manager and enable the plugin + docker swarm init --advertise-addr=$HOST1_IP + + [ -n "$COVERAGE" ] && docker plugin set $PLUGIN_NAME EXTRA_ARGS="-test.coverprofile=/home/weave/cover.prof --" + #docker plugin set $PLUGIN_NAME WEAVE_PASSWORD="foobar" + docker plugin enable $PLUGIN_NAME + ps aux | grep weave + cat /var/lib/weave/weaver.log +EOF +} + +setup_worker() { + $SSH $HOST2</dev/null 2>&1; then + return + fi + echo "Waiting for \"$2\" network" + sleep 2 + done + echo "Failed to wait for \"$2\" network" >&2 + return 1 +} + +wait_for_service() { + for i in $(seq 60); do + replicas=$($SSH $1 docker service ls -f="name=$2" | awk '{print $4}' | grep -v REPLICAS) + if [ "$replicas" == "$3/$3" ]; then + return + fi + echo "Waiting for \"$2\" service" + sleep 2 + done + echo "Failed to wait for \"$2\" service" >&2 + return 1 +} + +start_suite "Test Docker plugin-v2" + +setup_master +#sleep 20 # registry seems to be async :( +setup_worker $($SSH $HOST1 docker swarm join-token --quiet worker) + +echo "Creating network and service..." + +# Create network and service +$SSH $HOST1<