Skip to content

Commit

Permalink
fix test failure for TestV3CurlAuthClientTLSCertAuth
Browse files Browse the repository at this point in the history
Cherry pick part of the following commits:
* 093282f
* 4725567
* 25556a0

Signed-off-by: Benjamin Wang <wachao@vmware.com>
  • Loading branch information
ahrtr committed Jun 29, 2022
1 parent f169e5d commit 9a8993d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 17 deletions.
8 changes: 4 additions & 4 deletions tests/e2e/cluster_proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func (v2p *proxyV2Proc) Start() error {
if err := v2p.start(); err != nil {
return err
}
return v2p.waitReady("httpproxy: endpoints found")
return v2p.waitReady("endpoints found")
}

func (v2p *proxyV2Proc) Restart() error {
Expand Down Expand Up @@ -245,13 +245,13 @@ func newProxyV3Proc(cfg *etcdServerProcessConfig) *proxyV3Proc {
for i := 0; i < len(cfg.tlsArgs); i++ {
switch cfg.tlsArgs[i] {
case "--cert-file":
tlsArgs = append(tlsArgs, "--cert", cfg.tlsArgs[i+1], "--cert-file", cfg.tlsArgs[i+1])
tlsArgs = append(tlsArgs, "--cert-file", cfg.tlsArgs[i+1])
i++
case "--key-file":
tlsArgs = append(tlsArgs, "--key", cfg.tlsArgs[i+1], "--key-file", cfg.tlsArgs[i+1])
tlsArgs = append(tlsArgs, "--key-file", cfg.tlsArgs[i+1])
i++
case "--trusted-ca-file":
tlsArgs = append(tlsArgs, "--cacert", cfg.tlsArgs[i+1], "--trusted-ca-file", cfg.tlsArgs[i+1])
tlsArgs = append(tlsArgs, "--trusted-ca-file", cfg.tlsArgs[i+1])
i++
case "--auto-tls":
tlsArgs = append(tlsArgs, "--auto-tls", "--insecure-skip-tls-verify")
Expand Down
3 changes: 1 addition & 2 deletions tests/e2e/ctl_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,11 +264,10 @@ func testCtlV2Backup(t *testing.T, snapCount int, v3 bool) {
defer os.Unsetenv("ETCDCTL_API")
defer testutil.AfterTest(t)

backupDir, err := ioutil.TempDir("", "testbackup0.etcd")
backupDir, err := ioutil.TempDir(t.TempDir(), "testbackup0.etcd")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(backupDir)

etcdCfg := configNoTLS
etcdCfg.snapshotCount = snapCount
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/etcd_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
)

var (
etcdServerReadyLines = []string{"enabled capabilities for version", "published"}
etcdServerReadyLines = []string{"ready to serve client requests"}
binPath string
ctlBinPath string
)
Expand Down
14 changes: 4 additions & 10 deletions tests/e2e/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,13 @@ import (
)

func waitReadyExpectProc(exproc *expect.ExpectProcess, readyStrs []string) error {
c := 0
matchSet := func(l string) bool {
for _, s := range readyStrs {
if strings.Contains(l, s) {
c++
break
return true
}
}
return c == len(readyStrs)
return false
}
_, err := exproc.ExpectFunc(matchSet)
return err
Expand All @@ -56,20 +54,16 @@ func spawnWithExpectLines(args []string, xs ...string) ([]string, error) {
// process until either stdout or stderr contains
// the expected string
var (
lines []string
lineFunc = func(txt string) bool { return true }
lines []string
)
for _, txt := range xs {
for {
l, lerr := proc.ExpectFunc(lineFunc)
l, lerr := proc.Expect(txt)
if lerr != nil {
proc.Close()
return nil, fmt.Errorf("%v (expected %q, got %q)", lerr, txt, lines)
}
lines = append(lines, l)
if strings.Contains(l, txt) {
break
}
}
}
perr := proc.Close()
Expand Down

0 comments on commit 9a8993d

Please sign in to comment.