mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
E2E tests should log commandlines used to spawn etcd or etcd proxy binaries.
This commit is contained in:
parent
f5c26814ab
commit
582d02e7f5
@ -27,6 +27,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"go.etcd.io/etcd/pkg/v3/expect"
|
"go.etcd.io/etcd/pkg/v3/expect"
|
||||||
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
|
||||||
type proxyEtcdProcess struct {
|
type proxyEtcdProcess struct {
|
||||||
@ -115,6 +116,7 @@ func (p *proxyEtcdProcess) WithStopSignal(sig os.Signal) os.Signal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type proxyProc struct {
|
type proxyProc struct {
|
||||||
|
lg *zap.Logger
|
||||||
execPath string
|
execPath string
|
||||||
args []string
|
args []string
|
||||||
ep string
|
ep string
|
||||||
@ -130,7 +132,7 @@ func (pp *proxyProc) start() error {
|
|||||||
if pp.proc != nil {
|
if pp.proc != nil {
|
||||||
panic("already started")
|
panic("already started")
|
||||||
}
|
}
|
||||||
proc, err := spawnCmd(append([]string{pp.execPath}, pp.args...))
|
proc, err := spawnCmdWithLogger(pp.lg, append([]string{pp.execPath}, pp.args...))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -192,6 +194,7 @@ func newProxyV2Proc(cfg *etcdServerProcessConfig) *proxyV2Proc {
|
|||||||
}
|
}
|
||||||
return &proxyV2Proc{
|
return &proxyV2Proc{
|
||||||
proxyProc{
|
proxyProc{
|
||||||
|
lg: cfg.lg,
|
||||||
execPath: cfg.execPath,
|
execPath: cfg.execPath,
|
||||||
args: append(args, cfg.tlsArgs...),
|
args: append(args, cfg.tlsArgs...),
|
||||||
ep: listenAddr,
|
ep: listenAddr,
|
||||||
@ -276,6 +279,7 @@ func newProxyV3Proc(cfg *etcdServerProcessConfig) *proxyV3Proc {
|
|||||||
}
|
}
|
||||||
return &proxyV3Proc{
|
return &proxyV3Proc{
|
||||||
proxyProc{
|
proxyProc{
|
||||||
|
lg: cfg.lg,
|
||||||
execPath: cfg.execPath,
|
execPath: cfg.execPath,
|
||||||
args: append(args, tlsArgs...),
|
args: append(args, tlsArgs...),
|
||||||
ep: listenAddr,
|
ep: listenAddr,
|
||||||
|
@ -25,6 +25,7 @@ import (
|
|||||||
|
|
||||||
"go.etcd.io/etcd/server/v3/etcdserver"
|
"go.etcd.io/etcd/server/v3/etcdserver"
|
||||||
"go.etcd.io/etcd/tests/v3/integration"
|
"go.etcd.io/etcd/tests/v3/integration"
|
||||||
|
"go.uber.org/zap/zaptest"
|
||||||
)
|
)
|
||||||
|
|
||||||
const etcdProcessBasePort = 20000
|
const etcdProcessBasePort = 20000
|
||||||
@ -225,6 +226,8 @@ func (cfg *etcdProcessClusterConfig) peerScheme() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (cfg *etcdProcessClusterConfig) etcdServerProcessConfigs(tb testing.TB) []*etcdServerProcessConfig {
|
func (cfg *etcdProcessClusterConfig) etcdServerProcessConfigs(tb testing.TB) []*etcdServerProcessConfig {
|
||||||
|
lg := zaptest.NewLogger(tb)
|
||||||
|
|
||||||
if cfg.basePort == 0 {
|
if cfg.basePort == 0 {
|
||||||
cfg.basePort = etcdProcessBasePort
|
cfg.basePort = etcdProcessBasePort
|
||||||
}
|
}
|
||||||
@ -309,6 +312,7 @@ func (cfg *etcdProcessClusterConfig) etcdServerProcessConfigs(tb testing.TB) []*
|
|||||||
}
|
}
|
||||||
|
|
||||||
etcdCfgs[i] = &etcdServerProcessConfig{
|
etcdCfgs[i] = &etcdServerProcessConfig{
|
||||||
|
lg: lg,
|
||||||
execPath: cfg.execPath,
|
execPath: cfg.execPath,
|
||||||
args: args,
|
args: args,
|
||||||
tlsArgs: cfg.tlsArgs(),
|
tlsArgs: cfg.tlsArgs(),
|
||||||
|
@ -21,6 +21,7 @@ import (
|
|||||||
|
|
||||||
"go.etcd.io/etcd/client/pkg/v3/fileutil"
|
"go.etcd.io/etcd/client/pkg/v3/fileutil"
|
||||||
"go.etcd.io/etcd/pkg/v3/expect"
|
"go.etcd.io/etcd/pkg/v3/expect"
|
||||||
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -50,6 +51,7 @@ type etcdServerProcess struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type etcdServerProcessConfig struct {
|
type etcdServerProcessConfig struct {
|
||||||
|
lg *zap.Logger
|
||||||
execPath string
|
execPath string
|
||||||
args []string
|
args []string
|
||||||
tlsArgs []string
|
tlsArgs []string
|
||||||
@ -88,7 +90,7 @@ func (ep *etcdServerProcess) Start() error {
|
|||||||
if ep.proc != nil {
|
if ep.proc != nil {
|
||||||
panic("already started")
|
panic("already started")
|
||||||
}
|
}
|
||||||
proc, err := spawnCmd(append([]string{ep.cfg.execPath}, ep.cfg.args...))
|
proc, err := spawnCmdWithLogger(ep.cfg.lg, append([]string{ep.cfg.execPath}, ep.cfg.args...))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -21,14 +21,25 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
|
|
||||||
"go.etcd.io/etcd/pkg/v3/expect"
|
"go.etcd.io/etcd/pkg/v3/expect"
|
||||||
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
|
||||||
const noOutputLineCount = 0 // regular binaries emit no extra lines
|
const noOutputLineCount = 0 // regular binaries emit no extra lines
|
||||||
|
|
||||||
func spawnCmd(args []string) (*expect.ExpectProcess, error) {
|
func spawnCmd(args []string) (*expect.ExpectProcess, error) {
|
||||||
|
return spawnCmdWithLogger(zap.NewNop(), args)
|
||||||
|
}
|
||||||
|
|
||||||
|
func spawnCmdWithLogger(lg *zap.Logger, args []string) (*expect.ExpectProcess, error) {
|
||||||
|
wd, err := os.Getwd()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
if args[0] == ctlBinPath+"3" {
|
if args[0] == ctlBinPath+"3" {
|
||||||
env := append(os.Environ(), "ETCDCTL_API=3")
|
env := append(os.Environ(), "ETCDCTL_API=3")
|
||||||
|
lg.Info("spawning process with ETCDCTL_API=3", zap.Strings("args", args), zap.String("working-dir", wd))
|
||||||
return expect.NewExpectWithEnv(ctlBinPath, args[1:], env)
|
return expect.NewExpectWithEnv(ctlBinPath, args[1:], env)
|
||||||
}
|
}
|
||||||
|
lg.Info("spawning process", zap.Strings("args", args), zap.String("working-dir", wd))
|
||||||
return expect.NewExpect(args[0], args[1:]...)
|
return expect.NewExpect(args[0], args[1:]...)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user