locust 2.31.4.dev27__py3-none-any.whl → 2.31.4.dev47__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/contrib/postgres.py +45 -0
- locust/webui/dist/assets/{index-BTVvoV6z.js → index-K5xg1SLs.js} +2 -2
- locust/webui/dist/auth.html +1 -1
- locust/webui/dist/index.html +1 -1
- locust/webui/dist/report.html +1 -1
- {locust-2.31.4.dev27.dist-info → locust-2.31.4.dev47.dist-info}/METADATA +1 -1
- {locust-2.31.4.dev27.dist-info → locust-2.31.4.dev47.dist-info}/RECORD +11 -10
- {locust-2.31.4.dev27.dist-info → locust-2.31.4.dev47.dist-info}/LICENSE +0 -0
- {locust-2.31.4.dev27.dist-info → locust-2.31.4.dev47.dist-info}/WHEEL +0 -0
- {locust-2.31.4.dev27.dist-info → locust-2.31.4.dev47.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.4.
|
17
|
+
__version__ = "2.31.4.dev47"
|
18
18
|
version = __version__
|
19
|
-
__version_tuple__ = (2, 31, 4, "
|
19
|
+
__version_tuple__ = (2, 31, 4, "dev47")
|
20
20
|
version_tuple = __version_tuple__
|
@@ -0,0 +1,45 @@
|
|
1
|
+
from locust import User, events
|
2
|
+
|
3
|
+
import time
|
4
|
+
|
5
|
+
import psycopg
|
6
|
+
|
7
|
+
|
8
|
+
class PostgresClient:
|
9
|
+
def __init__(self, conn_string):
|
10
|
+
self.connection = psycopg.connect(conn_string)
|
11
|
+
|
12
|
+
def execute_query(self, query):
|
13
|
+
start_time = time.time()
|
14
|
+
try:
|
15
|
+
self.connection.execute(query)
|
16
|
+
response_time = int((time.time() - start_time) * 1000)
|
17
|
+
events.request.fire(
|
18
|
+
request_type="postgres_success",
|
19
|
+
name="execute_query",
|
20
|
+
response_time=response_time,
|
21
|
+
response_length=0,
|
22
|
+
)
|
23
|
+
except Exception as e:
|
24
|
+
response_time = int((time.time() - start_time) * 1000)
|
25
|
+
events.request.fire(
|
26
|
+
request_type="postgres_failure",
|
27
|
+
name="execute_query",
|
28
|
+
response_time=response_time,
|
29
|
+
response_length=0,
|
30
|
+
exception=e,
|
31
|
+
)
|
32
|
+
|
33
|
+
def close(self):
|
34
|
+
self.connection.close()
|
35
|
+
|
36
|
+
|
37
|
+
class PostgresUser(User):
|
38
|
+
abstract = True
|
39
|
+
|
40
|
+
def __init__(self, *args, **kwargs):
|
41
|
+
super().__init__(*args, **kwargs)
|
42
|
+
self.client = PostgresClient(conn_string=self.conn_string)
|
43
|
+
|
44
|
+
def on_stop(self):
|
45
|
+
self.client.close()
|