diff --git a/scripts/test.sh b/scripts/test.sh index 4523e32df..11c86056b 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -146,6 +146,12 @@ function generic_checker { fi } +function killall_functional_test { + log_callout "Killing all etcd-agent and etcd processes..." + killall -9 etcd-agent + killall -9 etcd +} + function functional_pass { run ./tests/functional/build.sh || exit 1 @@ -166,32 +172,32 @@ function functional_pass { done done + trap killall_functional_test INT + log_callout "functional test START!" run ./bin/etcd-tester --config ./tests/functional/functional.yaml -test.v && log_success "'etcd-tester' succeeded" local etcd_tester_exit_code=$? - if [[ "${etcd_tester_exit_code}" -ne "0" ]]; then - log_error "ETCD_TESTER_EXIT_CODE:" ${etcd_tester_exit_code} - exit 1 - fi - # shellcheck disable=SC2206 agent_pids=($agent_pids) kill -s TERM "${agent_pids[@]}" || true if [[ "${etcd_tester_exit_code}" -ne "0" ]]; then + log_error "ETCD_TESTER_EXIT_CODE:" ${etcd_tester_exit_code} + log_error -e "\\nFAILED! 'tail -1000 /tmp/etcd-functional-1/etcd.log'" - tail -1000 /tmp/etcd-functional-1/etcd.log + tail -100 /tmp/etcd-functional-1/etcd.log log_error -e "\\nFAILED! 'tail -1000 /tmp/etcd-functional-2/etcd.log'" - tail -1000 /tmp/etcd-functional-2/etcd.log + tail -100 /tmp/etcd-functional-2/etcd.log log_error -e "\\nFAILED! 'tail -1000 /tmp/etcd-functional-3/etcd.log'" - tail -1000 /tmp/etcd-functional-3/etcd.log + tail -100 /tmp/etcd-functional-3/etcd.log log_error "--- FAIL: exit code" ${etcd_tester_exit_code} - return ${etcd_tester_exit_code} + exit ${etcd_tester_exit_code} fi + log_success "functional test PASS!" } diff --git a/tests/functional/agent/server.go b/tests/functional/agent/server.go index 81bdec5ab..f76f7258c 100644 --- a/tests/functional/agent/server.go +++ b/tests/functional/agent/server.go @@ -19,7 +19,6 @@ import ( "net" "os" "os/exec" - "strings" "go.etcd.io/etcd/pkg/v3/proxy" "go.etcd.io/etcd/server/v3/embed" @@ -102,17 +101,16 @@ func (srv *Server) StartServe() error { zap.String("listener-address", srv.ln.Addr().String()), ) err = srv.grpcServer.Serve(srv.ln) - if err != nil && strings.Contains(err.Error(), "use of closed network connection") { - srv.lg.Info( - "gRPC server is shut down", + if err != nil { + srv.lg.Warn( + "gRPC server is stopped with error", zap.String("address", srv.address), zap.Error(err), ) } else { - srv.lg.Warn( - "gRPC server returned with error", + srv.lg.Info( + "gRPC server is stopped", zap.String("address", srv.address), - zap.Error(err), ) } return err