integration_test: fix the flaky test TestV3AuthRestartMembe

Signed-off-by: Benjamin Wang <wachao@vmware.com>
This commit is contained in:
Benjamin Wang 2022-09-14 14:30:37 +08:00
parent bbcbcd9db4
commit e8ad008067
2 changed files with 6 additions and 1 deletions

View File

@ -1097,11 +1097,15 @@ func (m *Member) WaitStarted(t testutil.TB) {
}
func WaitClientV3(t testutil.TB, kv clientv3.KV) {
WaitClientV3WithKey(t, kv, "/")
}
func WaitClientV3WithKey(t testutil.TB, kv clientv3.KV, key string) {
timeout := time.Now().Add(RequestTimeout)
var err error
for time.Now().Before(timeout) {
ctx, cancel := context.WithTimeout(context.Background(), RequestTimeout)
_, err = kv.Get(ctx, "/")
_, err = kv.Get(ctx, key)
cancel()
if err == nil {
return

View File

@ -492,6 +492,7 @@ func TestV3AuthRestartMember(t *testing.T) {
clus.Members[0].Stop(t)
err = clus.Members[0].Restart(t)
testutil.AssertNil(t, err)
integration.WaitClientV3WithKey(t, c2.KV, "foo")
// nothing has changed, but it fails without refreshing cache after restart
_, err = c2.Put(context.TODO(), "foo", "bar2")