From bc4669c90d9dc1fc028e5c9a39683e0797bb9d71 Mon Sep 17 00:00:00 2001 From: Benjamin Wang Date: Sat, 18 Jan 2025 18:50:47 +0000 Subject: [PATCH] wait for the member to get started Signed-off-by: Benjamin Wang --- tests/common/auth_test.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/common/auth_test.go b/tests/common/auth_test.go index c9544b9076d..4570824ea00 100644 --- a/tests/common/auth_test.go +++ b/tests/common/auth_test.go @@ -97,8 +97,10 @@ func TestAuthGracefulDisable(t *testing.T) { donec := make(chan struct{}) rootAuthClient := testutils.MustClient(clus.Client(WithAuth(rootUserName, rootPassword))) + startedC := make(chan struct{}, 1) go func() { defer close(donec) + defer close(startedC) // sleep a bit to let the watcher connects while auth is still enabled time.Sleep(time.Second) // now disable auth... @@ -112,10 +114,13 @@ func TestAuthGracefulDisable(t *testing.T) { t.Errorf("failed to restart member %v", err) return } + startedC <- struct{}{} // the watcher should still work after reconnecting assert.NoErrorf(t, rootAuthClient.Put(ctx, "key", "value", config.PutOptions{}), "failed to put key value") }() + <-startedC + wCtx, wCancel := context.WithCancel(ctx) defer wCancel()