tag1consulting / goose

Load testing framework, inspired by Locust
https://tag1.com/goose
Apache License 2.0
812 stars 71 forks source link

User Context #570

Closed thisilike closed 1 year ago

thisilike commented 1 year ago

Is there some way to give the user Context?

I can't seem to find anyway to get context into the transaction function. It would be nice to have some kind of context for the Scenario,Transaction and User.

To explain my problem: I want to load test an API, to make the request the API takes some parameters that can't be generated, but need to be picked from a pool of options. This pool is about 200k lines in a csv but it is problematic to open the file in every transaction, especially when it would end up with multiple hundred/thausand open files on the system so it would be nice to give the scenario the pool or each user an option etc.

jeremyandrews commented 1 year ago

There's a variety of methods you could use. For your specific use-case, you may want to explore setting a OnceCell prior to invoking GooseAttack::initialize which you can then read within specific transactions when needed.

You could also a session if you need per-user customizations.

thisilike commented 1 year ago

Thx. Seems like I overlooked it

jeremyandrews commented 1 year ago

Great! Feel free to re-open this, or open a new issue if you run into problems implementing it.