diff --git a/test/3nodetest/Makefile b/test/3nodetest/Makefile index ec13b9367..3dc3b4621 100644 --- a/test/3nodetest/Makefile +++ b/test/3nodetest/Makefile @@ -10,6 +10,9 @@ setup: docker_ipfs_image data/filetiny data/filerand save_logs: sh bin/save_logs.sh +save_profiling_data: + sh bin/save_profiling_data.sh + data/filetiny: Makefile cp Makefile ./data/filetiny # simple diff --git a/test/3nodetest/bin/save_profiling_data.sh b/test/3nodetest/bin/save_profiling_data.sh new file mode 100644 index 000000000..03c0cbabe --- /dev/null +++ b/test/3nodetest/bin/save_profiling_data.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +for container in 3nodetest_bootstrap_1 3nodetest_client_1 3nodetest_server_1; do + # ipfs binary is required by `go tool pprof` + docker cp $container:/go/bin/ipfs build/profiling_data_$container +done + +# since the nodes are executed with the --debug flag, profiling data is written +# to the the working dir. by default, the working dir is /go. + +for container in 3nodetest_bootstrap_1 3nodetest_client_1 3nodetest_server_1; do + docker cp $container:/go/ipfs.cpuprof build/profiling_data_$container +done + +# TODO get memprof from client (client daemon isn't terminated, so memprof isn't retrieved) +for container in 3nodetest_bootstrap_1 3nodetest_server_1; do + docker cp $container:/go/ipfs.memprof build/profiling_data_$container +done diff --git a/test/3nodetest/build/.gitignore b/test/3nodetest/build/.gitignore index ffb6b09b3..84820c767 100644 --- a/test/3nodetest/build/.gitignore +++ b/test/3nodetest/build/.gitignore @@ -1,2 +1,3 @@ .built_img *.log +profiling_data* diff --git a/test/3nodetest/client/run.sh b/test/3nodetest/client/run.sh index 9bb1fb6fa..7a34d7bbc 100644 --- a/test/3nodetest/client/run.sh +++ b/test/3nodetest/client/run.sh @@ -1,11 +1,15 @@ ipfs bootstrap add /ip4/$BOOTSTRAP_PORT_4011_TCP_ADDR/tcp/$BOOTSTRAP_PORT_4011_TCP_PORT/ipfs/QmNXuBh8HFsWq68Fid8dMbGNQTh7eG6hV9rr1fQyfmfomE ipfs bootstrap # list bootstrap nodes for debugging - echo "3nodetest> starting client daemon" -ipfs daemon & + +ipfs daemon --debug & sleep 3 +# switch dirs so ipfs client profiling data doesn't overwrite the ipfs daemon +# profiling data +cd /tmp + while [ ! -f /data/idtiny ] do echo "3nodetest> waiting for server to add the file..." diff --git a/test/3nodetest/fig.yml b/test/3nodetest/fig.yml index 677078a97..18a28c8ff 100644 --- a/test/3nodetest/fig.yml +++ b/test/3nodetest/fig.yml @@ -6,6 +6,7 @@ data: bootstrap: build: ./bootstrap + command: daemon --debug --init expose: - "4011" - "4012/udp" diff --git a/test/3nodetest/run-test-on-img.sh b/test/3nodetest/run-test-on-img.sh index d53cde34b..1baf02650 100755 --- a/test/3nodetest/run-test-on-img.sh +++ b/test/3nodetest/run-test-on-img.sh @@ -27,6 +27,10 @@ fig up --no-color | tee build/fig.log echo "make save_logs" make save_logs +# save the ipfs logs for inspection +echo "make save_profiling_data" +make save_profiling_data + # 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"' diff --git a/test/3nodetest/server/run.sh b/test/3nodetest/server/run.sh index 68a45d4a3..325ae3c3c 100644 --- a/test/3nodetest/server/run.sh +++ b/test/3nodetest/server/run.sh @@ -5,10 +5,16 @@ ipfs bootstrap # list bootstrap nodes for debugging # wait for daemon to start/bootstrap # alternatively use ipfs swarm connect echo "3nodetest> starting server daemon" -ipfs daemon & + +# run daemon in debug mode to collect profiling data +ipfs daemon --debug & sleep 3 # TODO instead of bootrapping: ipfs swarm connect /ip4/$BOOTSTRAP_PORT_4011_TCP_ADDR/tcp/$BOOTSTRAP_PORT_4011_TCP_PORT/ipfs/QmNXuBh8HFsWq68Fid8dMbGNQTh7eG6hV9rr1fQyfmfomE +# change dir before running add commands so ipfs client profiling data doesn't +# overwrite the daemon profiling data +cd /tmp + # must mount this volume from data container ipfs add -q /data/filetiny > tmptiny mv tmptiny /data/idtiny