integration: Support using a different CLI.

- `docker` will now use the CLI defined in $DOCKER_BINARY
- In order to communicate with the host docker, one must use
  `docker_host`

Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
Andrea Luzzardi 2015-05-04 22:06:50 -07:00
parent fdf74cef2a
commit 86bf53a504
3 changed files with 20 additions and 7 deletions

View File

@ -41,7 +41,7 @@ function teardown() {
# if connected successfull, it returns two lines, "Session Open" and "Session Closed"
# Note: with stdout=1&stdin=1&stream=1: it can be used as SSH
URL="ws://${SWARM_HOST}/${CLIENT_API_VERSION}/containers/test_container/attach/ws?stderr=1"
run docker run --rm --net=host jimmyxian/centos7-wssh wssh $URL
run docker_host run --rm --net=host jimmyxian/centos7-wssh wssh $URL
[ "$status" -eq 0 ]
[ "${#lines[@]}" -eq 2 ]
[[ "${lines[0]}" == *"Session Open"* ]]
@ -382,8 +382,8 @@ function teardown() {
IMAGE_FILE=$(mktemp)
# create a tar file
docker pull busybox:latest
docker save -o $IMAGE_FILE busybox:latest
docker_host pull busybox:latest
docker_host save -o $IMAGE_FILE busybox:latest
start_docker 2
swarm_manage

View File

@ -9,6 +9,7 @@ SWARM_BINARY=${SWARM_BINARY:-${SWARM_ROOT}/swarm}
# Docker image and version to use for integration tests.
DOCKER_IMAGE=${DOCKER_IMAGE:-dockerswarm/dind}
DOCKER_VERSION=${DOCKER_VERSION:-1.6.0}
DOCKER_BINARY=${DOCKER_BINARY:-`command -v docker`}
# Host on which the manager will listen to (random port between 6000 and 7000).
SWARM_HOST=127.0.0.1:$(( ( RANDOM % 1000 ) + 6000 ))
@ -27,6 +28,18 @@ function join() {
echo "$*"
}
# Run docker using the binary specified by $DOCKER_BINARY.
# This must ONLY be run on engines created with `start_docker`.
function docker() {
"$DOCKER_BINARY" "$@"
}
# Communicate with Docker on the host machine.
# Should rarely use this.
function docker_host() {
command docker "$@"
}
# Run the swarm binary. You must NOT fork this command (swarm foo &) as the PID
# ($!) will be the one of the subshell instead of swarm and you won't be able
# to kill it.
@ -117,7 +130,7 @@ function start_docker() {
# We have to manually call `hostname` since --hostname and --net cannot
# be used together.
DOCKER_CONTAINERS[$i]=$(
docker run -d --name node-$i --privileged -it --net=host \
docker_host run -d --name node-$i --privileged -it --net=host \
${DOCKER_IMAGE}:${DOCKER_VERSION} \
bash -c "\
hostname node-$i && \
@ -137,6 +150,6 @@ function start_docker() {
function stop_docker() {
for id in ${DOCKER_CONTAINERS[@]}; do
echo "Stopping $id"
docker rm -f -v $id > /dev/null;
docker_host rm -f -v $id > /dev/null;
done
}

View File

@ -9,11 +9,11 @@ ZK_HOST=127.0.0.1:$(( ( RANDOM % 1000 ) + 7000 ))
ZK_CONTAINER_NAME=swarm_integration_zk
function start_zk() {
docker run --name $ZK_CONTAINER_NAME -p $ZK_HOST:2181 -d jplock/zookeeper
docker_host run --name $ZK_CONTAINER_NAME -p $ZK_HOST:2181 -d jplock/zookeeper
}
function stop_zk() {
docker rm -f -v $ZK_CONTAINER_NAME > /dev/null
docker_host rm -f -v $ZK_CONTAINER_NAME > /dev/null
}
function teardown() {