Skip to content

Commit eb43e93

Browse files
authored
Merge branch 'master' into enh/hide-tags
2 parents 6349a31 + 9149e41 commit eb43e93

File tree

3 files changed

+54
-1
lines changed

3 files changed

+54
-1
lines changed

tests/performance/locustfiles/deployment_max_rps_single_endpoint.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import json
1313
from collections.abc import Callable
1414

15+
import jsf
1516
from common.base_user import OsparcWebUserBase
1617
from locust import events, task
1718
from locust.argument_parser import LocustArgumentParser
@@ -36,7 +37,19 @@ def _(parser: LocustArgumentParser) -> None:
3637
"--body",
3738
type=str,
3839
default="",
39-
help="The optional HTTP body as json string",
40+
help="Optional HTTP body as json string",
41+
)
42+
parser.add_argument(
43+
"--body-json-schema",
44+
type=str,
45+
default="",
46+
help="Optional JSON schema for the request body. If specified, the request data will be randomly generated from this schema.",
47+
)
48+
parser.add_argument(
49+
"--headers",
50+
type=str,
51+
default="",
52+
help="Optional HTTP headers as json string",
4053
)
4154

4255

@@ -52,4 +65,11 @@ def get_endpoint(self) -> None:
5265
kwargs = {}
5366
if len(self.environment.parsed_options.body) > 0:
5467
kwargs["json"] = json.loads(self.environment.parsed_options.body)
68+
if len(self.environment.parsed_options.body_json_schema) > 0:
69+
faker = jsf.JSF(
70+
json.loads(self.environment.parsed_options.body_json_schema)
71+
)
72+
kwargs["json"] = faker.generate()
73+
if len(self.environment.parsed_options.headers) > 0:
74+
kwargs["headers"] = json.loads(self.environment.parsed_options.headers)
5575
method(self.environment.parsed_options.endpoint, **kwargs)

tests/performance/requirements/_test.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
jsf
12
locust
23
locust-plugins[dashboards]
34
pydantic

tests/performance/requirements/_test.txt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
annotated-types==0.7.0
22
# via pydantic
3+
attrs==25.3.0
4+
# via
5+
# jsonschema
6+
# referencing
37
bidict==0.23.1
48
# via python-socketio
59
blinker==1.9.0
@@ -18,6 +22,8 @@ configargparse==1.7.1
1822
# via
1923
# locust
2024
# locust-cloud
25+
faker==37.6.0
26+
# via jsf
2127
flask==3.1.1
2228
# via
2329
# flask-cors
@@ -44,6 +50,12 @@ itsdangerous==2.2.0
4450
# via flask
4551
jinja2==3.1.6
4652
# via flask
53+
jsf==0.11.2
54+
# via -r requirements/_test.in
55+
jsonschema==4.25.1
56+
# via jsf
57+
jsonschema-specifications==2025.4.1
58+
# via jsonschema
4759
locust==2.37.5
4860
# via
4961
# -r requirements/_test.in
@@ -70,6 +82,7 @@ psycopg2-binary==2.9.10
7082
pydantic==2.11.7
7183
# via
7284
# -r requirements/_test.in
85+
# jsf
7386
# pydantic-settings
7487
pydantic-core==2.33.2
7588
# via pydantic
@@ -83,29 +96,46 @@ python-socketio==5.13.0
8396
# via locust-cloud
8497
pyzmq==26.4.0
8598
# via locust
99+
referencing==0.36.2
100+
# via
101+
# jsonschema
102+
# jsonschema-specifications
86103
requests==2.32.4
87104
# via
88105
# locust
89106
# python-socketio
107+
# smart-open
108+
rpds-py==0.27.1
109+
# via
110+
# jsonschema
111+
# referencing
112+
rstr==3.2.2
113+
# via jsf
90114
setuptools==80.9.0
91115
# via
92116
# locust
93117
# zope-event
94118
# zope-interface
95119
simple-websocket==1.1.0
96120
# via python-engineio
121+
smart-open==7.3.0.post1
122+
# via jsf
97123
tenacity==9.1.2
98124
# via -r requirements/_test.in
99125
typing-extensions==4.14.1
100126
# via
127+
# jsf
101128
# locust-plugins
102129
# pydantic
103130
# pydantic-core
131+
# referencing
104132
# typing-inspection
105133
typing-inspection==0.4.1
106134
# via
107135
# pydantic
108136
# pydantic-settings
137+
tzdata==2025.2
138+
# via faker
109139
urllib3==2.5.0
110140
# via
111141
# geventhttpclient
@@ -118,6 +148,8 @@ werkzeug==3.1.3
118148
# flask-cors
119149
# flask-login
120150
# locust
151+
wrapt==1.17.3
152+
# via smart-open
121153
wsproto==1.2.0
122154
# via simple-websocket
123155
zope-event==5.0

0 commit comments

Comments
 (0)