示例#1
0
def test_scen_assign_logdir():
    """Verify log file arguments when logdir is set using Scenario.defaults"""
    scen = pysipp.scenario()
    logdir = tempfile.mkdtemp(suffix="_pysipp")
    scen.defaults.logdir = logdir
    for ua in scen.prepare():
        check_log_files(ua, logdir)
示例#2
0
def scenarios(request, fs_socks, loglevel):
    '''Provision and return a SIPp scenario with the remote proxy set to the
    current FS server.
    '''
    sipp = spawn.find_executable('sipp')
    if not sipp:
        pytest.skip("SIPp is required to run call/speed tests")

    try:
        import pysipp
    except ImportError:
        pytest.skip("pysipp is required to run call/speed tests")

    pl = pysipp.utils.get_logger()
    pl.setLevel(loglevel)

    scens = []
    for fssock in fs_socks:
        # first hop should be fs server
        scen = pysipp.scenario(proxyaddr=fssock,
                               defaults={'src': socket.getfqdn()})
        scen.log = pl

        # set client destination
        # NOTE: you must add a park extension to your default dialplan!
        scen.agents['uac'].uri_username = '******'
        scens.append(scen)

    return scens
示例#3
0
def test_scen_logdir():
    """Verify log file arguments when logdir is set using Scenario.defaults
    """
    scen = pysipp.scenario()
    logdir = os.getcwd()
    scen.defaults.logdir = logdir
    for ua in scen.prepare():
        check_log_files(ua, logdir)
示例#4
0
def test_scen_logdir():
    """Verify log file arguments when logdir is set using Scenario.defaults
    """
    scen = pysipp.scenario()
    logdir = os.getcwd()
    scen.defaults.logdir = logdir
    for ua in scen.prepare():
        check_log_files(ua, logdir)
示例#5
0
文件: test_agent.py 项目: SIPp/pysipp
def test_scen_logdir():
    """Verify log file arguments when logdir is set using Scenario.defaults
    """
    scen = pysipp.scenario()
    logdir = tempfile.mkdtemp(suffix='_pysipp')
    scen.defaults.logdir = logdir
    for ua in scen.prepare():
        check_log_files(ua, logdir)
示例#6
0
def test_scen_pass_logdir():
    """Verify log file arguments when logdir is set using Scenario.defaults"""
    logdir = tempfile.mkdtemp(suffix="_pysipp")
    scen = pysipp.scenario(logdir=logdir)
    assert scen.defaults.logdir == logdir

    # logdir isn't set until the scenario is "prepared"
    assert scen.agents["uac"].logdir is None

    # logdir is set once scenario is "rendered"
    for ua in scen.prepare():
        check_log_files(ua, logdir)
示例#7
0
 def execute_scenario(self):
     self.scen = pysipp.scenario(dirpath=self.scen_dir,
                                 proxyaddr=(self.remote_host,
                                            self.remote_port))
     for agent in self.scen._agents:
         agent.local_host = self.local_host
         agent.local_port = self.local_port
     self.scen.remote_host = self.remote_host
     self.scen.remote_port = self.remote_port
     self.scen.uri_username = self.username
     self.scen.auth_password = self.auth_password
     self.scen.transport = self.transport
     self.scen()
示例#8
0
def test_proxyaddr_with_scendir(scendir):
    """When building a scenario from a xml file directory the
    `proxyaddr` kwarg should be assigned.
    """
    remoteaddr = ('9.9.9.9', 80)
    scen = pysipp.scenario(dirpath=scendir + '/default_with_confpy',
                           proxyaddr=remoteaddr)

    assert scen.clientdefaults.proxyaddr == remoteaddr
    for name, cmd in scen.cmditems():
        if name == 'uac':
            assert "-rsa '{}':'{}'".format(*remoteaddr) in cmd
            assert "'{}':'{}'".format(*scen.clientdefaults.destaddr) in cmd
        elif name == 'uas':
            assert "-rsa '{}':'{}'".format(*remoteaddr) not in cmd
示例#9
0
def test_autonet_overrides(dictname, data):
    """Ensure the auto-networking plugin doesn't override default or agent
    settings applied by client code.
    """
    scen = pysipp.scenario(**{dictname: data})
    scen = scen.from_agents()
    # netplug.py hooks shouldn't override the uac srcaddr
    if 'client' in dictname:
        agents = scen.clients
    elif 'server' in dictname:
        agents = scen.servers
    else:
        agents = scen.agents

    for key, val in data.items():
        for ua in agents.values():
            assert getattr(ua, key) == val
示例#10
0
def test_autonet_overrides(dictname, data):
    """Ensure the auto-networking plugin doesn't override default or agent
    settings applied by client code.
    """
    scen = pysipp.scenario(**{dictname: data})
    scen = scen.from_agents()
    # netplug.py hooks shouldn't override the uac srcaddr
    if 'client' in dictname:
        agents = scen.clients
    elif 'server' in dictname:
        agents = scen.servers
    else:
        agents = scen.agents

    for key, val in data.items():
        for ua in agents.values():
            assert getattr(ua, key) == val
示例#11
0
def scenarios(request, fs_socks, loglevel):
    '''Provision and return a SIPp scenario with the remote proxy set to the
    current FS server.
    '''
    sipp = spawn.find_executable('sipp')
    if not sipp:
        pytest.skip("SIPp is required to run call/speed tests")

    try:
        import pysipp
    except ImportError:
        pytest.skip("pysipp is required to run call/speed tests")

    pl = pysipp.utils.get_logger()
    pl.setLevel(loglevel)

    if request.config.option.usedocker:
        # use the docker 'bridge' network gateway address
        bind_addr = request.getfixturevalue(
            'containers')[0].attrs['NetworkSettings']['Gateway']
    else:
        # grab IP from DNS lookup
        bind_addr = socket.getaddrinfo(socket.getfqdn(), 0, socket.AF_INET,
                                       socket.SOCK_DGRAM)[0][4][0]

    scens = []
    for fssock in fs_socks:
        # first hop should be fs server
        scen = pysipp.scenario(proxyaddr=fssock,
                               defaults={'local_host': bind_addr})
        scen.log = pl

        # set client destination
        # NOTE: you must add a park extension to your default dialplan!
        scen.agents['uac'].uri_username = '******'
        scens.append(scen)

    return scens
示例#12
0
def basic_scen(request):
    """The most basic scenario instance
    """
    return scenario(autolocalsocks=request.param)
示例#13
0
文件: conftest.py 项目: JorisE/pysipp
def basic_scen():
    """The most basic scenario instance
    """
    return scenario()
示例#14
0
def basic_scen():
    """The most basic scenario instance
    """
    return scenario()