Jmeter configuration elements --JDBC Connection Configuration parametric Jmeter element arranged --CSV DataSet Config parameterization

Yesterday parametric Jmeter --CSV DataSet Config element disposed in an article, there are mentioned, during parameterization, may also be used to achieve JDBC Connection Configuration configuration element, in particular how, how, listen to explain.

jar package download

Want to use the function in connection to the database Jmeter, you must download the jar package, download address .

Download Well jar package, how to use it? Use in two ways.

First: the downloaded jar package saved in the non Jmeter EXT lib in the directory, specify the path Jmeter jar package engineering test program elements, as shown below ;

Second: Download the jar package stored in the ext directory under Jmeter's lib, you do not need to do additional configuration, and do not worry about the future to other computers copy files to a folder forget to copy the [personally recommend this kind of the way】

Basic Configuration

We first look at the interface, as shown below:

According to understand the figure, we can configure the interface is divided into five sections:

1, names and comments, can easily fill;

2, Variable Name for created pool, Variable Name is the definition of a variable name. Fill a variable name, and the need to use the JDBC request, or JDBC PreProcessor, or the same variable name in the JDBC PostProcessor. It found that a test plan can bind multiple DB sources;

3, Connection Pool Configuration, the configuration on the database connection pool, in general use, the default can be; but want to pressure testing, load testing alone DB, DB wanted to find the most suitable connection pool, we should pay attention;

4,Connection Validation by Pool,在一般使用中,默认即可,Validation Query 一般选择 select 1;

5,Database Connection Configuration,数据库连接配置,在这里着重讲解。数据库连接的配置,将数据库url/port/db name/用户名和密码等填入。jmeter还支持以下几种连接方式:

参数化

参数化一:正则表达式提取

使用JDBC Request请求方式,查询数据,并使用正则表达式提取唯一值,实现参数化,脚本实现如下:

运行脚本,查看结果,如下所示:

参数化二:引用JDBC Request请求变量名

在JDBC Request请求中,配置变量名,配置如下:

运行脚本,查看结果,数据库查询到2个name值,如下:

通过Debug Sampler查看到2个name分别对应的变量名为:

所以脚本参数化调整如下并运行:

参数化三:变量名循环

我们在参数化方式二中,通过Debug Sampler查看,有个变量为name_#的字段,由于查询到2个值,所以等于2,。如果数据库中有很多数据,而且要一一参数化的情况下,难道我们要重复写那么多次的接口吗?答案当然不是,可以引用name_#字段,做为循环次数即可,我们来细看。

①增加循环控制器

我们先增加一个循环控制器,并引用变量值,配置如下:

②增加计数器

再增加一个计数器,定义每次递增值,而来控制循环次数,配置如下:

③引用变量名

按以前引用写法,可能会直接写${name_${name}},但是jmeter中不支持这种写法,所以在这里,需要引进另一个函数,${__V()},参数引用如下:

④查看结果

运行脚本,查看结果如下:

 

 以上就是今天分享的参数化内容了,我们可以看出,方式三更适用于实际业务当中,个人也推荐这种方式。

 

本文仅代表作者观点,系作者@温一壶清酒发表。
欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
文章出处:http://www.cnblogs.com/hong-fithing/

Guess you like

Origin www.cnblogs.com/hong-fithing/p/12112624.html