Locust压测官方文档阅读笔记

官方文档地址:What is locust
1. Each Locust class must have a task_set attribute set, that points to a TaskSet and defines the behaviour of the user and is described in more detail below.
2. min_wait and max_wait attributes: each simulated user will wait between executing each task(milliseconds)
3. this is specified on the command line, using the –host option, when locust is started. If one declares a host attribute in the locust class, it will be used in the case when no –host is specified on the command line.
4. Declaring tasks
1.we can use the task decorator, @task takes an optional weight argument that can be used to specify the task’s execution ratio.
2.the task attribute can be described as a list, each time a task is to be performed, it will be randomly chosen from the tasks attribute; Also, it can be a dict, and the task that is to be executed will be chosen at random but with the int as ratio.
The ratio mentioned above means it would be n times more likely to be executed than another_task
5. Making HTTP requests
When using the HttpLocust class, each instance gets a client attribute which will be an instance of HttpSession which can be used to make HTTP requests.
The behaviour of this user is defined by the task_set attribute, which should point to a TaskSet class. This class creates a client attribute on instantiation which is an HTTP client with support for keeping a user session between requests. We can reference the HttpSession instance using self.client inside the TaskSet.
The instance of HttpLocust has methods such as get, post, put, delete, head, patch, options.
6. Assert
We can mark the requests as success using catch_response argument and a with statement; Also we can use the response code(status_code).
7. Running locust distributed

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值