Software testing

36
Presented by Mr. Nilesh R. JAISWAR

Transcript of Software testing

Page 1: Software testing

Presented by Mr. Nilesh R. JAISWAR

Page 2: Software testing

INDEX Introduction. How do we do it ? How we make parameters dynamic, reacting to the

unique server responses of each test run? How do we use external data files to define variables in

my Test scripts? Does JMeter process dynamic pages JMeter keeps getting "Out of Memory" errors. JMeter Distributed Testing Step-by-step JMeter proxy Step-by-step Configure your browser to use the JMeter HTTP Proxy Conclusion References

Page 3: Software testing

INTRODUCTION JMeter is an Apache Jakarta project that can be used as a load testing tool

for analyzing and measuring the performance of a variety of services, with a

focus on web applications. Apache JMeter is a 100% pure Java desktop application designed to load test client/server software (such as a web application ). It may be used to test performance both on static and dynamic resources such as static files, Java Servlets, CGI scripts, Java objects, databases , FTP servers , and more. JMeter can be used to simulate a heavy load on a server, network or object to test its strength or to analyze overall performance under different load types.

Stefano Mazzocchi of the Apache Software Foundation was the original developer of JMeter. He wrote it primarily to test the performance of Apache JServ (a project that has since been replaced by the Apache Tomcat project). We redesigned JMeter to enhance the GUI and to add functional-testing capabilities.

Page 4: Software testing

Why to use JMeter ? JMeter can be used as a unit test tool for JDBC database connection, FTP, LDAP, WebServices,J MS, HTTP and generic TCP connections. JMeter can also be configured as a monitor, although this is typically considered an ad-hoc solution in lieu of advanced monitoring solutions.

JMeter is not a browser. JMeter is not a browser. As far as web-services and remote services are

concerned, JMeter looks like a browser (or rather, multiple browsers); however JMeter does not perform all the actions supported by browsers. In particular, JMeter does not execute the Javascript found in HTML pages. Nor does it render the HTML pages as a browser does .

FeaturesFull multithreading framework allows concurrent sampling by many threads and simultaneous sampling of different functions by separate thread groups.

Careful GUI design allows faster operation and more precise timings.

Caching and offline analysis/replaying of test results.

Page 5: Software testing

How do we do JMeter Localisation ?

Page 6: Software testing

Building JMeter and Add-Ons

Page 7: Software testing

How we make parameters dynamic, reacting to the unique server responses of each test run?

we can use the Regular Expression Post Processor to extract a value from a response, and then reuse this response in another request. Looking at the previous question in this FAQ, you could extract the product id from the result and use it in the following request:

 

1. Load Test Plan created in previous FAQ question.

2. Add Post Processor > Regular Expression Extractor to thread Group with following values:

1. Reference Name: product

2. Regular Expression: product_id=(\w*-\w*-\w*)

3. Template: $1$

4. Match No.: 0 (Setting this parameter to 0 returns a random match)

 

3. Copy the HTTP Request we created in the previous question and paste to the thread group after the previous HTTP Request.

4. Change the following values:

1. Path: /estore/control/product

2. Add Parameter and set name to product_id, value to ${product}

 

5. Save Test Plan

6. Run > Start

 

When you view the results in the View Results Tree, you can see the ${product} value was replaced with the value extracted by the regular expression.

Page 8: Software testing

How do we use external data files to define variables in my Test scripts?

1. The CSV Data Set Config element is the best way to do this, as it can create multiple variables from a single data file. Or Start JMeter,

  2. Add a Thread Group to the Test Plan1. set the appropriate number of threads and iterations. 

3. Add Pre Processors > User Parameters to Thread Group. 

4. Click Add Variable

1. Set Update once per iteration

2. Set the Name to the name of the variable (e.g. ACCOUNTID)

3. Set the value (under User_1) to ${_StringFromFile(accounts.dat)}

 

5. Add Sampler > HTTP Request to Thread Group:

 

6. Click the Add button to add a parameter to the request:

1. Name: account_id

2. Value: ${ACCOUNTID}

7. Add Listener > View Results Tree to Thread Group. 

8. Save.

  9. create the file accounts.dat containing one line per account id. If it is not in the bin directory, then modify the StringFromFile parameter accordingly, 

10. Run > Start

Page 9: Software testing

Does JMeter process dynamic pages

  No,

JMeter does not process Javascript or applets embedded in HTML pages.

 

JMeter can download the relevant resources (some embedded resources are downloaded automatically if the correct options are set), but it does not process the HTML and execute any Javascript functions.

 

If the page uses Javascript to build up a URL or submit a form, you can use the Proxy Recording facility to create the necessary sampler. If this is not possible, then manual inspection of the code may be needed to determine what the Javascript is doing.

 

If there are several nodes running the JMeter test plan, it is a good idea to try and ensure that their clocks are synchronised, as this makes it easier to analyze the data later.

Page 10: Software testing

JMeter keeps getting "Out of Memory" errors. This is usually caused by including memory intensive listeners in your stress test. Listeners like "View Tree Results" are useful for debugging your test, but they are too memory intensive to remain in your test when you ramp up the number of simulated users and iterations. The best listeners to use for a long-term, high-load test are Aggregate Listener, Graph Listener, and Spline Listener.

 

In addition, you can instruct the JVM to use more memory by editing the jmeter/jmeter.bat files for linux/windows. Within these files, find a section that sets values for the Heap:

 

set HEAP=-Xms256m -Xmx256m

 

Feel free to change these values. Xms indicates the starting RAM the jvm will take, and Xmx will be the maximum it is allowed (for the HEAP).

Page 11: Software testing

JMeter Distributed Testing Step-by-step

This explains how to use multiple systems to perform stress testing. Before we 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.

Once you've made sure the systems are ready, it's time to setup remote testing. The tutorial assumes you already have JMeter installed on all the systems. The way JMeter works is 1 master controller initiates the test on multiple slave systems.

Page 12: Software testing

1. TerminologyBefore we dive into the step-by-step instructions, it's a good idea to define the

terms and make sure the definition is clear.Master – the system running JMeter GUI, which controls the test.Slave – the system running JMeter-server, which takes commands from the GUI and send requests to the target system(s).Target – the web server we plan to stress test.

Page 13: Software testing
Page 14: Software testing

Step by step

1. On the slave systems, go to jmeter/bin directory and execute jmeter-server.bat (jmeter-server on unix). On windows, you should see a dos window appear with “jre\[version]\bin\rmiregistry.exe”. If this doesn't happen, it means either the environment settings are not right, or there are multiple JRE installed on the system. Note: [version] would be the jre version installed on the system.1. Open jmeter-server.bat in a text editor2. go to line 44 and find “:setCP”3. edit “START rmiregistry” to the full path. Example: “START C:\<JAVA_HOME>\jre\bin\rmiregistry”2. On master system acting as the console, open windows explorer and go to jmeter/bin directory3. open jmeter.properties in a text editor4. edit the line “remote_hosts=127.0.0.1”5. add the IP address. For example, if I have jmeter server running on 192.168.0.10, 11, 12, 13, and 14, the entry would like like this:remote_hosts=192.168.0.10,192.168.0.11,192.168.0.12,192.168.0.13,192.168.0.14 6. Start jmeter.7. Open the test plan you want to use

Page 15: Software testing

Starting the TestAt this point, you are ready to start load testing. If you want to double check the slave systems are working, open jmeter.log in notepad. You should see the following in the log.Jmeter.engine.RemoteJMeterEngineImpl: Starting backing engineIf you do not see this message, it means JMeter-server did not start correctly. For tips on debugging the issue, go to the tips section. There are two ways to initiate the test: a single system and all systems.

Page 16: Software testing

1. click Run at the top2. select Remote start3. select the IP address

Page 17: Software testing

1. click Run at the top.2. select Remote start all or use CRTL-Z.

Page 18: Software testing

Limitations:There are some basic limitations for distributed testing. Here's the list of the known items in no specific order.1. RMI cannot communicate across subnets without a proxy; therefore neither can jmeter without a proxy.2. Since JMeter sends all the test results to the controlling console, it is easy to saturate the network IO. It is a good idea to use the simple data writer to save the results and view the file later with one of the graph listeners.3. Unless the server is a large multi processor system, in most cases 1-2 clients is sufficient to overwhelm the server.4. A single JMeter client running on a 2-3Ghz CPU (recent cpu) can handle 300-600 threads depending on the type of test. (The exception is the webservices). XML processing is CPU intensive and will rapidly consume all the CPU cycles. As a general rule, the performance of XML centric applications will perform 4-10 slower than applications using binary protocols.

TipsIn some cases, the firewall may still be blocking RMI traffic.Symantec Anti Virus and Firewall,In some cases, Symantec firewall needs to be stopped from windows services.1. open control panel2. open administrative tools3. double click services4. Go to down to symantec anti virus, right click and select stopWindows firewall1. open network connections2. select the network connection3. right click and select properties4. select advanced tab5. uncheck internet connection firewall

LinuxOn Suse linux, ipchains is turned on by default. For instructions, please refer to the “remote testing” in the user manual.On RedHat (or derivatives), iptables (netfilter) is turned on by default. Execute “service iptables stop” to stop the Linux netfilter firewall.

Page 19: Software testing

JMeter proxy Step-by-step8.1 Basic Proxy Instructions

1. Go to JMETER_HOME/bin and start JMeter with jmeterw.cmd on Windows and jmeter on Linux/Unix

2. Select “Test Plan” on the tree

3. Right click on the “Test Plan” and add a new thread group: Add > Threads (Users) > Thread Group

Page 20: Software testing

4. Select the Thread Group 5. Right click “Add -> Config Element -> Http Request Defaults”

6. In new HTTP Request Defaults element: Server name – enter “jmeter.apache.org”7. Path leave Blank.

Page 21: Software testing

6. In new HTTP Request Defaults element: Server name – enter “jmeter.apache.org”7. Path leave Blank.

 8. Right click on the “Thread Group” and add a recording controller: Add > Logic Controller > Recording Controller  

Page 22: Software testing

9. Next, select WorkBench10. Right click on WorkBench and add the Http proxy: Add -> Non-test elements -> HttpProxy Server  

Page 23: Software testing

11. On HTTP Proxy Server, click the “Add” button in “URL Patterns to Include”. This will create a blank entry.12. Enter “.*\.html”13. Click 3 times, the “Add” button in “URL Patterns to Exclude”. This will create 3 blank entries. 14. Enter “.*\.png” pattern, “.*\.gif” pattern and “.*\.ico” pattern

Page 24: Software testing

15. Right click on “HTTP Proxy Server” and add a listener: Add -> Listener -> View Results Tree.

Page 25: Software testing

Return to HTTP Proxy Server, and click the “Start” button at the bottom.

Page 26: Software testing

Configure your browser to use the JMeter HTTP ProxyAt this point, JMeter's proxy is running. For this exercise, we will use

Iceweasel/Firefox to view some pages on JMeter.

13. Start Iceweasel/Firefox, but do not close Jmeter.

14. From the tool bar, click “Edit -> Preferences” (or “Tools > Preferences”). This should bring up the options.

15. Select the “Advanced” tab, and “Network” tab

16. Click “Settings” button near the

bottom.

Page 27: Software testing

17. On the new popup, check “Manual proxy configuration”. The address and port fields should be enabled now.18. Address – enter “localhost” or the IP address of your system19. Port – enter “8080”.20. Check “Use this proxy server for all protocols”.

Page 28: Software testing

21. Click “ok” button22. Click “ok” button again. This should return you to the browser9.1 Record your navigation23. With your brower, in the “Address” bar at the top, enter“http://jmeter.apache.org/index.html” and hit the “enter” key.24. Click on a few links on JMeter's pages.25. Close your browser and bring up the JMeter window.Expand the thread group and there should be several samplers. At this point, the test plan can be saved as is. If you forget to add default http request settings, you will have to manually delete the servername, and port.

Page 29: Software testing

In this sample, there aren't any default request parameters. If a particular request parameter is required by all pages, the request defaults is where one would add the entries.25. Select “Thread Group”26. Right click “Add -> Listener -> Summary Report” to add an summary listener.

Page 30: Software testing

27. The summary listener will show some basic statistics

Page 31: Software testing

27. Select “Thread Group”28. Number of Threads – enter “5”29. Ramp up Period – do not change30. Loop Count – enter 100

Page 32: Software testing

9.2 Start the testAt this point, we are ready to run our test plan and see what happens. Save the test plan. When you're ready to run the test, there's two ways:1. Run -> Start2. Ctrl–RBefore you start the test, select “Summary Report”. As the test runs, the statistics will change until the test is done. At the end of the test, the summary report should look like this

Page 33: Software testing

While the test is running, in the upper right-hand corner, there should be a green square. When the test is done, the box should be grey.

Benefits:

1. Its pure Java tool, which allows to execute this tool in any platform (i.e. platform independent)2. Its have lot many configuration mechanism like Htt Request,FTP Request, java request , SOAP Request3. This tool mainly used for performance testing (load, stress)4. GUI are very user friendly, which helps in executing and recording application sessions5. User can apply automation frame work (data driven, parameter)

Drawbacks:1. It does not support recording SSL (https).2. Its only for web base application not windows base application3. User can't write its own script, or change any recorded script

Page 34: Software testing

CONCLUSION

Page 35: Software testing

REFERENCES

http://wiki.apache.org/jmeter/JMeterFAQ#How_to_do_remote_testing_the_.27proper_way.27.3F

http://jmeter.apache.org/usermanual/remote-test.html

http://ipoint-tech.com/

http://en.wikipedia.org/wiki/jmeter

 

Reference Books :

Software testing tools by v.k.k.k. dauling

Page 36: Software testing