Software system & database performance testing process

System and database performance test records

createBy lln
createTime 2023-03-01
Jmeter version: V5.3
背景:
公司内部某ToB大型项目前期准备工作之一,评估在特定条件下的系统性能、数据库性能情况,通过此测试决定需要申请的资源数量。
使用Jmeter完成Api接口测试及数据库吞吐测试。

Early thinking

How to Evaluate the Resource Information Needed by a Software System

insert image description here

How to perform an interface performance test

insert image description here

How to conduct database performance testing

insert image description here

How to use Jmeter for testing

How to obtain test report records

Jmeter learning record

Groom & Split & Test Records

insert image description here

线程组
配置原件
控制器
取样器
处理器

本质上是对一组资源的生命周期进行管理。
资源即需要测试的场景,这个场景可以是接口、可以是SQL语句等等。
然后针对该资源,进行相应的配置,如接口地址,请求数据,jdbc连接参数等等。
对于资源的请求,又可以进行各种逻辑的控制,如多线程的执行,顺序的执行,循环执行等等。
对于资源的请求结果,可以进行后置的处理,断言,数据处理等等。
对于资源的整个生命周期,又可以生成报告,包含了资源的请求信息,结果信息,异常信息,吞吐信息等等。

configuration element

HTTP配置

JDBC配置,需要将驱动文件,导入指定目录,或者放入jmeter中lib目录下

sampler

自定义url,token变量
测试线程递增配置-插件 Stepping Thread Group 的安装和处理 

insert image description here

controller

一些特殊测试情况,不可让测试用例随机执行,如顺序执行,循环执行等情况。使用控制器进行管理。

Multithreaded downsampling sequential execution

逻辑控制器-临界资源控制器,给每个请求进行加锁 || 或单线程,设置一个线程顺序执行,会按照取样上下顺序

Sampling is performed only once under multi-threading

逻辑控制器-仅一次控制器

CVS file

insert image description here

对于大批量的数据,如批量的URL,批量的SQL语句等,可以通过CVS文件读取的方式,快速执行取样配置

testing report

Environment configuration and commands

linux中环境的配置 
https://blog.csdn.net/Mrlijie00/article/details/121040418

-n 非GUI 模式运行 JMeter
-t 选择 .jmx   运行的jMeter 测试脚本文件
-l 结果 日志文件,记录结果的文件  后缀要是 .jtl
-e 生成报告
-o 输出报告文件
删除测试报告记录
rm -rf /sda/apache-jmeter-5.3/bin/report_output
删除测试日志
rm -rf /sda/apache-jmeter-5.3/bin/logFile
执行测试语句
./jmeter.sh -n -t /sda/apache-jmeter-5.3/jmx/test.jmx -l logFile-e -o ./report_output

Sinicization of test reports

https://gitee.com/smooth00/jmeter-cn-report-template

server monitoring

对于Api测试,试用k8s中的Prometheus+Grafana 进行性能的监控
对于数据测试,因为是裸服务器,只有基本数据库和数据,无权限按照其他监控软件。故使用 sar 命令进行监控,将监控数据导出为文件,处理至excel后,转为折线图,展示性能情况。

insert image description here

insert image description here

insert image description here

后台执行cpu监测,5秒一次,执行180次==15分钟
	nohup sar -u 5 180 >/sarCpu.txt &
后台执行Mem监测,5秒一次,执行180次==15分钟
	nohup sar -r 5 180 >/sarMem.txt &

Review & thinking

How Jmeter can help in development

insert image description here

分布式数据幂等性测试,大批测试数据入库

If you do it again, how to optimize the above process

使用工具如jenkins,将脚本自动化执行,完成测试,输出报告,输出内容的过程。可以写代码处理。而不是手动执行,手动录入。(经验不足导致)

other thoughts

【设计】GUI界面设计的灵活性
【对比】postman、apipost差异
【源码】线程组设计,自己设计一个线程处理函数,可以扩展,动态配置
【源码】POI模板报告的组合与生成

insert image description here

insert image description here

Guess you like

Origin blog.csdn.net/weixin_42559985/article/details/129986475