Stress testing stored procedures through Jmeter

1. Stored procedure preparation:

1. Create an empty table:

1

CREATE TABLE test_data ( id NUMBER, name VARCHAR2(50), age NUMBER );

2. Create a stored procedure:

CREATE OR REPLACE PROCEDURE insert_test_data

(n IN NUMBER) AS

BEGIN

  --EXECUTE IMMEDIATE 'truncate table test_data';

  FOR i IN 1..n LOOP

    INSERT INTO test_data VALUES (i, 'Name' || i, i * 10);

  END LOOP;

COMMIT;

END insert_test_data;

3. Debugging:

1

select count(*) from test_data t; call insert_test_data(1000); truncate table test_data;

2. Test tool preparation:
1. Found on the Internet: mysql-connector-java-8.0.29.jar (version is not limited), and put it in the Jmeter directory \lib\ext.

2. Find it online or put it locally: ojdbc14.jar in the Jmeter directory\lib.

3. Tool configuration and execution:
The global configuration is as shown below:

1, Place JDBC Connection Configuration:

Right-click and add a node under Config Element. The configuration is as shown:

a. The name can be changed at will, and it will take effect after saving.

b. Variable Name for created pool, choose any one, but it needs to be consistent with the configuration of the subsequent steps. It is recommended to call it oracle.

c. The large section in the middle is temporarily defaulted, and Validation Query can choose one at will.

d. Database URL: jdbc:oracle:thin:@{ip}/{oracle service name}, where {ip} is the database server ip, {oracle service name} is the Service_Name in TNS, similar to orcl

e. Username and password to connect to the database

2. Configure the throughput controller (can be skipped):

As shown in the figure, it accounts for 20% of the throughput. In the example, SP accounts for 20% and SQL accounts for 80%. Simulate the actual scenario of 80% query and 20% write.

3. Configure JDBC Request:

Right click, find JDBC Request in Sampler, and add it.

For stored procedures:

a. Variable Name of Pool...: The configuration is consistent with the JDBC Connection Configuration, here it is configured as: oracle

b. Query Type: For stored procedures, select Callable Statement

c. Query: As shown in the picture, write the stored procedure call according to the format in the picture. The parameters are represented by ?, and multiple parameters are separated by commas.

d. Para Values, parameter values, multiple separated by commas

e. Para types, data type of parameters

f. Variable names, return value column name

g. HandleResutleSet:Store as String will do

For SQL statements:

Select Select Statement for Query Type and write the SQL statement directly in Query. Be careful not to write ";" at the end of the statement

4. Other configurations such as query result tree, aggregation report, TPS, PerfMon monitoring, etc. are the same as the basic Jmeter configuration.

The following are supporting learning materials. For those who are doing [software testing], it should be the most comprehensive and complete preparation warehouse. This warehouse has also accompanied me through the most difficult journey. I hope it can also help you!

 

Guess you like

Origin blog.csdn.net/qq_73332379/article/details/133352980