提交 f48ad524 作者: Brian Tiger Chow

fix: make the dockertest a bit more robust

clean using script
misc
add another file
misc
good stuff

License: MIT
Signed-off-by: 's avatarBrian Tiger Chow <brian@perfmode.com>
上级 a2cc7dc1
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
test: clean setup test: clean setup
fig build --no-cache fig build --no-cache
fig up 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/file setup: docker_ipfs_image data/filetiny data/filerand
save_logs:
sh bin/save_logs.sh
docker_ipfs_image: docker_ipfs_image:
docker images | grep zaqwsx_ipfs-test-img docker images | grep $(IPFS_DOCKER_IMAGE)
data/filetiny: Makefile
cp Makefile ./data/filetiny # simple
data/file: bin/random data/filerand: bin/random
cp Makefile ./data/file ./bin/random 1000000 > ./data/filerand
bin/random: bin/random:
go build -o ./bin/random ../$(RANDOMSRC) go build -o ./bin/random ../$(RANDOMSRC)
clean: clean:
docker rm $(docker ps -q -a -f status=exited) || true sh bin/clean.sh
rm -f data/file fig stop
fig rm -v --force
rm -f bin/random
rm -f data/filetiny
rm -f data/filerand
rm -rf build/*
docker rm -f $( docker ps -q -a -f status=exited ) || true
STRIP="perl -pe 's/\e\[?.*?[\@-~]//g'"
# TODO use a for loop like a grownup
docker logs dockertest_bootstrap_1 2>&1 | eval $STRIP > ./build/bootstrap.log
docker logs dockertest_client_1 2>&1 | eval $STRIP > ./build/client.log
docker logs dockertest_data_1 2>&1 | eval $STRIP > ./build/data.log
docker logs dockertest_server_1 2>&1 | eval $STRIP > ./build/server.log
...@@ -3,23 +3,41 @@ ipfs bootstrap add /ip4/$BOOTSTRAP_PORT_4011_TCP_ADDR/tcp/$BOOTSTRAP_PORT_4011_T ...@@ -3,23 +3,41 @@ ipfs bootstrap add /ip4/$BOOTSTRAP_PORT_4011_TCP_ADDR/tcp/$BOOTSTRAP_PORT_4011_T
ipfs daemon & ipfs daemon &
sleep 3 sleep 3
while [ ! -f /data/id ] while [ ! -f /data/idtiny ]
do do
echo waiting for server to add the file... echo waiting for server to add the file...
sleep 1 sleep 1
done done
echo client found file with hash: $(cat /data/id) echo client found file with hash: $(cat /data/idtiny)
ipfs cat $(cat /data/id) > file ipfs cat $(cat /data/idtiny) > filetiny
cat file cat filetiny
diff -u filetiny /data/filetiny
if (($? > 0)); then
printf '%s\n' 'files did not match' >&2
exit 1
fi
while [ ! -f /data/idrand ]
do
echo waiting for server to add the file...
sleep 1
done
echo client found file with hash: $(cat /data/idrand)
cat /data/idrand
ipfs cat $(cat /data/idrand) > filerand
if (($? > 0)); then if (($? > 0)); then
printf '%s\n' 'ipfs cat failed.' >&2 printf '%s\n' 'ipfs cat failed' >&2
exit 1 exit 1
fi fi
diff -u file /data/file diff -u filerand /data/filerand
if (($? > 0)); then if (($? > 0)); then
printf '%s\n' 'files did not match' >&2 printf '%s\n' 'files did not match' >&2
......
FROM ubuntu FROM ubuntu
ADD file /data/file ADD filetiny /data/filetiny
ADD filerand /data/filerand
VOLUME ["/data"] VOLUME ["/data"]
...@@ -2,6 +2,7 @@ data: ...@@ -2,6 +2,7 @@ data:
build: ./data build: ./data
volumes: volumes:
- /data - /data
command: sleep 1000000
bootstrap: bootstrap:
build: ./bootstrap build: ./bootstrap
...@@ -9,7 +10,7 @@ bootstrap: ...@@ -9,7 +10,7 @@ bootstrap:
- "4011" - "4011"
- "4012/udp" - "4012/udp"
environment: environment:
IPFS_LOGGING: error IPFS_LOGGING: debug
server: server:
build: ./server build: ./server
...@@ -21,7 +22,7 @@ server: ...@@ -21,7 +22,7 @@ server:
- "4021" - "4021"
- "4022/udp" - "4022/udp"
environment: environment:
IPFS_LOGGING: error IPFS_LOGGING: debug
client: client:
build: ./client build: ./client
...@@ -33,4 +34,4 @@ client: ...@@ -33,4 +34,4 @@ client:
- "4031" - "4031"
- "4032/udp" - "4032/udp"
environment: environment:
IPFS_LOGGING: error IPFS_LOGGING: debug
...@@ -5,13 +5,14 @@ ipfs bootstrap add /ip4/$BOOTSTRAP_PORT_4011_TCP_ADDR/tcp/$BOOTSTRAP_PORT_4011_T ...@@ -5,13 +5,14 @@ ipfs bootstrap add /ip4/$BOOTSTRAP_PORT_4011_TCP_ADDR/tcp/$BOOTSTRAP_PORT_4011_T
# alternatively use ipfs swarm connect # alternatively use ipfs swarm connect
ipfs daemon & ipfs daemon &
sleep 3 sleep 3
echo $(ipfs id)
# TODO instead of bootrapping: ipfs swarm connect /ip4/$BOOTSTRAP_PORT_4011_TCP_ADDR/tcp/$BOOTSTRAP_PORT_4011_TCP_PORT/QmNXuBh8HFsWq68Fid8dMbGNQTh7eG6hV9rr1fQyfmfomE # TODO instead of bootrapping: ipfs swarm connect /ip4/$BOOTSTRAP_PORT_4011_TCP_ADDR/tcp/$BOOTSTRAP_PORT_4011_TCP_PORT/QmNXuBh8HFsWq68Fid8dMbGNQTh7eG6hV9rr1fQyfmfomE
# must mount this volume from data container # must mount this volume from data container
ipfs add -q /data/file > /data/id ipfs add -q /data/filetiny > /data/idtiny
echo added tiny file. hash is $(cat /data/idtiny)
echo added file. hash is $(cat /data/id) ipfs add -q /data/filerand > /data/idrand
echo added rand file. hash is $(cat /data/idrand)
# allow ample time for the client to pull the data # allow ample time for the client to pull the data
sleep 10000000 sleep 10000000
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论