Skip to content

Commit

Permalink
Sync with LocusIO Repo (#1)
Browse files Browse the repository at this point in the history
* More robust handling of ZMQ/RPC errors (locustio#2120)

* More robust RPC error handling on msg from worker

* Use dedicated exceptions, fewer nested try blocks

* Fix test_zmqrpc.py

* Undo function split since added new exceptions

* Fix more tests

* Fix some tests

* Fix typo

* Fix scoping of variables

* Add tests for RPC/ZMQ changes

* flake and black fixes

* Remove debug print line

Co-authored-by: Ryan Warner <ryan.warner@edgecast.com>

* Remove timeout parameter from FastHttpUser unit tests

* Update changelog for 2.10

* Increase CONNECT_RETRY_COUNT to avoid workers giving up too soon if master is not up yet

* Escape user supplied data in html report (locustio#2126) (locustio#2127)

* Escape user supplied data in html report (locustio#2126)

authored-by: Tom Herrmann <t.herrmann@sab-engineering.com>

* Replace the MD5 usage by SHA256

MD5 is old, insecure, and can create problems for people using this package when they are trying to pass some compliance requirements (for example, FIPS).

* Fix escaping for exceptions in normal web ui (related to locustio#2126)

* implement table-sorting in report.html

* fix: Fix typo at user/wait_time.py

* improve report sorting

* enabled sorting of error messages as well as stacktraces

* Minor edits to the documentation

* Small documentation correction

* Minor edits to the documentation

* Log an error for every failed attempt to connect to master

The connection timeout and number of attempts are hardcoded, so a failure will take very long
These log lines will allow to troubleshoot issues with the connection to master

* Minor edits to the documentation

* Minor edits to the documentation

* Minor edits to the documentation

* Stop calling attributes 'properties' in some places.

* Give a better error message when someone accidentally sets User.task instead of User.tasks

* Fix detection of accidental TaskSet.task attribute

* fix spelling in comment

* style: add a report favicon

* Removed cache_timeout kwarg from request_stats_full_history_csv for flask 2.2.0

* temporary change to see logs for py38

* restored resource warning masking

* enabled tracemalloc temporarily

* removed tracemalloc

* Ensure no caching of stats history csv (replaces cache_timeout=None which was removed in locustio#2148)

* Update changelog for 2.10.2 (automatic changelog generation is broken, so CHANGELOG.md is incomplete)

* test: Implement failing test for issue locustio#2135

* fix: Set users_dispatcher to None when test is stopped

* chore: Remove misleading docstring in test

* chore: Do not use intermediate variable for one-use

* perf(test): Decrease test runtime

Co-authored-by: solowalker27 <ryan.subscriptions@me.com>
Co-authored-by: Ryan Warner <ryan.warner@edgecast.com>
Co-authored-by: Lars Holmberg <lars.holmberg@svenskaspel.se>
Co-authored-by: Tom Herrmann <linux@randoom.org>
Co-authored-by: Renan Gomes Barreto <RenanGBarreto@users.noreply.github.com>
Co-authored-by: Tom Herrmann <t.herrmann@sab-engineering.com>
Co-authored-by: Lukas Lanzner <l.lanzner@sab-engineering.com>
Co-authored-by: Dmytro Litvinov <me@dmytrolitvinov.com>
Co-authored-by: Xavier Sosnovsky <xso@sosna.ws>
Co-authored-by: Andy Byrne <andybyrne@users.noreply.github.com>
Co-authored-by: gdm85 <gdm85@users.noreply.github.com>
Co-authored-by: Xavier Sosnovsky <sosna@users.noreply.github.com>
Co-authored-by: Lars Holmberg <lars.holmberg@redshirt.se>
Co-authored-by: Lijiawei <1456470136@qq.com>
Co-authored-by: Michael Nester <mike.nester0@gmail.com>
Co-authored-by: Maxence Boutet <maxenceboutet@outlook.com>
Co-authored-by: Maxence Boutet <52334444+mboutet@users.noreply.github.com>
  • Loading branch information
18 people authored Aug 9, 2022
1 parent 20c1d15 commit b7b5284
Show file tree
Hide file tree
Showing 34 changed files with 394 additions and 144 deletions.
34 changes: 33 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,37 @@
# Changelog
Note that PRs for the latest version are sometimes missing here, check [github](https://github.com/locustio/locust/releases) for the latest info.
# Automatic change log generation is broken at the moment. See [github](https://github.com/locustio/locust/releases) instead.

------------------------------------------------------------------------------------------------------------------------------

## [2.10.2](https://github.com/locustio/locust/tree/2.10.2)

[Full Changelog](https://github.com/locustio/locust/compare/2.10.1...2.10.2)

## [2.10.1](https://github.com/locustio/locust/tree/2.10.1)

[Full Changelog](https://github.com/locustio/locust/compare/2.10.0...2.10.1)

## [2.10.0](https://github.com/locustio/locust/tree/2.10.0) (2022-06-27)

[Full Changelog](https://github.com/locustio/locust/compare/2.9.0...2.10.0)

**Closed issues:**

- Add ACK for worker connection [\#2044](https://github.com/locustio/locust/issues/2044)

**Merged pull requests:**

- Remove timeout parameter from FastHttpUser unit tests [\#2123](https://github.com/locustio/locust/pull/2123) ([cyberw](https://github.com/cyberw))
- Convert url for getting tasks to relative [\#2121](https://github.com/locustio/locust/pull/2121) ([5imun](https://github.com/5imun))
- More robust handling of ZMQ/RPC errors [\#2120](https://github.com/locustio/locust/pull/2120) ([solowalker27](https://github.com/solowalker27))
- Update the link for reporting data to a database [\#2119](https://github.com/locustio/locust/pull/2119) ([AlexMooney](https://github.com/AlexMooney))
- fix: stopping state when running more than one worker node. [\#2116](https://github.com/locustio/locust/pull/2116) ([renato-farias](https://github.com/renato-farias))
- add support for custom SSLContext when using FastHttpUser [\#2113](https://github.com/locustio/locust/pull/2113) ([renato-farias](https://github.com/renato-farias))
- chore: Set permissions for GitHub actions [\#2107](https://github.com/locustio/locust/pull/2107) ([naveensrinivasan](https://github.com/naveensrinivasan))
- additional typing improvements [\#2106](https://github.com/locustio/locust/pull/2106) ([mgor](https://github.com/mgor))
- Stop client\_listener from raising a KeyError when receiving a client\_stopped message from unknown worker [\#2102](https://github.com/locustio/locust/pull/2102) ([BirdLearn](https://github.com/BirdLearn))
- Fix multiple resetting connection after RPCError [\#2096](https://github.com/locustio/locust/pull/2096) ([Nosibb](https://github.com/Nosibb))
- Add ack for worker connection [\#2077](https://github.com/locustio/locust/pull/2077) ([Nosibb](https://github.com/Nosibb))

## [2.9.0](https://github.com/locustio/locust/tree/2.9.0) (2022-05-19)

Expand Down
15 changes: 15 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@ Changelog Highlights

For full details of the Locust changelog, please see https://github.com/locustio/locust/blob/master/CHANGELOG.md

2.10.2
======
* Fix for Flask 2.2.0 breaking changes https://github.com/locustio/locust/pull/2148

2.10.1
======
* Increase CONNECT_RETRY_COUNT to avoid workers giving up too soon if master is not up yet by https://github.com/locustio/locust/pull/2125

2.10.0
======
* Add ack for worker connection https://github.com/locustio/locust/pull/2077 (note that 2.10 workers will not work with a 2.9 master)
* add support for custom SSLContext when using FastHttpUser https://github.com/locustio/locust/pull/2113
* More robust handling of ZMQ/RPC errors https://github.com/locustio/locust/pull/2120 / https://github.com/locustio/locust/pull/2096
* Full Changelog https://github.com/locustio/locust/compare/2.9.0...2.10.0

2.9.0
=====

Expand Down
2 changes: 1 addition & 1 deletion docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Customization of statistics settings

Default configuration for Locust statistics is set in constants of stats.py file.
It can be tuned to specific requirements by overriding these values.
To do this, import locust.stats module and override required settings
To do this, import locust.stats module and override required settings:

.. code-block:: python
Expand Down
4 changes: 2 additions & 2 deletions docs/developing-locust.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ You want to contribute to Locust? Great! Here is a list of `open bugs/feature re
Install Locust for development
==============================

Fork Locust on `Github <https://github.com/locustio/locust/>`_ and then run
Fork Locust on `GitHub <https://github.com/locustio/locust/>`_ and then run

.. code-block:: console
Expand Down Expand Up @@ -53,7 +53,7 @@ Then you can build the documentation locally using:
make build_docs
Then the documentation should be build and available at ``docs/_build/index.html``
Then the documentation should be build and available at ``docs/_build/index.html``.



Expand Down
2 changes: 1 addition & 1 deletion docs/extending-locust.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ For example, here's how to set up an event listener that will trigger after a re

.. note::

In the above example the wildcard keyword argument (\**kwargs) will be empty, because we're handling all arguments, but it is prevents the code from breaking if new arguments are added in some future version of Locust.
In the above example the wildcard keyword argument (\**kwargs) will be empty, because we're handling all arguments, but it prevents the code from breaking if new arguments are added in some future version of Locust.

Also, it is entirely possible to implement a client that does not supply all parameters for this event.
For example, non-HTTP protocols might not even have the a concept of `url` or `response` object.
Expand Down
2 changes: 1 addition & 1 deletion docs/further-reading.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ You'll also find a lot of answers on `stackoverflow <https://stackoverflow.com/q

In other words, just google whatever problem or error message you're getting and you are likely to find good answers out there.

If you think Locust is missing some obvious feature (like stopping after a certain number of iterations/requests, setting goals/thresholds for when to fail a test run, support for additional User types like Kafka, Selenium/WebDriver etc), chances are it is implemented in `locust-plugins <https://github.com/SvenskaSpel/locust-plugins/>`_
If you think Locust is missing some obvious feature (like stopping after a certain number of iterations/requests, setting goals/thresholds for when to fail a test run, support for additional User types like Kafka, Selenium/WebDriver etc), chances are it is implemented in `locust-plugins <https://github.com/SvenskaSpel/locust-plugins/>`_.
2 changes: 1 addition & 1 deletion docs/increase-performance.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Just subclass FastHttpUser instead of HttpUser::

.. note::

FastHttpUser/geventhttpclient is very similar to for HttpUser/python-requests, but sometimes there are subtle differences. This is particularly true if you work with the client library's internals, e.g. when manually managing cookies.
FastHttpUser/geventhttpclient is very similar to HttpUser/python-requests, but sometimes there are subtle differences. This is particularly true if you work with the client library's internals, e.g. when manually managing cookies.

API
===
Expand Down
2 changes: 1 addition & 1 deletion docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Installation
============

`Install Python <https://docs.python-guide.org/starting/installation/>`_ 3.7 or later, if you dont already have it.
`Install Python <https://docs.python-guide.org/starting/installation/>`_ 3.7 or later, if you don't already have it.

Install Locust:

Expand Down
10 changes: 5 additions & 5 deletions docs/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Getting started
===============

A Locust test is essentially a Python program. This makes it very flexible and particularly good at implementing complex user flows. But it can do simple tests as well, so lets start with that:
A Locust test is essentially a Python program. This makes it very flexible and particularly good at implementing complex user flows. But it can do simple tests as well, so let's start with that:

.. code-block:: python
Expand Down Expand Up @@ -55,17 +55,17 @@ Number of users:

.. note::

Interpreting performance test results is quite complex (and mostly out of scope for this manual), but if your graphs start looking like this, the most likely reason is that your target service/system cannot handle the load you are hitting it with (it is overloaded or "saturated")
Interpreting performance test results is quite complex (and mostly out of scope for this manual), but if your graphs start looking like this, the most likely reason is that your target service/system cannot handle the load you are hitting it with (it is overloaded or "saturated").

The clearest sign of this is that when we get to around 9 users, response times start increasing so fast that the requests per second-curve flattens out, even though new users are still being added.

If you're having trouble generating enough load to saturate your system, or need some pointers on how to start digging into a server side problem have a look at the `Locust FAQ <https://github.com/locustio/locust/wiki/FAQ#increase-my-request-raterps>`_
If you're having trouble generating enough load to saturate your system, or need some pointers on how to start digging into a server side problem have a look at the `Locust FAQ <https://github.com/locustio/locust/wiki/FAQ#increase-my-request-raterps>`_.


Direct command line usage / headless
====================================

Using the Locust web UI is entirely optional. You can supply the load parameters on command line and get reports on the results in text form:
Using the Locust web UI is entirely optional. You can supply the load parameters on the command line and get reports on the results in text form:

.. code-block:: console
:substitutions:
Expand Down Expand Up @@ -100,4 +100,4 @@ To see all available options type: ``locust --help`` or check :ref:`configuratio

|
Now, lets have a more in-depth look at locustfiles and what they can do: :ref:`writing-a-locustfile`
Now, let's have a more in-depth look at locustfiles and what they can do: :ref:`writing-a-locustfile`.
8 changes: 4 additions & 4 deletions docs/running-distributed.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Optionally used together with ``--worker`` to set the port number of the master
``--master-bind-host=X.X.X.X``
------------------------------

Optionally used together with ``--master``. Determines what network interface that the master node
Optionally used together with ``--master``. Determines which network interface the master node
will bind to. Defaults to * (all available interfaces).

``--master-bind-port=5557``
Expand Down Expand Up @@ -118,7 +118,7 @@ order to coordinate data. This can be easily accomplished with custom messages u
environment.runner.send_message('test_users', users)
Note that when running locally (i.e. non-distributed), this functionality will be preserved;
the messages will simply be handled by the same runner that sends them.
the messages will simply be handled by the runner that sends them.

A more complete example can be found in the `examples directory <https://github.com/locustio/locust/tree/master/examples>`_ of the Locust
source code.
Expand All @@ -139,5 +139,5 @@ See :ref:`running-distributed-without-web-ui`
Increase Locust's performance
=============================

If you're planning to run large-scale load tests you might be interested to use the alternative
HTTP client that's shipped with Locust. You can read more about it here: :ref:`increase-performance`
If you're planning to run large-scale load tests, you might be interested to use the alternative
HTTP client that's shipped with Locust. You can read more about it here: :ref:`increase-performance`.
6 changes: 3 additions & 3 deletions docs/running-in-debugger.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Running Locust in a debugger is extremely useful when developing your tests. Amo

But debuggers sometimes have issues with complex gevent-applications like Locust, and there is a lot going on in the framework itself that you probably aren't interested in. To simplify this, Locust provides a method called :py:func:`run_single_user <locust.debug.run_single_user>`:

Note that this is fairly new feature, and the api is subject to change.
Note that this is a fairly new feature, and the api is subject to change.

.. literalinclude:: ../examples/debugging.py
:language: python
Expand All @@ -28,12 +28,12 @@ Make sure you have enabled gevent in your debugger settings. In VS Code's ``laun
.. literalinclude:: ../.vscode/launch.json
:language: json

There is a similar setting in `PyCharm <https://www.jetbrains.com/help/pycharm/debugger-python.html>`_
There is a similar setting in `PyCharm <https://www.jetbrains.com/help/pycharm/debugger-python.html>`_.

.. note::

| VS Code/pydev may give you warnings about:
| ``sys.settrace() should not be used when the debugger is being used``
| It can safely be ignored (and if you know how to get rid of it, please let us know)
You can execute run_single_user multiple times, as shown in `debugging_advanced.py <https://github.com/locustio/locust/tree/master/examples/debugging_advanced.py>`_
You can execute run_single_user multiple times, as shown in `debugging_advanced.py <https://github.com/locustio/locust/tree/master/examples/debugging_advanced.py>`_.
4 changes: 2 additions & 2 deletions docs/running-in-docker.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ official Locust docker image as a base image::
Running a distributed load test on Kubernetes
=============================================

The easiest way to run Locust on Kubernetes is to use a `Helm chart <https://helm.sh/>`_
The easiest way to run Locust on Kubernetes is to use a `Helm chart <https://helm.sh/>`_.

There is a good helm chart here: `github.com/deliveryhero/helm-charts <https://github.com/deliveryhero/helm-charts/tree/master/stable/locust>`_
There is a good helm chart here: `github.com/deliveryhero/helm-charts <https://github.com/deliveryhero/helm-charts/tree/master/stable/locust>`_.

Note: this Helm chart is a separate project, and not supported by Locust maintainers.
2 changes: 1 addition & 1 deletion docs/running-without-web-ui.rst
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,4 @@ Below is an example that'll set the exit code to non zero if any of the followin
else:
environment.process_exit_code = 0
(this code could go into the locustfile.py or in any other file that is imported in the locustfile)
Note that this code could go into the locustfile.py or in any other file that is imported in the locustfile.
2 changes: 1 addition & 1 deletion docs/tasksets.rst
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ For example, the following code will request URLs /1-/4 in order, and then repea
self.client.get("/1")
self.client.get("/2")
# you can still use the tasks property to specify a list of tasks
# you can still use the tasks attribute to specify a list of tasks
tasks = [function_task]
@task
Expand Down
10 changes: 5 additions & 5 deletions docs/testing-other-systems.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ Locust only comes with built-in support for HTTP/HTTPS but it can be extended to

It is important that the protocol libraries you use can be `monkey-patched <http://www.gevent.org/intro.html#monkey-patching>`_ by gevent.

Almost any libraries that are pure Python (using the Python ``socket`` module or some other standard library function like ``subprocess``) should work fine out of the box - but if they do their I/O calls in C gevent will be unable to patch it. This will block the whole Locust/Python process (in practice limiting you to running a single User per worker process)
Almost any libraries that are pure Python (using the Python ``socket`` module or some other standard library function like ``subprocess``) should work fine out of the box - but if they do their I/O calls in C, gevent will be unable to patch it. This will block the whole Locust/Python process (in practice limiting you to running a single User per worker process).

Some C libraries allow for other workarounds. For example, if you want to use psycopg2 to performance test PostgreSQL, you can use `psycogreen <https://github.com/psycopg/psycogreen/>`_. If you are willing to get your hands dirty, you may also be able to do patch a library yourself, but that is beyond the scope of this documentation.
Some C libraries allow for other workarounds. For example, if you want to use psycopg2 to performance test PostgreSQL, you can use `psycogreen <https://github.com/psycopg/psycogreen/>`_. If you are willing to get your hands dirty, you may also be able to patch a library yourself, but that is beyond the scope of this documentation.

Example: writing an XML-RPC User/client
=======================================

Lets assume we had an XML-RPC server that we wanted to load test
Lets assume we had an XML-RPC server that we wanted to load test.

.. literalinclude:: ../examples/custom_xmlrpc_client/server.py

We can build a generic XML-RPC client, by wrapping :py:class:`xmlrpc.client.ServerProxy`
We can build a generic XML-RPC client, by wrapping :py:class:`xmlrpc.client.ServerProxy`.

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

Expand All @@ -47,4 +47,4 @@ gRPC client, base User and example usage:
.. literalinclude:: ../examples/grpc/locustfile.py


For more examples of user types, see `locust-plugins <https://github.com/SvenskaSpel/locust-plugins#users>`_ (it has users for WebSocket/SocketIO, Kafka, Selenium/WebDriver and more)
For more examples of user types, see `locust-plugins <https://github.com/SvenskaSpel/locust-plugins#users>`_ (it has users for WebSocket/SocketIO, Kafka, Selenium/WebDriver and more).
4 changes: 2 additions & 2 deletions docs/testing-requests-based SDK's.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
Testing Requests based SDKs
=============================

If a prebuilt SDK is available for your target system. Locust has a supported pattern for integrating
If a prebuilt SDK is available for your target system, Locust has a supported pattern for integrating
its usage into your load testing efforts.

The only perquisite to achieve this; is that the SDK needs to have an accessible ``request.Sessions``
The only prerequisite to achieve this is that the SDK needs to have an accessible ``request.Sessions``
class.

The following example shows the locust client overwriting the internal ``_session`` object of ``Archivist`` SDK
Expand Down
Loading

0 comments on commit b7b5284

Please sign in to comment.