[QA] Change 'wait' method logic if no timeout is set

Bug #1349886 reported by Andrey Sledzinskiy
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Fuel for OpenStack
Fix Committed
Medium
Andrey Sledzinskiy

Bug Description

In devops/helpers/helpers.py we have 'wait' method:
 def wait(predicate, interval=5, timeout=None):
    start_time = time.time()
    while not predicate():
        if timeout and start_time + timeout < time.time():
            raise TimeoutError("Waiting timed out")

        seconds_to_sleep = interval
        if timeout:
            seconds_to_sleep = max(
                0,
                min(seconds_to_sleep, start_time + timeout - time.time()))
        time.sleep(seconds_to_sleep)

    return timeout + start_time - time.time() if timeout else 0

If timeout wasn't set we can have situation when predicate is always False and we stuck in infinite loop - we will sleep every 5 seconds and never timed out.
Method need to be refactored

Tags: fuel-devops
Igor Shishkin (teran)
tags: added: fuel-devops
removed: devops
summary: - [Devops] Change 'wait' method logic if no timeout is set
+ [QA] Change 'wait' method logic if no timeout is set
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to fuel-devops (master)

Fix proposed to branch: master
Review: https://review.openstack.org/110673

Changed in fuel:
assignee: Fuel QA Team (fuel-qa) → Andrey Sledzinskiy (asledzinskiy)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to fuel-devops (master)

Reviewed: https://review.openstack.org/110673
Committed: https://git.openstack.org/cgit/stackforge/fuel-devops/commit/?id=c85659bb4b10c79f2e9c84ad8f30d257daf67125
Submitter: Jenkins
Branch: master

commit c85659bb4b10c79f2e9c84ad8f30d257daf67125
Author: asledzinskiy <email address hidden>
Date: Wed Jul 30 18:13:36 2014 +0300

    Add default timeout to wait method to avoid
    infinite loop

    Change-Id: Iefd3db625c6b68d1ee95f121c628fe87ab64bbd2
    Closes-Bug: #1349886

Changed in fuel:
status: In Progress → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.