http压力测试和基准测试工具

mobbage的Python项目详细描述


mobbage是一个python脚本,用于压力测试工具 用于http(s)服务器和web感知应用程序。它类似于 直接灵感来自)seege,jeffrey开发的http负载测试实用程序 fulmer(可在https://github.com/JoeDog/siege找到)。

然而,莫比奇还包括一些铃铛和口哨(基帕里夫, http/2,身份验证,Cookiejar支持,多部分/表单数据上传, 以及通过url作业提供复杂测试计划的能力 文件。

安装

安装非常简单:

pip install mobbage

这将安装mobbage及其所有必需的python模块 (此时它只是requests模块)来自pypi。如果你 must必须是最新的和最好的,您可以直接安装 来自此回购:

pip install https://github.com/redfin/mobbage/zipball/master

用法

mobbage可以通过命令行或通过 构造的作业文件(或两者都有;全局默认值可以通过 命令行并由作业文件中的变量重写)。

命令行选项可以分为以下类别:

请求控制:

URL                      URL(s) to fetch
-f str, --jobfile str    Read job data from this file
-F str, --urlfile str    Read url data from this file. Mutually exclusive
                         with -f
-m str, --method str     HTTP method to use. Default is 'GET'
-a str, --agent str      Set User-Agent request header
-H str, --header str     Send request header in 'name:value' format. Specify
                         more than once for multiple headers
-u str, --upload str     Upload a file via multipart/form-data POST. Must be
                         formatted as 'form_var:file_path[:content_type]'.
                         If content type isn't specified, a best guess will
                         be made based on the filename. This option can be
                         specified more than once. Forces method to be POST
-i, --insecure           Disable SSL certificate validation
-k, --nokeepalive        Disable keep-alive requests
-c str, --cookiejar str  Path to Unix/Netscape formatted cookie jar file.
-2, --http2              Use HTTP/2 standard (experimental).

认证:

-A str, --auth str       Auth credentials in 'username:password' format
-T str, --authtype str   Authentication type to use: basic(default), digest

流量控制:

-w N, --workers N        Use this many concurrent workers. Default is 1
-n N, --num N            Quit after exceeding this number of requests
-t N, --time N           Quit after running for this number of seconds
-b N, --bytes N          Quit after for this number of seconds
-e N, --errors N         Quit after encountering this many errors
-d N, --delay N          Pause N ms after each request. Default is 0
-r, --random             Fetch URLs in random order instead of sequentially

输出控制(互斥):

-q, --quiet              Suppress all output
-j, --json               Format results as JSON
-s, --csv                Format results as CSV
-p, --progress           Show progress bar
-V, --verbose            Print verbose worker output

报告:

-g str, --graphite str   Graphite host to use, defined as 'server[:port]'
-P str, --prefix str     Prefix for graphite metrics. Default is 'mobbage'

信息:

-v, --version            Show version and quit
-h, --help               Show this help text

URL文件格式:

url文件是以换行分隔的url列表(以及可选的方法 与攻城文件格式兼容,例如:

http://www.site1.com
http://www.site1.com GET
http://www.site2.org POST foo=bar&bin=baz

作业文件格式

作业文件是一个json格式的对象数组,每个对象 表示要测试的单个url。每个测试的选项应该是 在key:value表单中为每个测试对象指定,使用相同的键 name作为命令行中选项名称的长版本。 作业对象中的选项是:*url*num*data *延迟*方法*代理*头*上载*不安全* nokeepalive*auth*authType

作业对象中未指定的选项将继承在 命令行,否则为默认值。“头”和“上传” 应指定为字符串的JSON数组。

示例文件格式:

[
    { "url": "http://www.foo.com", "count": 100,
      "header": ["host:www.bar.com", "accept-language:en-us"] },
    { "url": "http://www.google.com/search?q=lmgtfy",
      "agent": "lulzBot/0.1", "delay": 50 },
    { "url": "http://www.bar.com", "method": "POST",
      "data": "field1=boo&field2=baz" },
    { "url": "http://www.myhost.com", "count": 10,
      "upload": ["file1:/tmp/foo.txt", "file2:/tmp/bar.zip"] }
]

注意事项

  • http/2支持是通过pythonhyper模块实现的,该模块 在阿尔法早期。那里会有漏洞。要启用http/2支持, 必须首先安装hyper:pip install hyper
  • 如果使用作业,则无法在命令行上指定URL 控制文件
  • 用户代理可以通过-a选项指定,也可以通过 通过-H选项手动指定user-agent头。如果 两者都被指定,由-H选项设置的值接受 优先。
  • keep alives可以通过-k标志禁用,也可以通过设置 要“关闭”的connection头。如果使用-k标志, 但是,您将覆盖以前在 connection标题。
  • cookie jar(通过-c指定)在 每个工人,不写回磁盘上的原始文件。 因此,在每个工人中设置的cookie可以用于下一个 请求相同的资源,但不在工作人员之间共享,以及 无法持久化到后续的mobbage会话。
  • 所有输出控件标志都是互斥的(因此您不能 例如,有一个带有csv输出的进度条)。
  • 通过udp向graphite carbon服务器发送报告,因此 如果无法访问Carbon服务器,则不会产生错误。如果 未指定Carbon服务器的端口,假定为2003。

想帮忙吗?

补丁总是受欢迎的!请参见the contributing guide开始。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何从同步请求中获取响应代码   具有深度复制的类中的Java oop getter/setter   java LDAP“简单”用户身份验证(JNDI Tomcat)不稳定?   java将Jenkins jnlp代理设置为通过API以编程方式使用WebSocket   java如何获取在servlet筛选器的静态块中启动的静态类的实例?   前两个数字的java charAt循环不能循环它   java在Spring引导执行器中是否有检查子服务运行状况的标准方法?   java我可以将jacksonmapped@JsonProperties推到“顶层”吗?   json JAVA:opencsv随机读取CSV单元格   无第三方应用程序的java捆绑包JRE   使用openidConnectClient功能的WAS Liberty中出现java无效cookie标头错误   java如何在Restful Web服务中从Http Post获取数组?   java如何读取安卓开发的JSON url?   如何在java IO中打开包含汉字的文件?