Locust HTTP client
Http client 默认是以安全模式运行的,任何由于连接错误、超时或者类似错误引起的异常,都会返回一个空的Response对象,这个请求将会再locust统计中标记为failure,返回的虚拟对象Response’content属性将会被置为空,status_code为0。一般不用再使用try...exception处理异常。
默认情况下,返回2xx的状态码的都会标记为success,之外的情况都会被标记为failure,如果想手动改变这种情况,需要手动控制。
实例:如果返回的内容不包含Success文本,则标记为失败;如果返回码不是404失败
class UserTask1(TaskSet):
@task
def task(self):
with self.client.get("/", catch_response=True) as response:
if response.status_code == 400:
response.success()
else:
response.failure(response) class UserTask2(TaskSet):
@task
def task(self):
with self.client.get("/belle-ls/", catch_response=True, verify=False) as response:
if response.content != b"Success":
response.failure("Failed")
请求时参数替换
# Statistics for these requests will be grouped under: /blog/?id=[id]
for i in range(10):
client.get("/blog?id=%i" % i, name="/blog?id=[id]")
Locust HTTP client的更多相关文章
- 性能测试工具Locust的使用
一.写在前面 官网:https://www.locust.io/ 官方使用文档:https://docs.locust.io/en/latest/ 大并发量测试时,建议在linux系统下进行. 二.L ...
- Python3中性能测试工具Locust安装使用
Locust安装使用: 安装: python3中 ---> pip3 install locust 验证是否安装成功---> 终端中输入 locust --help ...
- locust===Writing a locustfile
The Locust class A locust class represents one user (or a swarming locust if you will). Locust will ...
- TCP 百万并发 数据连接测试 python+locust
过程笔记和总结 尝试一.locust 测试百万Tcp并发 另一种方式是使用jmeter 基础环境 服务端 虚拟机:Centos7.2 jdk 1.8 客户端 虚拟机: Centos7.2 python ...
- 性能测试工具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脚本对指定网站或者接口 ...
- Python Locust性能测试框架实践
[本文出自天外归云的博客园] Locust的介绍 Locust是一个python的性能测试工具,你可以通过写python脚本的方式来对web接口进行负载测试. Locust的安装 首先你要安装pyth ...
- 性能测试框架Locust初学笔记
Locust初探 Locust是一款类似于Jmeter开源负载测试工具,所不同的是它是用python实现,并支持python脚本. locust提供web ui界面,能够方便用户实时监控脚本运行状态. ...
随机推荐
- C# 实现对PPT编辑
C# Presentation 文本替换 我们可以通过插入占位符的方式,使用新的字词替换已有幻灯片里的文字. 本文将详细描述如何使用Spire.Presentation 来替换Prsentation ...
- 1256 Anagram
题目链接: http://poj.org/problem?id=1256 题意: 根据自定义的字典序: 'A'<'a'<'B'<'b'<...<'Z'<'z' 和输 ...
- R语言笔记完整版
[R笔记]R语言函数总结 R语言与数据挖掘:公式:数据:方法 R语言特征 对大小写敏感 通常,数字,字母,. 和 _都是允许的(在一些国家还包括重音字母).不过,一个命名必须以 . 或者字母开头, ...
- Smart3d 近景摄影测量与航空摄影测量
实例:http://blog.sina.com.cn/s/blog_8f68d2350102wef4.html ContextCapture(Smart3d):https://www.bentley. ...
- vim command
问题:对多行缩进 简述:向左缩是<,向右缩是> 详述:在命令状态,按v进入visual状态,选中多行,再按>,相当于一个TAB键:再选中多行,按<试试 ------------ ...
- Javascript原型与对象等知识
声明式函数定义: function add(m,n) { alert(m+n); } 这种方式等同于构造一个Function类的实例的方式: var add = new Function(" ...
- 系统数据库--修改tempdb的位置
use mastergoAlter database tempdb modify file (name = tempdev, filename = 'G:\db\tempdb.mdf')goAlter ...
- Entity Framework 高性能 泛型缓存+动态Lambda
前言:自学CSharp挺长时间的了,这是我第一编博客,跟大家分享一下.如有不足地方请多多包涵,也欢迎大家提出更好的意见,下面开始进入正题. 一.泛型缓存 1.概念:1.泛型(泛型也是一种推断类型,从而 ...
- ParserError: Error tokenizing data. C error: Expected 2 fields in line 15, saw 4
pandas 读取泰坦尼克号数据,报错 %matplotlib inline import numpy as np import pandas as pd import re as re train ...
- 936. Stamping The Sequence
You want to form a target string of lowercase letters. At the beginning, your sequence is target.len ...