3
Я начал использовать саранчу, чтобы выполнить тест производительности. Я хочу запустить два запроса на отправку двух разных конечных точек. Но второй запрос на почту требует ответа первого запроса. Как это сделать удобным способом. Я пробовал, как показано ниже, но не работал.В саранчах Как получить ответ от одной задачи и передать ее другой задаче
from locust import HttpLocust, TaskSet, task
class GetDeliveryDateTasks(TaskSet):
request_list = []
@task
def get_estimated_delivery_date(self):
self.client.headers['Content-Type'] = "application/json"
response = self.client.post("/api/v1/estimated-delivery-date/", json=
{
"xx": "yy"
}
)
json_response_dict = response.json()
request_id = json_response_dict['requestId']
self.request_list.append(request_id)
@task
def store_estimated_delivery_date(self):
self.client.headers['Content-Type'] = "application/json"
response = self.client.post("/api/v1/estimated-delivery-date/" + str(self.request_list.pop(0)) + "/assign-order?orderId=1")
class EDDApiUser(HttpLocust):
task_set = GetDeliveryDateTasks
min_wait = 1000
max_wait = 1000
host = "http://localhost:8080"