开发者友好的负载测试框架
项目描述
har2locust
从头开始创建 locust文件 有时很难。你难道不希望可以从浏览器会话自动生成它吗?
现在你可以做到了!har2locust将你的浏览器记录(HAR文件)转换为locust文件。
har2locust的核心使用一个 jinja2模板 来定义输出。你可以轻松地更改它以自定义输出,或者你可以更进一步,使用 插件系统 来对处理/输出进行任何类型的更改。
安装
pip install har2locust
用法
-
使用浏览器导航网页同时记录您的活动。然后将记录导出为HAR文件。以下是一个使用Chrome开发者工具的示例
-
运行
har2locust myrecording.har > locustfile.py
> har2locust --help
usage: har2locust [-h] [-t TEMPLATE] [--plugins PLUGINS] [--disable-plugins DISABLE_PLUGINS]
[--resource-types RESOURCE_TYPES] [--version] [--loglevel LOGLEVEL]
input
positional arguments:
input har input file
options:
-h, --help show this help message and exit
-t TEMPLATE, --template TEMPLATE
jinja2 template used to generate locustfile. Defaults to locust.jinja2. Will check current
directory/relative paths first and har2locust built-ins second
--plugins PLUGINS Comma separated list of extra python files to source OR packages to import, containing
decorated methods for processing the har file.
--disable-plugins DISABLE_PLUGINS
Temporarily disable default plugins. Specified by comma separated list of default plugin
python files to source.
--resource-types RESOURCE_TYPES
Commas separated list of resource types to be included in the locustfile. Supported type are
`xhr`, `script`, `stylesheet`, `image`, `font`, `document`, `other`. Defaults to
xhr,document,other.
--version, -V show program's version number and exit
--loglevel LOGLEVEL, -L LOGLEVEL
Simplest usage:
har2locust myrecording.har > locustfile.py
Load extra plugins by import path and/or filename:
har2locust --plugins har2locust.extra_plugins.plugin_example,myplugin.py myrecording.har
Disable one of the default plugins:
har2locust --disable-plugins=rest.py myrecording.har
Parameters can also be set using environment variables or config files (har2locust.conf or ~/.har2locust.conf) For details about how to set parameters see https://goo.gl/R74nmi
- 运行locust!
高级用法
-
使用文件
.urlignore
和.headerignore
过滤您的记录(从您的当前目录读取)。用正则表达式填充它们以过滤记录中的任何不想要的请求或头部。一些头部始终被忽略(cookie、content-length和chrome的“fake”头部)。以下是一些示例: .urlignore,.headerignore -
使用插件系统进行更高级的处理。
注意
har2locust基于har2py构建,修改为生成locustfile而不是基本的Python文件,并扩展以支持插件。
har2locust非常新,在1.0版本之前,接口可能会有变动而不通知。如果您遇到问题,PR(Pull Requests)非常受欢迎。
此外,不要期望生成的文件总是非常有用。您可能需要添加响应验证以确保测试质量,也许还需要参数化动态数据,如用户名。
项目详情
下载文件
下载适用于您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。
源分布
har2locust-0.9.3.tar.gz (25.6 MB 查看哈希值)
构建分布
har2locust-0.9.3-py3-none-any.whl (16.9 kB 查看哈希值)
关闭
har2locust-0.9.3.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 5e581fdf780bb01ef5978bb6765d62fd05ba329a71cd939b6eacb71996c39f47 |
|
MD5 | 94fc5965070fe6ed03906e5383b74fe4 |
|
BLAKE2b-256 | 3726e0e3cde3170fe4444215564e47ea3e830c60461f200c02dbdae1cd546794 |
关闭
har2locust-0.9.3-py3-none-any.whl的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 55fbe8ca620d023c0d86e4e183fc3f8a1940f68c38bd130fbc0b12aad9665b71 |
|
MD5 | 6ef173c1abcf986d5dfe8a7df370f245 |
|
BLAKE2b-256 | c3e6f451c6c077f461347553e9610d493743e88d02869f03ae49295a3a034709 |