Skip to content

Commit

Permalink
e2e: more debugging output for lock and elect etcdctl tests
Browse files Browse the repository at this point in the history
Meant to debug etcd-io#6464 and etcd-io#6934

Dumps the output from the etcd/etcdctl servers and SIGQUITs to get a
golang backtrace in case of a hanged process.
  • Loading branch information
Anthony Romano committed May 5, 2017
1 parent 0b62eca commit d97518a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
20 changes: 19 additions & 1 deletion e2e/ctl_v3_elect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,32 @@ package e2e
import (
"os"
"strings"
"syscall"
"testing"
"time"

"github.com/coreos/etcd/pkg/expect"
)

func TestCtlV3Elect(t *testing.T) { testCtl(t, testElect) }
func TestCtlV3Elect(t *testing.T) {
oldenv := os.Getenv("EXPECT_DEBUG")
defer os.Setenv("EXPECT_DEBUG", oldenv)
os.Setenv("EXPECT_DEBUG", "1")

testCtl(t, testElect)
}

func testElect(cx ctlCtx) {
// debugging for #6934
for _, p := range cx.epc.procs {
p.proc.StopSignal = syscall.SIGQUIT
}
defer func() {
for _, ep := range cx.epc.procs {
ep.proc.StopSignal = os.Interrupt
}
}()

name := "a"

holder, ch, err := ctlV3Elect(cx, name, "p1")
Expand Down Expand Up @@ -102,6 +119,7 @@ func ctlV3Elect(cx ctlCtx, name, proposal string) (*expect.ExpectProcess, <-chan
close(outc)
return proc, outc, err
}
proc.StopSignal = syscall.SIGQUIT
go func() {
s, xerr := proc.ExpectFunc(func(string) bool { return true })
if xerr != nil {
Expand Down
20 changes: 19 additions & 1 deletion e2e/ctl_v3_lock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,32 @@ package e2e
import (
"os"
"strings"
"syscall"
"testing"
"time"

"github.com/coreos/etcd/pkg/expect"
)

func TestCtlV3Lock(t *testing.T) { testCtl(t, testLock) }
func TestCtlV3Lock(t *testing.T) {
oldenv := os.Getenv("EXPECT_DEBUG")
defer os.Setenv("EXPECT_DEBUG", oldenv)
os.Setenv("EXPECT_DEBUG", "1")

testCtl(t, testLock)
}

func testLock(cx ctlCtx) {
// debugging for #6464
for _, p := range cx.epc.procs {
p.proc.StopSignal = syscall.SIGQUIT
}
defer func() {
for _, ep := range cx.epc.procs {
ep.proc.StopSignal = os.Interrupt
}
}()

name := "a"

holder, ch, err := ctlV3Lock(cx, name)
Expand Down Expand Up @@ -102,6 +119,7 @@ func ctlV3Lock(cx ctlCtx, name string) (*expect.ExpectProcess, <-chan string, er
close(outc)
return proc, outc, err
}
proc.StopSignal = syscall.SIGQUIT
go func() {
s, xerr := proc.ExpectFunc(func(string) bool { return true })
if xerr != nil {
Expand Down

0 comments on commit d97518a

Please sign in to comment.