pysipp icon indicating copy to clipboard operation
pysipp copied to clipboard

Provide some doc for pytest usage

Open jimbojd72 opened this issue 6 years ago • 9 comments

The main wiki page is ok to see usage of scenario and uac and uas, but it seems that there is no documentation for integration with pytest (example: auto-discovery of scenario directory, how to override defaults command line value for uas and uac).

pysipp is great work and seems very usable though. Thanks for it.

jimbojd72 avatar Aug 16 '17 14:08 jimbojd72

Hey @jdesmarais-jive thanks for the poke.

I believe @vodik actually has a full pytest-pysipp already although not sure there's many docs :(

I know we had talked about that project getting moved here. So maybe as part of that @vodik can spin up some 👍

goodboy avatar Aug 16 '17 19:08 goodboy

Yeah, no docs yet, as I ripped basically ripped it out of our internal repository and tossed it on github with the plan of eventually making time to clean it up and document it.

There are a few issues with it as its currently written however:

  • It exposes a bug with pluggy (remember the one about callbacks and historic hooks @tgoodlet) which upstream has fixed but pytest hasn't adopted yet (last time I looked they're still using a vendored version). I need to either wait on that, or change the approach.
  • It depends on one or two pieces other plugins we wrote for storing files and logging. They're currently also undocumented in the bowels of pytestlab which I need to also pull out and properly release.

And while I very much need to get around to doing that, my current short term focus as work is building a pure python sipp replacement, so I might not get around to it for a bit ☹️.

vodik avatar Aug 16 '17 20:08 vodik

Thanks for your quick answer.

With a bit a digging it is still usable though.

jimbojd72 avatar Aug 16 '17 20:08 jimbojd72

@jdesmarais-jive iirc with @vodik's plugin you use the --sippscen cmdline arg to set the dir to scan for scenarios. All the network config stuff has to be done manually by you though - otherwise the default random sockets pysipp allocates are used.

You also usually need to set the proxy addr you're testing either using remote_host, proxy_host or both. The full list of flag / config options is here. Additionally, tuple-"combo" settings can be set on each agent for convenience as listed here.

Hope that helps :)

goodboy avatar Aug 16 '17 21:08 goodboy

I roll out my own way around wrapping pysipp in pytest.

Still here was really helping in implementing auto-discovery test.

Thank you all

jimbojd72 avatar Aug 17 '17 13:08 jimbojd72

No worries.

And if you're feeling bold, keep an eye on aiosip. I'm currently rewritting all our SIPp scripts to pure python. I've done two projects with that library thus far, and while its still super alpha, its easier to debug and work with than SIPp.

vodik avatar Aug 17 '17 15:08 vodik

@vodik you have my star

jimbojd72 avatar Aug 17 '17 16:08 jimbojd72

I don't if I should open another issue for that. I'm trying to override a uac parameter (in my specific case: auth_password) and I'm not sure what I'm doing wrong.

scenario files:

/scenarios/register/
                                 uac.xml
                                 pysipp_conf.py

It is not working (the password stay to the clientdefaults["auth_password"] if I did this in pysipp_conf.py:

def pysipp_conf_scen(agents, scen):
    agents['uac'].auth_password = agents['uac'].auth_password + "_incorrect_password"
def pysipp_post_ua_defaults(ua):
    ua.auth_password = ua.auth_password + "_incorrect_password"

What is working though is to override the clientdefaults directly, but I don't like this solution since i may need different password per uac:

#def pysipp_conf_scen(agents, scen):
    scen.clientdefaults['auth_password'] = scen.clientdefaults['auth_password'] + "_incorrect_password"

It there any hook that i'm not aware of that can override UserAgent parameter before running the test?

Another solution that I have though of was using Scenario.from_agents with some agents that I have created myself.

Thanks for your help so far you have been of great help.

jimbojd72 avatar Aug 17 '17 16:08 jimbojd72

Hey @jdesmarais-jive this could very well be a bug. You're first example should definitely work but I'd need to see the entire script you're using to launch the scenario.

If you can make a separate issue that would be great so that this issue doen't get lost and can be closed with a PR if need be.

Also if you find that it is a bug it'd be great if you could write a test to verify it. I think there's one that already tests such overrides using a plugin here.

goodboy avatar Aug 20 '17 16:08 goodboy