我想从Locust运行多个负载测试,例如测试前端和后端。我想知道我是否可以通过一个单一的locust文件来做这件事,但是通过哪一个测试,我想在locust -f locustfile.py --host=<host>中作为参数运行。
发布于 2020-10-28 15:56:08
使用@task修饰器,它将运行每个示例代码
# The multiple uer login script with - https://opensource-demo.orangehrmlive.org
from locust import HttpUser, TaskSet,task,between
class UserBehaviour(TaskSet):
@task(1)
def login_post(self):
print("from user 1 logining in")
resp = self.client.post("/index.php/auth/login",data={"action": "process","userName": "Admin","password": "admin123" , "_csrf_token": " f28bb18622cc82a56c41be5f7de07690"})
print(resp.status_code)
@task(1)
def load_dashboard(self):
print("from user 2")
resp = self.client.get("/webres_5f61a473615588.75870608/orangehrmDashboardPlugin/js/graph-visualizer/pie-chart.js")
self.client.get("/webres_5f61a473615588.75870608/orangehrmDashboardPlugin/js/flot/JUMFlot.min.js")
self.client.get("/webres_5f61a473615588.75870608/orangehrmDashboardPlugin/js/flot/jquery.flot.pie.min.js")
self.client.get("/index.php/dashboard/employeeDistribution")
print(resp.status_code)
@task(1)
def apply_leave(self):
print("from user 3")
resp = self.client.get("/index.php/leave/getWorkWeekAjax?_=1602164350152")
self.client.get("/index.php/leave/getHolidayAjax?year=2020&_=1602164350151")
self.client.get("/index.php/leave/getLeaveBalanceAjax?&leaveType=1&startDate=yyyy-mm-dd&endDate=yyyy-mm-dd")
self.client.get("/index.php/leave/getLeaveBalanceAjax?&leaveType=1&startDate=2020-10-09&endDate=2020-10-09")
self.client.get("/index.php/leave/getLeaveBalanceAjax?&leaveType=1&startDate=2020-10-09&endDate=2020-10-16")
print(resp.status_code)
class User(HttpUser):
tasks=[UserBehaviour]
wait_time = between(5000, 10000)
host="https://opensource-demo.orangehrmlive.com"https://stackoverflow.com/questions/58616842
复制相似问题