From d97518a657ef9defe0b9d78f95e8c299f0f7fb5c Mon Sep 17 00:00:00 2001 From: Anthony Romano Date: Thu, 4 May 2017 18:36:17 -0700 Subject: [PATCH] e2e: more debugging output for lock and elect etcdctl tests Meant to debug #6464 and #6934 Dumps the output from the etcd/etcdctl servers and SIGQUITs to get a golang backtrace in case of a hanged process. --- e2e/ctl_v3_elect_test.go | 20 +++++++++++++++++++- e2e/ctl_v3_lock_test.go | 20 +++++++++++++++++++- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/e2e/ctl_v3_elect_test.go b/e2e/ctl_v3_elect_test.go index 3da54278099e..9bce4cd7265c 100644 --- a/e2e/ctl_v3_elect_test.go +++ b/e2e/ctl_v3_elect_test.go @@ -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") @@ -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 { diff --git a/e2e/ctl_v3_lock_test.go b/e2e/ctl_v3_lock_test.go index e380f7cd843f..c9b4233aab32 100644 --- a/e2e/ctl_v3_lock_test.go +++ b/e2e/ctl_v3_lock_test.go @@ -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) @@ -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 {