2012-11-13

Testing Web Service(SOAP/XML-RPC) using JMete

 
In this article, we are going to see a very simple web service testing procedure using JMeter.
Scenario : We are going to test a web service where the service provide us data . To be specific, the service link is http://www.webservicex.net/periodictable.asmx, the Data action link http://www.webservicex.net/periodictable.asmx?op=GetAtoms. The functionality of the service is to provide atom names in tabular format. As we are testing the data service, we can not see the HTML table, but if we can get the data, that will solve the purpose of Testing data service. 
So, if we follow those steps, we can see a very simple test for web services.

Step 1. Run JMeter(jmeter.bat) from stored location “apache-jmeter-2.8\bin”

Step 2. Create a Thread Group( right click test plan –>Add –> Thread Group) and rename as SOAPThread(I am using this name).

Step 3 : Put Number of Threads(User) as 20( I am using ) and Ramp-Up Period as 2( I am using)

Step 4. Save the Thread Group. 

Step 5 . Add a Sampler “SOAP/XML-RPC Request” under your thread group
 

Step 6. Add "http://www.webservicex.net/periodictable.asmx" as the URL and "http://www.webserviceX.NET/GetAtoms" as the Send SoapAction
 

Step 7 . Add This following request as “SOAP/XML-RPC Data”(link or Drive)
 

So, there might be a question , where I get the this XML code. It’s simple, from the service link (http://www.webservicex.net/periodictable.asmx) , you will get the GetAtoms function. 
 
If you click GetAtoms , then you will get the function definition of different  XML format(http://www.webservicex.net/periodictable.asmx?op=GetAtoms). I use SOAP 1.1 format
 

Step 8. Add Listener to your thread group(I have added view result tree, view result in table)
 

Step 9 . Now, Run the Thread Group from Menu. 
Its done. We have make and run the service test using jmeter, lets observe the results.
Here is the Request of a sample under tree listener.
 

This is the response data( the tabular format atom names) [Note : we don’t need to check the format as we are not checking the font end. If the data is present, that is ok.
 
Here is table results.
 
I am inspired by this post.….. Thanks …. :)

We can do the same test using WebService(SOAP) Request which is another type of sampler. I am adding the screenshot in Google drive. This is more smarter than SOAP/XML-RPC Request. But, a little bit slower.

2012-10-30

Stress Testing in JMeter

In this following article we are going to see how to perform stress testing on a sample website(www.kaz.com.bd).
Before going inside of it, we should have basic idea on what is stress testing ? Stress testing is a form of testing that is used to determine the stability of a given system or entity[wiki]. Stress testing determines the data handle capability of a site
Before starting, we should know the basic working process with JMeter. If we go through the article step by step, it would be very easy for us to understand the basic work process of JMeter.
Step 1. : Start JMeter by clicking “jmeter.bat” from “apache-jmeter-2.8\bin” and you will see this
image
Step 2 : From here, you will see Test Plan. Our full test procedure will be under Test plan(as sub section).
JMeter allows for many different types of requests like as HTTP Requests, FTP Requests, WebService Requests, SOAP Requests and many others. In here we will see an example of HTTP Testing. When we have the basic idea we will try others in a same fashion.
Step 3 : Adding Thread Group :
A Thread Group will define is the number of users you want to use for stress testing. Or we can say, if you open www.kaz.com.bd as one user in pc browser, this Thread Group will do the same , the only difference is, you can define how many users you want to hit the target URL within a time span .
Now, right click on test plan and keep mouse on Threads(Users) and we will get Thread group, setUp thread group, tearDown thread group.
image
Select Thread Group and you will see the UI
image
Provide name as “KazTest”, comments as “Demo Stress Testing”. Please look at the options carefully, I have used 50 threads(means 50 users) in Ramp-up period 5 seconds(after each 5 second , 50 user will hit the URL). I use Loop Count as forever, meaning, I want to continue the test all times. If you provide any value in the in the Loop Count text box, this test will be continued up to that time.(i.e. 5 times). I will use Loop Count as 5. If you select the scheduler then the 4 text box will come to take the inputs. though I have selected to show, but I will not use that. So, my settings screenshot will be
image
Now, save the thread group in the PC to a suitable location.
Step 4 : HTTP Request Defaults : What is HTTP Request Defaults ? This is nothing but a configuration set of default http request settings which will be perform under our thread group.
For this,  Add HTTP Request Defaults (under Config Element)to our KazTest.
image
After adding, provide this URL(www.kaz.com.bd) as Server Name or IP(out test site) . 
We have left other options blank, but when we need we can configure Port, Protocol, Content encoding, Implementations image , Timeout etc.There is also options to send any URL parameters with request(key-value pairs).
Step 5: Loop Controller : We will add a Loop Controller under Logic Controller. What is a Loop Controller? A Loop Controller simply runs all its child elements one by one in order up to the number that we configure. There is also Random Controller which does pretty much the same thing but does not do them in the specified order.
image
image Now that We have the Loop Controller in.
Step 6: Http Requests : We will add Http Requests for each of my page inside of that loop controller. This is because, the loop controller will hit the pages of my site.(In here, JMeter will execute as per the settings of the Loop Controller and the Thread Group) .In our URL(www.kaz.com.bd), we have 4 pages, Home, Talents, Culture, Contact. Lets add a Http Requests for Home page.
image
Right click on Loop controller->Add->Sampler->HTTP Request. When we add one , we will get similar page as “HTTP Request Defaults” with some extra Http request option. We will name every request as out page, select Redirect Automatically instead of follow redirects and put comments(optional). We will use Get method. Please look at the path section where you see that we have inserted only sub URL part of the full path this is because the base URL will be taken from initial setting at HTTP Request Defaults.
 image
So my Http Request pages are Home,
image
Talents,
image
Culture,
image
and Contact.
image
So, Up to this we have completed the stress test arrangements using Http Request. Now, we need way of looking at the test results.
Viewing results :
For viewing data , we need to add some ‘Listeners’ to our Thread group. There are a few Listeners JMeter and all of them capture exactly the same data. The only difference is how they work with the data. Each Listener has its own purpose and analyses the data differently. To add a ‘Listeners’ right click on thread name(KazTest) –> Listener –> ‘Summary Report’. This will add ‘Summary Report” listener in the thread group. Like the same we will add total 4 Listeners to KazTest [‘View Results in Table’, ‘View Results Tree’, ‘Summary Report’ and ‘Graph Results’]. The process of adding these to our Test Plan are the same. We can add more listeners based on our needs. To read more about listeners see this.
image
Now, We are ready for testing. To run your test, click on the Run Menu and then Start. Once we run the Test, we can see the data in the Listeners [I am providing some sample screenshots]
image
image
image
image
image

Some Extra Listeners …
image
image
image
So, that’s it. It is a very simple example using 4 requests. I have added only few listeners, you can add according to your need. We will learn details on those customization later on. I wrote this from the inspiration of this site.
Thanks…:)