Showing posts with label JMeter. Show all posts
Showing posts with label JMeter. Show all posts

Thursday, 21 July 2016

Performance Testing on Smart phone


We often hear performance testing in our software testing field. This was very confusing to me, but now it is a very interesting subject to me. Performance testing does not mean to find any bugs or issue at all instead of it checks software program's
  • Speed - Determines whether the application responds quickly
  • Scalability - Determines maximum user load the software application can handle.
  • Stability - Determines if the application is stable under varying loads


In today’s tech world the technology is improving day by day, as a result, most of us are using high performing smartphone that is capable of doing nearly everything that a computer can do. So here I’m going to discuss how to do performance testing of a mobile based application.
Mostly two types of mobile based application can be seen
  • Client-Server App - An application  that communicates with server
  • Stand Alone App - An application that doesn’t communicate with server
The performance of client-server app depends on the following parameter:
  • CPU usage
  • Memory usage
  • Power consumption / Battery usage
  • Server performance
And for Stand alone based app’s performance also depends on the same parameter except the server performance. Now today’s high-tech world, availability of CPU & Memory of any mobile is huge so we wouldn’t worry about that two parameters. So our main focus will be power consumption & Server performance. Now let’s see how to do that:


Power consumption / Battery usage: First check whether the targeted app is showing under battery usage section or not. If yes, then it is OK otherwise use GSam Battery Monitor like app to monitor your targeted app’s battery consumption. Now reset the battery usage and switch off the phone and charge it fully. Now use it as you normally use your mobile until you need recharge your mobile and check your targeted app’s battery consumption. Repeat this two or three times and you will get your answer.


Server Performance: To check server performance we need to create some virtual users that will simulate the request as if someone using the app and for that we need to know the request format / type. What kind of request is getting generated by app can be known only by recording that request and it can be easily done JMeter recording. Following are the steps to configure it:
  • Open a Test plan & Add a Thread group
  • Right click on the “Thread Group” and add a recording controller: Add -> Logic Controller -> Recording Controller
  • Next, select WorkBench and right click on it and add the recorder: Add -> Non-Test Elements -> HTTP(S) Test Script Recorder
  • Configure HTTP(S) Test Script Recorder: Under Test plan content select the Target Controller as Test Plan -> Thread Group -> Recording Controller
  • Click on Start Button on HTTP(S) Test Script Recorder page. That will generate a Root CA Certificate in your JMeter’s bin folder.
  • Now install this certificate to your targeted devices and configure it’s proxy server to your system’s IP address. Configuration step to mobile:
    • Send certificate to mobile and touch it, will be installed automatically
    • Go to device’s settings -> go to WIFI section -> modify the WIFI(either by long pressing to that WIFI or from menu option) -> checked the advance settings -> select proxy settings to MANUAL -> set host / IP address to your system’s IP address (for example: 192.168.0.212) -> Set your port 8080 (Can be changed from Global settings -> Port field in JMeter script recorder page) -> Save it.
Note: Your system and you mobile device should be into same LAN otherwise it will not work
  • Now open the targeted App in your mobile, JMeter will record your activity. You can check it live.
After recording is over filter it smartly and run it. Now add listener to your script to analyze the server performance in terms of throughput (Request processed by server) Response time.

Any comments, suggestions will be appreciated. Feel free to contact anytime. Thank you for your patience.


Sunday, 19 June 2016

JMeter Overview


JMeter is an open source load / performance testing tool. It generates virtual user in the form of thread and hit the target server and record the response accordingly. Depending upon the recorded response we concluded the server performance in the form of response time, throughput etc. I'm trying to give an overview from the scratch:
  1. Download latest version JMeter according to your O/S from JMeter official site. http://jmeter.apache.org/download_jmeter.cgi
  2. Unzip it & go to go to bin directory.
  3. For windows open jmeter.bat file, for Linux open jmeter.sh file either from CUI or GUI.
  4. Now either record the script by using http(s) script recorder & proxy server or write the script manually
    • Scrip record by using http(s) script recorder & proxy server
      1. Open Test Plan & Add a Thread Group
      2. Right click on the Thread Group and add a recording controller: Add > Logic Controller > Recording Controller
      3. Next, select WorkBench and right click on it and add the recorder: Add -> Non-Test Elements -> HTTP(S) Test Script Recorder
      4. Configure HTTP(S) Test Script Recorder: Under Test plan content select the Target Controller as Test Plan > Thread Group > Recording Controller
      5. Click on Start Button on HTTP(S) Test Script Recorder page. That will generate a Root CA Certificate in your JMeter’s bin directory.
      6. Import this Root CA Certificate to required browser and also set browser’s proxy server to localhost with port 8080 ( Can be changed from Global settings -> Port field in script recorder page )
      7. Now open the browser and navigate it. JMeter will record accordingly. You should filter it smartly to run it further.
    • Manually script writing
      1. Open Test Plan and Add Thread Group under test plan. Here number of thread represent the total number of virtual user. Here ramps-up time represent the total time in which all the virtual user will hit the server. For example, thread group: 1000 & ramps-up: 100 i.e all 1000 user will hit the server within 100 seconds. Loop count represent how many times this thread group will continue.
      2. Add Sampler -> HTTP Request under thread group. If we use any URL repeatedly then we can add Config Element -> HTTP Request Defaults with base URL.
      3. We can use HTTP Cookie Manager / HTTP Cache Manager / HTTP Authentication Manager from Config Element option to maintain cookie / cache / authentication respectively.
    • Add listener accordingly
      1. View Results Tree : Capture all request & Response in details
      2. View Results in Table: capture some specific info and shows in tabular form.
      3. Summary Report: Shows an overall summary report.
      4. Graph Generator : install it using JMeter plugin ( Click Here ) and Configure it to use.
  5. Run the script either from graphically or by using command.
    • Initially run script graphically for single user to check script and then run script for load test according to required number of user. At the of running the script you may have face memory related issue and to avoid such issue & faster execution, you should set up Distributed Environment Link Here ) and also run it using command.
  6. Analyze the result from listener & make full report.