Skip to content

Commit

Permalink
dockertest script to run the test on any img
Browse files Browse the repository at this point in the history
- run the build image task every time to avoid
  running the test on stale code
- run the test from a script, so that we can
  run the test on different pre-built images.
  like:

    # build an image now and run tests on it
    make test

    # run tests on previously built image
    ./run-test-on-img.sh ipfs-stable

    # TODO: run test on git ref
    ./run-test-on-git-ref.sh <git-ref>
  • Loading branch information
jbenet committed Dec 23, 2014
1 parent ad07f60 commit 5e475e1
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 17 deletions.
24 changes: 7 additions & 17 deletions dockertest/Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
RANDOMSRC = Godeps/_workspace/src/github.com/jbenet/go-random/random
IPFS_DOCKER_IMAGE = zaqwsx_ipfs-test-img
IMAGE_NAME = ipfs-test-latest

test: clean setup
fig build --no-cache
fig up --no-color | tee build/fig.log
make save_logs # save the ipfs logs for inspection
# fig up won't report the error using an error code, so we grep the
# fig.log file to find out whether the call succeeded
tail build/fig.log | grep "exited with code 0"
./run-test-on-img.sh $(IMAGE_NAME)

setup: docker_ipfs_image data/filetiny data/filerand

Expand All @@ -23,15 +18,11 @@ data/filerand: bin/random
bin/random:
go build -o ./bin/random ../$(RANDOMSRC)

docker_ipfs_image: build/.built_img
docker images | grep $(IPFS_DOCKER_IMAGE)

# this is here so that "make clean; make" rebuilds the docker img.
# but otherwise will reuse whatever you last built.
# TODO: make this detect whether code has been changed
build/.built_img:
cd .. && docker build -t $(IPFS_DOCKER_IMAGE) .
touch build/.built_img
# just build it every time... this part isn't
# even the lengthy part, and it decreases pain.
docker_ipfs_image:
cd .. && docker build -t $(IMAGE_NAME) .
docker images | grep $(IMAGE_NAME)

clean:
sh bin/clean.sh
Expand All @@ -41,4 +32,3 @@ clean:
rm -f data/filetiny
rm -f data/filerand
rm -rf build/*
rm -rf build/.built_img
33 changes: 33 additions & 0 deletions dockertest/run-test-on-img.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/sh
if [ "$#" -ne 1 ]; then
echo "usage: $0 <docker-image-ref>"
echo "runs this test on image matching <docker-image-ref>"
exit 1
fi

# this tag is used by the dockerfiles in
# {data, server, client, bootstrap}
tag=zaqwsx_ipfs-test-img

# could use set -v, but i dont want to see the comments...

img=$(docker images | grep $1 | awk '{print $3}')
echo "using docker image: $img ($1)"

echo docker tag -f $img $tag
docker tag -f $img $tag

echo "fig build --no-cache"
fig build --no-cache

echo "fig up --no-color | tee build/fig.log"
fig up --no-color | tee build/fig.log

# save the ipfs logs for inspection
echo "make save_logs"
make save_logs

# fig up won't report the error using an error code, so we grep the
# fig.log file to find out whether the call succeeded
echo 'tail build/fig.log | grep "exited with code 0"'
tail build/fig.log | grep "exited with code 0"

0 comments on commit 5e475e1

Please sign in to comment.