mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-24 03:47:45 +08:00
Merge pull request #451 from jbenet/feat/docker-test
first docker-driven integration test
This commit is contained in:
commit
97dacd484d
1
.dockerignore
Normal file
1
.dockerignore
Normal file
@ -0,0 +1 @@
|
||||
.git
|
||||
5
Makefile
5
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 ./...
|
||||
|
||||
|
||||
36
dockertest/Makefile
Normal file
36
dockertest/Makefile
Normal file
@ -0,0 +1,36 @@
|
||||
RANDOMSRC = Godeps/_workspace/src/github.com/jbenet/go-random/random
|
||||
IPFS_DOCKER_IMAGE = zaqwsx_ipfs-test-img
|
||||
|
||||
test: clean setup
|
||||
fig build --no-cache
|
||||
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/filetiny data/filerand
|
||||
|
||||
save_logs:
|
||||
sh bin/save_logs.sh
|
||||
|
||||
docker_ipfs_image:
|
||||
docker images | grep $(IPFS_DOCKER_IMAGE)
|
||||
|
||||
data/filetiny: Makefile
|
||||
cp Makefile ./data/filetiny # simple
|
||||
|
||||
data/filerand: bin/random
|
||||
./bin/random 1000000 > ./data/filerand
|
||||
|
||||
bin/random:
|
||||
go build -o ./bin/random ../$(RANDOMSRC)
|
||||
|
||||
clean:
|
||||
sh bin/clean.sh
|
||||
fig stop
|
||||
fig rm -v --force
|
||||
rm -f bin/random
|
||||
rm -f data/filetiny
|
||||
rm -f data/filerand
|
||||
rm -rf build/*
|
||||
15
dockertest/README.md
Normal file
15
dockertest/README.md
Normal file
@ -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
|
||||
```
|
||||
1
dockertest/bin/.gitignore
vendored
Normal file
1
dockertest/bin/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
random
|
||||
1
dockertest/bin/clean.sh
Normal file
1
dockertest/bin/clean.sh
Normal file
@ -0,0 +1 @@
|
||||
docker rm -f $( docker ps -q -a -f status=exited ) || true
|
||||
8
dockertest/bin/save_logs.sh
Normal file
8
dockertest/bin/save_logs.sh
Normal file
@ -0,0 +1,8 @@
|
||||
# STRIP strips color from terminal output
|
||||
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
|
||||
8
dockertest/bootstrap/Dockerfile
Normal file
8
dockertest/bootstrap/Dockerfile
Normal file
@ -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
|
||||
3
dockertest/bootstrap/README.md
Normal file
3
dockertest/bootstrap/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
this is a bootstrap peer with an empty bootstrap list
|
||||
|
||||
it listens on 4011 and 4012
|
||||
39
dockertest/bootstrap/config
Normal file
39
dockertest/bootstrap/config
Normal file
@ -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
|
||||
}
|
||||
}
|
||||
2
dockertest/build/.gitignore
vendored
Normal file
2
dockertest/build/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
*.log
|
||||
go-random
|
||||
0
dockertest/build/.gitkeep
Normal file
0
dockertest/build/.gitkeep
Normal file
11
dockertest/client/Dockerfile
Normal file
11
dockertest/client/Dockerfile
Normal file
@ -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"]
|
||||
39
dockertest/client/config
Normal file
39
dockertest/client/config
Normal file
@ -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"
|
||||
}
|
||||
}
|
||||
47
dockertest/client/run.sh
Normal file
47
dockertest/client/run.sh
Normal file
@ -0,0 +1,47 @@
|
||||
ipfs bootstrap add /ip4/$BOOTSTRAP_PORT_4011_TCP_ADDR/tcp/$BOOTSTRAP_PORT_4011_TCP_PORT/QmNXuBh8HFsWq68Fid8dMbGNQTh7eG6hV9rr1fQyfmfomE
|
||||
|
||||
ipfs daemon &
|
||||
sleep 3
|
||||
|
||||
while [ ! -f /data/idtiny ]
|
||||
do
|
||||
echo waiting for server to add the file...
|
||||
sleep 1
|
||||
done
|
||||
echo client found file with hash: $(cat /data/idtiny)
|
||||
|
||||
ipfs cat $(cat /data/idtiny) > filetiny
|
||||
|
||||
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
|
||||
printf '%s\n' 'ipfs cat failed' >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
diff -u filerand /data/filerand
|
||||
|
||||
if (($? > 0)); then
|
||||
printf '%s\n' 'files did not match' >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "success"
|
||||
1
dockertest/data/.gitignore
vendored
Normal file
1
dockertest/data/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
file*
|
||||
6
dockertest/data/Dockerfile
Normal file
6
dockertest/data/Dockerfile
Normal file
@ -0,0 +1,6 @@
|
||||
FROM ubuntu
|
||||
|
||||
ADD filetiny /data/filetiny
|
||||
ADD filerand /data/filerand
|
||||
|
||||
VOLUME ["/data"]
|
||||
37
dockertest/fig.yml
Normal file
37
dockertest/fig.yml
Normal file
@ -0,0 +1,37 @@
|
||||
data:
|
||||
build: ./data
|
||||
volumes:
|
||||
- /data
|
||||
command: sleep 1000000
|
||||
|
||||
bootstrap:
|
||||
build: ./bootstrap
|
||||
expose:
|
||||
- "4011"
|
||||
- "4012/udp"
|
||||
environment:
|
||||
IPFS_LOGGING: debug
|
||||
|
||||
server:
|
||||
build: ./server
|
||||
links:
|
||||
- bootstrap
|
||||
volumes_from:
|
||||
- data
|
||||
expose:
|
||||
- "4021"
|
||||
- "4022/udp"
|
||||
environment:
|
||||
IPFS_LOGGING: debug
|
||||
|
||||
client:
|
||||
build: ./client
|
||||
links:
|
||||
- bootstrap
|
||||
volumes_from:
|
||||
- data
|
||||
expose:
|
||||
- "4031"
|
||||
- "4032/udp"
|
||||
environment:
|
||||
IPFS_LOGGING: debug
|
||||
12
dockertest/server/Dockerfile
Normal file
12
dockertest/server/Dockerfile
Normal file
@ -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"]
|
||||
4
dockertest/server/README.md
Normal file
4
dockertest/server/README.md
Normal file
@ -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
|
||||
39
dockertest/server/config
Normal file
39
dockertest/server/config
Normal file
@ -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"
|
||||
}
|
||||
}
|
||||
18
dockertest/server/run.sh
Normal file
18
dockertest/server/run.sh
Normal file
@ -0,0 +1,18 @@
|
||||
# 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
|
||||
# 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/filetiny > /data/idtiny
|
||||
echo added tiny file. hash is $(cat /data/idtiny)
|
||||
|
||||
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
|
||||
sleep 10000000
|
||||
Loading…
Reference in New Issue
Block a user