Skip to content

Commit

Permalink
address the review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Benjamin Wang <[email protected]>
  • Loading branch information
ahrtr committed Sep 29, 2023
1 parent 70a3205 commit 67ee7e4
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions tests/e2e/ctl_v3_member_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,16 @@ func TestCtlV3MemberUpdatePeerTLS(t *testing.T) {
testCtl(t, memberUpdateTest, withCfg(*e2e.NewConfigPeerTLS()))
}

// TestCtlV3ConsistentMemberList requires the gofailpoint to be enabled.
// If you execute this case locally, please do not forget to execute
// `make gofail-enable`.
func TestCtlV3ConsistentMemberList(t *testing.T) {
e2e.BeforeTest(t)

epc, err := e2e.NewEtcdProcessCluster(context.TODO(), t,
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()

epc, err := e2e.NewEtcdProcessCluster(ctx, t,
e2e.WithClusterSize(1),
e2e.WithWaitClusterReadyTimeout(0),
e2e.WithEnvVars(map[string]string{"GOFAIL_FAILPOINTS": `beforeApplyOneConfChange=sleep("2s")`}),
Expand All @@ -73,14 +79,14 @@ func TestCtlV3ConsistentMemberList(t *testing.T) {
}()

t.Log("Adding and then removing a learner")
resp, err := epc.Etcdctl().MemberAddAsLearner(context.TODO(), "newLearner", []string{fmt.Sprintf("http://localhost:%d", e2e.EtcdProcessBasePort+11)})
resp, err := epc.Etcdctl().MemberAddAsLearner(ctx, "newLearner", []string{fmt.Sprintf("http://localhost:%d", e2e.EtcdProcessBasePort+11)})
require.NoError(t, err)
_, err = epc.Etcdctl().MemberRemove(context.TODO(), resp.Member.ID)
_, err = epc.Etcdctl().MemberRemove(ctx, resp.Member.ID)
require.NoError(t, err)
t.Logf("Added and then removed a learner with ID: %x", resp.Member.ID)

t.Log("Restarting the etcd process to ensure all data is persisted")
err = epc.Procs[0].Restart(context.TODO())
err = epc.Procs[0].Restart(ctx)
require.NoError(t, err)

var wg sync.WaitGroup
Expand All @@ -100,7 +106,7 @@ func TestCtlV3ConsistentMemberList(t *testing.T) {
default:
}

merr := epc.Procs[0].Restart(context.TODO())
merr := epc.Procs[0].Restart(ctx)
require.NoError(t, merr)
epc.WaitLeader(t)

Expand All @@ -123,7 +129,7 @@ func TestCtlV3ConsistentMemberList(t *testing.T) {
default:
}

mresp, merr := epc.Etcdctl().MemberList(context.TODO(), true)
mresp, merr := epc.Etcdctl().MemberList(ctx, true)
if merr != nil {
continue
}
Expand Down

0 comments on commit 67ee7e4

Please sign in to comment.