예제 #1
0
    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)
예제 #2
0
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
예제 #3
0
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
예제 #4
0
    def __init__(self,
                 test_dir,
                 scenario,
                 positional_args=(),
                 target='127.0.0.1',
                 scenario_id=None):
        """Constructor.

        Keyword Arguments:
        test_dir               -- The path to the directory containing the
                                  test module.
        scenario               -- The SIPp scenario to execute (dictionary).
        positional_args        -- SIPp non-standard parameters (those that can
                                  be specified multiple times, or take
                                  multiple arguments (iterable). Optional.
                                  Default: Empty iterable.
        target                 -- The address for the remote host. Optional.
                                  Default: 127.0.0.1.
        scenario_id            -- The scenario_id for this scenario. Used for
                                  logging. If nothing is provided, the id will
                                  be the value of scenario['scenario'].
                                  Optional. Default: None.
        """

        self.__actual_result = None
        self.__expected_result = None
        self.__on_complete = None
        self.__passed = None
        self.__running = False
        self.__scenario_id = scenario_id or scenario['scenario']

        SIPpScenario.__init__(self, test_dir, scenario, positional_args,
                              target)
예제 #5
0
    def __init__(self, test_dir, scenario, positional_args=(),
                 target='127.0.0.1', scenario_id=None):
        """Constructor.

        Keyword Arguments:
        test_dir               -- The path to the directory containing the
                                  test module.
        scenario               -- The SIPp scenario to execute (dictionary).
        positional_args        -- SIPp non-standard parameters (those that can
                                  be specified multiple times, or take
                                  multiple arguments (iterable). Optional.
                                  Default: Empty iterable.
        target                 -- The address for the remote host. Optional.
                                  Default: 127.0.0.1.
        scenario_id            -- The scenario_id for this scenario. Used for
                                  logging. If nothing is provided, the id will
                                  be the value of scenario['scenario'].
                                  Optional. Default: None.
        """

        self.__actual_result = None
        self.__expected_result = None
        self.__on_complete = None
        self.__passed = None
        self.__running = False
        self.__scenario_id = scenario_id or scenario['scenario']

        SIPpScenario.__init__(self,
                              test_dir,
                              scenario,
                              positional_args,
                              target)
    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 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)
예제 #8
0
    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)
예제 #9
0
    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)
예제 #10
0
    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
예제 #11
0
    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
    def ami_connect(self, ami):
        """Starts the PJSIPQualify scenario and Runs Through the XML"""
        super(AMISendTest, self).ami_connect(ami)

        def _ami_action():
            """ This Sends the PJSIPQualify Action """
            LOGGER.info('Sending PJSIPQualify Action...')
            ami.sendDeferred(ACTION).addCallback(ami.errorUnlessResponse)

        LOGGER.info('Starting PJSIPQualify scenario')

        sipp_options = (SIPpScenario(self.test_name, {
            'scenario': 'options.xml',
            '-p': '5062'
        }))
        sipp_options.run(self).addCallback(self.__on_return)
        reactor.callLater(1, _ami_action)