开发者

How to use FOrEach Loop and Regular Expression Extractor in JDBC request Sampler in JMeter

开发者 https://www.devze.com 2023-03-23 15:03 出处:网络
I have configured JDBC connection to mysql. And I have added the JDBC sampler and a listener. But I wanted to extract the details with regular expression extractor and then to enter into a foreach loo

I have configured JDBC connection to mysql.

And I have added the JDBC sampler and a listener.

But I wanted to extract the details with regular expression extractor and then to enter into a foreach loop.

In ForEach loop, I wanted to execute a HTTP re开发者_开发知识库quest.

My results window look as:

empid   empname empDesgination
10          lee     jrtester
10          lee     MURAEE
123         lee     MURAEE
1234567890  leeee   MURALEE
1234567890  lee     MURALEE

Please explain the following points:

  • How to write Regular Expression Extractor(i.e.. Regular Expression)?
  • How to extract from that?
  • What should I enter in ForEach loop Input Variable and in Output Varible?

As, with the information provided, i have worked on the JDBC, but it doesn't extracting the data and entering into loop. Could u please Explain what Exactly Regex expression we write to extract the above data. Where we give the Reference name as ${VAR_out} for Http request sampler. Please expalin me the full flow with Regex, ForEach and Http Sampler.

Please provide me simple example on JDBC sampler Extracting data using Regular Expression Extractor and entering into the ForEach Loop.


I have recently worked this out, try the following steps:

  1. Create your HTTP Request to pull down the response data
  2. Create a Regular Expression Extractor as a child to your HTTP Request. And set the following
    • Set your reference name (Which becomes the variable name later in the script)
    • Set your regex (There is some good help here: http://jmeter.apache.org/usermanual/regular_expressions.html)
    • Set your template (Again review the url above for info on template)
    • Set the Match No. to -1 (This allows you to save all captured results to one variable)
  3. Now create a ForEach controller below HTTP Sample setting the 'Input variable prefix' to the reference name you gave the Regular Expression Extractor and the 'Output variable name' to whatever you like (something like tmpvar) and check the 'Add "_" before number' checkbox
  4. Create an HTTP request under your ForEach controller and set either the Server or Path with your varibale ${tmpvar} and that should run the HTTP request for each hit the Regular Expression Extractor found.


To write a regular expression, please see this fantastic site: http://www.regular-expressions.info/ Jmeter uses PERL for it's regex and you'll find everything you need to know here. Also take a look at the manual for regular expression extractor on how to setup the controller. If you want to loop through every result, you'll want a negative match number (see manual).

The foreach controller manual can be slightly confusing at first. In the ForEach Input Variable - enter the variable you declared in the Regular Expression Extractor under the Reference Name. In the output field, enter the Variable reference for your sampler.

Roughly, something like this:

Regex controller:
      Reference Name: VAR_in

For Each:  
    Input: VAR_in
    Output: VAR_out

Sampler:
    reference ${VAR_out}
0

精彩评论

暂无评论...
验证码 换一张
取 消