test: run "functional" tests in 3.1 branch

Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
This commit is contained in:
Gyuho Lee 2018-03-08 00:26:52 -08:00
parent 7a148fee36
commit 0874fcbed4

54
test
View File

@ -18,6 +18,11 @@ source ./build
# build tests with vendored dependencies
etcd_setup_gopath
# build before setting up test GOPATH
if [[ "${PASSES}" == *"functional"* ]]; then
./tools/functional-tester/build
fi
if [ -z "$PASSES" ]; then
PASSES="fmt dep compile build unit"
fi
@ -76,10 +81,55 @@ function integration_pass {
go test -timeout 1m -v ${RACE} -cpu 1,2,4 -run=Example $@ ${TEST}
}
function functional_pass {
# Clean up any data and logs from previous runs
rm -rf ./agent-*
for a in 1 2 3; do
mkdir -p ./agent-$a
./bin/etcd-agent -etcd-path ./bin/etcd -etcd-log-dir "./agent-$a" -port ":${a}9027" &
pid="$!"
agent_pids="${agent_pids} $pid"
done
for a in 1 2 3; do
echo "Waiting for 'etcd-agent' on ${a}9027..."
while ! nc -z localhost ${a}9027; do
sleep 1
done
done
echo "Starting 'etcd-tester'"
./bin/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 1 \
-schedule-cases "0 1 2 3 4 5 6 7 8 9" \
-stress-qps 1000 \
-stress-key-txn-count 100 \
-stress-key-txn-ops 10 \
-exit-on-failure && echo "'etcd-tester' succeeded"
ETCD_TESTER_EXIT_CODE=$?
echo "ETCD_TESTER_EXIT_CODE:" ${ETCD_TESTER_EXIT_CODE}
echo "Waiting for processes to exit"
agent_pids=($agent_pids)
kill -s TERM "${agent_pids[@]}"
for a in "${agent_pids[@]}"; do wait "$a" || true; done
if [[ "${ETCD_TESTER_EXIT_CODE}" -ne "0" ]]; then
echo "--- FAIL: exit code" ${ETCD_TESTER_EXIT_CODE}
exit ${ETCD_TESTER_EXIT_CODE}
fi
}
function cov_pass {
echo "Running code coverage..."
# install gocovmerge before running code coverage from github.com/wadey/gocovmerge
# gocovmerge merges coverage files
# gocovmerge merges coverage files
if ! which gocovmerge >/dev/null; then
echo "gocovmerge not installed"
exit 255
@ -93,7 +143,7 @@ function cov_pass {
mkdir -p "$COVERDIR"
# PKGS_DELIM contains all the core etcd pkgs delimited by ',' which will be profiled for code coverage.
# Integration tests will generate code coverage for those pkgs
# Integration tests will generate code coverage for those pkgs
PKGS_DELIM=$(echo $TEST | sed 's/ /,/g')
# TODO create coverage to e2e test