24
Oracle Database Oracle Database Testing Testing using using Apache JMeter Apache JMeter

23648950 JMeter Oracle Database Testing

Embed Size (px)

Citation preview

Page 1: 23648950 JMeter Oracle Database Testing

Oracle Database TestingOracle Database Testing using using

Apache JMeterApache JMeter

Page 2: 23648950 JMeter Oracle Database Testing

IndexIndex About - Apache JmeterAbout - Apache Jmeter FeaturesFeatures BenefitsBenefits Downloading JmeterDownloading Jmeter JMeter Components JMeter Components Preparing Test PlanPreparing Test Plan

• Thread Group ControlThread Group Control• JDBC Connection Configuration controlJDBC Connection Configuration control• JDBC Request ControlJDBC Request Control• View Result Tree ControlView Result Tree Control

ParameterizationParameterization• User Parameter ControlUser Parameter Control• CSV Data Set ConfigCSV Data Set Config

Stored Procedure ExecutionStored Procedure Execution Log FileLog File Measuring Response Time & ThroughputMeasuring Response Time & Throughput

Page 3: 23648950 JMeter Oracle Database Testing

About Apache JMeterAbout Apache JMeter Apache JMeter Apache JMeter is open source software, a 100% pure Java desktop is open source software, a 100% pure Java desktop

application designed to load test functional behavior and measure application designed to load test functional behavior and measure performance. It was originally designed for testing Web Applications performance. It was originally designed for testing Web Applications but has since expanded to other test functions.but has since expanded to other test functions.

Apache JMeter may be used to test performance both on static and Apache JMeter may be used to test performance both on static and dynamic resources (files, Servlets, Perl scripts, Java Objects, Data dynamic resources (files, Servlets, Perl scripts, Java Objects, Data Bases and Queries, FTP Servers and more). It can be used to Bases and Queries, FTP Servers and more). It can be used to simulate a heavy load on a server, network or object to test its simulate a heavy load on a server, network or object to test its strength or to analyze overall performance under different load strength or to analyze overall performance under different load types. You can use it to make a graphical analysis of performance types. You can use it to make a graphical analysis of performance or to test your server/script/object behavior under heavy concurrent or to test your server/script/object behavior under heavy concurrent load.load.

Page 4: 23648950 JMeter Oracle Database Testing

FeaturesFeatures Can load and performance test many different server types: Can load and performance test many different server types:

• Web - HTTP, HTTPS Web - HTTP, HTTPS • SOAP SOAP • Database via JDBC Database via JDBC • LDAP LDAP • JMS JMS • Mail - POP3(S) and IMAP(S) Mail - POP3(S) and IMAP(S)

Complete portability and Complete portability and 100% Java purity100% Java purity. . Full Full multithreading multithreading framework allows concurrent sampling by many threads and framework allows concurrent sampling by many threads and

simultaneous sampling of different functions by separate thread groups. simultaneous sampling of different functions by separate thread groups. Careful Careful GUI GUI design allows faster operation and more precise timings. design allows faster operation and more precise timings. Caching and offline analysis/replaying of test results. Caching and offline analysis/replaying of test results. Highly Extensible: Highly Extensible:

• Pluggable Samplers allow unlimited testing capabilities. Pluggable Samplers allow unlimited testing capabilities. • Several load statistics may be chosen with Several load statistics may be chosen with pluggable timers pluggable timers . . • Data analysis and Data analysis and visualization plugins visualization plugins allow great extendibility as well as allow great extendibility as well as

personalization. personalization. • Functions can be used to provide dynamic input to a test or provide data Functions can be used to provide dynamic input to a test or provide data

manipulation. manipulation. • Scriptable Samplers (BeanShell is fully supported; and there is a sampler Scriptable Samplers (BeanShell is fully supported; and there is a sampler

which supports BSF-compatible languages) which supports BSF-compatible languages)

Page 5: 23648950 JMeter Oracle Database Testing

BenefitsBenefits

Allows to perform load testing of sql queries, stored procedure, Allows to perform load testing of sql queries, stored procedure, triggers and functions at different volume sizes.triggers and functions at different volume sizes.

Helps in data validation of sql queries, stored procedures.Helps in data validation of sql queries, stored procedures.

Helps in graphical monitoring and analysis of response time & Helps in graphical monitoring and analysis of response time & throughput of the database objects under heavy concurrent load.throughput of the database objects under heavy concurrent load.

Allows saving the results obtained in a file for analysis.Allows saving the results obtained in a file for analysis.

Page 6: 23648950 JMeter Oracle Database Testing

Download & Running JMeterDownload & Running JMeter Download the JMeter version 2.3.4 from the following url:Download the JMeter version 2.3.4 from the following url:

• http://http://jakarta.apache.org/site/downloads/downloads_jmeter.cgijakarta.apache.org/site/downloads/downloads_jmeter.cgi Run the Run the jmeter.batjmeter.bat file from the JMeter installation directory. file from the JMeter installation directory.

Page 7: 23648950 JMeter Oracle Database Testing

JMeter ComponentsJMeter ComponentsGroupGroup PurposePurpose

SamplersSamplers The requests to the servers are being sent by these elements for the The requests to the servers are being sent by these elements for the request types SOAP, JDBC, "Java", HTTP/HTTPS, FTP.request types SOAP, JDBC, "Java", HTTP/HTTPS, FTP.

ListenersListeners The results of the run can be saved by these elements in the single The results of the run can be saved by these elements in the single request, tabular forms etc by saving the results in a named file.request, tabular forms etc by saving the results in a named file.

TimersTimers To make the test more realistic we use Timers element to insert delays To make the test more realistic we use Timers element to insert delays between the requests. between the requests. 

LogicLogic Logic controllers are used if you have defined the request to be executed Logic controllers are used if you have defined the request to be executed on some logic like if-then-else and loop structures in Java etc.on some logic like if-then-else and loop structures in Java etc.

Configuration Configuration ElementsElements

Common information about the requests is added to work with samplers Common information about the requests is added to work with samplers using this element.  using this element.  

AssertionsAssertions This element is used to check whether you are getting the responses This element is used to check whether you are getting the responses within a given amount of time containing the expected data or not.within a given amount of time containing the expected data or not.

Page 8: 23648950 JMeter Oracle Database Testing

Thread Group allows to run script with nThread Group allows to run script with nthth no. of users with defined no. of users with defined ramp-up period and also the scheduling of execution.ramp-up period and also the scheduling of execution.

Right click on the Test Plan and add the Thread Group control.Right click on the Test Plan and add the Thread Group control.

Preparing Test PlanPreparing Test PlanThread Group ControlThread Group Control

Thread Properties: Allows to set the no. of

users, ramp-up time and iterations

Page 9: 23648950 JMeter Oracle Database Testing

Used to configure the database i.e. Oracle, MS SQL Server etc.Used to configure the database i.e. Oracle, MS SQL Server etc. Add Add JDBC Connection ConfigurationJDBC Connection Configuration control to the control to the Test PlanTest Plan..

Database Connection ConfigurationDatabase Connection Configuration

• Database URL:Database URL: jdbc:oracle:thin:@localhost:IP:service (e.g. jdbc:oracle:thin:@localhost:IP:service (e.g. IP: IP: 15211521, , Service: oracleService: oracle))

• JDBC Driver Class: JDBC Driver Class: oracle.jdbc.driver.OracleDriveroracle.jdbc.driver.OracleDriver• Username:Username: Username of the database (e.g. Username of the database (e.g. Username: scottUsername: scott))• Password:Password: Password of the user (e.g. Password of the user (e.g. Password: tigerPassword: tiger))

Important:Important:• Add the following Jars in Add the following Jars in JMeter Installation directory JMeter Installation directory (D:\jakarta-(D:\jakarta-

jmeter-2.3.1\lib)jmeter-2.3.1\lib)

classes12.jar classes12.jar && ojdbc14.jar ojdbc14.jar

• These files are available inThese files are available in Oracle installation directory Oracle installation directory (C:\(C:\oracle\ora92\jdbc\lib\)oracle\ora92\jdbc\lib\)

JDBC Connection Configuration controlJDBC Connection Configuration control

Page 10: 23648950 JMeter Oracle Database Testing

JDBC Request control allows to run a SQL query, procedure etc.JDBC Request control allows to run a SQL query, procedure etc. Add the Add the JDBC RequestJDBC Request control below the Thread Group. control below the Thread Group.

JDBC Request ControlJDBC Request Control

Query: type SQL Queries and stored procedure

Page 11: 23648950 JMeter Oracle Database Testing

View Result Tree controlView Result Tree control View Result Tree control is used to view the result of the query View Result Tree control is used to view the result of the query

executed. executed. Add Add View Result TreeView Result Tree control to the control to the Test Plan.Test Plan.

Green: Request passed

Red: Request failed

Sampler Result: shows the load time, response

code etc..

Page 12: 23648950 JMeter Oracle Database Testing

View Result Tree controlView Result Tree control

Request: shows the request

Page 13: 23648950 JMeter Oracle Database Testing

View Result Tree controlView Result Tree control

Response data: shows the

output

Page 14: 23648950 JMeter Oracle Database Testing

ParameterizationParameterization

User Parameters control allows the script to be run with multiple User Parameters control allows the script to be run with multiple values like username, password, department no. etc. We can add values like username, password, department no. etc. We can add variables and also provide values of the variable to multiple users.variables and also provide values of the variable to multiple users.

1.1. Add the User Parameters control to the Thread Group.Add the User Parameters control to the Thread Group.

User Parameters ControlUser Parameters Control

Name: variable name

User_1: value of User_1

User_2: value of User_2

Page 15: 23648950 JMeter Oracle Database Testing

2.2. Pass the variable to the query or procedure.Pass the variable to the query or procedure.

Syntax:Syntax:

${variable_name} (e.g. ${Dept_No})${variable_name} (e.g. ${Dept_No})

Sample Query:Sample Query:

update dept set loc=‘India' where deptno=${Dept_No}update dept set loc=‘India' where deptno=${Dept_No}

ParameterizationParameterizationUser Parameters ControlUser Parameters Control

$: used to fetch the variable value

Page 16: 23648950 JMeter Oracle Database Testing

ParameterizationParameterization

Allows parameterization using a file.Allows parameterization using a file. Add the CSV Data Set Config control to the Thread Group.Add the CSV Data Set Config control to the Thread Group.

CSV Data Set Config ControlCSV Data Set Config Control

Page 17: 23648950 JMeter Oracle Database Testing

Execution of Stored ProcedureExecution of Stored Procedure

Add the Add the JDBC RequestJDBC Request control to the control to the Thread Group.Thread Group.• Procedure must exist in database.Procedure must exist in database.

Type the following command in Type the following command in SQL Query SQL Query text box of the JDBC Request text box of the JDBC Request controlcontrol

beginbegin

{call update_DEPT_PKG.update_DEPT(10)};{call update_DEPT_PKG.update_DEPT(10)};

end;end;

• Stored Procedure must be written inside the Stored Procedure must be written inside the begin…endbegin…end block. block. • CallCall keyword is used to call the stored procedure. keyword is used to call the stored procedure.

begin{…};end; block: PL/SQL statement should be enclosed within

block

This example takes the department no as input

and doesn’t return anything

Page 18: 23648950 JMeter Oracle Database Testing

View Result Tree controlView Result Tree control

Response Message: Ok – if request passed else error message will

be returned

Page 19: 23648950 JMeter Oracle Database Testing

Viewing SProc returning valueViewing SProc returning value

Choose Choose Callable StatementCallable Statement from Query Type combo box. from Query Type combo box. Type the following command in SQL Query parameter of the JDBC Type the following command in SQL Query parameter of the JDBC

Request controlRequest control

declaredeclare

deptname varchar2(20);deptname varchar2(20);

beginbegin

{call update_DEPT_PKG1.update_DEPT1(${Dept_No},?)};{call update_DEPT_PKG1.update_DEPT1(${Dept_No},?)};

end;end;

Write Write ${deptname}${deptname} in Parameter values text field. in Parameter values text field. Write Write OUT VARCHAROUT VARCHAR in Parameter types text field. in Parameter types text field.

declare: used to declare variable(s)

${Dept_No}: IN variable – passing

department no. to the SProc

?: store the OUT variable in variable $

{deptname} to verify the output

This example takes the department no as input and

return department name which we store in deptname

variable

Page 20: 23648950 JMeter Oracle Database Testing

Viewing SProc returning valueViewing SProc returning value

Callable Statement: choose in case of PL/SQL

request

Page 21: 23648950 JMeter Oracle Database Testing

Viewing SProc returning valueViewing SProc returning value

ACCOUNTING: output returned by

SProc

Page 22: 23648950 JMeter Oracle Database Testing

Log fileLog file Create a file_name.jtl file to save log and provide the .jtl file path in Create a file_name.jtl file to save log and provide the .jtl file path in File File

NameName text box in any of the Listener (View Results Tree). text box in any of the Listener (View Results Tree). Click on the configure button and choose the following checkbox:Click on the configure button and choose the following checkbox:

• Save Response Data (XML)Save Response Data (XML) Returns the output dataReturns the output data

• Save Sampler Data (XML)Save Sampler Data (XML) Returns the executed sql queryReturns the executed sql query

• Save Response message (XML)Save Response message (XML) Returns the error message (if returned) Returns the error message (if returned)

Page 23: 23648950 JMeter Oracle Database Testing

Measure Response Time & ThroughputMeasure Response Time & ThroughputStatistical Aggregate ReportStatistical Aggregate Report

Page 24: 23648950 JMeter Oracle Database Testing

Thanks!!!Thanks!!!