locust的 -T,--tags使用
官网的TAG配置说明:
-T [TAG [TAG ...]], --tags [TAG [TAG ...]]List of tags to include in the test, so only tasks with any matching tags will be executed
使用-T(大写)或者--tags都可以,命令里输入的标签是要被执行压测的
-E [TAG [TAG ...]], --exclude-tags [TAG [TAG ...]] List of tags to exclude from the test, so only tasks with no matching tags will be executed
使用-E(大写)或者--exclude-tags都可以,命令里输入的标签是不会被执行压测的
TAG方法说明:
tag decoratortag(*tags)
-
Decorator for tagging tasks and TaskSets with the given tag name. You can then limit the test to only execute tasks that are tagged with any of the tags provided by the --
tagscommand-line argument. Example:class ForumPage(TaskSet):
@tag('thread')
@task(100)
def read_thread(self):
pass @tag('thread')
@tag('post')
@task(7)
def create_thread(self):
pass @tag('post')
@task(11)
def comment(self):
pass
在需要标签区分执行的方法前通过tag装饰类引入标签即可,可以同时打上多个标签
执行时候得命令:直接在命令后面加上该参数即可,若是分布式压测,只需在slave里加即可,如:
master:
locust -f D:\***.py --master --master-bind-port 9800 --headless -u 1000 -r 50 --expect-workers 1 -t 10m -s 10 --csv D:\theco***y0106115648
slave:
locust -f D:\***.py --master-host 170.240.110.245 --master-port 9800 --headless --worker -T "test1" "test2" "test3"
这样就只执行含有test1,test2,test3标签的方法
当然,-E也是如此
但是 -T有个坑:
比如:@tag('test1')
@task
def api_api_channel_item_list(self):
headers = {'tenantId': 'FA9DA2211F880F10', 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'}
# 请求参数组装 ## r_url:固定参数
r_url = "/api/channel/itemList"
requests_data = {'channelId': '11', 'pageSize': '3', 'page': '1', 'queryType': '2', 'queryAllImg': 'true', 'client': 'WEB'}
# 发起请求
with self.client.post(r_url, data=requests_data, catch_response=True, name=r_url) as r:
if r.content == b"":
r.failure("No data")
if r.status_code != 200:
em = "request error --" + str(r.status_code)
r.failure(em) @tag('test2')
@task
def api_api_channel_item_list(self):
headers = {'tenantId': 'FA9DA2211F880F10', 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'}
# 请求参数组装 ## r_url:固定参数
r_url = "/api/channel/itemList"
requests_data = {'channelId': '11', 'pageSize': '3', 'page': '1', 'queryType': '2', 'queryAllImg': 'true', 'client': 'WEB'}
# 发起请求
with self.client.post(r_url, data=requests_data, catch_response=True, name=r_url) as r:
if r.content == b"":
r.failure("No data")
if r.status_code != 200:
em = "request error --" + str(r.status_code)
r.failure(em)以上的方法名是一样的,但一个打的标签是test1,一个打的是test2
当执行-T "test1"时,locust会报错:
Traceback (most recent call last):
File "d:\python\lib\site-packages\locust\user\task.py", line 285, in run
self.schedule_task(self.get_next_task())
File "d:\python\lib\site-packages\locust\user\task.py", line 417, in get_next_task
raise Exception(
Exception: No tasks defined on SYLocust. use the @task decorator or set the tasks property of the User (or mark it as abstract = True if you only intend to subclass it)-E倒是不会错
如果不是按场景压测的话,一般是不会遇到上面问题的,若压测代码是自动生成的话,相同的方法打上相同的标签即可,不会存在这个问题。
Locust QQ 群:

locust的 -T,--tags使用的更多相关文章
- Locust性能测试工具核心技术@task和@events
Tasks和Events是Locust性能测试工具的核心技术,有了它们,Locust才能称得上是一个性能工具. Tasks 从上篇文章知道,locustfile里面必须要有一个类,继承User类,当性 ...
- 6000字Locust入门详解
目录 一.Locust 性能测试 (一). 性能测试工具 主流性能测试工具对比 认识Locust (二) locust 基本用法 1.安装locust 2.编写用例 3. 启动测试 GUI 模式启动 ...
- Locust 任务类介绍
前言: 任务:简单的理解就是,你想要你脚本的虚拟用户去做哪些事,比如请求某一个接口,或者执行某一个事件 用户:可以理解为,执这个任务的实例主体,或者在locust 中,也可以认为是一群蝗虫 一.Tas ...
- 在开源中国(oschina)git中新建标签(tags)
我今天提交代码到主干上面,本来想打个标签(tags)的. 因为我以前新建过标签(tags),但是我现在新建的时候不知道入库在哪了.怎么找也找不到了. 从网上找资料也没有,找客服没有人理我,看到一个交流 ...
- struts tags
HTTP ERROR 500 Problem accessing /showognl.jsp. Reason: Server Error Caused by: org.apache.jasper.Ja ...
- 性能测试工具Locust
An open source load testing tool. 一个开源性能测试工具. define user behaviour with python code, and swarm your ...
- python httprequest, locust
r = self.client.get("/orders", headers = {"Cookie": self.get_user_cookie(user[0] ...
- Python Locust对指定网站“一键压测”
[本文出自天外归云的博客园] 前篇 前篇:Python Locust性能测试框架实践 本篇 承上——归纳过程 在前篇的基础上,我们可以利用Locust性能测试框架编写python脚本对指定网站或者接口 ...
- Make Notepad++ auto close HTML/XML tags after the slash(the Dreamweaver way)
I've been looking for a Notepad++ plugin that can close HTML/XML tags after a slash just like the wa ...
- linux安装locust
linux安装locust 1. 安装epel扩展源(目的是为了在安装Pip时不出现一堆乱七八糟的错误信息) EPEL(http://fedoraproject.org/wiki/EPEL) 是由 F ...
随机推荐
- GPT Prompt
GPT Prompt 本文总结我关于GPT prompt的一些常用模板和资源. 我常用的模板 大致模板:你是一个怎样的人,我的场景是什么,我想要什么,你需要做什么. 比如: 你是一个经验丰富的前端开发 ...
- enum class 用法
enum的主要缺点 1.类型不明确 首先,无法指定数据类型,导致我们无法明确枚举类型所占的内存大小.这种麻烦在结构体当中尤为突出,特别是当我们需要内存对齐和填充处理的时候. #include < ...
- PAT 甲级【1012 The Best Rank】
本题用java极容易超时,提交了好几次才成功 另外90 88 77 77 50,名次应该是1 2 3 3 5 ,不是1 2 3 3 4 import java.io.*; public class M ...
- Harris/Shi-Tomasi角点检测
机器视觉--角点检测 什么是角点检测 在几何学里,我们会看到各种各样的三角形.多边形等,它们都有一个显著的特征:包含了角点信息.比如在三角形里,我们有三个角:在矩形里,我们有四个角.我们将找到这些图像 ...
- 3DCAT 首届行业生态交流会 | 瑞云科技技术总监赵志杰:实时渲染助力元宇宙应用触手可及
2021 年 12 月 17 日下午,由深圳市瑞云科技有限公司主办,深圳市虚拟现实产业联合会协办的云 XR 如何赋能元宇宙--3DCAT实时云渲染首届行业生态合作交流会圆满落幕.此次活动围绕 &quo ...
- 新闻新体验!3DCAT助力开启红网“元宇宙”新闻直播间
2022年10月20日,湖南红网新媒体集团"华章·20--红网时刻新闻党的二十大报道云展厅"正式上线.深入到新闻元宇宙,开拓新的传播领域,这也是红网党政新媒体元宇宙传播应用实验室的 ...
- 记录--微信小程序,uniapp,H5端发送,显示emoji表情
这里给大家分享我在网上总结出来的一些知识,希望对大家有所帮助 小伙伴们,在开发中有没有遇到过发布帖子或者实时聊天需要发送到一些emoji表情的. 但是每当我们直接将emoji表情提交到后台的接口又会报 ...
- C++ Concurrency in Action 读书笔记一:thread的管理
为避免混淆,用thread表示std::thread及其对象实例,用线程表示操作系统概念下的线程 Chapter 2 thread的管理 2.1 thread的创建(构造函数) a. 默认构造函数 d ...
- 【论文阅读】NIDS对抗性机器学习综述
基本信息 题目:Adversarial Machine Learning for Network Intrusion Detection Systems: A Comprehensive Survey ...
- Oracle通过数据库链连接KingbaseES
测试环境: ip 数据库版本 192.168.254.135 oracle 11g 192.168.254.137 V008R006C005B0023 通过oracle官网得知,Oracle使用DG4 ...