Posts

Showing posts from 2015

Database Test Plan with JMeter

Image
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 Connection JDBC Connection Configuration Thread Group JDBC Request under Thread Group BeanShell 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:por...

Using a Custom Jar in BeanShell Sampler in Jmeter

Image
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 NetBeans Create a Jar of the above project Import the Jar to JMeter location Use the Java method in Jmeter BeanShell sampler Run 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 Fact.java is as below: package  FactClass; public   class  Fact {  ...

How to use a value between two different threads in Jmeter

Image
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: log.info("Request Id in Thread 1 = " + "${Request_Id}"); log.info("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}")}; ...

Tuning JDBC Data Sources Connection Pool in WebLogic

Image
Tuning JDBC Data Sources Connection Pool in WebLogic: While we are Load testing Web services with our application deployed on WebLogic Server Version: 10.3.6.0 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> <server.com> <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> <server.com> <clust1> <[ACTIVE] ExecuteThread: '82' for queue: 'weblogic.kernel.Default (self-tuning)'> <guest> <> <> <1439904774589> <BEA-000000> <ERROR wf - WfSubscriberSysJMSB...

Running Load Test in Jmeter for Webservices

Image
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 LoopCo...

WebServices LoadTesting Using Jmeter - Part 2

Image
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 Sam...

WebServices LoadTesting Using Jmeter

Image
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 ...