cloudstack-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jburwell <...@git.apache.org>
Subject [GitHub] cloudstack pull request: CLOUDSTACK-9323: Fix cancel host maintena...
Date Fri, 08 Apr 2016 00:05:33 GMT
Github user jburwell commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/1454#discussion_r58964733
  
    --- Diff: tools/marvin/marvin/lib/utils.py ---
    @@ -520,4 +520,22 @@ def verifyRouterState(apiclient, routerid, allowedstates):
         if routers[0].state.lower() not in allowedstates:
             return [FAIL, "state of the router should be in %s but is %s" %
                 (allowedstates, routers[0].state)]
    -    return [PASS, None]
    \ No newline at end of file
    +    return [PASS, None]
    +
    +
    +
    +def wait_until(retry_interval=2, no_of_times=2, callback=None, *callback_args):
    +    """ Utility method to try out the callback method at most no_of_times with a interval
of retry_interval,
    +    Will return immediately if callback returns True. The callback method should be written
to return a list of values first being a boolean """
    +
    +    if callback is None:
    +        return INVALID_INPUT
    +    success = False
    +    for i in range(0,no_of_times):
    +        time.sleep(retry_interval)
    +        success = callback(*callback_args)
    +        if success[0]: 
    +            break 
    +
    +    return success
    --- End diff --
    
    Assuming I am reading this correctly, this function will return an array not a Boolean
value based on the array operation on line 536.
    
    Would be possible to add a unit test for this function to verify proper return of ``True``
when the callback succeeds and ``False`` when it doesn't pass after the number of retries
fails?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message