@cryptotaxi247 / kubo / commits / f48ad524f

fix: make the dockertest a bit more robust

clean using script misc add another file misc good stuff License: MIT Signed-off-by: Brian Tiger Chow <brian@perfmode.com>

Brian Tiger Chow committed Dec 15, 2014 at 05:24 UTC f48ad524f8c224b3b443853c56cfbdaefcc149b8
9 files changed +69 -21
dockertest/Makefile
+24 -8
@@ -1,20 +1,36 @@
1 RANDOMSRC = Godeps/_workspace/src/github.com/jbenet/go-random/random
2 +IPFS_DOCKER_IMAGE = zaqwsx_ipfs-test-img
3
4 test: clean setup
5 fig build --no-cache
5 - fig up
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"
11
7 -setup: docker_ipfs_image data/file
12 +setup: docker_ipfs_image data/filetiny data/filerand
13 +
14 +save_logs:
15 + sh bin/save_logs.sh
16
17 docker_ipfs_image:
10 - docker images | grep zaqwsx_ipfs-test-img
18 + docker images | grep $(IPFS_DOCKER_IMAGE)
19 +
20 +data/filetiny: Makefile
21 + cp Makefile ./data/filetiny # simple
22
12 -data/file: bin/random
13 - cp Makefile ./data/file
23 +data/filerand: bin/random
24 + ./bin/random 1000000 > ./data/filerand
25
15 -bin/random:
26 +bin/random:
27 go build -o ./bin/random ../$(RANDOMSRC)
28
29 clean:
19 - docker rm $(docker ps -q -a -f status=exited) || true
20 - rm -f data/file
30 + sh bin/clean.sh
31 + fig stop
32 + fig rm -v --force
33 + rm -f bin/random
34 + rm -f data/filetiny
35 + rm -f data/filerand
36 + rm -rf build/*
dockertest/bin/clean.sh new
+1
@@ -0,0 +1 @@
1 +docker rm -f $( docker ps -q -a -f status=exited ) || true
dockertest/bin/save_logs.sh new
+7
@@ -0,0 +1,7 @@
1 +STRIP="perl -pe 's/\e\[?.*?[\@-~]//g'"
2 +
3 +# TODO use a for loop like a grownup
4 +docker logs dockertest_bootstrap_1 2>&1 | eval $STRIP > ./build/bootstrap.log
5 +docker logs dockertest_client_1 2>&1 | eval $STRIP > ./build/client.log
6 +docker logs dockertest_data_1 2>&1 | eval $STRIP > ./build/data.log
7 +docker logs dockertest_server_1 2>&1 | eval $STRIP > ./build/server.log
dockertest/build/.gitignore new
+2
@@ -0,0 +1,2 @@
1 +*.log
2 +go-random
dockertest/client/run.sh
+24 -6
@@ -3,23 +3,41 @@ ipfs bootstrap add /ip4/$BOOTSTRAP_PORT_4011_TCP_ADDR/tcp/$BOOTSTRAP_PORT_4011_T
3 ipfs daemon &
4 sleep 3
5
6 -while [ ! -f /data/id ]
6 +while [ ! -f /data/idtiny ]
7 do
8 echo waiting for server to add the file...
9 sleep 1
10 done
11 -echo client found file with hash: $(cat /data/id)
11 +echo client found file with hash: $(cat /data/idtiny)
12
13 -ipfs cat $(cat /data/id) > file
13 +ipfs cat $(cat /data/idtiny) > filetiny
14
15 -cat file
15 +cat filetiny
16 +
17 +diff -u filetiny /data/filetiny
18 +
19 +if (($? > 0)); then
20 + printf '%s\n' 'files did not match' >&2
21 + exit 1
22 +fi
23 +
24 +while [ ! -f /data/idrand ]
25 +do
26 + echo waiting for server to add the file...
27 + sleep 1
28 +done
29 +echo client found file with hash: $(cat /data/idrand)
30 +
31 +cat /data/idrand
32 +
33 +ipfs cat $(cat /data/idrand) > filerand
34
35 if (($? > 0)); then
18 - printf '%s\n' 'ipfs cat failed.' >&2
36 + printf '%s\n' 'ipfs cat failed' >&2
37 exit 1
38 fi
39
22 -diff -u file /data/file
40 +diff -u filerand /data/filerand
41
42 if (($? > 0)); then
43 printf '%s\n' 'files did not match' >&2
dockertest/data/.gitignore new
+1
@@ -0,0 +1 @@
1 +file*
dockertest/data/Dockerfile
+2 -1
@@ -1,5 +1,6 @@
1 FROM ubuntu
2
3 -ADD file /data/file
3 +ADD filetiny /data/filetiny
4 +ADD filerand /data/filerand
5
6 VOLUME ["/data"]
dockertest/fig.yml
+4 -3
@@ -2,6 +2,7 @@ data:
2 build: ./data
3 volumes:
4 - /data
5 + command: sleep 1000000
6
7 bootstrap:
8 build: ./bootstrap
@@ -9,7 +10,7 @@ bootstrap:
10 - "4011"
11 - "4012/udp"
12 environment:
12 - IPFS_LOGGING: error
13 + IPFS_LOGGING: debug
14
15 server:
16 build: ./server
@@ -21,7 +22,7 @@ server:
22 - "4021"
23 - "4022/udp"
24 environment:
24 - IPFS_LOGGING: error
25 + IPFS_LOGGING: debug
26
27 client:
28 build: ./client
@@ -33,4 +34,4 @@ client:
34 - "4031"
35 - "4032/udp"
36 environment:
36 - IPFS_LOGGING: error
37 + IPFS_LOGGING: debug
dockertest/server/run.sh
+4 -3
@@ -5,13 +5,14 @@ ipfs bootstrap add /ip4/$BOOTSTRAP_PORT_4011_TCP_ADDR/tcp/$BOOTSTRAP_PORT_4011_T
5 # alternatively use ipfs swarm connect
6 ipfs daemon &
7 sleep 3
8 -echo $(ipfs id)
8 # TODO instead of bootrapping: ipfs swarm connect /ip4/$BOOTSTRAP_PORT_4011_TCP_ADDR/tcp/$BOOTSTRAP_PORT_4011_TCP_PORT/QmNXuBh8HFsWq68Fid8dMbGNQTh7eG6hV9rr1fQyfmfomE
9
10 # must mount this volume from data container
12 -ipfs add -q /data/file > /data/id
11 +ipfs add -q /data/filetiny > /data/idtiny
12 +echo added tiny file. hash is $(cat /data/idtiny)
13
14 -echo added file. hash is $(cat /data/id)
14 +ipfs add -q /data/filerand > /data/idrand
15 +echo added rand file. hash is $(cat /data/idrand)
16
17 # allow ample time for the client to pull the data
18 sleep 10000000