|
@@ -16,16 +16,49 @@ package e2e
|
|
|
|
|
|
|
|
import (
|
|
import (
|
|
|
"os"
|
|
"os"
|
|
|
|
|
+ "runtime"
|
|
|
"strings"
|
|
"strings"
|
|
|
|
|
+ "syscall"
|
|
|
"testing"
|
|
"testing"
|
|
|
"time"
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/coreos/etcd/pkg/expect"
|
|
"github.com/coreos/etcd/pkg/expect"
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
-func TestCtlV3Lock(t *testing.T) { testCtl(t, testLock) }
|
|
|
|
|
|
|
+// debugLockSignal forces SIGQUIT to debug etcdctl elect and lock failures
|
|
|
|
|
+var debugLockSignal os.Signal
|
|
|
|
|
+
|
|
|
|
|
+func init() {
|
|
|
|
|
+ // hacks to ignore SIGQUIT debugging for some builds
|
|
|
|
|
+ switch {
|
|
|
|
|
+ case os.Getenv("COVERDIR") != "":
|
|
|
|
|
+ // SIGQUIT interferes with coverage collection
|
|
|
|
|
+ debugLockSignal = syscall.SIGTERM
|
|
|
|
|
+ case runtime.GOARCH == "ppc64le":
|
|
|
|
|
+ // ppc64le's signal handling won't kill processes with SIGQUIT
|
|
|
|
|
+ // in the same way as amd64/i386, so processes won't terminate
|
|
|
|
|
+ // as expected. Since this debugging code for CI, just ignore
|
|
|
|
|
+ // ppc64le.
|
|
|
|
|
+ debugLockSignal = syscall.SIGKILL
|
|
|
|
|
+ default:
|
|
|
|
|
+ // stack dumping OK
|
|
|
|
|
+ debugLockSignal = syscall.SIGQUIT
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+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) {
|
|
func testLock(cx ctlCtx) {
|
|
|
|
|
+ // debugging for #6464
|
|
|
|
|
+ sig := cx.epc.withStopSignal(debugLockSignal)
|
|
|
|
|
+ defer cx.epc.withStopSignal(sig)
|
|
|
|
|
+
|
|
|
name := "a"
|
|
name := "a"
|
|
|
|
|
|
|
|
holder, ch, err := ctlV3Lock(cx, name)
|
|
holder, ch, err := ctlV3Lock(cx, name)
|
|
@@ -102,6 +135,7 @@ func ctlV3Lock(cx ctlCtx, name string) (*expect.ExpectProcess, <-chan string, er
|
|
|
close(outc)
|
|
close(outc)
|
|
|
return proc, outc, err
|
|
return proc, outc, err
|
|
|
}
|
|
}
|
|
|
|
|
+ proc.StopSignal = debugLockSignal
|
|
|
go func() {
|
|
go func() {
|
|
|
s, xerr := proc.ExpectFunc(func(string) bool { return true })
|
|
s, xerr := proc.ExpectFunc(func(string) bool { return true })
|
|
|
if xerr != nil {
|
|
if xerr != nil {
|