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 3 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
4 changes: 2 additions & 2 deletions examples/custom_xmlrpc_client/xmlrpc_locustfile.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import time
from xmlrpc.client import ServerProxy, Fault

from locust import Locust, task, between
from locust import User, task, between


class XmlRpcClient(ServerProxy):
Expand Down Expand Up @@ -31,7 +31,7 @@ def wrapper(*args, **kwargs):
return wrapper


class XmlRpcLocust(Locust):
class XmlRpcLocust(User):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

XmlRpcUser

"""
This is the abstract Locust class which should be subclassed. It provides an XML-RPC client
that can be used to make XML-RPC requests that will be tracked in Locust's statistics.
Expand Down
2 changes: 1 addition & 1 deletion locust/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .core import HttpLocust, Locust, TaskSet, TaskSequence, task, seq_task
from .core import HttpLocust, User, TaskSet, TaskSequence, task, seq_task
from .exception import InterruptTaskSet, ResponseError, RescheduleTaskImmediately
from .wait_time import between, constant, constant_pacing
from .event import Events
Expand Down
20 changes: 10 additions & 10 deletions locust/argument_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,20 +198,20 @@ def setup_parser_arguments(parser):
action='store_true',
help="Disable the web interface, and instead start running the test immediately. Requires -c and -t to be specified."
)
# Number of clients
# Number of users
parser.add_argument(
'-c', '--clients',
'-u', '--users',
type=int,
dest='num_clients',
dest='num_users',
default=1,
help="Number of concurrent Locust users. Only used together with --no-web"
help="Number of concurrent users. Only used together with --no-web"
)
# Client hatch rate
# User hatch rate
parser.add_argument(
'-r', '--hatch-rate',
type=float,
default=1,
help="The rate per second in which clients are spawned. Only used together with --no-web"
help="The rate per second in which users are spawned. Only used together with --no-web"
)
# Time limit of the test run
parser.add_argument(
Expand All @@ -230,14 +230,14 @@ def setup_parser_arguments(parser):
parser.add_argument(
'--step-load',
action='store_true',
help="Enable Step Load mode to monitor how performance metrics varies when user load increases. Requires --step-clients and --step-time to be specified."
help="Enable Step Load mode to monitor how performance metrics varies when user load increases. Requires --step-users and --step-time to be specified."
)
# Number of clients to incease by Step
# Number of users to incease by Step
parser.add_argument(
'--step-clients',
'--step-users',
type=int,
default=1,
help="Client count to increase by step in Step Load mode. Only used together with --step-load"
help="User count to increase by step in Step Load mode. Only used together with --step-load"
)
# Time limit of each step
parser.add_argument(
Expand Down
4 changes: 2 additions & 2 deletions locust/contrib/fasthttp.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from geventhttpclient.useragent import UserAgent, CompatRequest, CompatResponse, ConnectionError
from geventhttpclient.response import HTTPConnectionClosed

from locust.core import Locust
from locust.core import User
from locust.exception import LocustError, CatchResponseError, ResponseError
from locust.env import Environment

Expand Down Expand Up @@ -47,7 +47,7 @@ def _construct_basic_auth_str(username, password):
return 'Basic ' + b64encode(b':'.join((username, password))).strip().decode("ascii")


class FastHttpLocust(Locust):
class FastHttpLocust(User):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FastHttpUser

"""
FastHttpLocust uses a different HTTP client (geventhttpclient) compared to HttpLocust (python-requests).
It's significantly faster, but not as capable.
Expand Down
8 changes: 4 additions & 4 deletions locust/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def __init__(self, parent):

if isinstance(parent, TaskSet):
self.locust = parent.locust
elif isinstance(parent, Locust):
elif isinstance(parent, User):
self.locust = parent
else:
raise LocustError("TaskSet should be called with Locust instance or TaskSet instance as first argument")
Expand Down Expand Up @@ -447,7 +447,7 @@ def __new__(mcs, classname, bases, class_dict):
return type.__new__(mcs, classname, bases, class_dict)


class Locust(object, metaclass=LocustMeta):
heyman marked this conversation as resolved.
Show resolved Hide resolved
class User(object, metaclass=LocustMeta):
"""
Represents a "user" which is to be hatched and attack the system that is to be load tested.

Expand Down Expand Up @@ -517,7 +517,7 @@ class ForumPage(TaskSet):
_greenlet = None

def __init__(self, environment):
super(Locust, self).__init__()
super(User, self).__init__()
# check if deprecated wait API is used
deprecation.check_for_deprecated_wait_api(self)
self.environment = environment
Expand Down Expand Up @@ -588,7 +588,7 @@ def stop(self, gevent_group, force=False):
return False


class HttpLocust(Locust):
class HttpLocust(User):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HttpUser

"""
Represents an HTTP "user" which is to be hatched and attack the system that is to be load tested.

Expand Down
4 changes: 2 additions & 2 deletions locust/inspectlocust.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import inspect

from .core import Locust, TaskSet
from .core import User, TaskSet
from .log import console_logger


Expand Down Expand Up @@ -37,7 +37,7 @@ def get_task_ratio_dict(tasks, total=False, parent_ratio=1.0):
for locust, ratio in ratio_percent.items():
d = {"ratio":ratio}
if inspect.isclass(locust):
if issubclass(locust, (Locust, TaskSet)):
if issubclass(locust, (User, TaskSet)):
T = locust.tasks
if total:
d["tasks"] = get_task_ratio_dict(T, total, ratio)
Expand Down
10 changes: 5 additions & 5 deletions locust/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

from .event import Events
from .argument_parser import parse_locustfile_option, parse_options
from .core import HttpLocust, Locust
from .core import HttpLocust, User
from .env import Environment
from .inspectlocust import get_task_ratio_dict, print_task_ratio
from .log import console_logger, setup_logging
Expand All @@ -23,7 +23,7 @@
from .util.timespan import parse_timespan
from .web import WebUI

_internals = [Locust, HttpLocust]
_internals = [User, HttpLocust]
version = locust.__version__


Expand All @@ -34,7 +34,7 @@ def is_locust(tup):
name, item = tup
return bool(
inspect.isclass(item)
and issubclass(item, Locust)
and issubclass(item, User)
and item.abstract == False
)

Expand Down Expand Up @@ -248,9 +248,9 @@ def timelimit_stop():
if not options.worker:
# start the test
if options.step_time:
runner.start_stepload(options.num_clients, options.hatch_rate, options.step_clients, options.step_time)
runner.start_stepload(options.num_users, options.hatch_rate, options.step_users, options.step_time)
else:
runner.start(options.num_clients, options.hatch_rate)
runner.start(options.num_users, options.hatch_rate)

if options.run_time:
spawn_run_time_limit_greenlet()
Expand Down
36 changes: 18 additions & 18 deletions locust/test/test_locust_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from gevent.pool import Group

from locust import InterruptTaskSet, ResponseError
from locust.core import HttpLocust, Locust, TaskSet, task
from locust.core import HttpLocust, TaskSet, task, User
from locust.env import Environment
from locust.exception import (CatchResponseError, LocustError, RescheduleTask,
RescheduleTaskImmediately, StopLocust)
Expand All @@ -16,10 +16,10 @@ class TestTaskSet(LocustTestCase):
def setUp(self):
super(TestTaskSet, self).setUp()

class User(Locust):
class MyUser(User):
host = "127.0.0.1"
self.environment = Environment()
self.locust = User(self.environment)
self.locust = MyUser(self.environment)

def test_task_ratio(self):
t1 = lambda l: None
Expand All @@ -39,12 +39,12 @@ def test_tasks_missing_gives_user_friendly_exception(self):
class MyTasks(TaskSet):
tasks = None

class User(Locust):
class MyUser(User):
wait_time = constant(0)
tasks = [MyTasks]
_catch_exceptions = False

l = MyTasks(User(self.environment))
l = MyTasks(MyUser(self.environment))
self.assertRaisesRegex(Exception, "No tasks defined.*", l.run)
l.tasks = []
self.assertRaisesRegex(Exception, "No tasks defined.*", l.run)
Expand Down Expand Up @@ -78,7 +78,7 @@ def t4(self):
self.assertEqual(t4_count, 13)

def test_tasks_on_locust(self):
class MyLocust(Locust):
class MyLocust(User):
@task(2)
def t1(self):
pass
Expand All @@ -90,7 +90,7 @@ def t2(self):
self.assertEqual(3, len([t for t in l.tasks if t.__name__ == MyLocust.t2.__name__]))

def test_tasks_on_abstract_locust(self):
class AbstractLocust(Locust):
class AbstractLocust(User):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AbstractUser maybe?

abstract = True
@task(2)
def t1(self):
Expand All @@ -105,7 +105,7 @@ def t2(self):

def test_taskset_on_abstract_locust(self):
v = [0]
class AbstractLocust(Locust):
class AbstractLocust(User):
abstract = True
@task
class task_set(TaskSet):
Expand All @@ -122,7 +122,7 @@ class MyLocust(AbstractLocust):

def test_task_decorator_on_taskset(self):
state = [0]
class MyLocust(Locust):
class MyLocust(User):
wait_time = constant(0)
@task
def t1(self):
Expand Down Expand Up @@ -204,7 +204,7 @@ def on_stop(self):
def t2(self):
self.locust.t2_executed = True

class MyUser(Locust):
class MyUser(User):
t2_executed = False
on_stop_executed = False

Expand Down Expand Up @@ -391,7 +391,7 @@ def on_start(self):
else:
self.interrupt(reschedule=False)

class MyLocust(Locust):
class MyLocust(User):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MyUser...

host = ""
tasks = [SubTaskSet]

Expand Down Expand Up @@ -419,7 +419,7 @@ def stop(self):
class RootTaskSet(TaskSet):
tasks = [SubTaskSet]

class MyLocust(Locust):
class MyLocust(User):
host = ""
tasks = [RootTaskSet]

Expand All @@ -431,7 +431,7 @@ class MyLocust(Locust):

class TestLocustClass(LocustTestCase):
def test_locust_on_start(self):
class MyLocust(Locust):
class MyLocust(User):
t1_executed = False
t2_executed = False

Expand All @@ -452,7 +452,7 @@ def t2(self):
self.assertTrue(l.t2_executed)

def test_locust_on_stop(self):
class MyLocust(Locust):
class MyLocust(User):
on_stop_executed = False
t2_executed = True

Expand All @@ -470,7 +470,7 @@ def t2(self):
self.assertTrue(l.t2_executed)

def test_locust_start(self):
class TestUser(Locust):
class TestUser(User):
wait_time = constant(0.1)
test_state = 0
@task
Expand All @@ -491,7 +491,7 @@ def t(self):
timeout.cancel()

def test_locust_graceful_stop(self):
class TestUser(Locust):
class TestUser(User):
wait_time = constant(0)
test_state = 0
@task
Expand All @@ -518,7 +518,7 @@ def t(self):
self.assertEqual(2, user.test_state)

def test_locust_forced_stop(self):
class TestUser(Locust):
class TestUser(User):
wait_time = constant(0)
test_state = 0
@task
Expand Down Expand Up @@ -648,7 +648,7 @@ def t1(self):
self.client.get("/")
self.interrupt()

class MyLocust(Locust):
class MyLocust(User):
host = "http://127.0.0.1:%i" % self.port
tasks = [MyTaskSet]

Expand Down
8 changes: 4 additions & 4 deletions locust/test/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
from locust import main
from locust.argument_parser import parse_options
from locust.main import create_environment
from locust.core import HttpLocust, Locust, TaskSet
from locust.core import HttpLocust, User, TaskSet
from .testcases import LocustTestCase
from .mock_locustfile import mock_locustfile


class TestLoadLocustfile(LocustTestCase):
def test_is_locust(self):
self.assertFalse(main.is_locust(("Locust", Locust)))
self.assertFalse(main.is_locust(("Locust", User)))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...

self.assertFalse(main.is_locust(("HttpLocust", HttpLocust)))
self.assertFalse(main.is_locust(("random_dict", {})))
self.assertFalse(main.is_locust(("random_list", [])))
Expand All @@ -21,13 +21,13 @@ class MyTaskSet(TaskSet):
class MyHttpLocust(HttpLocust):
tasks = [MyTaskSet]

class MyLocust(Locust):
class MyLocust(User):
tasks = [MyTaskSet]

self.assertTrue(main.is_locust(("MyHttpLocust", MyHttpLocust)))
self.assertTrue(main.is_locust(("MyLocust", MyLocust)))

class ThriftLocust(Locust):
class ThriftLocust(User):
abstract = True

self.assertFalse(main.is_locust(("ThriftLocust", ThriftLocust)))
Expand Down
Loading