JMeter: How to benchmark data deletion from database table in batches? - jmeter

I am trying to compare the performance difference between DELETE batch sizes using JMeter.
I have a table which I populate with a large amount of test data. Next, I have a JDBC Request that runs the following statement:
delete from tbl where (entry_dt < '2019-02-01') and (rownum <= 10000);
I want to keep running this until the table is empty, and record the time taken to clear the table.
I will run this thread multiple times to get an average execution time, and repeat this process for different batch sizes.
How should I define my While Controller to achieve this?
I read from other sites that I can use a Transaction Controller to time my process, but I am not familiar with this feature. How should I define my Transaction Controller to achieve this?

Add Transaction Controller to be a top level test element under the Thread Group
Add While Controller as a child of the Transaction Controller and use the following condition expression:
${__jexl3(${count_1} > 0,)}
Put your JDBC Request sampler as a child of the While Controller
Add JDBC PostProcessor as a child of the JDBC Request sampler and configure it like:
That's it, While Controller will iterate until there are entries in the tbl table and the Transaction Controller will record the cumulative time of all JDBC Request samplers executed.

I would do it this way:
Use the "JDBC Request - Get Count" sampler to get the data from the db which has to be deleted
Use a BeanShell Assertion to check if there is more data that can be deleted. Otherwise stop the thread
Execute the request to delete the data
Thread Group should stop Test on error

Related

Jmeter-JDBC request wait till have result

I am trying to run the performance script which has API which takes the payload as file from S3 and submit to target system. After the request is completed I need to login to db and verify the status of the transaction. Here there is delay in getting inserted to db which is fast for payload with small file size. As I started submitting large files 1 GB to 15 GB, there will be delay in inserting a table.
So the JDBC request which has modified_date will be null for large payload. I have used constant timer but not sure how long it takes to insert in table.
Is there any way I can make jdbc request to wait till i get result for modified_date for message table.
You can put your JDBC Request sampler under the While Controller and use i.e. following jexl3() function as the condition:
${__jexl3("${modified_date}" == "null",)}
Once done you can use the Constant Timer for introducing the reasonable delay, i.e. run the JDBC Request each second or several seconds until the result is there.
More information: Using the While Controller in JMeter

Jmeter test database read performance

I am going to test database read performance with Jmeter Java Sampler.
Basically, query database 10000 times with primary key as query condition like ID with Thread group and Java Sampler.
I need to load 10000 records into database before executing the Thread Group.
The 10000 records will be looped for the 10000 times database read.
I have looked into the preprocessor of Jmeter. I can insert 10000 records into database in preprocessor, but I do not know how to pass the 10000 IDs to Thread Group or Java Sampler. It is too long to contact IDs as a String parameter.
How I can archive the purpose? Any comment is welcome.
Instead of inserting the data using PreProcessor I would rather recommend preparing the test data in setUp Thread Group. You can write the generated IDs into a file using i.e. Flexible File Writer and then read them back with the CSV Data Set Config
If the database you're testing supports JDBC protocol it makes more sense to use JDBC Request sampler because JDBC Connection Configuration allows using connection pool pattern which most probably your application will be using when talking to the database, the main idea is to set up JMeter to produce the same footprint as the application which will be accessing the database.

How to pass a unique id stored in database to HTTP request in JMeter

In my JMeter script, When I save equipment detail using HTTP REQUEST then a unique auto incremented id(Suppose 123) store in database. Then in same script when I am adding Incentive on previously saved equipment then in it's HTTP REQUEST that unique ID(123) is passing. Since that ID is fetching from database so I am unable to get that.
Initially I was thinking to use a COUNTER and start it from a high number which is not stored in database but it didn't work because it requires same ID which generated at the time of savings the equipment.
I created my JMeter script using HTTP(S) TEST SCRIPT RECORDER.
To connect to database you need JDBC Connection Configuration and to define database connection properly, Then you need to add JDBC Element as JDBC PreProcessor (or Sampler), and add your select of this id, Query Type: Select Statement, Query will be for example select sequnceName.NEXTVAL from dual in oracle DB, you can put sequence result in a Result variable name,for example mySequence and use it later in JSR 223 element:
columnValue = vars.getObject("mySequence").get(0).get("NEXTVAL");
So you can extract the ID generated in the "Equipment Detail" Request/Response and save it in an external .csv file using JSR223 Post processor and use the .csv file for "Incentive" request.
This way you can eliminate database calls and your scripts run only for HTTP Requests with less turnaround time.

Why all columns in Aggregate Report shows identical same values?

Configured a Test Plan where I have checked the option 'Generate parent sample' in Transaction Controller, in order to get the stats of individual transactions. And ran the test on Non-GUI mode, but I get identical same values in all columns of Aggregate Report, such as; Average, Median, 90% Line, Min, Max, etc.
Is it because of the configuration I did in Transaction Controller or any other settings need to be configured in the jmeter.properties file?
Thanks
It is absolutely expected assuming that your Transaction Controller ran once hence only one result is recorded. You will see the same output for any other singe sampler.
If you add more iterations on Thread Group level or via Loop Controller you should see differences.
Check out Using JMeter's Transaction Controller guide to learn more about Transaction Controller use cases.

How to create database connection in Http Request Sampler in Jmeter

I am new to JMeter. I want to make MySQL connection to database so I can calculate the time that took to upload an audio and it is inserted in the database. I am trying to upload audio to my API and when the audio uploads then it go for background processing and then it is inserted in database. I am doing load testing when I hit this API it returns success when it go for background processing. But I want to calculate time taken by when I upload audio and it is inserted in database. How can I do it?
I would do it as follows:
Transaction Controller - to measure time of all nested samplers
HTTP Request to upload file
While Controller to loop until postprocessing is finished
JDBC Request - to check your mysql database
When the upload completes, insert a record for the given content with current time. Then Pass this new record's ID to the background job so when processing is finished it can update the same record and insert current time again. Here you go, compare the 2 times...

Resources