diff --git a/tests/e2e/etcd_spawn_cov.go b/tests/e2e/etcd_spawn_cov.go index 7f11423f5..e71c752c7 100644 --- a/tests/e2e/etcd_spawn_cov.go +++ b/tests/e2e/etcd_spawn_cov.go @@ -19,31 +19,41 @@ package e2e import ( "fmt" - "log" "os" "path/filepath" + "strings" "syscall" "time" "go.etcd.io/etcd/client/pkg/v3/fileutil" "go.etcd.io/etcd/pkg/v3/expect" + "go.uber.org/zap" ) const noOutputLineCount = 2 // cov-enabled binaries emit PASS and coverage count lines func spawnCmd(args []string) (*expect.ExpectProcess, error) { + return spawnCmdWithLogger(zap.NewNop(), args) +} + +func spawnCmdWithLogger(lg *zap.Logger, args []string) (*expect.ExpectProcess, error) { cmd := args[0] env := make([]string, 0) - switch cmd { - case binPath: - cmd = "../../bin/etcd_test" - case ctlBinPath: - cmd = "../../bin/etcdctl_test" - case ctlBinPath + "3": - cmd = "../../bin/etcdctl_test" + switch { + case strings.HasSuffix(cmd, "/etcd"): + cmd = cmd + "_test" + case strings.HasSuffix(cmd, "/etcdctl"): + cmd = cmd + "_test" + case strings.HasSuffix(cmd, "/etcdctl3"): + cmd = ctlBinPath + "_test" env = append(env, "ETCDCTL_API=3") } + wd, err := os.Getwd() + if err != nil { + return nil, err + } + covArgs, err := getCovArgs() if err != nil { return nil, err @@ -52,7 +62,7 @@ func spawnCmd(args []string) (*expect.ExpectProcess, error) { // they must be included in ctl_cov_env. env = append(env, os.Environ()...) all_args := append(args[1:], covArgs...) - log.Printf("Executing %v %v", cmd, all_args) + lg.Info("spawning process", zap.Strings("args", all_args), zap.String("working-dir", wd)) ep, err := expect.NewExpectWithEnv(cmd, all_args, env) if err != nil { return nil, err