How to run http request until 400 is returned

21 Views Asked by At
  1. Ran JDBC request and got result JDBC request : select id from epx.unavailability where startdate >= (NOW() - INTERVAL '7 days') and siteid='${su-siteid}';

Result: Please refer screen shot enter image description here

Created HTTP request to delete records which is retrieved from the DB request.

It deleted first record but I want to delete all the records which is reteieved from the DB request.

I'm using ' JSR223 PreProcessor ' to HTTP request.

JSR223 PreProcessor: def Scenario = vars.get("Scenario") def unavailabilityid = vars.get("${unavailabilityid}")

if(Scenario.contains("epx_diary_Unavailability_Del_old")){ vars.put("unavailabilityid","${__groovy(vars.getObject('unavailabilityid')[0].get('id'),)}") }

Please let me know it's possible

1

There are 1 best solutions below

0
Ivan G On

If you set "Variable names" in JDBC Request sampler:

enter image description here

you will get the following JMeter Variables:

id_1=foo
id_2=bar
id_3=baz
...
etc
id_#=number of rows returned by SQL query

The ${id} variable can be used in ForEach Controller

enter image description here

ForEach Controller will run its children as many times as there are "ids" returned by your SQL query and you will be able to refer the current "id" as ${id} in the HTTP Request sampler:

enter image description here