test(withdocker)!
misc fixes set all nodes to error fix: check return value after cat License: MIT Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
Brian Tiger Chow committed
Dec 14, 2014 at 22:29 UTC
a2cc7dc10780799b99662a3a44e37d9ce3fc787b
17 files changed
+283
Makefile
+5
@@ -17,6 +17,11 @@ test: test_go test_sharness
17
18
test_expensive: test_go_expensive test_sharness_expensive
19
20
+test_docker:
21
+ cd ./src/github.com/jbenet/go-ipfs
22
+ docker build -t zaqwsx_ipfs-test-img .
23
+ cd dockertest/ && make
24
+
25
test_go:
26
go test -test.short ./...
27
dockertest/Makefile
new
+20
@@ -0,0 +1,20 @@
1
+RANDOMSRC = Godeps/_workspace/src/github.com/jbenet/go-random/random
2
+
3
+test: clean setup
4
+ fig build --no-cache
5
+ fig up
6
+
7
+setup: docker_ipfs_image data/file
8
+
9
+docker_ipfs_image:
10
+ docker images | grep zaqwsx_ipfs-test-img
11
+
12
+data/file: bin/random
13
+ cp Makefile ./data/file
14
+
15
+bin/random:
16
+ go build -o ./bin/random ../$(RANDOMSRC)
17
+
18
+clean:
19
+ docker rm $(docker ps -q -a -f status=exited) || true
20
+ rm -f data/file
dockertest/README.md
new
+15
@@ -0,0 +1,15 @@
1
+this is an ipfs integration test
2
+
3
+**requirements**
4
+
5
+* Docker
6
+* fig
7
+* Go
8
+
9
+* ipfs image named "zaqwsx_ipfs-test-img"
10
+
11
+```
12
+make setup
13
+fig build
14
+fig up
15
+```
dockertest/bin/.gitignore
new
+1
@@ -0,0 +1 @@
1
+random
dockertest/bootstrap/Dockerfile
new
+8
@@ -0,0 +1,8 @@
1
+FROM zaqwsx_ipfs-test-img
2
+
3
+RUN ipfs init -b=1024
4
+ADD . /tmp/id
5
+RUN mv -f /tmp/id/config /root/.go-ipfs/config
6
+RUN ipfs id
7
+
8
+EXPOSE 4011 4012/udp
dockertest/bootstrap/README.md
new
+3
@@ -0,0 +1,3 @@
1
+this is a bootstrap peer with an empty bootstrap list
2
+
3
+it listens on 4011 and 4012
dockertest/bootstrap/config
new
+39
@@ -0,0 +1,39 @@
1
+{
2
+ "Identity": {
3
+ "PeerID": "QmNXuBh8HFsWq68Fid8dMbGNQTh7eG6hV9rr1fQyfmfomE",
4
+ "PrivKey": "CAAS4gQwggJeAgEAAoGBAL+E7A0fcQS9+CHO3YAHj+JzHnWyVA7qqtiAIYbTnp9UvHBb2VFj2Q8eeyKFZD5wHoq3AtOqmIb4TUOMEtWYqXnE8o0T9np8vyCRK5dPn5SVoUw9uax6o2X7OxO1HqTcXHNHGbracawJUdwsk4yuZUpzXLez03yocWwneR0JpVJPAgMBAAECgYAXsa4ygW1OFOKZ7CnjKQxYC738+a8EmWvBlTiQoaXCOI2HqRVdyGiWQkMhpjccsmpU5wdmgHiWWinU7YN3AYgV3cP3qAjyNLBFoxy2dKsS9AOWVwRuuRP12tD05kCCjG4rJAX0JEOClOOtzvQ7/bXarMc3/tMHW7TMLNV8MzcYwQJBAOP9aYSHp8VnsO5j32Ju5SjOQorSdcCweqeUxwlAnXz50KdbNSCMypP3TOt7VeiXTuSITtN44yh+eogF5c4ehycCQQDXDHVmPeBN7uqqqZxZwW5pdeJWvx+REiXXCLE6KEPWlcxbw1D9ublpCCFLYuM68rjq1sjsIVGtiV1tYoMdHJSZAkEA0ddMZ070fB0UHFaQJGktQoGVfXB4MQI94kBtcXanfX/xLBgmre7oBYh4o8TBLXMWigFri/iYG41N+iRzf2NZwQJBAIh8rMpufT2ZZLFaoxRIc4ZVvojmFufhR8j6CFnsElpQivq2tWHEDcx+z3rkUWopgXnzRmSwJQHqTDTPsH26lQkCQQCehmxqaQEwE/QKAI8L8YVolgY2cjUGi6qF/awnI584lDSCuJRU3R/c6nc9R8qljtlJYTtp9iUr8vuN+jt48j+6"
5
+ },
6
+ "Datastore": {
7
+ "Type": "leveldb",
8
+ "Path": "/root/.go-ipfs/datastore"
9
+ },
10
+ "Addresses": {
11
+ "Swarm": [
12
+ "/ip4/0.0.0.0/tcp/4011",
13
+ "/ip4/0.0.0.0/udp/4012/utp"
14
+ ],
15
+ "API": "/ip4/127.0.0.1/tcp/5001"
16
+ },
17
+ "Mounts": {
18
+ "IPFS": "/ipfs",
19
+ "IPNS": "/ipns"
20
+ },
21
+ "Version": {
22
+ "Current": "0.1.7",
23
+ "Check": "error",
24
+ "CheckDate": "0001-01-01T00:00:00Z",
25
+ "CheckPeriod": "172800000000000",
26
+ "AutoUpdate": "minor"
27
+ },
28
+ "Bootstrap": [
29
+ ],
30
+ "Tour": {
31
+ "Last": ""
32
+ },
33
+ "Logs": {
34
+ "Filename": "/root/.go-ipfs/logs/events.log",
35
+ "MaxSizeMB": 0,
36
+ "MaxBackups": 0,
37
+ "MaxAgeDays": 0
38
+ }
39
+}
dockertest/build/.gitkeep
dockertest/client/Dockerfile
new
+11
@@ -0,0 +1,11 @@
1
+FROM zaqwsx_ipfs-test-img
2
+
3
+RUN ipfs init -b=1024
4
+ADD . /tmp/id
5
+RUN mv -f /tmp/id/config /root/.go-ipfs/config
6
+RUN ipfs id
7
+
8
+EXPOSE 4031 4032/udp
9
+
10
+ENTRYPOINT ["/bin/bash"]
11
+CMD ["/tmp/id/run.sh"]
dockertest/client/config
new
+39
@@ -0,0 +1,39 @@
1
+{
2
+ "Addresses": {
3
+ "API": "/ip4/127.0.0.1/tcp/5001",
4
+ "Swarm": [
5
+ "/ip4/0.0.0.0/tcp/4031",
6
+ "/ip4/0.0.0.0/udp/4032/utp"
7
+ ]
8
+ },
9
+ "Bootstrap": [
10
+ ],
11
+ "Datastore": {
12
+ "Path": "/root/.go-ipfs/datastore",
13
+ "Type": "leveldb"
14
+ },
15
+ "Identity": {
16
+ "PeerID": "Qmbtc35vdjVh5o9w2AaT2SgcWwigsaoZUpRfq2FSrFD6mb",
17
+ "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=="
18
+ },
19
+ "Logs": {
20
+ "Filename": "/root/.go-ipfs/logs/events.log",
21
+ "MaxAgeDays": 0,
22
+ "MaxBackups": 0,
23
+ "MaxSizeMB": 0
24
+ },
25
+ "Mounts": {
26
+ "IPFS": "/ipfs",
27
+ "IPNS": "/ipns"
28
+ },
29
+ "Tour": {
30
+ "Last": ""
31
+ },
32
+ "Version": {
33
+ "AutoUpdate": "minor",
34
+ "Check": "error",
35
+ "CheckDate": "0001-01-01T00:00:00Z",
36
+ "CheckPeriod": "172800000000000",
37
+ "Current": "0.1.7"
38
+ }
39
+}
dockertest/client/run.sh
new
+29
@@ -0,0 +1,29 @@
1
+ipfs bootstrap add /ip4/$BOOTSTRAP_PORT_4011_TCP_ADDR/tcp/$BOOTSTRAP_PORT_4011_TCP_PORT/QmNXuBh8HFsWq68Fid8dMbGNQTh7eG6hV9rr1fQyfmfomE
2
+
3
+ipfs daemon &
4
+sleep 3
5
+
6
+while [ ! -f /data/id ]
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)
12
+
13
+ipfs cat $(cat /data/id) > file
14
+
15
+cat file
16
+
17
+if (($? > 0)); then
18
+ printf '%s\n' 'ipfs cat failed.' >&2
19
+ exit 1
20
+fi
21
+
22
+diff -u file /data/file
23
+
24
+if (($? > 0)); then
25
+ printf '%s\n' 'files did not match' >&2
26
+ exit 1
27
+fi
28
+
29
+echo "success"
dockertest/data/Dockerfile
new
+5
@@ -0,0 +1,5 @@
1
+FROM ubuntu
2
+
3
+ADD file /data/file
4
+
5
+VOLUME ["/data"]
dockertest/fig.yml
new
+36
@@ -0,0 +1,36 @@
1
+data:
2
+ build: ./data
3
+ volumes:
4
+ - /data
5
+
6
+bootstrap:
7
+ build: ./bootstrap
8
+ expose:
9
+ - "4011"
10
+ - "4012/udp"
11
+ environment:
12
+ IPFS_LOGGING: error
13
+
14
+server:
15
+ build: ./server
16
+ links:
17
+ - bootstrap
18
+ volumes_from:
19
+ - data
20
+ expose:
21
+ - "4021"
22
+ - "4022/udp"
23
+ environment:
24
+ IPFS_LOGGING: error
25
+
26
+client:
27
+ build: ./client
28
+ links:
29
+ - bootstrap
30
+ volumes_from:
31
+ - data
32
+ expose:
33
+ - "4031"
34
+ - "4032/udp"
35
+ environment:
36
+ IPFS_LOGGING: error
dockertest/server/Dockerfile
new
+12
@@ -0,0 +1,12 @@
1
+FROM zaqwsx_ipfs-test-img
2
+
3
+RUN ipfs init -b=1024
4
+ADD . /tmp/test
5
+RUN mv -f /tmp/test/config /root/.go-ipfs/config
6
+RUN ipfs id
7
+RUN chmod +x /tmp/test/run.sh
8
+
9
+EXPOSE 4021 4022/udp
10
+
11
+ENTRYPOINT ["/bin/bash"]
12
+CMD ["/tmp/test/run.sh"]
dockertest/server/README.md
new
+4
@@ -0,0 +1,4 @@
1
+**requirements**
2
+
3
+* docker container with bootstrap node linked as "bootstrap" with ID QmNXuBh8HFsWq68Fid8dMbGNQTh7eG6hV9rr1fQyfmfomE
4
+* file in data volume, internally mapped to /data/file
dockertest/server/config
new
+39
@@ -0,0 +1,39 @@
1
+{
2
+ "Addresses": {
3
+ "API": "/ip4/127.0.0.1/tcp/5001",
4
+ "Swarm": [
5
+ "/ip4/0.0.0.0/tcp/4021",
6
+ "/ip4/0.0.0.0/udp/4022/utp"
7
+ ]
8
+ },
9
+ "Bootstrap": [
10
+ ],
11
+ "Datastore": {
12
+ "Path": "/root/.go-ipfs/datastore",
13
+ "Type": "leveldb"
14
+ },
15
+ "Identity": {
16
+ "PeerID": "Qmbtc2C7rqmAfdeMTM7FX4YF8CeBumMCfk5Z1GBCMbMTfY",
17
+ "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=="
18
+ },
19
+ "Logs": {
20
+ "Filename": "/root/.go-ipfs/logs/events.log",
21
+ "MaxAgeDays": 0,
22
+ "MaxBackups": 0,
23
+ "MaxSizeMB": 0
24
+ },
25
+ "Mounts": {
26
+ "IPFS": "/ipfs",
27
+ "IPNS": "/ipns"
28
+ },
29
+ "Tour": {
30
+ "Last": ""
31
+ },
32
+ "Version": {
33
+ "AutoUpdate": "minor",
34
+ "Check": "error",
35
+ "CheckDate": "0001-01-01T00:00:00Z",
36
+ "CheckPeriod": "172800000000000",
37
+ "Current": "0.1.7"
38
+ }
39
+}
dockertest/server/run.sh
new
+17
@@ -0,0 +1,17 @@
1
+# must be connected to bootstrap node
2
+ipfs bootstrap add /ip4/$BOOTSTRAP_PORT_4011_TCP_ADDR/tcp/$BOOTSTRAP_PORT_4011_TCP_PORT/QmNXuBh8HFsWq68Fid8dMbGNQTh7eG6hV9rr1fQyfmfomE
3
+
4
+# wait for daemon to start/bootstrap
5
+# alternatively use ipfs swarm connect
6
+ipfs daemon &
7
+sleep 3
8
+echo $(ipfs id)
9
+# TODO instead of bootrapping: ipfs swarm connect /ip4/$BOOTSTRAP_PORT_4011_TCP_ADDR/tcp/$BOOTSTRAP_PORT_4011_TCP_PORT/QmNXuBh8HFsWq68Fid8dMbGNQTh7eG6hV9rr1fQyfmfomE
10
+
11
+# must mount this volume from data container
12
+ipfs add -q /data/file > /data/id
13
+
14
+echo added file. hash is $(cat /data/id)
15
+
16
+# allow ample time for the client to pull the data
17
+sleep 10000000