diff --git a/Makefile b/Makefile index ad32c0f847edb9002bcfa636ecc1e1bbbbe232e9..d8f2d80fb346908def2faa99dacabc9934e5437d 100644 --- a/Makefile +++ b/Makefile @@ -17,6 +17,11 @@ test: test_go test_sharness test_expensive: test_go_expensive test_sharness_expensive +test_docker: + cd ./src/github.com/jbenet/go-ipfs + docker build -t zaqwsx_ipfs-test-img . + cd dockertest/ && make + test_go: go test -test.short ./... diff --git a/dockertest/Makefile b/dockertest/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..fec031d9da0c7ccd47b8849f533f7dccdebf8a8c --- /dev/null +++ b/dockertest/Makefile @@ -0,0 +1,20 @@ +RANDOMSRC = Godeps/_workspace/src/github.com/jbenet/go-random/random + +test: clean setup + fig build --no-cache + fig up + +setup: docker_ipfs_image data/file + +docker_ipfs_image: + docker images | grep zaqwsx_ipfs-test-img + +data/file: bin/random + cp Makefile ./data/file + +bin/random: + go build -o ./bin/random ../$(RANDOMSRC) + +clean: + docker rm $(docker ps -q -a -f status=exited) || true + rm -f data/file diff --git a/dockertest/README.md b/dockertest/README.md new file mode 100644 index 0000000000000000000000000000000000000000..3991a6307b3ca98253868e7c4235ae134a09987a --- /dev/null +++ b/dockertest/README.md @@ -0,0 +1,15 @@ +this is an ipfs integration test + +**requirements** + +* Docker +* fig +* Go + +* ipfs image named "zaqwsx_ipfs-test-img" + +``` +make setup +fig build +fig up +``` diff --git a/dockertest/bin/.gitignore b/dockertest/bin/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..a1e4bc59a50bd617b035b98f47a08c4d85cca324 --- /dev/null +++ b/dockertest/bin/.gitignore @@ -0,0 +1 @@ +random diff --git a/dockertest/bootstrap/Dockerfile b/dockertest/bootstrap/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..2b645857fe916dd729b3487ba47cca8bba387618 --- /dev/null +++ b/dockertest/bootstrap/Dockerfile @@ -0,0 +1,8 @@ +FROM zaqwsx_ipfs-test-img + +RUN ipfs init -b=1024 +ADD . /tmp/id +RUN mv -f /tmp/id/config /root/.go-ipfs/config +RUN ipfs id + +EXPOSE 4011 4012/udp diff --git a/dockertest/bootstrap/README.md b/dockertest/bootstrap/README.md new file mode 100644 index 0000000000000000000000000000000000000000..09d7307feab58592d60780572806be31a323030f --- /dev/null +++ b/dockertest/bootstrap/README.md @@ -0,0 +1,3 @@ +this is a bootstrap peer with an empty bootstrap list + +it listens on 4011 and 4012 diff --git a/dockertest/bootstrap/config b/dockertest/bootstrap/config new file mode 100644 index 0000000000000000000000000000000000000000..b9fac5503b0eb95a63e95540726513478641a65f --- /dev/null +++ b/dockertest/bootstrap/config @@ -0,0 +1,39 @@ +{ + "Identity": { + "PeerID": "QmNXuBh8HFsWq68Fid8dMbGNQTh7eG6hV9rr1fQyfmfomE", + "PrivKey": "CAAS4gQwggJeAgEAAoGBAL+E7A0fcQS9+CHO3YAHj+JzHnWyVA7qqtiAIYbTnp9UvHBb2VFj2Q8eeyKFZD5wHoq3AtOqmIb4TUOMEtWYqXnE8o0T9np8vyCRK5dPn5SVoUw9uax6o2X7OxO1HqTcXHNHGbracawJUdwsk4yuZUpzXLez03yocWwneR0JpVJPAgMBAAECgYAXsa4ygW1OFOKZ7CnjKQxYC738+a8EmWvBlTiQoaXCOI2HqRVdyGiWQkMhpjccsmpU5wdmgHiWWinU7YN3AYgV3cP3qAjyNLBFoxy2dKsS9AOWVwRuuRP12tD05kCCjG4rJAX0JEOClOOtzvQ7/bXarMc3/tMHW7TMLNV8MzcYwQJBAOP9aYSHp8VnsO5j32Ju5SjOQorSdcCweqeUxwlAnXz50KdbNSCMypP3TOt7VeiXTuSITtN44yh+eogF5c4ehycCQQDXDHVmPeBN7uqqqZxZwW5pdeJWvx+REiXXCLE6KEPWlcxbw1D9ublpCCFLYuM68rjq1sjsIVGtiV1tYoMdHJSZAkEA0ddMZ070fB0UHFaQJGktQoGVfXB4MQI94kBtcXanfX/xLBgmre7oBYh4o8TBLXMWigFri/iYG41N+iRzf2NZwQJBAIh8rMpufT2ZZLFaoxRIc4ZVvojmFufhR8j6CFnsElpQivq2tWHEDcx+z3rkUWopgXnzRmSwJQHqTDTPsH26lQkCQQCehmxqaQEwE/QKAI8L8YVolgY2cjUGi6qF/awnI584lDSCuJRU3R/c6nc9R8qljtlJYTtp9iUr8vuN+jt48j+6" + }, + "Datastore": { + "Type": "leveldb", + "Path": "/root/.go-ipfs/datastore" + }, + "Addresses": { + "Swarm": [ + "/ip4/0.0.0.0/tcp/4011", + "/ip4/0.0.0.0/udp/4012/utp" + ], + "API": "/ip4/127.0.0.1/tcp/5001" + }, + "Mounts": { + "IPFS": "/ipfs", + "IPNS": "/ipns" + }, + "Version": { + "Current": "0.1.7", + "Check": "error", + "CheckDate": "0001-01-01T00:00:00Z", + "CheckPeriod": "172800000000000", + "AutoUpdate": "minor" + }, + "Bootstrap": [ + ], + "Tour": { + "Last": "" + }, + "Logs": { + "Filename": "/root/.go-ipfs/logs/events.log", + "MaxSizeMB": 0, + "MaxBackups": 0, + "MaxAgeDays": 0 + } +} diff --git a/dockertest/build/.gitkeep b/dockertest/build/.gitkeep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/dockertest/client/Dockerfile b/dockertest/client/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..55b04f320e6e1fc4cdec2e27d8ecced1a92304aa --- /dev/null +++ b/dockertest/client/Dockerfile @@ -0,0 +1,11 @@ +FROM zaqwsx_ipfs-test-img + +RUN ipfs init -b=1024 +ADD . /tmp/id +RUN mv -f /tmp/id/config /root/.go-ipfs/config +RUN ipfs id + +EXPOSE 4031 4032/udp + +ENTRYPOINT ["/bin/bash"] +CMD ["/tmp/id/run.sh"] diff --git a/dockertest/client/config b/dockertest/client/config new file mode 100644 index 0000000000000000000000000000000000000000..afb9f8d77cdaee54996f1de107cfafcb994a0494 --- /dev/null +++ b/dockertest/client/config @@ -0,0 +1,39 @@ +{ + "Addresses": { + "API": "/ip4/127.0.0.1/tcp/5001", + "Swarm": [ + "/ip4/0.0.0.0/tcp/4031", + "/ip4/0.0.0.0/udp/4032/utp" + ] + }, + "Bootstrap": [ + ], + "Datastore": { + "Path": "/root/.go-ipfs/datastore", + "Type": "leveldb" + }, + "Identity": { + "PeerID": "Qmbtc35vdjVh5o9w2AaT2SgcWwigsaoZUpRfq2FSrFD6mb", + "PrivKey": "CAAS4AQwggJcAgEAAoGBANlJUjOCbPXgYUfo1Pr6nlIjJDPNwN81ACamhaoEZ9VRHXI3fPe7RVAaaXrWLHb892mRqFi1ScE2lcMTLc7WGfyc7dwPqBOZqkVvT0KpCx3Mg246+WvnG8I3HCbWyjSP9tJflOBQxVq6qT2yZSXjNTtDdO4skd4PsPqBco53guYTAgMBAAECgYEAtIcYhrdMNBSSfp5RpZxnwbJ0t52xK0HruDEOSK2UX0Ufg+/aIjEza1QmYupi0xFltg5QojMs7hyd3Q+oNXro5tKsYVeiqrLsUh9jMjaQofzSlV9Oc+bhkkl48YWvF6Y8qx88UYAX+oJqB627H4S1gxLdNEJhPjEAD6n/jql3zUECQQDmHP75wJ7nC4TlxT1SHim5syMAqWNs/SOHnvX8yLrFV9FrMRzsD5qMlIEGBrAjaESzEck6XpbqkyxB8KKGo7OjAkEA8brtEh/AMoQ/yoSWdYT2MRbJxCAn+KG2c6Hi9AMMmJ+K779HxywpUIDYIa22hzLKYumYIuRa1X++1glOAFGq0QJAPQgXwFoMSy9M8jwcBXmmi3AtqnFCw5doIwJQL9l1X/3ot0txZlLFJOAGUHjZoqp2/h+LhYWs9U5PgLW4BYnJjQJAPydY/J0y93+5ss1FCdr8/wI3IHhOORT2t+sZgiqxxcYY5F4TAKQ2/wNKdDIQN+47FfB1gNgsKw8+6mhv6oFroQJACBF2yssNVXiXa2Na/a9tKYutGvxbm3lXzOvmpkW3FukbsObKYS344J1vdg0nzM6EWQCaiBweSA5TQ27iNW6BzQ==" + }, + "Logs": { + "Filename": "/root/.go-ipfs/logs/events.log", + "MaxAgeDays": 0, + "MaxBackups": 0, + "MaxSizeMB": 0 + }, + "Mounts": { + "IPFS": "/ipfs", + "IPNS": "/ipns" + }, + "Tour": { + "Last": "" + }, + "Version": { + "AutoUpdate": "minor", + "Check": "error", + "CheckDate": "0001-01-01T00:00:00Z", + "CheckPeriod": "172800000000000", + "Current": "0.1.7" + } +} diff --git a/dockertest/client/run.sh b/dockertest/client/run.sh new file mode 100644 index 0000000000000000000000000000000000000000..bd316bd56a9eefa58982667022df5a6c5a798591 --- /dev/null +++ b/dockertest/client/run.sh @@ -0,0 +1,29 @@ +ipfs bootstrap add /ip4/$BOOTSTRAP_PORT_4011_TCP_ADDR/tcp/$BOOTSTRAP_PORT_4011_TCP_PORT/QmNXuBh8HFsWq68Fid8dMbGNQTh7eG6hV9rr1fQyfmfomE + +ipfs daemon & +sleep 3 + +while [ ! -f /data/id ] +do + echo waiting for server to add the file... + sleep 1 +done +echo client found file with hash: $(cat /data/id) + +ipfs cat $(cat /data/id) > file + +cat file + +if (($? > 0)); then + printf '%s\n' 'ipfs cat failed.' >&2 + exit 1 +fi + +diff -u file /data/file + +if (($? > 0)); then + printf '%s\n' 'files did not match' >&2 + exit 1 +fi + +echo "success" diff --git a/dockertest/data/Dockerfile b/dockertest/data/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..998656b6b960528d6f325e795a20a2a7474b5668 --- /dev/null +++ b/dockertest/data/Dockerfile @@ -0,0 +1,5 @@ +FROM ubuntu + +ADD file /data/file + +VOLUME ["/data"] diff --git a/dockertest/fig.yml b/dockertest/fig.yml new file mode 100644 index 0000000000000000000000000000000000000000..205b7b167eb7495273f0359c29a5ceccc95b2720 --- /dev/null +++ b/dockertest/fig.yml @@ -0,0 +1,36 @@ +data: + build: ./data + volumes: + - /data + +bootstrap: + build: ./bootstrap + expose: + - "4011" + - "4012/udp" + environment: + IPFS_LOGGING: error + +server: + build: ./server + links: + - bootstrap + volumes_from: + - data + expose: + - "4021" + - "4022/udp" + environment: + IPFS_LOGGING: error + +client: + build: ./client + links: + - bootstrap + volumes_from: + - data + expose: + - "4031" + - "4032/udp" + environment: + IPFS_LOGGING: error diff --git a/dockertest/server/Dockerfile b/dockertest/server/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..5590c78237abac7131bc7a8f743fec36ca613945 --- /dev/null +++ b/dockertest/server/Dockerfile @@ -0,0 +1,12 @@ +FROM zaqwsx_ipfs-test-img + +RUN ipfs init -b=1024 +ADD . /tmp/test +RUN mv -f /tmp/test/config /root/.go-ipfs/config +RUN ipfs id +RUN chmod +x /tmp/test/run.sh + +EXPOSE 4021 4022/udp + +ENTRYPOINT ["/bin/bash"] +CMD ["/tmp/test/run.sh"] diff --git a/dockertest/server/README.md b/dockertest/server/README.md new file mode 100644 index 0000000000000000000000000000000000000000..01048ddbe974664ac1644cfb0e57fdd65b8a87cf --- /dev/null +++ b/dockertest/server/README.md @@ -0,0 +1,4 @@ +**requirements** + +* docker container with bootstrap node linked as "bootstrap" with ID QmNXuBh8HFsWq68Fid8dMbGNQTh7eG6hV9rr1fQyfmfomE +* file in data volume, internally mapped to /data/file diff --git a/dockertest/server/config b/dockertest/server/config new file mode 100644 index 0000000000000000000000000000000000000000..9d04b820b500ce2bfe99234d2e5393a0c398733b --- /dev/null +++ b/dockertest/server/config @@ -0,0 +1,39 @@ +{ + "Addresses": { + "API": "/ip4/127.0.0.1/tcp/5001", + "Swarm": [ + "/ip4/0.0.0.0/tcp/4021", + "/ip4/0.0.0.0/udp/4022/utp" + ] + }, + "Bootstrap": [ + ], + "Datastore": { + "Path": "/root/.go-ipfs/datastore", + "Type": "leveldb" + }, + "Identity": { + "PeerID": "Qmbtc2C7rqmAfdeMTM7FX4YF8CeBumMCfk5Z1GBCMbMTfY", + "PrivKey": "CAAS4AQwggJcAgEAAoGBANW3mJMmDSJbdRyykO0Ze5t6WL6jeTtpOhklxePBIkJL/Uil78Va/tODx6Mvv3GMCkbGvzWslTZXpaHa9vBmjE3MVZSmd5fLRybKT0zZ3juABKcx+WIVNw8JlkpEORihJdwb+5tRUC5pUcMzxqHSmGX+d6e9KZqLnv7piNKg2+r7AgMBAAECgYAqc6+w+wv82SHoM2gqULeG6MScCajZLkvGFwS5+vEtLh7/wUZhc3PO3AxZ0/A5Q9H+wRfWN5PkGYDjJ7WJhzUzGfTbrQ821JV6B3IUR4UHo2IgJkZO4EUB5L9KBUqvYxDJigtGBopgQh0EeDSS+9X8vaGmit5l4zcAfi+UGYPgMQJBAOCJQU8N2HW5SawBo2QX0bnCAAnu5Ilk2QaqwDZbDQaM5JWFcpRpGnjBhsZihHwVWvKCbnq83JhAGRQvKAEepMUCQQDzqjvIyM+Au42nP7SFDHoMjEnHW8Nimvz8zPbyrSUEHe4l9/yS4+BeRPxpwI5xgzp8g1wEYfNeXt08buYwCsy/AkBXWg5mSuSjJ+pZWGnQTtPwiGCrfJy8NteXmGYev11Z5wYmhTwGML1zrRZZp4oTG9u97LA+X6sSMB2RlKbjiKBhAkEAgl/hoSshK+YugwCpHE9ytmgRyeOlhYscNj+NGofeOHezRwmLUSUwlgAfdo4bKU1n69t1TrsCNspXYdCMxcPhjQJAMNxkJ8t2tFMpucCQfWJ09wvFKZSHX1/iD9GKWL0Qk2FcMCg3NXiqei5NL3NYqCWpdC/IfjsAEGCJrTFwp/OoUw==" + }, + "Logs": { + "Filename": "/root/.go-ipfs/logs/events.log", + "MaxAgeDays": 0, + "MaxBackups": 0, + "MaxSizeMB": 0 + }, + "Mounts": { + "IPFS": "/ipfs", + "IPNS": "/ipns" + }, + "Tour": { + "Last": "" + }, + "Version": { + "AutoUpdate": "minor", + "Check": "error", + "CheckDate": "0001-01-01T00:00:00Z", + "CheckPeriod": "172800000000000", + "Current": "0.1.7" + } +} diff --git a/dockertest/server/run.sh b/dockertest/server/run.sh new file mode 100644 index 0000000000000000000000000000000000000000..6c1f4b00578e1a3d4b436324368e2457e30a5a55 --- /dev/null +++ b/dockertest/server/run.sh @@ -0,0 +1,17 @@ +# must be connected to bootstrap node +ipfs bootstrap add /ip4/$BOOTSTRAP_PORT_4011_TCP_ADDR/tcp/$BOOTSTRAP_PORT_4011_TCP_PORT/QmNXuBh8HFsWq68Fid8dMbGNQTh7eG6hV9rr1fQyfmfomE + +# wait for daemon to start/bootstrap +# alternatively use ipfs swarm connect +ipfs daemon & +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 + +# must mount this volume from data container +ipfs add -q /data/file > /data/id + +echo added file. hash is $(cat /data/id) + +# allow ample time for the client to pull the data +sleep 10000000