Commit 29ec4c06 authored by Christian Couder's avatar Christian Couder

test/ipfs-test-lib: add docker support

We have to do something special for CircleCI in docker_exec()
because "docker exec" doesn't work on CircleCi:

https://circleci.com/docs/docker#docker-exec

We indeed get "Unsupported: Exec is not supported by the lxc
driver" with CircleCi, when using "docker exec".

License: MIT
Signed-off-by: default avatarChristian Couder <chriscool@tuxfamily.org>
parent 1c403c03
......@@ -3,6 +3,7 @@ machine:
TEST_NO_FUSE: 1
TEST_VERBOSE: 1
TRAVIS: 1
CIRCLE: 1
post:
- sudo rm -rf /usr/local/go
- if [ ! -e go1.5.linux-amd64.tar.gz ]; then curl -o go1.5.linux-amd64.tar.gz https://storage.googleapis.com/golang/go1.5.linux-amd64.tar.gz; fi
......
......@@ -35,3 +35,30 @@ shellquote() {
done
printf '\n'
}
# Docker
# This takes a directory, that should contain a Dockerfile, as argument
docker_build() {
docker build --rm "$1"
}
# This takes an image as argument and writes a docker ID on stdout
docker_run() {
docker run -it -d -p 8080:8080 -p 4001:4001 -p 5001:5001 "$1"
}
# This takes a docker ID and a command as arguments
docker_exec() {
if test "$CIRCLE" = 1
then
sudo lxc-attach -n "$(docker inspect --format '{{.Id}}' $1)" -- /bin/bash -c "$2"
else
docker exec -i "$1" /bin/bash -c "$2"
fi
}
# This takes a docker ID as argument
docker_stop() {
docker stop "$1"
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment