Skip to main content


Showing posts from 2015

Database Test Plan with JMeter

Let us see how we can test the database in Jmeter using JDBC Request Sampler. In this tutorial we will use oracle jdbc driver. Required jar E.g. “ojdbc6.jar” is placed in <JMETER_Path>/lib. Prepare a Test Plan as shown below:
Here we have added: User Defined Variables – Defined the required parameters for Database ConnectionJDBC Connection ConfigurationThread GroupJDBC Request under Thread GroupBeanShell Sampler – To display the output of the JDBC Request.View Results Tree – To View the Results JDBC Request Sampler is used to send an JDBC Request to database. But before using this we need to setup the required JDBC connection and it is done via JDBC Connection Configuration element. Under JDBC Connection Configuration we have the below defined values: We defined the Variable Name as “JDBC_Pool”. The values required for Database Connection are defined in User Defined Variables and are used here. E.g: jdbc_url = jdbc:oracle:thin:@DB_Server:port:DB_Instance jdbc_driver = oracle.jdb…

Using a Custom Jar in BeanShell Sampler in Jmeter

Let us see an example on how we can use a custom Java classes and methods in JMeter BeanShell sampler. Outline of the steps: Write Java classes and methods in IDE tools like Eclipse or NetBeansCreate a Jar of the above projectImport the Jar to JMeter locationUse the Java method in Jmeter BeanShell samplerRun the test plan and check results
Let us see the above step by step: For getting the concepts clear, let us create an example class which will generate factorial of a given number. The number will also be a random number. Let us create a class containing the method to calculate a factorial and this will be used in JMeter. I created the method as below in eclipse. Here we have created new project “FactorialJar”. Under the project, we created two projects named as “FactClass” and “TestFact”. Under each class we created a Class called “Fact” and “Facttest”. Code for is as below: package FactClass; publicclass Fact { publicint facto(int f)        { int fact=1; for(int i=1;i<=f;i+…

How to use a value between two different threads in Jmeter

How to use a value between two different threads: Let us see how we can use the extracted value in one thread can be used in a different thread: As shown below we have Two threads (Thread Group – 1 and Thread Group -2). Under Thread Group -1 we have a HTTP Request where we extracted Request_Id and Session_Id. In our example we will use the same Ids in Thread Group -2 We have BeanShell PostProcessor to log the output of the variables in the output log. The Lines in the both BeanShell is as below:"Request Id in Thread 1 = " + "${Request_Id}");"Session Id in Thread 1 = " + "${Session_Id}");
Now if we run the Script we get the below output: As we see the values of both the IDs are not passed to Thread Group-2. Now we will add few lines in the BeanShell PostProcessor as below and run again: ${__setProperty(Request_Id,"${Request_Id}")}; ${__setProperty(Session_Id,"${Session_Id}")};"Request Id in …

Tuning JDBC Data Sources Connection Pool in WebLogic

Tuning JDBC Data Sources Connection Pool in WebLogic: While we are Load testing Web services with our application deployed on WebLogic Server Version: most of transactions started failing and when checked in the logs we found the below exception: ####<28.08.2015 17:32:54 MSK> <Info> <Common> <> <clust1> <[ACTIVE] ExecuteThread: '50' for queue: 'weblogic.kernel.Default (self-tuning)'> <internal> <BEA1-17FBAA30098FE2C54C98> <> <1439904774589> <BEA-000627> <Reached maximum capacity of pool "AppDataSource", making "0" new resource instances instead of "1".> ####<28.08.2015 17:32:54 MSK> <Error> <> <clust1> <[ACTIVE] ExecuteThread: '82' for queue: 'weblogic.kernel.Default (self-tuning)'> <guest> <> <> <1439904774589> <BEA-000000> <ERROR wf - WfSubscriberSysJMSBean.onM…

Running Load Test in Jmeter for Webservices

Once we have completed the scripting for required flows. We need to design a scenario according to the NFRs and execute the test in Jmeter to obtain results for our Load test. Let us see how this can be achieved in Jmeter for the previously webservices with 4 threads to be Load tested. Creation of the Scenario file and defining them in the Thread group: Let us create a Scenario.csv file with below details and save it. sc0=0_DataFolder:1_NumberOfThreads:2_RampUp_sec:3_LoopCount:4_Duration_sec:5_StartUpDelay_sec:6_UserThinkTime_ms:7_Throughput_spm sc1=SC1_1USR:1:30:1:36000:0:1000:2.5 sc2=SC2_5USR:1:30:1:36000:60:1000:1.67 sc3=SC3_1USR:1:30:1:36000:120:1000:1.2 sc4=SC4_5USR:1:30:1:36000:240:1000:5.1 The above file is a csv file which has details of the following: 0_DataFolder : where the xml files and csv files required are kept 1_NumberOfThreads : Defines the number of users. 2_RampUp_sec : value for the Ramp-up Period (in Sec). 3_LoopCount : value for LoopCount 4_Duration_sec : value for Du…

WebServices LoadTesting Using Jmeter - Part 2

In Previous post we mentioned that “In case there is change in the XML we need to modify the SOAP/XML-RPC Request everytime.”
Also, if in case we want to create some different orders with different prefixes then we need to add different threads and in that case if the xml is changed, we need to modify the xml in all the Xmls.
We can overcome such situations by keeping the xml at a location which can be accessed by the thread when ran. Only one xml can be modified for any changes without updating them on each request. Let’s proceed with the steps
The xml is saved at certain location with name as “order.xml”Add a “Once Only Controller” to the Thread Group. Add a BeanShell sampler to the controller.Simple code in BeanShell sampler to read the required xml as below: The above step read the order.xml and stored it in OrderXML. We wrote a function readxmlFile which can be used to read any xml file and store for further modifications. 4. Add another “BeanShell Sampler” to the Thread Group fo…

WebServices LoadTesting Using Jmeter

Before starting Jmeter Webservices testing we need to keep below information handy for : 1. XML/XMLs required for the flow 2. URL where the SOAP/XML-RPC Request
Let us Create a new order using webservice: 1. Create a Test Plan 2. Add a Thread Group 3. Add Sampler -> SOAP/XML-RPC Request as shown below: SOAP/XML-RPC Request sampler sends a SOAP request to a webservice. It can also be used to send XML-RPC over HTTP. 4. Fill the required details in URL and SOAP/XML-RPC Data (XML) in the Request as shown below:
In this XML we have some fields which are unique and need to be changed every time we send the request else it will fail as duplicate record as below: “There is an ongoing Customer Order with the same Customer Order ID”
We will bring uniqueness to the record in 2 ways: 1. Using the Data generated in a CSV file 2. Using a Beanshell sampler and change the Parameters in the xml
Method 1: 1. We will create a CSV file with the required data (may be Manual entry of the required format) and sto…