Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename locust to user #1314

Merged
merged 43 commits into from
Apr 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
66e7942
Rename Locust to User
Apr 6, 2020
26573d8
Rename client to users where applicable
Apr 6, 2020
c6207d3
Correct the usage in tests
Apr 6, 2020
ad5f4b0
Merge remote-tracking branch 'locustmaster/master' into rename_locust…
Apr 8, 2020
0777fba
Rename clients options to users and suppress the existing ones
Apr 16, 2020
01a733f
More renaming from locust to user
Apr 16, 2020
b0ff683
Merge branch 'master' of https://github.com/locustio/locust into rena…
Apr 16, 2020
7db61c7
More renaming
Apr 16, 2020
ad584f5
Merge branch 'master' of https://github.com/locustio/locust into rena…
Apr 16, 2020
c783824
More renaming. This was causing the earlier build to fail.
Apr 17, 2020
5589257
rever to -c
Apr 17, 2020
25d253c
use User class in test data
Apr 17, 2020
3c03129
Rename runners
Apr 17, 2020
fdd4d5f
Merge branch 'master' of https://github.com/locustio/locust into rena…
anuj-ssharma Apr 18, 2020
39a42cc
Merge branch 'master' of https://github.com/locustio/locust into rena…
anuj-ssharma Apr 19, 2020
b990796
Use user instead of Locust
anuj-ssharma Apr 19, 2020
530db29
More renaming. Includes renaming in test and example files as well.
anuj-ssharma Apr 20, 2020
5076958
fixed typo
anuj-ssharma Apr 20, 2020
de53ef8
documentation updated
anuj-ssharma Apr 20, 2020
07ff348
Rename the locust_classes to user_classes. Updated relevant documenta…
anuj-ssharma Apr 21, 2020
365d2e5
More renaming. There is an implicit contextual change i.e. locusts ar…
anuj-ssharma Apr 21, 2020
a8239a3
Rename Runner.users to Runner.user_greenlets.
heyman Apr 21, 2020
5d23b6d
Fix broken tests
heyman Apr 21, 2020
6a2e914
Change LocustClass to UserClass in CLI help message
heyman Apr 21, 2020
f53d397
Fix docstring
heyman Apr 21, 2020
0dc6f05
Replace renamed `-c` flag with `-u` in the docs examples
heyman Apr 21, 2020
c078cad
Merge branch 'master' of https://github.com/locustio/locust into rena…
anuj-ssharma Apr 21, 2020
405dd86
fix broken test
anuj-ssharma Apr 22, 2020
e450dc2
More renaming after merging from master
anuj-ssharma Apr 22, 2020
8ba4629
fix broken test
anuj-ssharma Apr 22, 2020
3723be5
A fem more Locust -> User renames
heyman Apr 22, 2020
cc8d553
A fem more Locust -> User renames
heyman Apr 22, 2020
3667397
Rename locust attribute on TaskSet to user
heyman Apr 22, 2020
47c104b
Rename locust -> user in docstrings
heyman Apr 22, 2020
ad42d4e
Rename is_locust function to is_user_class
heyman Apr 22, 2020
17edbb6
More "locust" -> "user" renaming
heyman Apr 22, 2020
29c18cf
Rename "locust" to -> "user" in WebUI HTML template
heyman Apr 22, 2020
796d86e
Increase sleep time to make test less flaky
heyman Apr 22, 2020
8db7c2d
More "locust" -> "user" renaming
heyman Apr 23, 2020
08228a4
Update python references in documentation ("locust" -> "user" renaming)
heyman Apr 23, 2020
339eae3
Use new tasks API in example that had been missed
heyman Apr 23, 2020
4f4b83b
Rename local variable worker_num_clients to worker_num_users
heyman Apr 23, 2020
5aca141
Add entry about "Locust" -> "User" renaming, to Changelog
heyman Apr 23, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
Locust is an easy-to-use, distributed, user load testing tool. It is intended for load-testing web sites (or other systems) and
figuring out how many concurrent users a system can handle.

The idea is that during a test, a swarm of locusts will attack your website. The behavior of each locust (or test user if you will) is
defined by you and the swarming process is monitored from a web UI in real-time. This will help you battle test and identify bottlenecks
in your code before letting real users in.
The idea is that during a test, a swarm of simulated users will attack your website. The behavior of each user is defined by you
using Python code, and the swarming process is monitored from a web UI in real-time. This will help you battle test and identify
bottlenecks in your code before letting real users in.

Locust is completely event-based, and therefore it's possible to support thousands of concurrent users on a single machine.
In contrast to many other event-based apps it doesn't use callbacks. Instead it uses light-weight processes, through <a href="http://www.gevent.org/">gevent</a>.
Expand All @@ -42,7 +42,7 @@ of callbacks, your code looks and behaves like normal, blocking Python code.
Locust has a neat HTML+JS that shows all relevant test details in real-time. And since the UI is web-based, it's cross-platform and easily extendable.

* **Can test any system**<br>
Even though Locust is web-oriented, it can be used to test almost any system. Just write a client for what ever you wish to test and swarm it with locusts! It's super easy!
Even though Locust is web-oriented, it can be used to test almost any system. Just write a client for what ever you wish to test and swarm it with users! It's super easy!

* **Hackable**<br>
Locust is very small and very hackable and we intend to keep it that way. All heavy-lifting of evented I/O and coroutines are delegated to gevent. The brittleness of alternative testing tools was the reason we created Locust.
Expand Down
22 changes: 11 additions & 11 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@ API
###


Locust class
User class
============

.. autoclass:: locust.core.Locust
.. autoclass:: locust.core.User
:members: wait_time, tasks, weight, abstract, on_start, on_stop, wait

HttpLocust class
HttpUser class
================

.. autoclass:: locust.core.HttpLocust
.. autoclass:: locust.core.HttpUser
:members: wait_time, tasks, client, abstract


TaskSet class
=============

.. autoclass:: locust.core.TaskSet
:members: locust, parent, wait_time, client, tasks, interrupt, schedule_task, on_start, on_stop, wait
:members: user, parent, wait_time, client, tasks, interrupt, schedule_task, on_start, on_stop, wait

task decorator
==============
Expand All @@ -31,7 +31,7 @@ SequentialTaskSet class
=======================

.. autoclass:: locust.sequential_taskset.SequentialTaskSet
:members: locust, parent, wait_time, client, tasks, interrupt, schedule_task, on_start, on_stop
:members: user, parent, wait_time, client, tasks, interrupt, schedule_task, on_start, on_stop


.. _wait_time_functions:
Expand Down Expand Up @@ -107,17 +107,17 @@ The event hooks are instances of the **locust.events.EventHook** class:
to prevent your code from breaking if new arguments are added in a future version.


Locust Runner classes
Runner classes
=====================

.. autoclass:: locust.runners.LocustRunner
.. autoclass:: locust.runners.Runner
:members: start, stop, quit, user_count

.. autoclass:: locust.runners.LocalLocustRunner
.. autoclass:: locust.runners.LocalRunner

.. autoclass:: locust.runners.MasterLocustRunner
.. autoclass:: locust.runners.MasterRunner

.. autoclass:: locust.runners.WorkerLocustRunner
.. autoclass:: locust.runners.WorkerRunner


Web UI class
Expand Down
14 changes: 12 additions & 2 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,18 @@ For full details of the Locust changelog, please see https://github.com/locustio
1.0 (In development)
====================

Breaking changes
----------------
This version contains some breaking changes.

Locust class renamed to User
----------------------------

We've renamed the ``Locust`` and ``HttpLocust`` classes to ``User`` and ``HttpUser``. The ``locust`` attribute on
:py:class:`TaskSet <locust.core.TaskSet>` instances has been renamed to :py:attr:`user <locust.core.TaskSet.user>`.



Other breaking changes
----------------------

* The option for running Locust without the Web UI has been renamed from ``--no-web`` to ``--headless``.
* Removed ``Locust.setup``, ``Locust.teardown``, ``TaskSet.setup`` and ``TaskSet.teardown`` hooks. If you want to
Expand Down
2 changes: 1 addition & 1 deletion docs/extending-locust.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Locust comes with a number of events hooks that can be used to extend Locust in
Event hooks live on the Environment instance under the :py:attr:`events <locust.env.Environment.events>`
attribute. However, since the Environment instance hasn't been created when locustfiles are imported,
the events object can also be accessed at the module level of the locustfile through the
:py:attr:`locust.events` variable.
:py:obj:`locust.events` variable.

Here's an example on how to set up an event listener::

Expand Down
24 changes: 12 additions & 12 deletions docs/increase-performance.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,27 @@ Increase Locust's performance with a faster HTTP client
Locust's default HTTP client uses `python-requests <http://www.python-requests.org/>`_.
The reason for this is that requests is a very well-maintained python package, that
provides a really nice API, that many python developers are familiar with. Therefore,
in many cases, we recommend that you use the default :py:class:`HttpLocust <locust.core.HttpLocust>`
in many cases, we recommend that you use the default :py:class:`HttpUser <locust.core.HttpUser>`
which uses requests. However, if you're planning to run really large scale tests,
Locust comes with an alternative HTTP client,
:py:class:`FastHttpLocust <locust.contrib.fasthttp.FastHttpLocust>` which
:py:class:`FastHttpUser <locust.contrib.fasthttp.FastHttpUser>` which
uses `geventhttpclient <https://github.com/gwik/geventhttpclient/>`_ instead of requests.
This client is significantly faster, and we've seen 5x-6x performance increases for making
HTTP-requests. This does not necessarily mean that the number of users one can simulate
per CPU core will automatically increase 5x-6x, since it also depends on what else
the load testing script does. However, if your locust scripts are spending most of their
CPU time in making HTTP-requests, you are likely to see signifant performance gains.
CPU time in making HTTP-requests, you are likely to see significant performance gains.


How to use FastHttpLocust
How to use FastHttpUser
===========================

Subclass FastHttpLocust instead of HttpLocust::
Subclass FastHttpUser instead of HttpUser::

from locust import task, between
from locust.contrib.fasthttp import FastHttpLocust
from locust.contrib.fasthttp import FastHttpUser

class MyLocust(FastHttpLocust):
class MyUser(FastHttpUser):
wait_time = between(1, 60)

@task
Expand All @@ -37,19 +37,19 @@ Subclass FastHttpLocust instead of HttpLocust::

.. note::

FastHttpLocust uses a whole other HTTP client implementation, with a different API, compared to
the default HttpLocust that uses python-requests. Therefore FastHttpLocust might not work as a
drop-in replacement for HttpLocust, depending on how the HttpClient is used.
FastHttpUser uses a whole other HTTP client implementation, with a different API, compared to
the default HttpUser that uses python-requests. Therefore FastHttpUser might not work as a
drop-in replacement for HttpUser, depending on how the HttpClient is used.


API
===


FastHttpLocust class
FastHttpUser class
--------------------

.. autoclass:: locust.contrib.fasthttp.FastHttpLocust
.. autoclass:: locust.contrib.fasthttp.FastHttpUser
:members: network_timeout, connection_timeout, max_redirects, max_retries, insecure


Expand Down
10 changes: 5 additions & 5 deletions docs/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ Below is a quick little example of a simple **locustfile.py**:
.. code-block:: python

import random
from locust import HttpLocust, task, between
from locust import HttpUser, task, between

class WebsiteUser(HttpLocust):
class WebsiteUser(HttpUser):
wait_time = between(5, 9)

@task(2)
Expand All @@ -37,7 +37,7 @@ Below is a quick little example of a simple **locustfile.py**:
self.client.get("/post?id=%i" % post_id, name="/post?id=[post-id]")

def on_start(self):
""" on_start is called when a Locust start before any task is scheduled """
""" on_start is called when a User starts before any task is scheduled """
self.login()

def login(self):
Expand All @@ -49,10 +49,10 @@ Let's break it down:

.. code-block:: python

class WebsiteUser(HttpLocust):
class WebsiteUser(HttpUser):

Here we define a class for the users that we will be simulating. It inherits from
:py:class:`HttpLocust <locust.core.HttpLocust>` which gives each user a ``client`` attribute,
:py:class:`HttpUser <locust.core.HttpUser>` which gives each user a ``client`` attribute,
which is an instance of :py:class:`HttpSession <locust.clients.HttpSession>`, that
can be used to make HTTP requests to the target system that we want to load test. When a test starts,
locust will create an instance of this class for every user that it simulates, and each of these
Expand Down
6 changes: 3 additions & 3 deletions docs/running-locust-distributed.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ processor core** on the worker machines.

.. note::
It's recommended that you start a number of simulated users that are greater than
``number of locust classes * number of workers`` when running Locust distributed.
``number of user classes * number of workers`` when running Locust distributed.

Otherwise - due to the current implementation -
you might end up with a distribution of the Locust classes that doesn't correspond to the
Locust classes' ``weight`` attribute. And if the hatch rate is lower than the number of worker
you might end up with a distribution of the User classes that doesn't correspond to the
User classes' ``weight`` attribute. And if the hatch rate is lower than the number of worker
nodes, the hatching would occur in "bursts" where all worker node would hatch a single user and
then sleep for multiple seconds, hatch another user, sleep and repeat.

Expand Down
2 changes: 1 addition & 1 deletion docs/running-locust-in-step-load-mode.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ If you want to run Locust in step load mode without the web UI, you can do that

.. code-block:: console

$ locust -f --headless -c 1000 -r 100 --run-time 1h30m --step-load --step-clients 300 --step-time 20m
$ locust -f --headless -u 1000 -r 100 --run-time 1h30m --step-load --step-clients 300 --step-time 20m

Locust will swarm the clients by step and shutdown once the time is up.

Expand Down
10 changes: 5 additions & 5 deletions docs/running-locust-without-web-ui.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ Running Locust without the web UI
=================================

You can run locust without the web UI - for example if you want to run it in some automated flow,
like a CI server - by using the ``--headless`` flag together with ``-c`` and ``-r``:
like a CI server - by using the ``--headless`` flag together with ``-u`` and ``-r``:

.. code-block:: console

$ locust -f locust_files/my_locust_file.py --headless -c 1000 -r 100
$ locust -f locust_files/my_locust_file.py --headless -u 1000 -r 100

``-c`` specifies the number of Locust users to spawn, and ``-r`` specifies the hatch rate
``-u`` specifies the number of Users to spawn, and ``-r`` specifies the hatch rate
(number of users to spawn per second).


Expand All @@ -22,7 +22,7 @@ If you want to specify the run time for a test, you can do that with ``--run-tim

.. code-block:: console

$ locust -f --headless -c 1000 -r 100 --run-time 1h30m
$ locust -f --headless -u 1000 -r 100 --run-time 1h30m

Locust will shutdown once the time is up.

Expand All @@ -33,7 +33,7 @@ By default, locust will stop your tasks immediately. If you want to allow your t

.. code-block:: console

$ locust -f --headless -c 1000 -r 100 --run-time 1h30m --stop-timeout 99
$ locust -f --headless -u 1000 -r 100 --run-time 1h30m --stop-timeout 99

.. _running-locust-distributed-without-web-ui:

Expand Down
12 changes: 6 additions & 6 deletions docs/testing-other-systems.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ any request/response based system, by writing a custom client that triggers
:py:attr:`request_success <locust.event.Events.request_success>` and
:py:attr:`request_failure <locust.event.Events.request_failure>` events.

Sample XML-RPC Locust client
Sample XML-RPC User client
============================

Here is an example of a Locust class, **XmlRpcLocust**, which provides an XML-RPC client,
**XmlRpcClient**, and tracks all requests made:
Here is an example of a User class, **XmlRpcUser**, which provides an XML-RPC client,
**XmlRpcUser**, and tracks all requests made:

.. literalinclude:: ../examples/custom_xmlrpc_client/xmlrpc_locustfile.py

If you've written Locust tests before, you'll recognize the class called ``ApiUser`` which is a normal
Locust class that has a couple of tasks declared. However, the ``ApiUser`` inherits from
``XmlRpcLocust`` that you can see right above ``ApiUser``. The ``XmlRpcLocust`` is marked as abstract
User class that has a couple of tasks declared. However, the ``ApiUser`` inherits from
``XmlRpcUser`` that you can see right above ``ApiUser``. The ``XmlRpcUser`` is marked as abstract
using ``abstract = True`` which means that Locust till not try to create simulated users from that class
(only of classes that extends it). ``XmlRpcLocust`` provides an instance of XmlRpcClient under the
(only of classes that extends it). ``XmlRpcUser`` provides an instance of XmlRpcClient under the
``client`` attribute.

The ``XmlRpcClient`` is a wrapper around the standard
Expand Down
4 changes: 2 additions & 2 deletions docs/third-party-tools.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ Using other languages
=====================

A Locust master and a Locust worker communicate by exchanging `msgpack <http://msgpack.org/>`_ messages, which is
supported by many languages. So, you can write your Locust tasks in any languages you like. For convenience, some
libraries do the job as a worker runner. They run your Locust tasks, and report to master regularly.
supported by many languages. So, you can write your User tasks in any languages you like. For convenience, some
libraries do the job as a worker runner. They run your User tasks, and report to master regularly.


Golang
Expand Down
6 changes: 3 additions & 3 deletions docs/use-as-lib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ To run Locust as a library you need to create an :py:class:`Environment <locust.

from locust.env import Environment

env = Environment(locust_classes=[MyTestUser])
env = Environment(user_classes=[MyTestUser])

The :py:class:`Environment <locust.env.Environment>` instance's
:py:meth:`create_local_runner <locust.env.Environment.create_local_runner>`,
:py:meth:`create_master_runner <locust.env.Environment.create_master_runner>` or
:py:meth:`create_worker_runner <locust.env.Environment.create_worker_runner> can then be used to start a
:py:class:`LocustRunner <locust.runners.LocustRunner>` instance, which can be used to start a load test:
:py:meth:`create_worker_runner <locust.env.Environment.create_worker_runner>` can then be used to start a
:py:class:`Runner <locust.runners.Runner>` instance, which can be used to start a load test:

.. code-block:: python

Expand Down
9 changes: 4 additions & 5 deletions docs/what-is-locust.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ What is Locust?
Locust is an easy-to-use, distributed, user load testing tool. It is intended for load-testing web sites
(or other systems) and figuring out how many concurrent users a system can handle.

The idea is that during a test, a swarm of `locusts <http://en.wikipedia.org/wiki/Locust>`_
will attack your website. The behavior of each
locust (or test user if you will) is defined by you and the swarming process is monitored from a
web UI in real-time. This will help you battle test and identify bottlenecks in your code before
letting real users in.
The idea is that during a test, a swarm of `locust <http://en.wikipedia.org/wiki/Locust>`_ users
will attack your website. The behavior of each user is defined by you using Python code, and the
swarming process is monitored from a web UI in real-time. This will help you battle test and identify
bottlenecks in your code before letting real users in.

Locust is completely event-based, and therefore it's possible to support thousands of concurrent
users on a single machine. In contrast to many other event-based apps it doesn't use callbacks.
Expand Down
Loading