locust性能测试
hoannnnnn
这个作者很懒,什么都没留下…
展开
-
docker+Locust+Prometheus+Grafana实现性能监控平台
原文参考:https://testerhome.com/topics/24873通过实现Locust的prometheus的exporter,将数据导入到proemtheus,然后由grafana进行数据展示。什么是proemtheus,请转prometheus什么是Grafana,请转grafanaExporter编写需要拓展一个web端接口/export/prometheus ,让prometheus根据配置定时拉取Metric信息,这里需要用到Prometheus转载 2021-08-01 20:53:05 · 1208 阅读 · 2 评论 -
自定义Locust统计信息
failure():将响应报告为失败success():将响应报告为成功 with self.client.get("/web/users/details", catch_response=True, name='users/details') as response: # print(f'这是第{i}个用户发的请求{j}:{response.text}') if response.status_code == 401:原创 2021-08-01 20:33:41 · 482 阅读 · 0 评论 -
Locust自定义负载策略
在Locust中可直接定义一个继承LoadTestshape类的类,有则自动启动。在该类中定义tick()方法,返回用户数user_count和产生率spawn_rate的元组,如果返回None则停止测试 通过get_run_time()方法获取测试运行时间,使用此方法控制压测时间基于时间峰值策略# 基于时间峰值策略: 每秒生成10个用户,持续时间60sclass TimePeadShape(LoadTestShape): # time_limit设置整个压测过程为60秒 t原创 2021-08-01 20:32:49 · 422 阅读 · 0 评论 -
Locust Events 事件钩子
目录test_start&test_stopinit_command_line_parserinitspawning_completerequest_failurerequest_successrequesttest_start&test_stoptest_start和test_stop事件只在locust主节点中触发执行@events.test_start.add_listenerdef on_test_start(**k...原创 2021-08-01 20:29:34 · 892 阅读 · 1 评论 -
Locust集合点
模拟一定数量的用户,同时并发请求。from gevent._semaphore import BoundedSemaphore# 创建集合点all_locusts_spawned = BoundedSemaphore()all_locusts_spawned.acquire()# 注册事件@events.spawning_complete.add_listenerdef on_hatch_complete(**kwargs): all_locusts_spawned.re.原创 2021-08-01 20:23:13 · 375 阅读 · 0 评论 -
Locust测试数据参数化
目录全局数据非全局数据常见场景:全局数据同一份数据,随机取数同一份数据,顺序取数每个worker节点拥有独立的一份数据 & 不重复通过init事件注册监听,可结合init_command_line_parser事件配置全局数据,数据针对worker独立唯一。def work_id_data(): """队列获取作品ID数据""" # work_ids = queue.Queue() with open('work_id.t...原创 2021-08-01 20:21:09 · 573 阅读 · 0 评论 -
Locust V1.5.3压测websocket接口
import jsonimport loggingimport reimport timeimport geventimport websocketfrom locust import events, User"""自定义websocket客户端"""header = { 'Accept-Encoding': 'gzip, deflate, br', 'Connection': 'keep-alive', 'Content-Type': 'application原创 2021-06-29 22:53:47 · 718 阅读 · 1 评论