LGTM, thanks
On Thu, Apr 17, 2014 at 8:52 AM, Thomas Thrainer <[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]> > Reviewed-by: Petr Pudlak <[email protected]> > Signed-off-by: Thomas Thrainer <[email protected]> > > (cherry picked from commit 57efdaf53a4d40a39befaa7e9a5ce9ff72063523) > > Conflicts: > qa/qa_rapi.py (didn't backport changes to this file) > > Signed-off-by: Thomas Thrainer <[email protected]> > --- > qa/qa_job_utils.py | 15 ++++++++++----- > 1 file changed, 10 insertions(+), 5 deletions(-) > > diff --git a/qa/qa_job_utils.py b/qa/qa_job_utils.py > index fc068e2..e5d5773 100644 > --- a/qa/qa_job_utils.py > +++ b/qa/qa_job_utils.py > @@ -192,7 +192,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 > @@ -202,6 +202,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 > @@ -256,10 +258,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) > > -- > 1.9.1.423.g4596e3a > > -- -- Helga Velroyen | Software Engineer | [email protected] | Google Germany GmbH Dienerstr. 12 80331 München Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg Geschäftsführer: Graham Law, Christine Elizabeth Flores
