2. Setting up and recording a test
--------------------------
Overview:
A Test Plan is a group of Thread Groups which all run concurrently.
A Thread Group is a set of config elements and series of HTTP Requests (known as Samplers) for a user or group of users to execute in order. If there are several users in the group, each of them can be thought of as a Thread, and in fact each will run in its own java thread. I typically break Thread Groups down into groups of users of a specific type exercising a specific part of the application. For example: Inst users that each do 1 request or Partner users that visit several screens and exercise DWR functions (sort/filter lists) or Admin users that each run 3 reports.
In our setup, a Thread Group typically has a CSV Data Set Config, a Cookie Manager, a Uniform Random Timer, and the HTTP Requests.
Setting up a Test Plan:
- right click on your Test Plan, Add -> Config Element -> CSV Data Set Config
- Name: Hostname Config
- Filename: ../data/input/HOSTNAME.csv
- Variable Names: HOSTNAME
- Delimiter: a plain comma char
- Recycle on EOF?: I usually set this to true and use the Thread Group's Number of Threads and Loop Count to control how the test runs
- Stop thread on EOF?: again, I usually use the Thread Group to control this
- right click on your Test Plan, Add -> Listener -> Graph Results
- Filename: ../data/output/out_graph_results.csv
- on the Graph Results screen, click Configure
- uncheck any box with (XML)
- check: save field names, save active thread counts, save assertion failure message
Setting up a Thread Group in JMeter (we'll use my Inst User (IU) group 01 as an example):
- right click on your Test Plan, Add -> Thread Group
- give it a descriptive name and description in comments field
- Number of Threads: If you have 10 users in your input .csv, this # can be up to 10.
- Rampup: If it's a heavy duty test (20+ min), not bad to make it ramp for a couple minutes.
- Loop Count: Only tricky thing here is if you have 10 users in your .csv and you enter 3 in the Number of Threads and 2 in Loop count, users 1-6 in your .csv will each run the HTTP Requests 1 time. Another thing is, in this scenario for example, it will try to keep 3 threads alive, meaning if threads 1 and 2 finish and thread 3 is slow, threads 4 and 5 will kick off and run while 3 is also running.
- right click on your Thread Group, Add -> Config Element -> HTTP Cookie Manager
- done with cookie manager
- right click on your Thread Group, Add -> Config Element -> CSV Data Set Config
- Filename: something like "../data/input/IU_01.csv"
- Variable Names: a comma separated list of your var names such as IU_01_USER,IU_01_PASS
- Delimiter: a plain comma character
- right click on your Thread Group, Add -> Timer -> Uniform Random Timer
- I'm not positive this is the best way to do this, but I believe it is: Let's say you're running a report. When you record the test and you're actually going through the process of logging in, running the report, logging out, let's say it takes you 3 minutes. Now when you run the test, it will run the requests back-to-back, making it take 20 seconds or so. Play with the Timer's Random Delay Maximum field and try to find a number that makes the test take about 3 minutes so that it simulates a real user. Mine are typically between 1500-2500ms
- save your Test Plan in the data folder (jakarta-jmeter-2.5.1/data) and give it a descriptive name, not for the Thread Group but for the whole Test Plan!
Set up HTTP Proxy (for recording) in JMeter:
- right click Workbench -> Add -> Non-test Elements -> HTTP Proxy Server
- if you have a specific Thread Group that you want to save the recording to, choose it in the Target Controller dropdown
- check Attempt HTTPS Spoofing
- under URL Patterns to Exclude, click Add
- double-click the text area just created, enter .*google.* and press enter (don't want requests to google fouling up our response time metrics!)
- save the test plan
Record from Firefox (IE is similar):
- start Firefox
- go to Tools -> Options
- click Advanced at the top
- click the Network tab
- under Connections click Settings
- click the Manual Proxy Config radio button
- in HTTP Proxy enter localhost, port 8080
- check "Use this proxy server for all protocols"
- clear out the "No proxy for" text area
- click ok a few times
- if you want to simulate a user who has not been to the site before (has no JS cached), go to Tools -> Clear Recent History and clear it out
- in the browser address bar now instead of using https... you'll use http... when entering the app URL
- in JMeter, click Start at the bottom of the HTTP Proxy Server config screen
- log in, run a report, do whatever it is you want to record, log out
- in JMeter, click Stop at the bottom of the HTTP Proxy Server config screen
- undo the Proxy settings in Firefox if you're done
- save the Test Plan
No comments:
Post a Comment