Skip to content

Commit 1dbc632

Browse files
committed
ensure locust load test is set up correctly
1 parent ce8e87d commit 1dbc632

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

tests/performance/locust_files/functions/workflow.py

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
from datetime import timedelta
44
from pathlib import Path
55
from tempfile import TemporaryDirectory
6-
from typing import Annotated
6+
from typing import Annotated, Any
77
from urllib.parse import quote
88

9-
from locust import HttpUser, task
9+
from locust import HttpUser, run_single_user, task
1010
from pydantic import BaseModel, Field
1111
from pydantic_settings import BaseSettings, SettingsConfigDict
1212
from requests.auth import HTTPBasicAuth
@@ -56,7 +56,7 @@ class Function(BaseModel):
5656
description: str
5757
input_schema: Annotated[Schema, Field()] = Schema()
5858
output_schema: Annotated[Schema, Field()] = Schema()
59-
default_inputs: Annotated[dict[str, str], Field()] = dict()
59+
default_inputs: Annotated[dict[str, Any], Field()] = dict()
6060
solver_key: Annotated[str, Field()] = _SOLVER_KEY
6161
solver_version: Annotated[str, Field()] = _SOLVER_VERSION
6262

@@ -137,7 +137,7 @@ def run_function(self):
137137
_function = Function(
138138
title="Test function",
139139
description="Test function",
140-
default_inputs={"input_1": json.dumps(self._script)},
140+
default_inputs={"input_1": self._script},
141141
)
142142
response = self.client.post(
143143
"/v0/functions", json=_function.model_dump(), auth=self._auth
@@ -148,7 +148,7 @@ def run_function(self):
148148

149149
response = self.client.post(
150150
f"/v0/functions/{self._function_uid}:run",
151-
json={"input_2": json.dumps(self._input_json)},
151+
json={"input_2": self._input_json},
152152
auth=self._auth,
153153
name="/v0/functions/[function_uid]:run",
154154
)
@@ -181,9 +181,9 @@ def wait_until_done(self):
181181
)
182182
response.raise_for_status()
183183
status = response.json().get("status")
184-
assert status in ["DONE", "FAILED"]
184+
assert status in ["SUCCESS", "FAILED"]
185185

186-
def upload_file(self, file: Path) -> dict:
186+
def upload_file(self, file: Path) -> dict[str, str]:
187187
assert file.is_file()
188188
with file.open(mode="rb") as f:
189189
files = {"file": f}
@@ -196,9 +196,4 @@ def upload_file(self, file: Path) -> dict:
196196

197197

198198
if __name__ == "__main__":
199-
function = Function(
200-
title="Test function",
201-
description="Test function",
202-
default_inputs={},
203-
)
204-
print(function.model_dump_json())
199+
run_single_user(MetaModelingUser)

0 commit comments

Comments
 (0)