Bug 1294653 - (v0.5) ovirtlago assertion check should sleep between retries
Summary: (v0.5) ovirtlago assertion check should sleep between retries
Keywords:
Status: CLOSED DEFERRED
Alias: None
Product: ovirt-system-tests
Classification: Community
Component: RFEs
Version: 0.4
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: ---
: ---
Assignee: David Caro
QA Contact: Pavel Stehlik
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-12-29 12:51 UTC by Yaniv Kaul
Modified: 2016-01-21 10:52 UTC (History)
2 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2016-01-21 10:08:19 UTC
oVirt Team: ---
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
oVirt gerrit 51568 0 None None None 2016-01-21 10:52:10 UTC

Description Yaniv Kaul 2015-12-29 12:51:46 UTC
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):
0.5

Comment 1 Yaniv Kaul 2016-01-21 10:52:10 UTC
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.