1
votes

I am stress testing application database. I have successfully setup JDBC connection configuration and able to execute queries. The requirement is: Insert new customers in customer_table in a database. Customer ID(which is a column name) should be unique and in sequential order. For e.g, In customer_table if 100 customers already exists then to add other customers the customer_id should begin with 101. So, In my test plan I need to first fetch the number of existing customers using Select query and then execute actual Insert query which is to be stress tested. So, I have added following to my test plan.

  1. A jdbc request with select query to get number of existing customers.(Only once in whole test plan) and save the number of customers in a variable name.
  2. A Counter element, where start value will be the variable name from first jdbc request and increment it by one.
  3. Actual JDBC request with insert query.

The problem with this approach is I need to execute the First request only once, irrespective of the number of thread count. Alternative approach I tried: I also tried creating two thread groups and passing the number of customer from first thread group to second thread group using Jmeter properties. But the second thread group is not able to access the customer count from first thread group which I have set as Jmeter property. Any help in appreciated.

1

1 Answers

2
votes

Put the request under the If Controller and use the following condition:

${__threadNum} == 1

This way JMeter will execute the sampler only for 1st thread.

If you use more than one loop on Thread Group level you might want to amend the condition to run only in the first loop like:

${__threadNum} == 1 && ${__groovy(vars.getIteration() == 1,)}

References: