Question

Here's my situation:

I want to do this:

I have a list of URLs in a MySQL database which I want to hit using a HTTP Request to see if the response is a HTTP Status code of 404 or not.

I have done this:

  1. Added and configured a JDBC Config Element.
  2. Added and configured a JDBC Request Sampler. Basically a select statement that returns a table with 8 columns. I have provided 8 comma-separated variables for the 'Variable names' field, so that the results of the JDBC request can be identified with these variable names.
  3. Created a HTTP Request Sampler that uses one of those variables ${url} in the 'Server Name or IP' field.

Though the JDBC request works flawlessly and returns a table with a bunch of rows, the problem with this is that the HTTP Request Sampler never picks up the variable from the JDBC Request result. The HTTP Request looks like this in the 'View Results Tree':

GET http://${url}/

I have tried these solutions:

  1. Add 'Save Responses to a File' listener to the JDBC Request. This creates a file of type '.plain' and not a CSV. Had it been a CSV, I could have utilized that CSV file by creating a CSV Data Set Config. So this attempt failed.
  2. I have tried forcing the file name in the above attempt to always use 'C:\JMETERTest\data.csv'. But it ends up creating a new file named 'C:\JMETERTest\data.csv1.plain'. This attempt failed too.
  3. I tried to reference the URL column as ${url_1} in the HTTP Request's Server Name field. It worked. But the problem now is that in the results tree, all the requests are going for the the URL from only the first row of the result set. I see that this is because of the row number '_1' specified in the ${url_1} above. I can use this if someone can suggest a way to parameterize the '_1' into a variable that I can loop through (probably using a 'Counter' element). I created a Counter Config Element by the Reference Name 'loopCounter'. And used this in the Server Name field of the HTTP Request:

    ${url_("${loopCounter}")}

But now my HTTP Requests look lamer:

GET http://${url_("${loopCounter}")}/

This did not work too.

Solution 3 looks more doable to be only if I could resolve the parameterization of the row number. I am open to JMeter Plugin suggestions too. I will update anything else that I try as we go on.

P.S. Please let me know if my question is not clear in anyway.

Was it helpful?

Solution

Have you tried wrapping the HTTP sampler in a ForEach controller (parent) where the variable for the controller is the URL variable obtained from the JDBC sampler?

Also, the output variable in the ForEach will be the variable you now use in the HTTP sampler.

That way it will iterate through each variable from the beginning of the index to the end and run the sampler once each time.

OTHER TIPS

In 'Save responses to a File' Listener, Select Checkboxes "Don't add Suffix and Prefix". Checking these two options will ensure, you get exact Log file name.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top