luatest icon indicating copy to clipboard operation
luatest copied to clipboard

`retrying()` function is unhandy

Open Gerold103 opened this issue 4 years ago • 3 comments

retrying() takes options as a first argument. It is almost never needed non-default. As a result, nearly all calls of retrying() are going to start with {}. The options must go last and be fully optional. Like it is done in test_run:wait_cond().

Gerold103 avatar Nov 22 '21 23:11 Gerold103

Another problem is that retrying() forces to raise an error instead of just returning nil/false. Usually an error is not thrown, and that forces to add assert()/error() which look ugly in a simple return value == expected expression. Which is almost always the case for retrying()/wait_cond().

Gerold103 avatar Nov 22 '21 23:11 Gerold103

Another problem is that retrying() has extra small timeout - 5 secs is not enough. It surely will produce flaky tests in CI jobs.

Gerold103 avatar Nov 22 '21 23:11 Gerold103

We can write a new helper without all these flaws. The function's name should be a verb, not gerund: do (what, how).

function helpers.retry(fn, config, ...)

NickVolynkin avatar Jan 14 '22 12:01 NickVolynkin