官网的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 decorator

tag(*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 --tags command-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使用的更多相关文章

  1. Locust性能测试工具核心技术@task和@events

    Tasks和Events是Locust性能测试工具的核心技术,有了它们,Locust才能称得上是一个性能工具. Tasks 从上篇文章知道,locustfile里面必须要有一个类,继承User类,当性 ...

  2. 6000字Locust入门详解

    目录 一.Locust 性能测试 (一). 性能测试工具 主流性能测试工具对比 认识Locust (二) locust 基本用法 1.安装locust 2.编写用例 3. 启动测试 GUI 模式启动 ...

  3. Locust 任务类介绍

    前言: 任务:简单的理解就是,你想要你脚本的虚拟用户去做哪些事,比如请求某一个接口,或者执行某一个事件 用户:可以理解为,执这个任务的实例主体,或者在locust 中,也可以认为是一群蝗虫 一.Tas ...

  4. 在开源中国(oschina)git中新建标签(tags)

    我今天提交代码到主干上面,本来想打个标签(tags)的. 因为我以前新建过标签(tags),但是我现在新建的时候不知道入库在哪了.怎么找也找不到了. 从网上找资料也没有,找客服没有人理我,看到一个交流 ...

  5. struts tags

    HTTP ERROR 500 Problem accessing /showognl.jsp. Reason: Server Error Caused by: org.apache.jasper.Ja ...

  6. 性能测试工具Locust

    An open source load testing tool. 一个开源性能测试工具. define user behaviour with python code, and swarm your ...

  7. python httprequest, locust

    r = self.client.get("/orders", headers = {"Cookie": self.get_user_cookie(user[0] ...

  8. Python Locust对指定网站“一键压测”

    [本文出自天外归云的博客园] 前篇 前篇:Python Locust性能测试框架实践 本篇 承上——归纳过程 在前篇的基础上,我们可以利用Locust性能测试框架编写python脚本对指定网站或者接口 ...

  9. 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 ...

  10. linux安装locust

    linux安装locust 1. 安装epel扩展源(目的是为了在安装Pip时不出现一堆乱七八糟的错误信息) EPEL(http://fedoraproject.org/wiki/EPEL) 是由 F ...

随机推荐

  1. liunx 安装 python 虚拟环境, 各种方法,

    liunx 安装 python 虚拟环境,主要是要解决工作中需要用到python3.6,但是系统的2.7又不能动,安装系统组件时避免造成冲突.低版本的python安装django  uwsgi 等都用 ...

  2. vid = two 切开 分开 - 两个眼睛 还有看的含义 - 词根

    vid = two 切开 分开 - 两个眼睛 还有看的含义 - 词根 vi = wo acs 构词

  3. linux 无法找到“/usr/bin/core_perl/gcc” vscode

    解决问题的思路 查看有没有gcc,没有安装 有的话就是,修改安装路径就可以? "/usr/bin/core_perl/gcc".修改成Gcc的绝对路径 我的修改是./usr/bin ...

  4. c语言运算符优先级实例解析

    壹:    对于优先级:算术运算符 > 关系运算符 > 逻辑运算符 > 赋值运算符.逻辑运算符中"逻辑非 !"除外.这是程序员总结出来的最快的学习方式. 可在实战 ...

  5. Prompt进阶系列4:LangGPT(构建高性能Prompt实践指南)--结构化Prompt

    Prompt进阶系列4:LangGPT(构建高性能Prompt实践指南)--结构化Prompt 1.结构化 Prompt简介 结构化的思想很普遍,结构化内容也很普遍,我们日常写作的文章,看到的书籍都在 ...

  6. C# AES CBC模式 加密和解密

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.S ...

  7. FPGA中的速度优化

    FPGA中的速度优化 一.逻辑设计中的速度概念 逻辑设计速度相关的概念有三个:设计吞吐量.设计延时和设计时序.速度优化策略而言,吞吐量需要提高,延时应该降低,时序应该收敛(时序余量slave越大,收敛 ...

  8. jsonb操作符

    json类型以文本方式存储json对象,把输入的数据原封不动的存放到数据库中,会保留多余的空格,保留重复的Key,保留Key的顺序. jsonb类型转换文本格式json对象为二进制格式,不保留多余的空 ...

  9. .net跨平台运行实践

    一个偶然的机会,一个朋友想做一个程序,同时支持windows和linux,本来想用go来写,奈何不太熟练,突然想到.net不是也支持跨平台了吗,还没有操作过,刚好可以试验一下. 最新的.net 6已经 ...

  10. #单调栈#CodeChef Meteor

    METEORAK 分析 设 \(dp[l][r]\) 表示第 \(l\) 到 \(r\) 行的答案,可以发现它由 \(f[l][r],dp[l][r+1],dp[l+1][r]\) 转移而来. 关键就 ...