@cryptotaxi247 / kubo / commits / 4c13b9585

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>

Juan Batiz-Benet committed Dec 23, 2014 at 01:18 UTC 4c13b9585a77283e625eb4cc0c196bb2a6bf8052
2 files changed +40 -17
dockertest/Makefile
+7 -17
@@ -1,13 +1,8 @@
1 RANDOMSRC = Godeps/_workspace/src/github.com/jbenet/go-random/random
2 -IPFS_DOCKER_IMAGE = zaqwsx_ipfs-test-img
2 +IMAGE_NAME = ipfs-test-latest
3
4 test: clean setup
5 - fig build --no-cache
6 - fig up --no-color | tee build/fig.log
7 - make save_logs # save the ipfs logs for inspection
8 - # fig up won't report the error using an error code, so we grep the
9 - # fig.log file to find out whether the call succeeded
10 - tail build/fig.log | grep "exited with code 0"
5 + ./run-test-on-img.sh $(IMAGE_NAME)
6
7 setup: docker_ipfs_image data/filetiny data/filerand
8
@@ -23,15 +18,11 @@ data/filerand: bin/random
18 bin/random:
19 go build -o ./bin/random ../$(RANDOMSRC)
20
26 -docker_ipfs_image: build/.built_img
27 - docker images | grep $(IPFS_DOCKER_IMAGE)
28 -
29 -# this is here so that "make clean; make" rebuilds the docker img.
30 -# but otherwise will reuse whatever you last built.
31 -# TODO: make this detect whether code has been changed
32 -build/.built_img:
33 - cd .. && docker build -t $(IPFS_DOCKER_IMAGE) .
34 - touch build/.built_img
21 +# just build it every time... this part isn't
22 +# even the lengthy part, and it decreases pain.
23 +docker_ipfs_image:
24 + cd .. && docker build -t $(IMAGE_NAME) .
25 + docker images | grep $(IMAGE_NAME)
26
27 clean:
28 sh bin/clean.sh
@@ -41,4 +32,3 @@ clean:
32 rm -f data/filetiny
33 rm -f data/filerand
34 rm -rf build/*
44 - rm -rf build/.built_img
dockertest/run-test-on-img.sh new
+33
@@ -0,0 +1,33 @@
1 +#!/bin/sh
2 +if [ "$#" -ne 1 ]; then
3 + echo "usage: $0 <docker-image-ref>"
4 + echo "runs this test on image matching <docker-image-ref>"
5 + exit 1
6 +fi
7 +
8 +# this tag is used by the dockerfiles in
9 +# {data, server, client, bootstrap}
10 +tag=zaqwsx_ipfs-test-img
11 +
12 +# could use set -v, but i dont want to see the comments...
13 +
14 +img=$(docker images | grep $1 | awk '{print $3}')
15 +echo "using docker image: $img ($1)"
16 +
17 +echo docker tag -f $img $tag
18 +docker tag -f $img $tag
19 +
20 +echo "fig build --no-cache"
21 +fig build --no-cache
22 +
23 +echo "fig up --no-color | tee build/fig.log"
24 +fig up --no-color | tee build/fig.log
25 +
26 +# save the ipfs logs for inspection
27 +echo "make save_logs"
28 +make save_logs
29 +
30 +# fig up won't report the error using an error code, so we grep the
31 +# fig.log file to find out whether the call succeeded
32 +echo 'tail build/fig.log | grep "exited with code 0"'
33 +tail build/fig.log | grep "exited with code 0"