-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Rename locust to user #1314
Changes from 3 commits
66e7942
26573d8
c6207d3
ad5f4b0
0777fba
01a733f
b0ff683
7db61c7
ad584f5
c783824
5589257
25d253c
3c03129
fdd4d5f
39a42cc
b990796
530db29
5076958
de53ef8
07ff348
365d2e5
a8239a3
5d23b6d
6a2e914
f53d397
0dc6f05
c078cad
405dd86
e450dc2
8ba4629
3723be5
cc8d553
3667397
47c104b
ad42d4e
17edbb6
29c18cf
796d86e
8db7c2d
08228a4
339eae3
4f4b83b
5aca141
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
||
|
@@ -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): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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") | ||
|
@@ -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. | ||
|
||
|
@@ -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 | ||
|
@@ -588,7 +588,7 @@ def stop(self, gevent_group, force=False): | |
return False | ||
|
||
|
||
class HttpLocust(Locust): | ||
class HttpLocust(User): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
|
@@ -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 | ||
|
@@ -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) | ||
|
@@ -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 | ||
|
@@ -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): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AbstractUser maybe? |
||
abstract = True | ||
@task(2) | ||
def t1(self): | ||
|
@@ -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): | ||
|
@@ -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): | ||
|
@@ -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 | ||
|
||
|
@@ -391,7 +391,7 @@ def on_start(self): | |
else: | ||
self.interrupt(reschedule=False) | ||
|
||
class MyLocust(Locust): | ||
class MyLocust(User): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. MyUser... |
||
host = "" | ||
tasks = [SubTaskSet] | ||
|
||
|
@@ -419,7 +419,7 @@ def stop(self): | |
class RootTaskSet(TaskSet): | ||
tasks = [SubTaskSet] | ||
|
||
class MyLocust(Locust): | ||
class MyLocust(User): | ||
host = "" | ||
tasks = [RootTaskSet] | ||
|
||
|
@@ -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 | ||
|
||
|
@@ -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 | ||
|
||
|
@@ -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 | ||
|
@@ -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 | ||
|
@@ -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 | ||
|
@@ -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] | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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", []))) | ||
|
@@ -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))) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
XmlRpcUser