mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
e2e tests were leaking 'defunc' etcdctl processes.
The commit ensures that spawned etcdctl processes are "closed", so they perform proper os wait processing. This might have contributed to file-descriptor/open-files limit being exceeded.
This commit is contained in:
parent
e2a65bee6e
commit
26f9b4be8f
@ -21,6 +21,7 @@ import (
|
||||
)
|
||||
|
||||
func AssertEqual(t *testing.T, e, a interface{}, msg ...string) {
|
||||
t.Helper()
|
||||
if (e == nil || a == nil) && (isNil(e) && isNil(a)) {
|
||||
return
|
||||
}
|
||||
@ -36,20 +37,24 @@ func AssertEqual(t *testing.T, e, a interface{}, msg ...string) {
|
||||
}
|
||||
|
||||
func AssertNil(t *testing.T, v interface{}) {
|
||||
t.Helper()
|
||||
AssertEqual(t, nil, v)
|
||||
}
|
||||
|
||||
func AssertNotNil(t *testing.T, v interface{}) {
|
||||
t.Helper()
|
||||
if v == nil {
|
||||
t.Fatalf("expected non-nil, got %+v", v)
|
||||
}
|
||||
}
|
||||
|
||||
func AssertTrue(t *testing.T, v bool, msg ...string) {
|
||||
t.Helper()
|
||||
AssertEqual(t, true, v, msg...)
|
||||
}
|
||||
|
||||
func AssertFalse(t *testing.T, v bool, msg ...string) {
|
||||
t.Helper()
|
||||
AssertEqual(t, false, v, msg...)
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,9 @@ import (
|
||||
"go.etcd.io/etcd/client/v3"
|
||||
)
|
||||
|
||||
func TestCtlV3AuthEnable(t *testing.T) { testCtl(t, authEnableTest) }
|
||||
func TestCtlV3AuthEnable(t *testing.T) {
|
||||
testCtl(t, authEnableTest)
|
||||
}
|
||||
func TestCtlV3AuthDisable(t *testing.T) { testCtl(t, authDisableTest) }
|
||||
func TestCtlV3AuthStatus(t *testing.T) { testCtl(t, authStatusTest) }
|
||||
func TestCtlV3AuthWriteKey(t *testing.T) { testCtl(t, authCredWriteKeyTest) }
|
||||
|
@ -24,10 +24,6 @@ import (
|
||||
)
|
||||
|
||||
func TestCtlV3Elect(t *testing.T) {
|
||||
oldenv := os.Getenv("EXPECT_DEBUG")
|
||||
defer os.Setenv("EXPECT_DEBUG", oldenv)
|
||||
os.Setenv("EXPECT_DEBUG", "1")
|
||||
|
||||
testCtl(t, testElect)
|
||||
}
|
||||
|
||||
|
@ -24,10 +24,6 @@ import (
|
||||
)
|
||||
|
||||
func TestCtlV3Lock(t *testing.T) {
|
||||
oldenv := os.Getenv("EXPECT_DEBUG")
|
||||
defer os.Setenv("EXPECT_DEBUG", oldenv)
|
||||
os.Setenv("EXPECT_DEBUG", "1")
|
||||
|
||||
testCtl(t, testLock)
|
||||
}
|
||||
|
||||
|
@ -114,6 +114,7 @@ func ctlV3RoleGrantPermission(cx ctlCtx, rolename string, perm grantingPerm) err
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer proc.Close()
|
||||
|
||||
expStr := fmt.Sprintf("Role %s updated", rolename)
|
||||
_, err = proc.Expect(expStr)
|
||||
@ -139,7 +140,7 @@ func ctlV3RoleRevokePermission(cx ctlCtx, rolename string, key, rangeEnd string,
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
defer proc.Close()
|
||||
_, err = proc.Expect(expStr)
|
||||
return err
|
||||
}
|
||||
|
@ -154,6 +154,14 @@ func getSnapshotStatus(cx ctlCtx, fpath string) (snapshot.Status, error) {
|
||||
// TestIssue6361 ensures new member that starts with snapshot correctly
|
||||
// syncs up with other members and serve correct data.
|
||||
func TestIssue6361(t *testing.T) {
|
||||
{
|
||||
// This tests is pretty flaky on semaphoreci as of 2021-01-10.
|
||||
// TODO: Remove when the flakiness source is identified.
|
||||
oldenv := os.Getenv("EXPECT_DEBUG")
|
||||
defer os.Setenv("EXPECT_DEBUG", oldenv)
|
||||
os.Setenv("EXPECT_DEBUG", "1")
|
||||
}
|
||||
|
||||
defer testutil.AfterTest(t)
|
||||
os.Setenv("ETCDCTL_API", "3")
|
||||
defer os.Unsetenv("ETCDCTL_API")
|
||||
|
@ -183,6 +183,7 @@ func ctlV3User(cx ctlCtx, args []string, expStr string, stdIn []string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer proc.Close()
|
||||
|
||||
// Send 'stdIn' strings as input.
|
||||
for _, s := range stdIn {
|
||||
|
@ -246,6 +246,7 @@ func testV3CurlAuth(cx ctlCtx) {
|
||||
cmdArgs = cURLPrefixArgs(cx.epc, "POST", cURLReq{endpoint: path.Join(p, "/auth/authenticate"), value: string(authreq)})
|
||||
proc, err := spawnCmd(cmdArgs)
|
||||
testutil.AssertNil(cx.t, err)
|
||||
defer proc.Close()
|
||||
|
||||
cURLRes, err := proc.ExpectFunc(lineFunc)
|
||||
testutil.AssertNil(cx.t, err)
|
||||
|
Loading…
x
Reference in New Issue
Block a user