tools/functional-test: add docker support

Commit adds docker bits to run functional tester within containers.

requires:
- docker 1.9 (networking)
- docker-compose
release-2.3
Pawel Palucki 2015-12-15 15:49:09 +01:00
parent 9b0b15c9be
commit 4f5f999847
6 changed files with 85 additions and 1 deletions

1
.gitignore vendored
View File

@ -9,3 +9,4 @@
*.swp
/hack/insta-discovery/.env
*.test
tools/functional-tester/docker/bin

View File

@ -14,4 +14,24 @@ etcd agent is a daemon on each machines. It can start, stop, restart, isolate an
## etcd tester
etcd functional tester control the progress of the functional tests. It calls the the RPC of the etcd agent to simulate various test cases. For example, it can start a three members cluster by sending three start RPC calls to three different etcd agents. It can make one of the member failed by sending stop RPC call to one etcd agent.
etcd functional tester control the progress of the functional tests. It calls the RPC of the etcd agent to simulate various test cases. For example, it can start a three members cluster by sending three start RPC calls to three different etcd agents. It can make one of the member failed by sending stop RPC call to one etcd agent.
## with Docker (optionally)
To run the functional tests using Docker, the provided script can be used to set up an environment using Docker Compose.
Script (on linux):
```sh
./tools/functional-tester/test
```
Running the script requires:
- Docker 1.9+ (with networking support) - to create isolated network
- docker-compose - to create etcd cluster and tester
- A multi-arch Go toolchain (OSX)
Notes:
- Docker image is based on Alpine Linux OS running in privileged mode to allow iptables manipulation.
- To specify testing parameters (etcd-tester arguments) modify tools/functional-tester/docker/docker-compose.yml or start etcd-tester manually
- (OSX) make sure that etcd binary is built for linux/amd64 (eg. `rm bin/etcd;GOOS=linux GOARCH=amd64 ./tools/functional-tester/test`) otherwise you get `exec format error`

4
tools/functional-tester/build Executable file
View File

@ -0,0 +1,4 @@
#!/bin/sh -e
CGO_ENABLED=0 go build -a -installsuffix cgo -ldflags "-s" -o bin/etcd-agent ./tools/functional-tester/etcd-agent
CGO_ENABLED=0 go build -a -installsuffix cgo -ldflags "-s" -o bin/etcd-tester ./tools/functional-tester/etcd-tester

View File

@ -0,0 +1,8 @@
FROM alpine
RUN apk update
RUN apk add -v iptables sudo
ADD bin/etcd-agent /
ADD bin/etcd /
ADD bin/etcd-tester /
RUN mkdir /failure_archive
CMD ["./etcd-agent", "-etcd-path", "./etcd"]

View File

@ -0,0 +1,28 @@
# build according provided Dockerfile
a1:
build: .
privileged: true
net: etcd-functional
a2:
build: .
privileged: true
net: etcd-functional
a3:
build: .
privileged: true
net: etcd-functional
tester:
build: .
privileged: true
net: etcd-functional
command:
- /etcd-tester
- -agent-endpoints
- "172.20.0.2:9027,172.20.0.3:9027,172.20.0.4:9027"
- -limit
- "1"
- -stress-key-count
- "1"
- -stress-key-size
- "1"

23
tools/functional-tester/test Executable file
View File

@ -0,0 +1,23 @@
#!/bin/sh -e
set -x
set -e
# 1. build etcd binaries
[ -f bin/etcd ] || ./build
# 2. build agent & tester
[ -f bin/etcd-agent -a -f bin/etcd-tester ] || ./tools/functional-tester/build
# 3. build docker image (alpine based)
mkdir -p ./tools/functional-tester/docker/bin
cp -v bin/etcd-agent bin/etcd-tester bin/etcd ./tools/functional-tester/docker/bin
docker-compose -f tools/functional-tester/docker/docker-compose.yml build
# 4. create network (assumption - no overlaps)
docker network ls | grep etcd-functional || docker network create --subnet 172.20.0.0/16 etcd-functional
# 5. run cluster and tester (assumption - agents'll get first ip addresses)
docker-compose -f tools/functional-tester/docker/docker-compose.yml up -d a1 a2 a3
# 6. run tester
docker-compose -f tools/functional-tester/docker/docker-compose.yml run tester