From 5f81beaeadb6d5482f1e6f0a6e18e43deed98878 Mon Sep 17 00:00:00 2001 From: Georgy Moiseev Date: Fri, 16 Dec 2022 12:54:11 +0300 Subject: [PATCH] code health: reuse Retry in test helpers Part of #214 --- test_helpers/utils.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/test_helpers/utils.go b/test_helpers/utils.go index 4862d90d8..488cc6bf0 100644 --- a/test_helpers/utils.go +++ b/test_helpers/utils.go @@ -47,20 +47,20 @@ func DeleteRecordByKey(t *testing.T, conn tarantool.Connector, // Returns false in case of connection is not in the connected state // after specified retries count, true otherwise. func WaitUntilReconnected(conn *tarantool.Connection, retries uint, timeout time.Duration) bool { - for i := uint(0); ; i++ { + err := Retry(func(arg interface{}) error { + conn := arg.(*tarantool.Connection) connected := conn.ConnectedNow() - if connected { - return true + if !connected { + return fmt.Errorf("not connected") } + return nil + }, conn, int(retries), timeout) - if i == retries { - break - } - - time.Sleep(timeout) + if err != nil { + return false } - return false + return true } func SkipIfSQLUnsupported(t testing.TB) {