## etcd Functional Testing [`functional`](https://godoc.org/github.com/coreos/etcd/functional) verifies the correct behavior of etcd under various system and network malfunctions. It sets up an etcd cluster under high pressure loads and continuously injects failures into the cluster. Then it expects the etcd cluster to recover within a few seconds. This has been extremely helpful to find critical bugs. See [`rpcpb.Case`](https://godoc.org/github.com/coreos/etcd/functional/rpcpb#Case) for all failure cases. See [functional.yaml](https://github.com/coreos/etcd/blob/master/functional.yaml) for an example configuration. ### Run locally ```bash PASSES=functional ./test ``` ### Run with Docker ```bash pushd .. make build-docker-functional popd ``` And run [example scripts](./scripts). ```bash # 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 ./scripts/docker-local-tester.sh ``` ## etcd Proxy Proxy layer that simulates various network conditions. Test locally ```bash $ ./build $ ./bin/etcd $ make build-functional $ ./bin/etcd-proxy --help $ ./bin/etcd-proxy --from localhost:23790 --to localhost:2379 --http-port 2378 --verbose $ ETCDCTL_API=3 ./bin/etcdctl --endpoints localhost:2379 put foo bar $ 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 ./tools/benchmark $ ./bin/benchmark \ --endpoints localhost:2379 \ --conns 5 \ --clients 15 \ put \ --key-size 48 \ --val-size 50000 \ --total 10000 < tcp://localhost:2379] $ ETCDCTL_API=3 ./bin/etcdctl \ --endpoints localhost:23790 \ put foo bar # Error: context deadline exceeded $ curl -L http://localhost:2378/pause-tx -X DELETE # unpaused forwarding [tcp://localhost:23790 -> tcp://localhost:2379] ``` Drop client packets ```bash $ curl -L http://localhost:2378/blackhole-tx -X PUT # blackholed; dropping packets [tcp://localhost:23790 -> tcp://localhost:2379] $ ETCDCTL_API=3 ./bin/etcdctl --endpoints localhost:23790 put foo bar # Error: context deadline exceeded $ curl -L http://localhost:2378/blackhole-tx -X DELETE # unblackholed; restart forwarding [tcp://localhost:23790 -> tcp://localhost:2379] ``` Trigger leader election ```bash $ ./build $ make build-functional $ rm -rf /tmp/etcd-proxy-data.s* $ goreman -f ./functional/Procfile-proxy start $ ETCDCTL_API=3 ./bin/etcdctl \ --endpoints localhost:13790,localhost:23790,localhost:33790 \ member list # isolate s1 when s1 is the current leader $ curl -L http://localhost:1381/blackhole-tx -X PUT $ curl -L http://localhost:1381/blackhole-rx -X PUT # s1 becomes follower after election timeout ```