Bug 1294653

Summary: (v0.5) ovirtlago assertion check should sleep between retries
Product: [Community] ovirt-system-tests Reporter: Yaniv Kaul <ykaul>
Component: RFEsAssignee: David Caro <dcaroest>
Status: CLOSED DEFERRED QA Contact: Pavel Stehlik <pstehlik>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 0.4CC: bugs, eedri
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-01-21 10:08:19 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

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.