性能测试总结(performance testing)(二)

项目地址:jmeter使用实战
jmeter 使用简介

同样性能测试工具包括两点:模拟协议,使用多线程。同样是录制脚本,或者手写脚本,进行多线程高并发,分布式进行压力测试。

使用场景以及特点:
性能测试总结(performance testing)(二)

安装jmeter 4.x:

  1. 安装jdk 1.8 及以上环境(jdk>jre)
  2. 下载地址:http://jmeter.apache.org/
  3. window下点击 bin>jmeter .bat 文件进入
  4. bin> jemeter-server.bat :window下面分布式压测启动文件
  5. bin>report-template :报告模板

文件目录:
性能测试总结(performance testing)(二)
bin目录:启动文件目录,包含配置
docs目录:文档目录
extras目录:插件目录,安装二次插件目录
lib目录:安装包目录,ext核心包,junit单元测试包

添加线程,一个请求,一个查看结果树
性能测试总结(performance testing)(二)

【 in second :多少秒达到峰值,10秒完成一个线程。】

性能测试总结(performance testing)(二)
【默认协议就是 http ,服务器名称是域名或者ip地址,路径则是接口的路径,一般会给出。

性能测试总结(performance testing)(二)

post 请求

性能测试总结(performance testing)(二)

jmeter 断言
对测试结果添加断言,选择只测本次请求main sample olny,以及需要断言的内容,断言的后输出error http code。
性能测试总结(performance testing)(二)

聚合报告分析
1、对一个线程组添加一个聚合报告(在结尾处添加一个聚合报告),点击运行可查看报告结果
性能测试总结(performance testing)(二)
性能测试总结(performance testing)(二)

lever:接口名称sample
samples:总共发送请求
avriage:平均响应时间
error:错误请求率
throughput:吞吐率(qps,性能)
receive:接收字节数量
send:发送字节数量

jemter 执行脚本文件
测试linux服务器,用配置脚本文件,执行本机服务器压力测试,10线程组.jmx
性能测试总结(performance testing)(二)
每个地方的数值都可以自己填写,再用jemter执行

用户自定义变量
1、全局出现的变量,可以用用户自定义,方便全局改变,类似于开发中的常量,一个地方定义,全局使用。压测地址可以设置成全局变量。
性能测试总结(performance testing)(二)
性能测试总结(performance testing)(二)

2、需要用到的地方可以写 ${ip}
性能测试总结(performance testing)(二)

csv文件读取(csv文件保存用户数据,也可以添加txt文件,分隔符使用|进行分割。)
性能测试总结(performance testing)(二)
1、添加csv路径,注意一行有两个变量接收
性能测试总结(performance testing)(二)
2、http请求中路径接口处,本地传入变量使用csv_namecsv_pwd
性能测试总结(performance testing)(二)

jemter 压测数据库
1、添加一个线程组,jdbc request,同时写一个查询语句select * from tag
性能测试总结(performance testing)(二)
2、给jdbc request 配置mysql,添加连接mysqljava
性能测试总结(performance testing)(二)
3、添加观察树,观察结果(聚合报告)
性能测试总结(performance testing)(二)
性能测试总结(performance testing)(二)
4、预查询使用,不指定查询变量,底下配置(prepared select statement )
同样配置 variable name :debug报告变量名称
性能测试总结(performance testing)(二)

1、variable name of pool declared in JDBC connection configuration(和配置文件同名)
2、Query Type 查询类型
3、parameter values 参数值
4、parameter types 参数类型
5、variable names sql执行结果变量名
6、result variable names 所有结果当做一个对象存储
7、query timeouts 查询超时时间
8、 handle results 处理结果集

5、添加一个debug 采样器,同时添加一个整体观察树
性能测试总结(performance testing)(二)
6、执行查看观察树
性能测试总结(performance testing)(二)