Bug 1294653 - (v0.5) ovirtlago assertion check should sleep between retries
(v0.5) ovirtlago assertion check should sleep between retries
Product: ovirt-system-tests
Classification: Community
Component: RFEs (Show other bugs)
Unspecified Unspecified
unspecified Severity medium
: ---
: ---
Assigned To: David Caro
Pavel Stehlik
Depends On:
  Show dependency treegraph
Reported: 2015-12-29 07:51 EST by Yaniv Kaul
Modified: 2016-01-21 05:52 EST (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2016-01-21 05:08:19 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

External Trackers
Tracker ID Priority Status Summary Last Updated
oVirt gerrit 51568 None None None 2016-01-21 05:52 EST

  None (edit)
Description Yaniv Kaul 2015-12-29 07:51:46 EST
Description of problem:
Currently the code @ ovirtlago/testlib.py is:
143 def assert_true_within(func, timeout):
144     with utils.EggTimer(timeout) as timer:
145         while not timer.elapsed():
146             try:
147                 if func():
148                     return
149             except Exception:
150                 pass
151     raise AssertionError('Timed out')

Specifically, there is a tight loop there, which consumes CPU needlessly - occupying both the client and the target of func() (for example, checking something on the engine).

Simple patch:

23 import time

144 def assert_true_within(func, timeout):
145     with utils.EggTimer(timeout) as timer:
146         while not timer.elapsed():
147             try:
148                 if func():
149                     return
150                 time.sleep(1)
151             except Exception:
152                 pass
153     raise AssertionError('Timed out')

solves this, by adding a 1 sec. sleep between retries (practically, can even extend to 3 or 5 seconds).

Version-Release number of selected component (if applicable):
Comment 1 Yaniv Kaul 2016-01-21 05:52:10 EST
https://gerrit.ovirt.org/#/c/51568/ implements this little change.

Note You need to log in before you can comment on or make changes to this bug.