4/26/16

Distributed Testing in JMeter

Distributed Testing in JMeter:

Distributed testing is a kind of testing which use multiple systems to perform stress testing. Distributed testing is applied for testing web sites and server applications when they are working with multiple clients simultaneously.Distributes testing uses client-server model as figure below:















Before you start,there are a couple of things to check.

1. the firewalls on the systems are turned off.
2. all the clients are on the same subnet.
3. the server is in the same subnet, if 192.x.x.x or 10.x.x.x ip addresses are used. If the server
doesn't use 192 or 10 ip address, there shouldn't be any problems.
4. Make sure JMeter can access the server.
5. Make sure you use the same version of JMeter on all the systems. Mixing versions may not work
correctly.



Master: the system running JMeter GUI, control each slave.

Slave: the system running jmeter-server, receive command from the master and send a request to server under test.Target: the web server under test, get request from slaves.
System configuration:
On the slave systems, go to jmeter/bin directory and execute file "jmeter-server.bat".
On the master systems, go to /bin directory and edit file jmeter.properites, add IP slave machine as below




Run the test:
On the master machine, run JMeter GUI and open the test plan.Click Run on the menu bar; select Remote start -> select the IP address of slave machine


JMeter in Non GUI mode

How to run JMeter in Non GUI mode:


Running JMeter using command line in non-GUI mode is very simple.
1. Open your *.jmx file
2. Remove all graphic data writers
3. In the non-gui mode they will not work, and it is no need to keep them in testing scenario.
4. Open command prompt
5. Go into JMeter’s bin folder

6. Enter following command, jmeter -n –t test.jmx -l test_results.jtl









-n: It specifies JMeter is to run in non-gui mode
-t: Name of JMX file that contains the Test Plan
-l: Name of JTL(JMeter text logs) file to log results
-j: Name of JMeter run log file.

Other than these options, JMeter has several other parameters that can be used for running in the non-GUI mode.
-R: list of remote servers,
-H: proxy server hostname or ip address
-P: proxy server port.

View test result:
Once your test is complete, you will see the following display:
















After completing the test, a JTL file will be generated at jmeter2.12/bin folder
Follow below steps to view test results from the resultant JTL file.
Open JMeter in GUI mode.
Add any listener Eg. View Results Tree.
Click Browse button of the file name field in listener.
Open testresult.jtl file.
You should be able to see the result in listener now.


4/20/16

Jmeter

About Jmeter
               
                The Apache JmeterTM is pure Java open source software, which was first developed by Stefano Mazzocchi of the Apache Software Foundation, designed to load test functional behavior and measure performance. You can use JMeter to analyze and measure the performance of web application or variety of services. Performance testing means testing a web application against heavy load, multiple and concurrent user traffic. JMeter originally is used for testing Web Application or FTP application. Nowadays, it is used for functional test, database server test etc.

Steps to Install JMeter

Step 1) Install Java

JMeter is pure Java desktop application, it requires a fully compliant JVM 6 or higher. You can download and install the latest version of Java SE Development Kit
Step 2) Download Jmeter
Download latest version of JMeter

Step 3) Installation

Installation of JMeter is extremely easy and simple. You simply unzip the zip/tar file into the directory where you want JMeter to be installed. There is no tedious installation screen to deal with! Simple unzip and you are done!
How to Open JMeter.

After downloading JMeter, go to the bin directory. In this case, it is/home/manisha/apache-jmeter-2.9/bin and click on jmeter.bat.






  













Test Plan is where you add elements required for your JMeter 
The WorkBench simply provides a place to store test elements temporarily. WorkBench has no relation with Test Plan. JMeter will not save the contents of the WorkBench. It only saves the contents of the Test Plan branch    

4/16/16

TRY-SCRIPT:-

We can Try-Script…by clicking the green colored    “Start button” in toolbar.

View Results Tree MUST NOT BE USED during load test as it consumes a lot of resources (memory and CPU). Use it only for either functional testing or during Test Plan debugging and Validation.

Post-Recording and Try script

Post-Recording and Try script
After-Recording:-
Remember to do Four things….
1. Click on test plan and save the script with new name.
2. For Try Script you need to add View Result Tree.
Add (Thread Group) -> Listener -> View Result Tree
3. Add Cookie Manager and Cache Manager
Add (Thread Group) -> Config Element -> HTTP Cache Manager
Add (Thread Group) -> Config Element -> HTTP Cookie Manager
Do required setting in cookie and cache manager.
4. To comment by right click on the request and disable.
5. Customization (Add CSV file.)
Right click on thread group click ->Add -> Config Element -> CSV Data set Config
1. Create Data file at Bin folder of JMeter (Eg. Login.csv).
2. Make the setting as shown in below fig

















3.Change Variable name as follow:

























6.Parsing (Add regular expression extractor).
To check parsing you can use RegExp Tester in View Result Tree.



























7. Right click on request Add -> Post Processors -> Regular Expression Extractor














The special characters above are:
( and ) - these enclose the portion of the match string to be returned
. - match any character
+ - one or more times
? - don't be greedy, i.e. stop when first match succeeds

8.Adding Verification Point (Assertion)
Right click on request Add -> Assertion -> Response Assertion






















Adding ThinkTime:
Right click on Transaction controller  Add (Transaction controller) -> Sampler-> Test Action.

Recording

Click on start button in ‘HTTP(S) test script recorder’ and manually open the browser.
For every new page add new transaction counter and change ‘Target Controller’ menu in HTTP(S) test recorder to timer name (transaction counter name).

After Recording is completed press stop button in ‘HTTP(S) test script recorder’.

Adding Element in jmeter

Change “Test Plan” to Name of the project.






















Add Thread Group (Scenarios) : ADD -> Threads (Users) ->Thread Group

Change name to name of the script. Here you can set No of iterations and No of threads (here threads means Users).






















Add Transaction Counter: Add(Thread Group) -> Logic Controller -> Transaction Controller
Change Name to name of the Timer (A101_HomePage).























Add HTTP(S) Recorder: Add(Work Bench) -> Non Test Elements -> HTTP(S) Test Script Recorder.
1. Change port to 8080
2. Change Target Controller to Name of the Timer. (Change target controller for every page). 
3. Change Grouping to ‘Put each group in a new transaction controller.

NOW make the browser proxy setting as follows.
Address: ‘localhost’ Port: ‘8080’





Element of test plan

Thread Group
Thread Group elements are the beginning points of your test plan. As the name suggests, the thread group elements control the number of threads JMeter will use during the test. We can also control the following via the Thread Group −
Setting the number of threads
Setting the ramp-up time
Setting the number of test iterations
The Thread Group Control Panel looks like this −

The Thread Group Panel holds the following components −
1. Action to be taken after a Sampler error − In case any error occurs during test execution, you may let the test either −
o Continue to the next element in the test
o Stop Thread to stop the current Thread.
o Stop Test completely, in case you want to inspect the error before it continues running.

2. Number of Threads − Simulates the number of users or connections to your server application.
3. Ramp-Up Period Defines how long it will take JMeter to get all threads running.
4. Loop Count − Defines the number of times to execute the test.
5. Scheduler checkbox − Once selected, the Scheduler Configuration section appears at the bottom of the control panel.
6. Scheduler Configuration − You can configure the start and end time of running the test. 


Samplers
Samplers allow JMeter to send specific types of requests to a server. They simulate a user request for a page from the target server. For example, you can add a HTTP Request sampler if you need to perform a POST, GET, or DELETE on a HTTP service.

Logical Controller
Logic Controllers let you control the order of processing of Samplers in a Thread. Logic controllers can change the order of a request coming from any of their child elements. Some examples are – For Each Controller, While Controller, Loop Controller, IF Controller, Run Time Controller, Interleave Controller, Throughput Controller, and Run Once Controller.
Listeners
Listeners let you view the results of Samplers in the form of tables, graphs, trees, or simple text in some log files. They provide visual access to the data gathered by JMeter about the test cases as a Sampler component of JMeter is executed.
Listeners can be added anywhere in the test, including directly under the test plan. They will collect data only from elements at or below their level.
Timers
By default, a JMeter thread sends requests without pausing between each sampler. This may not be what you want. You can add a timer element which allows you to define a period to wait between each request.
Assertions
Assertions allow you to include some validation test on the response of your request made using a Sampler. Using assertions you can prove that your application is returning the correct data. JMeter highlights when an assertion fails.
Configuration Elements
Configuration Elements allow you to create defaults and variables to be used by Samplers. They are used to add or modify requests made by Samplers.
They are executed at the start of the scope of which they are part, before any Samplers that are located in the same scope. Therefore, a Configuration Element is accessed only from inside the branch where it is placed.
Pre-processor Elements
A pre-processor element is something that runs just before a sampler executes. They are often used to modify the settings of a Sample Request just before it runs, or to update variables that are not extracted from response text.
Post-processor Elements
A post-processor executes after a sampler finishes its execution. This element is most often used to process the response data, for example, to retrieve a particular value for later use.