将数据库表用作JMeter的CSV数据集 [英] Use database table as CSV dataset for JMeter

查看:430
本文介绍了将数据库表用作JMeter的CSV数据集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在与JMeter一起为公司中的应用程序进行性能测试.该应用程序需要登录,我必须使用多个用户.通常在JMeter中完成此操作的方式似乎是通过CSV数据集,但是我可以访问该数据库,并且可以从那里直接读取所有凭据.

I am currently doing performance testing with JMeter for an application in my company. The application requires a login and I have to use multiple users. The way this is usually done in JMeter seems to be via CSV dataset, however I have access to the database and can read all the credentials from there directly.

因为它是一个测试环境,所以所有用户都具有相同的密码,因此我可以对其进行硬编码,但是我需要用户名列表. JMeter已经可以执行JDBC请求,但是我想知道是否有任何方法可以将这样的请求的结果用作数据集.

Since it is a test environment, all users have the same password, so I can hardcode it, but I need the list of usernames. JMeter can already do JDBC requests, but I was wondering if there was any way to use the results from such a request as a dataset.

理想的方法是对我查询数据库中的用户名,并将其用作登录测试的输入.

The ideal way would be for me to query the database for the usernames and use those as input for the login test.

有人知道这是否可能吗?

Does anyone know if this is possible?

推荐答案

当然可以.

  1. 按照以下步骤操作:构建数据库的真正秘诀使用JMeter进行测试计划建立JDBC连接并执行查询.
  2. 在JDBC Request采样器的变量名称"输入中定义一个变量
  1. Follow the steps from The Real Secret to Building a Database Test Plan With JMeter to establish JDBC Connection and execute your query.
  2. Define a variable in the "Variable Name" input of the JDBC Request sampler

3.查询结果将以

actor_1=John
actor_2=Doe
etc.

如果需要处理多个列,则方法相同.例如,请参见有关JDBC请求采样器的官方文档

If you need to deal with several columns, the approach is the same. See official documentation on JDBC Request Sampler for example

这篇关于将数据库表用作JMeter的CSV数据集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆