I need to stress-test a system and http://locust.io seems like the best way to go about this. However, it looks like it is set up to use the same user every time. I need each spawn to log in as a different user. How do I go about setting that up? Alternatively, is there another system that would be good to use?
相关问题
- Locust Request Statistics
- how to pass custom parameters to a locust test cla
- What are the current best practices for load testi
- How do I use the --header option to send cookies w
- Apache JMeter : Add random data in body for reques
相关文章
- how to pass custom parameters to a locust test cla
- What are the current best practices for load testi
- How do I use the --header option to send cookies w
- Apache JMeter : Add random data in body for reques
- Locust.io Load Testing getting “Connection aborted
- Locust : How to make locust run for a specific amo
- How do I calculate the number of concurrent users
- Best way to stress test a rails web app? [closed]
Alternatively, you can create
users.py
module to hold the users' information you need in your test cases, in my example, it holdsemail
andcookies
. Then you can call them randomly in your tasks. See below:User and user-agent can be called by a function. With this way, we could distribute the test with many users and different user-agents.
I took a slightly different approach when implementing this for a distributed system. I utilized a very simple flask server that I made a get call to during the on_start portion of the TaskSet.
In this way I now have an endpoint I can get at http://localhost:5000/ on whatever host I run this. I just need to make this endpoint accessible to the slave systems and I wont have to worry about duplicate users or some type of round robin effect caused by having a limited set of user_info.
Piggy-backing on @heyman's answer here. The example code will work, but continuing to start / stop tests will eventually clear out the
USER_CREDENTIALS
list, and start to throw errors.I ended up adding the following:
This refreshes your user list once your swarm finishes hatching.
Also keep in mind that you'll need a list longer than the number of users you wish to spawn.
Locust author here.
By default, each HttpLocust user instance has an HTTP client that has it's own separate session.
Locust doesn't have any feature for providing a list of user credentials or similar. However, your load testing scripts are just python code, and luckily it's trivial to implement this yourself.
Here's a short example:
The above code wouldn't work when running Locust distributed, since the same code runs on each slave node, and they don't share any state. Therefore you would have to introduce some external datastore which the slave nodes could use to share states (e.g. PostgreSQL, redis, memcached or something else).