From a47a733cd3232f9a898f203bbbb397d371a6032c Mon Sep 17 00:00:00 2001 From: Alexander Nyurenberg Date: Thu, 20 Jan 2022 22:57:02 +0300 Subject: [PATCH] Added the description of the 'fixed_count' property into the documentation. --- docs/api.rst | 2 +- docs/writing-a-locustfile.rst | 21 ++++++++++++++++++++- locust/user/users.py | 6 +++--- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/docs/api.rst b/docs/api.rst index bd2f5baef9..642682cfb3 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -7,7 +7,7 @@ User class ============ .. autoclass:: locust.User - :members: wait_time, tasks, weight, abstract, on_start, on_stop, wait, context, environment + :members: wait_time, tasks, weight, fixed_count, abstract, on_start, on_stop, wait, context, environment HttpUser class ================ diff --git a/docs/writing-a-locustfile.rst b/docs/writing-a-locustfile.rst index 3e43b76030..205a6f1c56 100644 --- a/docs/writing-a-locustfile.rst +++ b/docs/writing-a-locustfile.rst @@ -180,7 +180,7 @@ For example, the following User class would sleep for one second, then two, then ... -weight attribute +weight and fixed_count attributes ---------------- If more than one user class exists in the file, and no user classes are specified on the command line, @@ -204,6 +204,25 @@ classes. Say for example, web users are three times more likely than mobile user weight = 1 ... +Also you can set the :py:attr:`fixed_count ` attribute. +In this case the weight property will be ignored and the exact count users will be spawned. +These users are spawned first. In the below example the only instance of AdminUser +will be spawned to make some specific work with more accurate control +of request count independently of total user count. + +.. code-block:: python + + class AdminUser(User): + wait_time = constant(600) + fixed_count = 1 + + @task + def restart_app(self): + ... + + class WebUser(User): + ... + host attribute -------------- diff --git a/locust/user/users.py b/locust/user/users.py index 178f41ce79..1852c91ef5 100644 --- a/locust/user/users.py +++ b/locust/user/users.py @@ -99,9 +99,9 @@ class ForumPage(TaskSet): fixed_count = 0 """ - If the value > 0, the weight property will be ignored and the users will be spawned. - These users are spawed first. If target count is not enougth to spawn all users, - the final count of each user is undefined. + If the value > 0, the weight property will be ignored and the 'fixed_count'-instances will be spawned. + These Users are spawned first. If the total target count (specified by the --users arg) is not enougth + to spawn all instances of each User class with the defined property, the final count of each User is undefined. """ abstract = True