@cryptotaxi247 / kubo / commits / 29ec4c06e

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: Christian Couder <chriscool@tuxfamily.org>

Christian Couder committed Dec 14, 2015 at 22:59 UTC 29ec4c06e4358457fadd5d672cd9657d77e6d460
2 files changed +28
circle.yml
+1
@@ -3,6 +3,7 @@ machine:
3 TEST_NO_FUSE: 1
4 TEST_VERBOSE: 1
5 TRAVIS: 1
6 + CIRCLE: 1
7 post:
8 - sudo rm -rf /usr/local/go
9 - 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
test/ipfs-test-lib.sh
+27
@@ -35,3 +35,30 @@ shellquote() {
35 done
36 printf '\n'
37 }
38 +
39 +# Docker
40 +
41 +# This takes a directory, that should contain a Dockerfile, as argument
42 +docker_build() {
43 + docker build --rm "$1"
44 +}
45 +
46 +# This takes an image as argument and writes a docker ID on stdout
47 +docker_run() {
48 + docker run -it -d -p 8080:8080 -p 4001:4001 -p 5001:5001 "$1"
49 +}
50 +
51 +# This takes a docker ID and a command as arguments
52 +docker_exec() {
53 + if test "$CIRCLE" = 1
54 + then
55 + sudo lxc-attach -n "$(docker inspect --format '{{.Id}}' $1)" -- /bin/bash -c "$2"
56 + else
57 + docker exec -i "$1" /bin/bash -c "$2"
58 + fi
59 +}
60 +
61 +# This takes a docker ID as argument
62 +docker_stop() {
63 + docker stop "$1"
64 +}