grr/test_lib/flow_test_lib.py
def RunFlow(client_id,
            flow_id,
            client_mock=None,
            worker=None,
            check_flow_errors=True):
  """Runs the flow given until no further progress can be made."""

  all_processed_flows = set()

  if client_id or client_mock:
    client_mock = MockClient(client_id, client_mock)

  if worker is None:
    test_worker = TestWorker(token=True)
    data_store.REL_DB.RegisterFlowProcessingHandler(test_worker.ProcessFlow)
  else:
    test_worker = worker

  try:
    # Run the client and worker until nothing changes any more.
    while True:
      client_processed = client_mock.Next()
      worker_processed = test_worker.ResetProcessedFlows()
      all_processed_flows.update(worker_processed)

      if client_processed == 0 and not worker_processed:
        break

    if check_flow_errors:
      for client_id, flow_id in all_processed_flows:
        rdf_flow = data_store.REL_DB.ReadFlowObject(client_id, flow_id)
        if rdf_flow.flow_state != rdf_flow.FlowState.FINISHED:
          raise RuntimeError(
              "Flow %s on %s completed in state %s (error message: %s)" %
              (flow_id, client_id, rdf_flow.flow_state, rdf_flow.error_message))

    return flow_id
  finally:
    if worker is None:
      data_store.REL_DB.UnregisterFlowProcessingHandler(timeout=60)
      test_worker.Shutdown()
Runs the flow given until no further progress can be made.
Runs the flow given until no further progress can be made.
Runs the flow given until no further progress can be made .
def RunFlow(client_id,
            flow_id,
            client_mock=None,
            worker=None,
            check_flow_errors=True):
  all_processed_flows = set()
  if client_id or client_mock:
    client_mock = MockClient(client_id, client_mock)
  if worker is None:
    test_worker = TestWorker(token=True)
    data_store.REL_DB.RegisterFlowProcessingHandler(test_worker.ProcessFlow)
  else:
    test_worker = worker
  try:
    while True:
      client_processed = client_mock.Next()
      worker_processed = test_worker.ResetProcessedFlows()
      all_processed_flows.update(worker_processed)
      if client_processed == 0 and not worker_processed:
        break
    if check_flow_errors:
      for client_id, flow_id in all_processed_flows:
        rdf_flow = data_store.REL_DB.ReadFlowObject(client_id, flow_id)
        if rdf_flow.flow_state != rdf_flow.FlowState.FINISHED:
          raise RuntimeError(
              "Flow %s on %s completed in state %s (error message: %s)" %
              (flow_id, client_id, rdf_flow.flow_state, rdf_flow.error_message))
    return flow_id
  finally:
    if worker is None:
      data_store.REL_DB.UnregisterFlowProcessingHandler(timeout=60)
      test_worker.Shutdown()
def RunFlow ( client_id , flow_id , client_mock = None , worker = None , check_flow_errors = True ) : all_processed_flows = set ( ) if client_id or client_mock : client_mock = MockClient ( client_id , client_mock ) if worker is None : test_worker = TestWorker ( token = True ) data_store . REL_DB . RegisterFlowProcessingHandler ( test_worker . ProcessFlow ) else : test_worker = worker try : while True : client_processed = client_mock . Next ( ) worker_processed = test_worker . ResetProcessedFlows ( ) all_processed_flows . update ( worker_processed ) if client_processed == 0 and not worker_processed : break if check_flow_errors : for client_id , flow_id in all_processed_flows : rdf_flow = data_store . REL_DB . ReadFlowObject ( client_id , flow_id ) if rdf_flow . flow_state != rdf_flow . FlowState . FINISHED : raise RuntimeError ( "Flow %s on %s completed in state %s (error message: %s)" % ( flow_id , client_id , rdf_flow . flow_state , rdf_flow . error_message ) ) return flow_id finally : if worker is None : data_store . REL_DB . UnregisterFlowProcessingHandler ( timeout = 60 ) test_worker . Shutdown ( )
Runs the flow given until no further progress can be made.
Runs the flow given until no further progress can be made .
"""Runs the flow given until no further progress can be made.""" # Run the client and worker until nothing changes any more.
client_id
flow_id
client_mock
worker
check_flow_errors