Revision 57efdaf5

b/qa/qa_job_utils.py
192 192

  
193 193

  
194 194
# TODO: Can this be done as a decorator? Implement as needed.
195
def RunWithLocks(fn, locks, timeout, *args, **kwargs):
195
def RunWithLocks(fn, locks, timeout, block, *args, **kwargs):
196 196
  """ Runs the given function, acquiring a set of locks beforehand.
197 197

  
198 198
  @type fn: function
......
202 202
  @type timeout: number
203 203
  @param timeout: The number of seconds the locks should be held before
204 204
                  expiring.
205
  @type block: bool
206
  @param block: Whether the test should block when locks are used or not.
205 207

  
206 208
  This function allows a set of locks to be acquired in preparation for a QA
207 209
  test, to try and see if the function can run in parallel with other
......
256 258

  
257 259
  qa_thread.join()
258 260

  
259
  if test_blocked:
260
    blocking_lock_names = map(lock_name_map.get, blocking_owned_locks)
261
    raise qa_error.Error("QA test succeded, but was blocked by the locks: %s" %
262
                         ", ".join(blocking_lock_names))
261
  blocking_lock_names = ", ".join(map(lock_name_map.get, blocking_owned_locks))
262
  if not block and test_blocked:
263
    raise qa_error.Error("QA test succeded, but was blocked by locks: %s" %
264
                         blocking_lock_names)
265
  elif block and not test_blocked:
266
    raise qa_error.Error("QA test succeded, but was not blocked as it was "
267
                         "expected to by locks: %s" % blocking_lock_names)
263 268
  else:
264 269
    _TerminateDelayFunction(termination_socket)
265 270

  
b/qa/qa_rapi.py
968 968
  # assures that this happens, and while we cannot be sure where the instance
969 969
  # will land, it is a real move.
970 970
  locks = {locking.LEVEL_NODE: [pnode.primary]}
971
  RunWithLocks(_InvokeMoveInstance, locks, 600.0,
971
  RunWithLocks(_InvokeMoveInstance, locks, 600.0, False,
972 972
               dest_instance.name, src_instance.name, rapi_pw_file.name,
973 973
               master.primary, perform_checks)
974 974

  

Also available in: Unified diff