Exemple #1
0
  def get_talker_state(self, src, src_stream, dst, dst_stream, action):
    if graph.find_path(self, src, dst) is None:
      state = 'talker_redundant'

    elif action == 'connect':
      if self.connected(src, src_stream, dst, dst_stream):
        state = 'talker_redundant'
      else:
        if self.listener_active_count(dst, dst_stream):
          state = 'talker_redundant'
        elif self.talker_active_count(src, src_stream):
          state = 'talker_existing'
        else:
          state = 'talker_new'

    elif action == 'disconnect':
      if not self.connected(src, src_stream, dst, dst_stream):
        state = 'talker_redundant'
      else:
        if self.talker_active_count(src, src_stream) == 1:
          state = 'talker_all'
        else:
          state = 'talker_existing'

    else:
      base.testError("Unknown action '%s'" % action, critical=True)

    log_debug("get_talker_state for %s %d %s %d: %s" % (src, src_stream, dst, dst_stream, state))
    return (state + '_' + action)
Exemple #2
0
def action_discover(args, test_step, expected, params_list):
  if args.controller_type == 'c':
    # Can take up to 20 seconds to timeout entities which have disappeared
    yield base.sleep(20)

    print_title("Command: list")
    args.master.sendLine(args.controller_id, "list")

    yield base.sleep(2)

  else:
    args.master.clearExpectHistory(args.controller_id)
    print_title("Command: discover")
    args.master.sendLine(args.controller_id, "discover")

    yield args.master.expect(Expected(args.controller_id, "Found \d+ entities", 15))

  # Actually check that the right number of entities have been seen
  visible_endpoints = graph.get_endpoints_connected_to(state.get_current(), args.controller_id)
  controller = getActiveProcesses()[args.controller_id]
  if len(controller.entities) != len(visible_endpoints):
    base.testError("Found %d entities, expecting %d" % (len(controller.entities), len(visible_endpoints)), critical=True)
  else:
    log_info("Found %d entities" % len(controller.entities))

  yield args.master.expect(None)
Exemple #3
0
  def get_controller_state(self, controller_id, src, src_stream, dst, dst_stream, action):
    controllable_endpoints = graph.get_endpoints_connected_to(self, controller_id)
    if src not in controllable_endpoints or dst not in controllable_endpoints:
      state = 'timeout'

    elif action == 'connect':
      if src == dst:
        if self.listener_active_count(dst, dst_stream):
          state = 'listener_exclusive'
        else:
          state = 'listener_talker_timeout'
      elif self.connected(src, src_stream, dst, dst_stream):
        state = 'success'
      elif self.listener_active_count(dst, dst_stream):
        state = 'listener_exclusive'
      else:
        state = 'success'

    elif action == 'disconnect':
      if not self.connected(src, src_stream, dst, dst_stream):
        state = 'redundant'
      else:
        state = 'success'

    else:
      base.testError("Unknown action '%s'" % action, critical=True)

    log_debug("get_controller_state for %s %d %s %d: %s" % (src, src_stream, dst, dst_stream, state))
    return ('controller_' + state + '_' + action)
Exemple #4
0
def runTest(args):
  """ The test program - needs to yield on each expect and be decorated
    with @inlineCallbacks
  """
  for y in configure_generators():
    yield y

  for y in configure_analyzers():
    yield y

  for y in check_endpoint_startup():
    yield y

  expected = []
  for y in action_discover(args, generator.Command("discover"), expected, []):
    yield y
  for e in expected:
    yield args.master.expect(e)
  expected = []

  if not getEntities():
    base.testError("no entities found", critical=True)

  test_num = 1
  check_num = 1
  for test_step in test_steps:
    state.move_next_to_current()

    command = test_step.command
    print_title("Command %d: %s" % (test_num, command))
    test_num += 1

    action = command.split(' ')
    action_function = eval('action_%s' % action[0])
    for y in action_function(args, test_step, expected, action[1:]):
      yield y

    if test_step.checkpoint or test_step.checkpoint is None:
      print_title("Check: %d" % check_num)
      check_num += 1
      if expected:
        yield args.master.expect(AllOf(expected))
        expected = []

        # Ensure that any remaining output of a previous test step is flushed
        for process in getActiveProcesses():
          master.clearExpectHistory(process)

  # Allow everything time to settle (in case an error is being generated)
  yield base.sleep(5)
  base.testComplete(reactor)