def on_kickoff_start(test_object, triggered_by, ari, event): LOGGER.debug("on_kickoff_start(%r)" % event) def _start_referer_scenario(referer_scenario, test_object): referer_scenario.run(test_object) sipp_referer = SIPpScenario(test_object.test_name, { 'scenario': 'referer.xml', '-p': '5065', '-3pcc': '127.0.0.1:5064' }, target='127.0.0.1') sipp_referee = SIPpScenario(test_object.test_name, { 'scenario': 'referee.xml', '-p': '5066', '-3pcc': '127.0.0.1:5064' }, target='127.0.0.1') sipp_referee.run(test_object) # The 3pcc scenario that first uses sendCmd (sipp_referer) will establish # a TCP socket with the other scenario (sipp_referee). This _must_ start # after sipp_referee - give it a few seconds to get the process off the # ground. from twisted.internet import reactor reactor.callLater(3, _start_referer_scenario, sipp_referer, test_object) return True
def on_kickoff_start(test_object, triggered_by, ari, event): LOGGER.debug("on_kickoff_start(%r)" % event) def _start_referer_scenario(referer_scenario, test_object): referer_scenario.run(test_object) sipp_referer = SIPpScenario(test_object.test_name, {'scenario': 'referer.xml', '-p': '5065', '-3pcc': '127.0.0.1:5064'}, target='127.0.0.1') sipp_referee = SIPpScenario(test_object.test_name, {'scenario': 'referee.xml', '-p': '5066', '-3pcc': '127.0.0.1:5064'}, target='127.0.0.1') sipp_referee.run(test_object) # The 3pcc scenario that first uses sendCmd (sipp_referer) will establish # a TCP socket with the other scenario (sipp_referee). This _must_ start # after sipp_referee - give it a few seconds to get the process off the # ground. from twisted.internet import reactor reactor.callLater(3, _start_referer_scenario, sipp_referer, test_object) return True
def ami_connect(self, ami): super(AMISendTest, self).ami_connect(ami) ami.registerEvent("TestEvent", self.test_event) LOGGER.info('Starting subscription scenario') sipp = SIPpScenario(self.test_name, {'scenario':'subscribe.xml', '-p':'5061' }) sipp.run(self)
def ami_connect(self, ami): super(AMISendTest, self).ami_connect(ami) def _on_register(obj): LOGGER.info('Getting inbound registrations...') ami.sendDeferred(ACTION).addCallback(self.__on_response) return obj LOGGER.info('Starting inbound registration scenario') sipp = SIPpScenario(self.test_name, {'scenario':'register.xml', '-p':'5061' }) sipp.run(self).addCallback(_on_register)
def ami_connect(self, ami): super(AMISendTest, self).ami_connect(ami) def _on_register(obj): LOGGER.info('Getting inbound registrations...') ami.sendDeferred(ACTION).addCallback(self.__on_response) return obj LOGGER.info('Starting inbound registration scenario') sipp = SIPpScenario(self.test_name, { 'scenario': 'register.xml', '-p': '5061' }) sipp.run(self).addCallback(_on_register)
def _handle_ami_connection(self, ami): """Called when the AMI connection is made Keyword Arguments: ami Our AMI protocol wrapper """ def _check_result(scenario): """Append the result of the test to our list of results""" self.scenarios.remove(scenario) return scenario def _set_pass_fail(result): """Check if all tests have passed If any have failed, set our passed status to False""" passed = all(r[0] for r in result) self.test_object.set_passed(passed) if (self.module_config.get('end-on-success', False) and passed): self.test_object.stop_reactor() return result deferds = [] for scenario_def in self.module_config.get('sipp'): scenario = SIPpScenario(self.test_object.test_name, scenario_def) deferred = scenario.run(self.test_object) deferred.addCallback(_check_result) deferds.append(deferred) self.scenarios.append(scenario) defer.DeferredList(deferds).addCallback(_set_pass_fail)
def run(self): """Execute a SIPp scenario passed to this object. Returns: A twisted.internet.defer.Deferred instance that can be used to determine when the SIPp Scenario has exited. """ def __handle_results(result): """Handles scenario results post-processing. Keyword Arguments: result -- The SIPp exec result. """ msg = '{0} SIPp execution complete.' LOGGER.debug(msg.format(self)) self.__running = False self.__actual_result = self.result.exitcode self.__on_complete.callback(result) self.__running = True self.__setup_state() LOGGER.debug('{0} Starting SIPp execution'.format(self)) deferred = SIPpScenario.run(self) deferred.addCallback(__handle_results) return self.__on_complete