mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-30 09:59:13 +08:00
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>
This commit is contained in:
@ -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
|
||||
|
||||
@ -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
|
||||
@ -41,4 +32,3 @@ clean:
|
||||
rm -f data/filetiny
|
||||
rm -f data/filerand
|
||||
rm -rf build/*
|
||||
rm -rf build/.built_img
|
||||
|
33
dockertest/run-test-on-img.sh
Executable file
33
dockertest/run-test-on-img.sh
Executable file
@ -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"
|
Reference in New Issue
Block a user