def action_link_down(args, test_step, expected, params_list): analyzer_name = choose_analyzer(params_list, 0) checks = [] affected_talkers = set() # Expect all the connections which cross the relay to be lost for c,n in state.get_current().active_connections.iteritems(): if not n: continue path = graph.find_path(state.get_current(), c.talker.src, c.listener.dst) if path and analyzer_name in path: affected_talkers |= set([c.talker]) checks += [Expected(c.listener.dst, "ADP: Removing entity who timed out -> GUID", 30)] checks += sequences.analyzer_listener_disconnect_seq(test_step, c.talker.src, c.talker.src_stream, c.listener.dst, c.listener.dst_stream) state.get_next().disconnect(c.talker.src, c.talker.src_stream, c.listener.dst, c.listener.dst_stream) for talker in affected_talkers: if not state.get_next().talker_active_count(talker.src, talker.src_stream): checks += [Expected(talker.src, "Talker stream #%d off" % talker.src_stream, 30)] # Send the command to close the relay '(r)elay (c)lose' args.master.sendLine(analyzer_name, "r o") state.get_next().set_relay_open(analyzer_name) if test_step.do_checks and checks: expected += [AllOf(checks)] yield args.master.expect(None) else: # At least allow time for the relay to actually be closed yield base.sleep(0.1)
def action_link_downup(args, test_step, expected, params_list): """ Expect all connections which bridge the relay to be lost and restored if there is a quick link down/up event. The first argument is the analyzer controlling the relay. The second is the time to sleep before restoring the link. """ analyzer_name = choose_analyzer(params_list, 0) sleep_time = int(params_list[1]) lost = [] # Expect all the connections which cross the relay to be lost for c,n in state.get_current().active_connections.iteritems(): if n and analyzer_name in graph.find_path(state.get_current(), c.talker.src, c.listener.dst): lost += sequences.analyzer_listener_disconnect_seq(test_step, c.talker.src, c.talker.src_stream, c.listener.dst, c.listener.dst_stream) # Send the command to open the relay '(r)elay (o)pen' args.master.sendLine(analyzer_name, "r o") state.get_next().set_relay_open(analyzer_name) if test_step.do_checks and lost: expected += [AllOf(lost)] # Perform a sleep as defined by the second argument yield base.sleep(sleep_time) found = [] # Expect all the connections which cross the relay to be restored state.get_next().set_relay_closed(analyzer_name) for c,n in state.get_current().active_connections.iteritems(): if n and analyzer_name in graph.find_path(state.get_current(), c.talker.src, c.listener.dst): found += sequences.analyzer_listener_connect_seq(test_step, c.talker.src, c.talker.src_stream, c.listener.dst, c.listener.dst_stream) # Send the command to close the relay '(r)elay (c)lose' args.master.sendLine(analyzer_name, "r c") if test_step.do_checks and found: expected += [AllOf(found)] yield args.master.expect(None)