如何为动态 URL 列表创建 Locust 任务?
How to create a Locust task for a dynamic list of URLs?
我正在尝试根据 OpenAPI JSON 获取 所有 我的 API 端点的时间信息,所以我会喜欢在 setup
方法中做这样的事情:
for api_path in self.client.get('/api/doc/?format=openapi').json()['paths'].keys():
self.get_[api_path] = [@task decorated method which retrieves the API path]
或者有其他方法在运行时生成任务吗?
在 API docs 中找到它:
def setup(self) -> None:
for api_path in self.client.get('/api/doc/?format=openapi').json()['paths'].keys():
self.schedule_task(self.api_task, args=[api_path])
def api_task(self, path: str) -> None:
response = self.client.get("/api{}?limit=1000".format(path))
assert response.status_code == HTTPStatus.OK, response.content.decode()
我正在尝试根据 OpenAPI JSON 获取 所有 我的 API 端点的时间信息,所以我会喜欢在 setup
方法中做这样的事情:
for api_path in self.client.get('/api/doc/?format=openapi').json()['paths'].keys():
self.get_[api_path] = [@task decorated method which retrieves the API path]
或者有其他方法在运行时生成任务吗?
在 API docs 中找到它:
def setup(self) -> None:
for api_path in self.client.get('/api/doc/?format=openapi').json()['paths'].keys():
self.schedule_task(self.api_task, args=[api_path])
def api_task(self, path: str) -> None:
response = self.client.get("/api{}?limit=1000".format(path))
assert response.status_code == HTTPStatus.OK, response.content.decode()