JMeter Notes 7

Source: Internet
Author: User
Tags http 2

One, script recording (Jmeter): Jmeter script (. jmx) is in XML format, tree structure, composed of components, using "sampler" to generate the request. Add "HTTP Proxy Server" port to "Workbench": Proxy server port, default 8080, can modify itself, but do not apply port conflict with it destination controller: the location where the recorded script is stored, the selectable items are grouped into the thread groups in the test plan: groups the requests. The concept of "grouping" is to group a batch of request summaries and to interpret the URL request as a group. "Do not group samples": All requests are listed as "Add separation between groups": Add a Virtual split-line named action, run the same as "no sample grouping", no practical meaning "each group into a new controller": Execute when the controller gives the output "only the first sample of each group": for a single URL Request, the actual number of HTTP requests, this option is very useful, because we often do not care about the subsequent requests. Log HTTP header: Record Request's head information Add assertion: Empty checkpoint added when recording regex matching: Adding empty regular matches when recording starts the HTTP proxy server after recording in the browser, open the browser (Ie,firefox,opera, etc.) , add agent, address to fill in the local IP or host name, port to fill the proxy port just set, in the browser for normal web browsing, you can record the corresponding operation.
Second, the script recording (Badboy): Use JMeter Proxy server can record the complete HTTP request, including the request header, but cannot record the cookies, for the website script, most need the cookie support, can use the Badboy to record. Badboy is designed by a software company in Australia and has a free version available for download. Of course, you can add your own cookiesbadboy using: Download the installation package, one-click installation, Start > Programs > Badboy Click the Red Record button to start recording, enter the URL, as in the browser operation. The script bar on the left shows the recorded request. When the recording is complete, "file" > "Export to Jmeter", save the Jmeter script jmx file, and open the script with Jmeter to see the more complete request.
Third, parameterization: Method One: Use the function Assistant to add a function to read a string from a file. The function Assistant is paged out through the menu "options" à "Function Assistant dialog box". Select "__stringfromfile" to fill in the file path; You can fill in the name to use the function elsewhere. Click Generate. The function assistant retains the last generated function information. Copy the string, paste it where it needs to be called, such as a named ${named} that is filled in with the function when called elsewhere, such as ${keywords}: Method Two: Use the "CSV data set Config" component to add "config component" à "CSV data set in the script" Config "Filename and Variable Names are defined in the same way as the" __stringfromfile "function, and can be used after completion. Called when using Variable Names named ${to fill in the Variable Names}, such as ${keywords}:
Iv. using associated parameters: Add "Post Processor" > "Regular Expression Extractor" to the HTTP request: The reference name is the parameter name used, fill in the regular expression, the template selects the matching group, the matching number is the number of matches, the negative numbers are all matches, and the default value is the value without matching to. The example uses a regular expression to match the product ID as a parameter for subsequent use. Extracted parameters, called with ${product_id_1},${product_id_2},${product_id_3} ... If you want to get the number of matching parameters, use ${PRODUCT_ID_MATCHNR}; If you want to randomly select one of them, simply set the match number to 0 and use the ${product_id} call. You can match multiple groups at once, only one in the example, if the regular expression is Name= "Chkproductids" id= "chk (. +?)" Value= "(. +?)", there will be two sets of parameters. Want to get the number of matching groups with ${product_id_g}. The template is for the matching string to make a distinction between groups, for example, want ${product_id} to take out the value of the second set of parameters, with $2$.
Add checkpoints: Add "assert" à "response assertion" in the script to check with regular expressions, you can select regular pattern matching rules, and check the text fields.
Set the think time: Add "Timer" to "fixed timer" in the script to set the delay time.
Set the collection point: Add "Timer" à "Synchronizing timer" in the script to set the number of concurrent users at the collection point, that is, "how many" users reach the collection point and then execute.
Viii. use of cookies: when you visit a page that requires cookies, add "Configuration Components" > "HTTP Cookies Manager" to the script, important: The cookie Manager component needs to be located on the previous node of the request that requires the use of cookies. In the example, a transaction controller is added and the node under the task controller uses the same cookie manager
Nine, Simulation browser operation: HTTP Cache Manager is generally not recommended, because in LR we generally do not let the page cache, to avoid the cache caused by insufficient pressure, the result is too optimistic. HTTP request "Get all included resources from HTML file" If the item is checked, the external link to the HTML file is also stressful, and the response service must be within the system under test, i.e. the service is also one of the systems under pressure. It is generally not checked when the service environment is not available. Embedded URLs must match this is used to match the resource links in the HTML, regular expressions, only match matching will go to request such as regular expression http://www\.baidu\.com/.*, meaning only HTTP// Www.baidu.com RELATED LINKS will not be requested.
Ten, the controller implements the script logic: If controller: The child node of the execution controller when the condition conforms example: Determine whether ${is_run}=1 is established, if set up to execute HTTP request; check box "Evaluate for Allchildren?" Indicates whether to use the judging criteria for all child nodes, and not to select them, only for the first child node to take effect. No else judgment can be achieved by non-conditional. Random controller: Random Execution of a child node the sample has four sub-nodes under the Random controller: HTTP 1, HTTP 2, simple controller, HTTP 3, two sub-nodes under the simple controller: HTTP 3, HTTP 4, and when the checkbox "Ignore controller block" is unchecked, A simple controller is a node that participates in random execution with other random controller sub-nodes, and the sub-nodes under the simple controller participate in random execution with other random controller sub-nodes directly. Random order controller: child nodes are all executed, but in a random order. Loop controller: Sets the number of times the controller child node is executed, or it can be set to execute forever.
  12, Sample script (EXAMPLES.JMX) content: 1. HTTPS script: HTTPS GET request 2. Icbulogin script: HTTPS POST request, Cookie Manager, head manager, assertion (checkpoint) 3. ICBUWWW1 Script: Parameterized unique method, correlation parameter (get the number of parameters to determine whether to execute the request, randomly select a parameter) 4. ICBUWWW2 script: Parameterized sequential mode, correlation parameter (get the number of parameters to determine whether to execute the request, fixed selection parameters) 5. Collection Point script: Meeting point (Sync timer) 6. Logic control: Only once controller (INIT), switch (choose different request according to different vuser), random controller (randomly select a request execution), random order controller,  13, set scene set test plan: test plan is a complete scene " Run each thread group independently ": tick all thread groups to be executed sequentially. Generally unchecked, let all thread groups be started concurrently. "Function test Mode": After checking, there will be detailed request record, consume resources and affect client performance. Generally not checked. User-defined variables: Global variables Add a thread group: the action to be performed after the sampler error: Continue, stop the thread, stop the number of test threads: You can understand the number of concurrent users that the script runs under the current thread group. Rampupperiod (in seconds): The number of threads that start running is increased from 0 to the set value within "Set time". Number of cycles: the number of times the script runs under the current thread group; "Forever" option, infinite cycle start time: script auto-start time End time: script auto-end time duration (seconds): duration of continuous running period start delay (seconds): Start thread Group parameter analysis after the specified time is delayed: 1. Action performed after the sampler error: "Stop thread" runs for stopping the current thread; "Stop test" runs to stop the test plan. 2. Rampupperiod represents the time to increase from 0 to the specified number of threads, which is a linear increase, such as: 20 threads, rampupperiod of 50s,50/20=2.5s/, so every 2.5s increments a thread. 3. Number of cycles: tick "Forever", after the start must be manually "stop" to stop, the number of times when the scheduler is not running, the scheduler is invalid, stop execution, the scheduler is finished running, the number of times has not been reached, the number of times set invalid, stop execution. 4. Scheduler: After manual start, set the effective principle: the priority of the start delay is higher than the start time, the duration priority is higher than the end time, the setting is valid for "future Time", which is not valid for "past time", that is, the startup delay and startup time are setConsistent, the start delay is the same, and the duration and end time are set at the same time if they are inconsistent, the duration is the same, and setting to the past is not effective. Thread Run status display: In the upper right corner of the jmeter. The meaning of the diagram is: Green indicates running, total 20 threads, 8 started.
14, Response Data Graphics results: Add "monitor" à "graphical results" Display content meaning: sample number: The number of samples received by the runtime the latest sample: The response time of the most recent sampler result: The average deviation of the response time for all sampler results: standard deviation of response time for all sampler results: Median value of sampler results per minute: Median of response time for all sampler results display line To change the curve over time, but the x-axis is not the time axis, is the uniform distribution of the number of samplers axis view result tree: Add "monitor" à "see results tree" display content meaning: Sampler results: The sampler related parameters (client parameters and Response Parameters) Request: HTTP Requests Response data: HTTP Response Data Aggregation report: Adding "monitor" à "aggregation report" Display content meaning: Label: Sampler Name Samples: The number of sampler response results obtained at runtime average: Average response time for all sampler results median: Median response time for all sampler results 90%line: Response time for all sampler results 90% Line min: Minimum response time for all sampler results max: The average response time for all sampler results error%: The error sampler result accounted for the ratio of all sampler results throughput: Number of sampler results per second kb/ SEC: Data traffic per minute response Summary report: Add "monitor" à "Summary report" Display content meaning: Label: Sampler Name Samples: The number of sampler response results obtained at runtime min: Minimum response time for all sampler results max: The average response time for all sampler results is std.dev.: Standard deviation of response time for all sampler results error% : The result of the error sampler results in proportion to all sampler results throughput: Number of sampler results per second KB/SEC: Data traffic per minute response avg.bytes: All samplers return HTTP response data The average number of bytes saves the response to a file for statistics: After adding a monitor to a single sampler, enter the save file for the response record in the input box under "All data is written to a file," or browse for a selection; You can use the full path or relative path to save the path for the script. When multiple samplers use a single monitor, the resulting statistical results are summed up.
On the server resource Monitoring (Linux) Linux Server, join the monitoring script: Log on to the monitored server and put the status script up. When the script executes, it generates the Status.xml file on the path where it is located, either by placing the status script directly under the directory of the Web server or by chaining to the Status.xml file with a soft link. The following describes the configuration method on the Apache-based Web server: DocumentRoot is found in the Apache configuration file httpd.conf, typically htdocs in the Apache directory, where the status script is placed; Line permissions: chmod 744 status starts the script:./status start starts up and then stops the script when it is generated in the current directory Status.xml file is not required to be monitored:. Use monitoring on/status stopjmeter: Using Open JMeter, set up a thread group, add an HTTP request, IP is the server address to monitor, the port number is Apache listening HTTP port, the protocol is "HTTP", the path is "/status.xml", tick "use as monitor"; The HTTP request adds a "fixed timer" component and a "monitor result" component, and the delay of the "fixed timer" is set to a time greater than 1 seconds, which is the sampling time of the data. Set the number of cycles in the thread set tick "forever"; Run, you can see the monitoring server just added on the monitor results, currently monitoring 6 parameters: cpu%user,cpu%iowait,load,mem% (used/total), swap in, Swap out. Save the monitored resources to a file for statistics: Method with "Save response to file for statistics:"
  16, statistical analysis will record the response and resource monitoring of the file to generate an HTML chart report for analysis (note: The record file format is XML, if incomplete is unresolved; that is, the files generated in the script run cannot be resolved and must be processed after the script has finished running) The method of generation is as follows: Set JMeter saved file address open the Jmeterdatachart.ini file under the bin directory of the JMeter directory, follow the format: response= response file Path resources= monitor resource file path to fill in. For example, there are 2 response files res/r1.jtl,res/r2.jtl,1 A monitoring resource file res/linux.jtl, fill in the file content is: response=res/r1.jtlresponse=res/r2.jtlresources= RES/LINUX.JTL Save exit. Double-click the Jmeterdatachart.bat in the Run Bin directory to parse the file and generate the chart. After the resolution processing succeeds, in the bin directory will generate a named curdatachartindex.html, double-click Open, you can see the corresponding chart link, is the original filename + res.html file Click Link Open report, IE prompt script risk click Allow, You can see the complete chart: Response Chart: Resource Monitoring chart: note: Because the chart is written in VML, it cannot be displayed on browsers that do not support VML. The Appendix Monitor implements the resource monitoring on the Linux system, requiring that at least one Web server on the server (because of the need to get the resource XML through HTTP requests), the script used in the build server resource XML uses the instructions in the Sysstat package, so you need to install Sysstat Package. If the Sysstat package is not installed on the monitored Linux, it is not possible to generate the monitoring data properly, the installation method of Sysstat package is attached here: first to  http://perso.wanadoo.fr/sebastien.godard/   Download the latest version, preferably a source package, such as SYSSTAT5.1.1.TAR.GZ1. Unpacking: Tar zxvf sysstat5.1.1.tar.gz2. Installation: CD Sysstat5.1.1make config This step can be omitted, There will be errors in some distributions, and if you do not use this command, you can install it directly into its default/usr/local/lib directory.

JMeter Notes 7

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.