From 1dcdfc1ba9701c67df6656bb0237809ffd3d0e23 Mon Sep 17 00:00:00 2001 From: Benjamin Wang Date: Fri, 17 Jan 2025 20:19:04 +0000 Subject: [PATCH] Update TestAuthGracefulDisable to wait for member to get started Signed-off-by: Benjamin Wang --- tests/common/auth_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/common/auth_test.go b/tests/common/auth_test.go index c9544b9076dd..cf4b2e8b0f5d 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,12 @@ 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()