Skip to content

Commit

Permalink
code health: reuse Retry in test helpers
Browse files Browse the repository at this point in the history
Part of #214
  • Loading branch information
DifferentialOrange authored and oleg-jukovec committed Dec 28, 2022
1 parent b0956f3 commit f4f47ae
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions test_helpers/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,16 @@ 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)
}

return false
return err == nil
}

func SkipIfSQLUnsupported(t testing.TB) {
Expand Down

0 comments on commit f4f47ae

Please sign in to comment.