Skip to content

Commit

Permalink
Merge pull request #9323 from gyuho/functional-tester-guide
Browse files Browse the repository at this point in the history
*: clean up functional tester guide with local cluster, docker container
  • Loading branch information
gyuho authored Feb 14, 2018
2 parents 10185b1 + 0210d27 commit 1e9ba31
Show file tree
Hide file tree
Showing 12 changed files with 147 additions and 196 deletions.
4 changes: 2 additions & 2 deletions Dockerfile-functional-tester
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ RUN go get -v github.com/coreos/gofail \
&& cp ./bin/etcd-agent /etcd-agent \
&& cp ./bin/etcd-tester /etcd-tester \
&& cp ./bin/etcd-runner /etcd-runner \
&& go build -v -o /benchmark ./cmd/tools/benchmark \
&& go build -v -o /etcd-test-proxy ./cmd/tools/etcd-test-proxy \
&& go build -v -o /benchmark ./tools/benchmark \
&& go build -v -o /etcd-test-proxy ./tools/etcd-test-proxy \
&& popd \
&& rm -rf ${GOPATH}/src/github.com/coreos/etcd
2 changes: 1 addition & 1 deletion hack/scripts-dev/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ docker-dns-srv-test-certs-wildcard-run:
# make build-etcd-test-proxy -f ./hack/scripts-dev/Makefile

build-etcd-test-proxy:
go build -v -o ./bin/etcd-test-proxy ./cmd/tools/etcd-test-proxy
go build -v -o ./bin/etcd-test-proxy ./tools/etcd-test-proxy



Expand Down
2 changes: 1 addition & 1 deletion tools/etcd-test-proxy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ $ ETCDCTL_API=3 ./bin/etcdctl --endpoints localhost:23790 put foo bar
Proxy overhead per request is under 500μs

```bash
$ go build -v -o ./bin/benchmark ./cmd/tools/benchmark
$ go build -v -o ./bin/benchmark ./tools/benchmark

$ ./bin/benchmark \
--endpoints localhost:2379 \
Expand Down
30 changes: 20 additions & 10 deletions tools/functional-tester/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ etcd functional test suite tests the functionality of an etcd cluster with a foc

etcd functional test suite has two components: etcd-agent and etcd-tester. etcd-agent runs on every test machines and etcd-tester is a single controller of the test. etcd-tester controls all the etcd-agent to start etcd clusters and simulate various failure cases.

## requirements
## Requirements

The environment of the cluster must be stable enough, so etcd test suite can assume that most of the failures are generated by itself.

Expand All @@ -18,8 +18,8 @@ etcd functional tester control the progress of the functional tests. It calls th

### Run locally

```
$ PASSES=functional ./test
```bash
PASSES=functional ./test
```

### Run with Docker
Expand All @@ -29,8 +29,7 @@ To run locally, first build tester image:
```bash
pushd ../..

GO_VERSION=1.9.3 \
make build-docker-functional-tester \
make build-docker-functional-tester \
-f ./hack/scripts-dev/Makefile

popd
Expand All @@ -39,9 +38,20 @@ popd
And run [example scripts](./scripts).

```bash
./scripts/agent-1.sh
./scripts/agent-2.sh
./scripts/agent-3.sh

./scripts/tester-limit.sh
# run 3 agents for 3-node local etcd cluster
./scripts/docker-local-agent.sh 1
./scripts/docker-local-agent.sh 2
./scripts/docker-local-agent.sh 3

# to run only 1 tester round
LIMIT=1 ./scripts/docker-local-tester.sh

# to run long-running tests with no limit
LIMIT=1 ./scripts/docker-local-tester.sh

# to run only 1 tester round with election runner and others
# default is STRESSER="keys,lease"
LIMIT=1 \
STRESSER="keys,lease,election-runner,watch-runner,lock-racer-runner,lease-runner" \
./scripts/docker-local-tester.sh
```
37 changes: 0 additions & 37 deletions tools/functional-tester/scripts/agent-1.sh

This file was deleted.

37 changes: 0 additions & 37 deletions tools/functional-tester/scripts/agent-2.sh

This file was deleted.

37 changes: 0 additions & 37 deletions tools/functional-tester/scripts/agent-3.sh

This file was deleted.

58 changes: 58 additions & 0 deletions tools/functional-tester/scripts/docker-local-agent.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/env bash

<<COMMENT
# run 3 agents for 3-node local etcd cluster
./scripts/docker-local-agent.sh 1
./scripts/docker-local-agent.sh 2
./scripts/docker-local-agent.sh 3
COMMENT

if ! [[ "${0}" =~ "scripts/docker-local-agent.sh" ]]; then
echo "must be run from tools/functional-tester"
exit 255
fi

if [[ -z "${GO_VERSION}" ]]; then
GO_VERSION=1.9.4
fi
echo "Running with GO_VERSION:" ${GO_VERSION}

if [[ -z ${1} ]]; then
echo "Expected second argument: 1, 2, or 3"
exit 255
else
case ${1} in
1) ;;
2) ;;
3) ;;
*) echo "Expected second argument 1, 2, or 3, got" \"${1}\"
exit 255 ;;
esac
AGENT_NAME="agent-${1}"
AGENT_PORT_FLAG="--port :${1}9027"
FAILPOINT_ADDR_FLAG="--failpoint-addr :738${1}"
fi
echo "AGENT_NAME:" ${AGENT_NAME}
echo "AGENT_PORT_FLAG:" ${AGENT_PORT_FLAG}
echo "FAILPOINT_ADDR_FLAG:" ${FAILPOINT_ADDR_FLAG}

if [[ -z "${ETCD_EXEC_PATH}" ]]; then
ETCD_EXEC_PATH=/etcd
elif [[ "${ETCD_EXEC_PATH}" != "/etcd-failpoints" ]]; then
echo "Cannot find etcd executable:" ${ETCD_EXEC_PATH}
exit 255
fi
echo "ETCD_EXEC_PATH:" ${ETCD_EXEC_PATH}

rm -rf `pwd`/${AGENT_NAME} && mkdir -p `pwd`/${AGENT_NAME}
docker run \
--rm \
--net=host \
--name ${AGENT_NAME} \
--mount type=bind,source=`pwd`/${AGENT_NAME},destination=/${AGENT_NAME} \
gcr.io/etcd-development/etcd-functional-tester:go${GO_VERSION} \
/bin/bash -c "/etcd-agent \
--etcd-path ${ETCD_EXEC_PATH} \
--etcd-log-dir /${AGENT_NAME} \
${AGENT_PORT_FLAG} \
${FAILPOINT_ADDR_FLAG}"
65 changes: 65 additions & 0 deletions tools/functional-tester/scripts/docker-local-tester.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/usr/bin/env bash

<<COMMENT
# to run with different Go version
# requires prebuilt Docker image
# GO_VERSION=1.9.4 make build-docker-functional-tester -f ./hack/scripts-dev/Makefile
GO_VERSION=1.9.4 ./scripts/docker-local-tester.sh
# to run only 1 tester round
LIMIT=1 ./scripts/docker-local-tester.sh
# to run long-running tests with no limit
LIMIT=1 ./scripts/docker-local-tester.sh
# to run only 1 tester round with election runner and others
# default is STRESSER="keys,lease"
LIMIT=1 \
STRESSER="keys,lease,election-runner,watch-runner,lock-racer-runner,lease-runner" \
./scripts/docker-local-tester.sh
# TODO: make stresser QPS configurable
COMMENT

if ! [[ "${0}" =~ "scripts/docker-local-tester.sh" ]]; then
echo "must be run from tools/functional-tester"
exit 255
fi

if [[ -z "${GO_VERSION}" ]]; then
GO_VERSION=1.9.4
fi
echo "Running with GO_VERSION:" ${GO_VERSION}

if [[ "${LIMIT}" ]]; then
LIMIT_FLAG="--limit ${LIMIT}"
echo "Running with:" ${LIMIT_FLAG}
else
echo "Running with no limit"
fi

if [[ "${STRESSER}" ]]; then
STRESSER_FLAG="--stresser ${STRESSER}"
else
STRESSER_FLAG="--stresser keys,lease"
fi
echo "Running with:" ${STRESSER_FLAG}

docker run \
--rm \
--net=host \
--name tester \
gcr.io/etcd-development/etcd-functional-tester:go${GO_VERSION} \
/bin/bash -c "/etcd-tester \
--agent-endpoints '127.0.0.1:19027,127.0.0.1:29027,127.0.0.1:39027' \
--client-ports 1379,2379,3379 \
--advertise-client-ports 13790,23790,33790 \
--peer-ports 1380,2380,3380 \
--advertise-peer-ports 13800,23800,33800 \
${LIMIT_FLAG} \
--etcd-runner /etcd-runner \
--stress-qps=2500 \
--stress-key-txn-count 100 \
--stress-key-txn-ops 10 \
${STRESSER_FLAG} \
--exit-on-failure"
24 changes: 0 additions & 24 deletions tools/functional-tester/scripts/tester-limit.sh

This file was deleted.

25 changes: 0 additions & 25 deletions tools/functional-tester/scripts/tester-runner.sh

This file was deleted.

22 changes: 0 additions & 22 deletions tools/functional-tester/scripts/tester.sh

This file was deleted.

0 comments on commit 1e9ba31

Please sign in to comment.