diff --git a/tests/e2e/cluster_proxy_test.go b/tests/e2e/cluster_proxy_test.go index 7a5740d14..47ac18f96 100644 --- a/tests/e2e/cluster_proxy_test.go +++ b/tests/e2e/cluster_proxy_test.go @@ -27,6 +27,7 @@ import ( "strings" "go.etcd.io/etcd/pkg/v3/expect" + "go.uber.org/zap" ) type proxyEtcdProcess struct { @@ -115,6 +116,7 @@ func (p *proxyEtcdProcess) WithStopSignal(sig os.Signal) os.Signal { } type proxyProc struct { + lg *zap.Logger execPath string args []string ep string @@ -130,7 +132,7 @@ func (pp *proxyProc) start() error { if pp.proc != nil { 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 { return err } @@ -192,6 +194,7 @@ func newProxyV2Proc(cfg *etcdServerProcessConfig) *proxyV2Proc { } return &proxyV2Proc{ proxyProc{ + lg: cfg.lg, execPath: cfg.execPath, args: append(args, cfg.tlsArgs...), ep: listenAddr, @@ -276,6 +279,7 @@ func newProxyV3Proc(cfg *etcdServerProcessConfig) *proxyV3Proc { } return &proxyV3Proc{ proxyProc{ + lg: cfg.lg, execPath: cfg.execPath, args: append(args, tlsArgs...), ep: listenAddr, diff --git a/tests/e2e/cluster_test.go b/tests/e2e/cluster_test.go index cc47121fa..f30d7db23 100644 --- a/tests/e2e/cluster_test.go +++ b/tests/e2e/cluster_test.go @@ -25,6 +25,7 @@ import ( "go.etcd.io/etcd/server/v3/etcdserver" "go.etcd.io/etcd/tests/v3/integration" + "go.uber.org/zap/zaptest" ) const etcdProcessBasePort = 20000 @@ -225,6 +226,8 @@ func (cfg *etcdProcessClusterConfig) peerScheme() string { } func (cfg *etcdProcessClusterConfig) etcdServerProcessConfigs(tb testing.TB) []*etcdServerProcessConfig { + lg := zaptest.NewLogger(tb) + if cfg.basePort == 0 { cfg.basePort = etcdProcessBasePort } @@ -309,6 +312,7 @@ func (cfg *etcdProcessClusterConfig) etcdServerProcessConfigs(tb testing.TB) []* } etcdCfgs[i] = &etcdServerProcessConfig{ + lg: lg, execPath: cfg.execPath, args: args, tlsArgs: cfg.tlsArgs(), diff --git a/tests/e2e/etcd_process.go b/tests/e2e/etcd_process.go index 55f3494eb..aecd56ce3 100644 --- a/tests/e2e/etcd_process.go +++ b/tests/e2e/etcd_process.go @@ -21,6 +21,7 @@ import ( "go.etcd.io/etcd/client/pkg/v3/fileutil" "go.etcd.io/etcd/pkg/v3/expect" + "go.uber.org/zap" ) var ( @@ -50,6 +51,7 @@ type etcdServerProcess struct { } type etcdServerProcessConfig struct { + lg *zap.Logger execPath string args []string tlsArgs []string @@ -88,7 +90,7 @@ func (ep *etcdServerProcess) Start() error { if ep.proc != nil { 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 { return err } diff --git a/tests/e2e/etcd_spawn_nocov.go b/tests/e2e/etcd_spawn_nocov.go index b70240496..e753a967f 100644 --- a/tests/e2e/etcd_spawn_nocov.go +++ b/tests/e2e/etcd_spawn_nocov.go @@ -21,14 +21,25 @@ import ( "os" "go.etcd.io/etcd/pkg/v3/expect" + "go.uber.org/zap" ) const noOutputLineCount = 0 // regular binaries emit no extra lines 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" { 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) } + lg.Info("spawning process", zap.Strings("args", args), zap.String("working-dir", wd)) return expect.NewExpect(args[0], args[1:]...) }