Commit 4c13b958 authored by Juan Batiz-Benet's avatar Juan Batiz-Benet

dockertest script to run the test on any img

- 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>
parent 2c95cb54
RANDOMSRC = Godeps/_workspace/src/github.com/jbenet/go-random/random 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 test: clean setup
fig build --no-cache ./run-test-on-img.sh $(IMAGE_NAME)
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"
setup: docker_ipfs_image data/filetiny data/filerand setup: docker_ipfs_image data/filetiny data/filerand
...@@ -23,15 +18,11 @@ data/filerand: bin/random ...@@ -23,15 +18,11 @@ data/filerand: bin/random
bin/random: bin/random:
go build -o ./bin/random ../$(RANDOMSRC) go build -o ./bin/random ../$(RANDOMSRC)
docker_ipfs_image: build/.built_img # just build it every time... this part isn't
docker images | grep $(IPFS_DOCKER_IMAGE) # even the lengthy part, and it decreases pain.
docker_ipfs_image:
# this is here so that "make clean; make" rebuilds the docker img. cd .. && docker build -t $(IMAGE_NAME) .
# but otherwise will reuse whatever you last built. docker images | grep $(IMAGE_NAME)
# TODO: make this detect whether code has been changed
build/.built_img:
cd .. && docker build -t $(IPFS_DOCKER_IMAGE) .
touch build/.built_img
clean: clean:
sh bin/clean.sh sh bin/clean.sh
...@@ -41,4 +32,3 @@ clean: ...@@ -41,4 +32,3 @@ clean:
rm -f data/filetiny rm -f data/filetiny
rm -f data/filerand rm -f data/filerand
rm -rf build/* rm -rf build/*
rm -rf build/.built_img
#!/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"
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