LGTM, thanks.

On Tue, Feb 18, 2014 at 3:39 PM, Hrvoje Ribicic <[email protected]> wrote:

> To compensate for the cases where a QA test is supposed to block when
> a lock is present, add an additional option showing whether blocking is
> supposed to happen or not.
>
> Signed-off-by: Hrvoje Ribicic <[email protected]>
> ---
>  qa/qa_job_utils.py | 15 ++++++++++-----
>  qa/qa_rapi.py      |  2 +-
>  2 files changed, 11 insertions(+), 6 deletions(-)
>
> diff --git a/qa/qa_job_utils.py b/qa/qa_job_utils.py
> index 03f8ee1..36f5fa4 100644
> --- a/qa/qa_job_utils.py
> +++ b/qa/qa_job_utils.py
> @@ -188,7 +188,7 @@ def _GetBlockingLocks():
>
>
>  # TODO: Can this be done as a decorator? Implement as needed.
> -def RunWithLocks(fn, locks, timeout, *args, **kwargs):
> +def RunWithLocks(fn, locks, timeout, block, *args, **kwargs):
>    """ Runs the given function, acquiring a set of locks beforehand.
>
>    @type fn: function
> @@ -198,6 +198,8 @@ def RunWithLocks(fn, locks, timeout, *args, **kwargs):
>    @type timeout: number
>    @param timeout: The number of seconds the locks should be held before
>                    expiring.
> +  @type block: bool
> +  @param block: Whether the test should block when locks are used or not.
>
>    This function allows a set of locks to be acquired in preparation for a
> QA
>    test, to try and see if the function can run in parallel with other
> @@ -252,10 +254,13 @@ def RunWithLocks(fn, locks, timeout, *args,
> **kwargs):
>
>    qa_thread.join()
>
> -  if test_blocked:
> -    blocking_lock_names = map(lock_name_map.get, blocking_owned_locks)
> -    raise qa_error.Error("QA test succeded, but was blocked by the locks:
> %s" %
> -                         ", ".join(blocking_lock_names))
> +  blocking_lock_names = ", ".join(map(lock_name_map.get,
> blocking_owned_locks))
> +  if not block and test_blocked:
> +    raise qa_error.Error("QA test succeded, but was blocked by locks: %s"
> %
> +                         blocking_lock_names)
> +  elif block and not test_blocked:
> +    raise qa_error.Error("QA test succeded, but was not blocked as it was
> "
> +                         "expected to by locks: %s" % blocking_lock_names)
>    else:
>      _TerminateDelayFunction(termination_socket)
>
> diff --git a/qa/qa_rapi.py b/qa/qa_rapi.py
> index 9ad8afb..73c3463 100644
> --- a/qa/qa_rapi.py
> +++ b/qa/qa_rapi.py
> @@ -968,7 +968,7 @@ def TestInterClusterInstanceMove(src_instance,
> dest_instance,
>    # assures that this happens, and while we cannot be sure where the
> instance
>    # will land, it is a real move.
>    locks = {locking.LEVEL_NODE: [pnode.primary]}
> -  RunWithLocks(_InvokeMoveInstance, locks, 600.0,
> +  RunWithLocks(_InvokeMoveInstance, locks, 600.0, False,
>                 dest_instance.name, src_instance.name, rapi_pw_file.name,
>                 master.primary, perform_checks)
>
> --
> 1.9.0.rc1.175.g0b1dcb5
>
>

Reply via email to