Jmeter 使用

来源:互联网 发布:手机淘宝怎样切换卖家 编辑:程序博客网 时间:2024/05/16 08:09

Jmeter 使用

1. 可以用Os Process Sampler 来模仿 cmd 启动 exe 文件

  在Command: 输入 路径, 比如 D:\work\fiddler.exe,  可以通过timeout 强制关闭

2.JDBC Connection Configuration 配置

在Variable Name 填入变量名, 给之后的JDBC sampler 使用, 在Database URL 填数据库的相关信息,

  eg: jdbc:sqlserver://机器名:端口号;DatabaseName=****;integratedSecurity= true  (此处是用电脑账号登录,如果使用账户密码登录替换掉integratedSecurity= true)

JDBC Driver class: com.microsoft.sqlserver.jdbc.SQLServerDriver

3.通过正则表达式获取response 数据。

 

正则表达式:提取内容的正则表达式【稍注意一下:()表示提取,对于你要提前的内容需要用小括号括起来】

匹配数字(0代表随机):0代表随机,-1代表所有,其余正整数代表将在已提取的内容中,第几个匹配的内容。

4. 在JDBC Request 中引用 正则表达式提取的值

Query Type 选 prepared Update Satement(此处例子是删除功能)

方法1:直接在语句里参数化 delete  from dbo.XXX  where file_id =${file_id}

方法2; 可以delete  from dbo.XXX  where file_id = ?, 然后在 Parameter values: file_id  , Parameter Types: INTEGRE . Variable names: file_id . 可以填多个。


5. 基于file_id 来删除N 个table里面 file_id 为 某个值的记录。

首先或者这个file_id :select file_id from dbo.xxx  where file_name like '%sample%'  , 然后用正则提取这个file_id ,([0-9]+)

然后创建一个 Loop Controller, 里面有CSV Data Set Config, 事先把 每个table都保存在外部文件 txt 中,逐个读入,读完后就end,设置好后,在JDBC Request 里面 直接调用。delete from ${table} where file_id = ${file_id} ,然后就会循环的把每一个table 都delete一遍。几个table就在loop里面设置循环几次。

6.  可以在Function Helper 查看Jmeter提供的内置函数, 常用的有 获取本机地址IP: ${_machineIP()}, 随机数 :${_Random(,,)}, 随机生成字符串:${_RandomString()}

0 0
原创粉丝点击