Locust/pyCharm:每个端点有N个用户达到X RPS
Locust/pyCharm: Each end point with N users to achieve X RPS
我正在开发 Locust/pyCharm 项目,为每个端点提供单独的文件,用户数不同,以便为每个端点实现不同的 RPS。
在下面的代码片段中,如果我删除
if __name__ == '__main__': ApiUser().run()
和运行 .py 文件使用像
这样的命令
locust -f .\locustfiles\test.py --host https://something.another.nothing --users 34 --hatch-rate 10
我看到 Locust 按预期工作。
下面的示例代码会引发错误。我错过了什么?
from locust import HttpUser, task, between, TaskSet, User
headerJsonContent = {'Content-Type': 'application/json', 'Accept': 'application/json'}
URL2 = "/Auth/report"
host = "https://something.another.nothing"
NoOfUse = 50
class MyBaseTasks(TaskSet):
@task
def getData(self):
self.client.get(URL2 = "/Auth/report", verify=False)
class ApiUser(HttpUser):
tasks = [MyBaseTasks]
wait_time = between(0.100, 1.500)
if __name__ == '__main__':
ApiUser().run()
*错误: *super(HttpUser, self).init(*args, kwargs)
类型错误:init() 缺少 1 个必需的位置参数:'environment'
用户需要一个环境参数。尝试这样的事情:
from locust.env import Environment
if __name__ == '__main__':
env = Environment()
ApiUser(env).run()
我正在开发 Locust/pyCharm 项目,为每个端点提供单独的文件,用户数不同,以便为每个端点实现不同的 RPS。
在下面的代码片段中,如果我删除
if __name__ == '__main__': ApiUser().run()
和运行 .py 文件使用像
这样的命令locust -f .\locustfiles\test.py --host https://something.another.nothing --users 34 --hatch-rate 10
我看到 Locust 按预期工作。
下面的示例代码会引发错误。我错过了什么?
from locust import HttpUser, task, between, TaskSet, User
headerJsonContent = {'Content-Type': 'application/json', 'Accept': 'application/json'}
URL2 = "/Auth/report"
host = "https://something.another.nothing"
NoOfUse = 50
class MyBaseTasks(TaskSet):
@task
def getData(self):
self.client.get(URL2 = "/Auth/report", verify=False)
class ApiUser(HttpUser):
tasks = [MyBaseTasks]
wait_time = between(0.100, 1.500)
if __name__ == '__main__':
ApiUser().run()
*错误: *super(HttpUser, self).init(*args, kwargs) 类型错误:init() 缺少 1 个必需的位置参数:'environment'
用户需要一个环境参数。尝试这样的事情:
from locust.env import Environment
if __name__ == '__main__':
env = Environment()
ApiUser(env).run()