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)
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
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)
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)
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)
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()
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
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
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
def basic_scen(request): """The most basic scenario instance """ return scenario(autolocalsocks=request.param)
def basic_scen(): """The most basic scenario instance """ return scenario()