locust 2.31.6.dev23__py3-none-any.whl → 2.31.7__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- locust/_version.py +2 -2
- locust/argument_parser.py +6 -0
- locust/contrib/mongodb.py +41 -0
- locust/main.py +4 -2
- locust/web.py +15 -4
- locust/webui/dist/assets/index-sZjNzlO0.js +221 -0
- locust/webui/dist/auth.html +1 -1
- locust/webui/dist/index.html +1 -1
- locust/webui/dist/report.html +48 -61
- {locust-2.31.6.dev23.dist-info → locust-2.31.7.dist-info}/METADATA +1 -1
- {locust-2.31.6.dev23.dist-info → locust-2.31.7.dist-info}/RECORD +15 -14
- poetry.lock +308 -279
- locust/webui/dist/assets/index-DQd3Odi5.js +0 -234
- {locust-2.31.6.dev23.dist-info → locust-2.31.7.dist-info}/LICENSE +0 -0
- {locust-2.31.6.dev23.dist-info → locust-2.31.7.dist-info}/WHEEL +0 -0
- {locust-2.31.6.dev23.dist-info → locust-2.31.7.dist-info}/entry_points.txt +0 -0
locust/_version.py
CHANGED
@@ -14,7 +14,7 @@ __version_tuple__: VERSION_TUPLE
|
|
14
14
|
version_tuple: VERSION_TUPLE
|
15
15
|
|
16
16
|
|
17
|
-
__version__ = "2.31.
|
17
|
+
__version__ = "2.31.7"
|
18
18
|
version = __version__
|
19
|
-
__version_tuple__ = (2, 31,
|
19
|
+
__version_tuple__ = (2, 31, 7)
|
20
20
|
version_tuple = __version_tuple__
|
locust/argument_parser.py
CHANGED
@@ -424,6 +424,12 @@ def setup_parser_arguments(parser):
|
|
424
424
|
help="Host to bind the web interface to. Defaults to '*' (all interfaces)",
|
425
425
|
env_var="LOCUST_WEB_HOST",
|
426
426
|
)
|
427
|
+
web_ui_group.add_argument(
|
428
|
+
"--web-host-display-name",
|
429
|
+
type=str,
|
430
|
+
help=configargparse.SUPPRESS,
|
431
|
+
env_var="LOCUST_WEB_HOST_DISPLAY_NAME",
|
432
|
+
)
|
427
433
|
web_ui_group.add_argument(
|
428
434
|
"--web-port",
|
429
435
|
"-P",
|
@@ -0,0 +1,41 @@
|
|
1
|
+
from locust import User, events
|
2
|
+
|
3
|
+
import time
|
4
|
+
|
5
|
+
from pymongo import MongoClient
|
6
|
+
from pymongo.errors import PyMongoError
|
7
|
+
|
8
|
+
|
9
|
+
class MongoDBClient(MongoClient):
|
10
|
+
def __init__(self, conn_string, db_name):
|
11
|
+
super().__init__(conn_string)
|
12
|
+
self.db = self.client[db_name]
|
13
|
+
|
14
|
+
def execute_query(self, collection_name, query):
|
15
|
+
start_time = time.time()
|
16
|
+
try:
|
17
|
+
collection = self.db[collection_name]
|
18
|
+
collection.find(query)
|
19
|
+
|
20
|
+
response_time = int((time.time() - start_time) * 1000)
|
21
|
+
events.request.fire(request_type="MONGODB", name="QUERY", response_time=response_time, response_length=0)
|
22
|
+
except PyMongoError as e:
|
23
|
+
response_time = int((time.time() - start_time) * 1000)
|
24
|
+
events.request.fire(
|
25
|
+
request_type="MONGODB",
|
26
|
+
name="QUERY",
|
27
|
+
response_time=response_time,
|
28
|
+
response_length=0,
|
29
|
+
exception=e,
|
30
|
+
)
|
31
|
+
|
32
|
+
|
33
|
+
class MongoDBUser(User):
|
34
|
+
abstract = True
|
35
|
+
|
36
|
+
def __init__(self, *args, **kwargs):
|
37
|
+
super().__init__(*args, **kwargs)
|
38
|
+
self.client = MongoDBClient(conn_string=self.conn_string, db_name=self.db_name)
|
39
|
+
|
40
|
+
def on_stop(self):
|
41
|
+
self.client.close()
|
locust/main.py
CHANGED
@@ -199,6 +199,8 @@ def main():
|
|
199
199
|
sys.exit(1)
|
200
200
|
|
201
201
|
children = []
|
202
|
+
logger = logging.getLogger(__name__)
|
203
|
+
logger.info(f"Starting Locust {version}")
|
202
204
|
|
203
205
|
if options.processes:
|
204
206
|
if os.name == "nt":
|
@@ -298,7 +300,6 @@ def main():
|
|
298
300
|
|
299
301
|
atexit.register(kill_workers, children)
|
300
302
|
|
301
|
-
logger = logging.getLogger(__name__)
|
302
303
|
greenlet_exception_handler = greenlet_exception_logger(logger)
|
303
304
|
|
304
305
|
if options.stop_timeout:
|
@@ -486,6 +487,8 @@ See https://github.com/locustio/locust/wiki/Installation#increasing-maximum-numb
|
|
486
487
|
web_host = options.web_host
|
487
488
|
if web_host:
|
488
489
|
logger.info(f"Starting web interface at {protocol}://{web_host}:{options.web_port}")
|
490
|
+
if options.web_host_display_name:
|
491
|
+
logger.info(f"Starting web interface at {options.web_host_display_name}")
|
489
492
|
else:
|
490
493
|
if os.name == "nt":
|
491
494
|
logger.info(
|
@@ -686,7 +689,6 @@ See https://github.com/locustio/locust/wiki/Installation#increasing-maximum-numb
|
|
686
689
|
gevent.signal_handler(signal.SIGTERM, sig_term_handler)
|
687
690
|
|
688
691
|
try:
|
689
|
-
logger.info(f"Starting Locust {version}")
|
690
692
|
if options.class_picker:
|
691
693
|
logger.info("Locust is running with the UserClass Picker Enabled")
|
692
694
|
if options.autostart and not options.headless:
|
locust/web.py
CHANGED
@@ -136,9 +136,9 @@ class WebUI:
|
|
136
136
|
mimetypes.add_type("application/javascript", ".js")
|
137
137
|
|
138
138
|
if self.web_login:
|
139
|
-
self.
|
140
|
-
self.
|
141
|
-
self.
|
139
|
+
self._login_manager = LoginManager()
|
140
|
+
self._login_manager.init_app(self.app)
|
141
|
+
self._login_manager.login_view = "login"
|
142
142
|
|
143
143
|
if environment.runner:
|
144
144
|
self.update_template_args()
|
@@ -150,7 +150,7 @@ class WebUI:
|
|
150
150
|
error_message = str(error)
|
151
151
|
error_code = getattr(error, "code", 500)
|
152
152
|
logger.log(
|
153
|
-
logging.
|
153
|
+
logging.DEBUG if error_code <= 404 else logging.ERROR,
|
154
154
|
f"UI got request for {request.path}, but it resulted in a {error_code}: {error.name}",
|
155
155
|
)
|
156
156
|
return make_response(error_message, error_code)
|
@@ -518,6 +518,17 @@ class WebUI:
|
|
518
518
|
|
519
519
|
return {}, 201
|
520
520
|
|
521
|
+
@property
|
522
|
+
def login_manager(self):
|
523
|
+
if self.web_login:
|
524
|
+
return self._login_manager
|
525
|
+
|
526
|
+
raise AttributeError("The login_manager is only available with --web-login.\n")
|
527
|
+
|
528
|
+
@login_manager.setter
|
529
|
+
def login_manager(self, value):
|
530
|
+
self._login_manager = value
|
531
|
+
|
521
532
|
def start(self):
|
522
533
|
self.greenlet = gevent.spawn(self.start_server)
|
523
534
|
self.greenlet.link_exception(greenlet_exception_handler)
|