mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Cleanup all etcd-agent and etcd processes when the test finishes
There are two cases, when interrupted by users, then forcibly kill all processes. Otherwise, gracefully terminate all processes. Signed-off-by: Benjamin Wang <wachao@vmware.com>
This commit is contained in:
parent
ba0c7c31a7
commit
d8ee37641d
@ -146,6 +146,12 @@ function generic_checker {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function killall_functional_test {
|
||||||
|
log_callout "Killing all etcd-agent and etcd processes..."
|
||||||
|
killall -9 etcd-agent
|
||||||
|
killall -9 etcd
|
||||||
|
}
|
||||||
|
|
||||||
function functional_pass {
|
function functional_pass {
|
||||||
run ./tests/functional/build.sh || exit 1
|
run ./tests/functional/build.sh || exit 1
|
||||||
|
|
||||||
@ -166,32 +172,32 @@ function functional_pass {
|
|||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
|
trap killall_functional_test INT
|
||||||
|
|
||||||
log_callout "functional test START!"
|
log_callout "functional test START!"
|
||||||
run ./bin/etcd-tester --config ./tests/functional/functional.yaml -test.v && log_success "'etcd-tester' succeeded"
|
run ./bin/etcd-tester --config ./tests/functional/functional.yaml -test.v && log_success "'etcd-tester' succeeded"
|
||||||
local etcd_tester_exit_code=$?
|
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
|
# shellcheck disable=SC2206
|
||||||
agent_pids=($agent_pids)
|
agent_pids=($agent_pids)
|
||||||
kill -s TERM "${agent_pids[@]}" || true
|
kill -s TERM "${agent_pids[@]}" || true
|
||||||
|
|
||||||
if [[ "${etcd_tester_exit_code}" -ne "0" ]]; then
|
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'"
|
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'"
|
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'"
|
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}
|
log_error "--- FAIL: exit code" ${etcd_tester_exit_code}
|
||||||
return ${etcd_tester_exit_code}
|
exit ${etcd_tester_exit_code}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
log_success "functional test PASS!"
|
log_success "functional test PASS!"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,6 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"go.etcd.io/etcd/pkg/v3/proxy"
|
"go.etcd.io/etcd/pkg/v3/proxy"
|
||||||
"go.etcd.io/etcd/server/v3/embed"
|
"go.etcd.io/etcd/server/v3/embed"
|
||||||
@ -102,17 +101,16 @@ func (srv *Server) StartServe() error {
|
|||||||
zap.String("listener-address", srv.ln.Addr().String()),
|
zap.String("listener-address", srv.ln.Addr().String()),
|
||||||
)
|
)
|
||||||
err = srv.grpcServer.Serve(srv.ln)
|
err = srv.grpcServer.Serve(srv.ln)
|
||||||
if err != nil && strings.Contains(err.Error(), "use of closed network connection") {
|
if err != nil {
|
||||||
srv.lg.Info(
|
srv.lg.Warn(
|
||||||
"gRPC server is shut down",
|
"gRPC server is stopped with error",
|
||||||
zap.String("address", srv.address),
|
zap.String("address", srv.address),
|
||||||
zap.Error(err),
|
zap.Error(err),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
srv.lg.Warn(
|
srv.lg.Info(
|
||||||
"gRPC server returned with error",
|
"gRPC server is stopped",
|
||||||
zap.String("address", srv.address),
|
zap.String("address", srv.address),
|
||||||
zap.Error(err),
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
|
Loading…
x
Reference in New Issue
Block a user