Preliminary introduction of JMeter Application

Source: Internet
Author: User
Tags to domain

I. Introduction of TOOLS

Apache JMeter is a Java-based stress testing tool developed by the Apache organization. For stress testing of software, it was originally designed for web application testing, but later extended to other test areas. It can be used to test static and dynamic resources, such as static files, Java applets, CGI scripts, Java objects, databases, FTP servers, and so on. JMeter can be used to simulate huge loads on servers, networks, or objects, testing their strength and analyzing overall performance from different pressure classes. In addition, JMeter is able to perform functional/regression testing of the application by creating a script with assertions to verify that your program returns the results you expect. For maximum flexibility, JMeter allows you to create assertions using regular expressions.
Apache JMeter can be used to test the performance of static and dynamic resources (files, Servlet,perl scripts, Java objects, databases and queries, FTP servers, and so on). It can be used to simulate heavy loads on servers, networks, or objects to test their strength or to analyze overall performance under different pressure types. You can use it to do graphical analysis of performance or to test your server/scripts/objects in a large concurrent load.

Two. Download and install

JMeter Official website: http://jmeter.apache.org/

A. Installation Environment requirements:
    • Java version

JMeter requirements fully meet JVM1.3 or higher.

    • Operating system

JMeter can be run on any currently deployed Java operating system.

Unix (SOLARIS,LINUX,ETC)

Windows (98,NT,2000,XP)

Open VMS Alpha 7.3+

B. Installation steps
    • Installation Environment

Mac OS X Lion

    • installation package Preparation

JDK (Requires Java 6 or later) can be downloaded on the official website

apache-jmeter-2.13 Specific:

Http://apache.fayea.com//jmeter/binaries/apache-jmeter-2.13.tgz

    • installation process
1) JDK Installation

Click on the downloaded JDK and select the installation path.

2) JDK Environment configuration
sudo chmod +xw/etc/profilesudo vim/etc/profile#示例export java_home=/library/java/ Javavirtualmachines/jdk1. 8. 0_40.jdk/contents/Home #添加如下内容export java_home=[Your JAVA home]export class_path= $JAVA _home/lib:%java_home/lib/tools.jarexport Ptah= $JAVA _home//etc/profile
3) Check that the JDK installation is OK
Java-version #查看java版本
4) JMeter Installation
Curl-o http://apache.fayea.com//jmeter/binaries/apache-jmeter-2.13.tgz  Tar -xzf apache-jmeter-2.13. tgz

5) JMeter Environment configuration

sudo chmod +x/etc/profilesudo vim/etc/profile#示例export jmeter_home=/users/ snifferhu/software/apache-jmeter-2.13  #添加如下内容export PATH= $JMETER _home/bin: $JMETER _home/lib : $PATH

6) Check JMeter installation is OK

JMeter #如果能显示jmeter操作页面则安装成功

7) jmeter Start parameter adjustment

sudo chmod +xw $JMETER _home/bin/jmetervim $JMETER _home/bin/JMETER #调整如下HEAP="- xms2g-xmx2g"

Initial memory is too small to run often error oom

Three. Introduction to HTTP Interface testing

This article mainly focuses on actual combat, with our company's main application of the HTTP interface as the core explanation.

1. Open JMeter

Introduction to the main interface:

The main interface of JMeter is divided into status bar, menu bar, toolbar, Tree tab bar and content bar.

Status bar: The main version and release version of JMeter are displayed.

Menu bar: All features are included in the menu bar.

Toolbars: The buttons on the toolbar are found in the menu bar, which is the shortcut button for the menu bar's common functions.

Tree tab Bar: The Tree tab bar is typically used to display the label associated with the test case.

Content bar: With the Tree tab bar display, the tree tag click on which tab, the content bar displays the corresponding content and action.

2. Concurrent Request Simulation-----Thread Group

Performance testing is primarily intended to simulate a large number of concurrent requests. JMeter uses a thread group to simulate a scenario that has concurrent access by multiple users.

On the test plan, right-click the Add-->threads (Users) –> thread Group, add the test scene settings component, the interface test is generally set to 1 "threads", according to the number of test data set "number of cycles."

Thread Group Interface Description:

    • Name: You can set a personalized name for the thread group
    • Note: You can add notes to a thread group to mark
    • Actions to be performed after a sampler error: How to execute after an error, optionally continue with subsequent, stop execution, and so on.
    • Number of threads: is how many threads need to be set to perform the test.
    • Ramp-up Period (in Seconds): Used to tell JMeter how long to build all the threads. The default value is 0. If ramp-up period is not specified, that is, ramp-up period is zero, JMeter will establish all threads immediately. Assuming that ramp-up period is set to T-second, the total number of threads is set to N, JMeter will establish a thread every t/n seconds.
    • Number of cycles: determines how many times a thread should run the test.
    • Delay thread creation until needed: delay creation of threads until required
    • Scheduler: Select to configure startup time, immediate or scheduled time
3. test Scenario Environment parameter setting ——— HTTP request Defaults component

This component is useful when the system under test has a unique access to the domain name and port.

Unified configuration data when you change access to domain names and ports

HTTP Request Defaults Component Configuration page

4. Add the HTTP Header Manager component

The request header information often needs to contain tokens, session, type and other information.

5. Set the "HTTP Information Header Manager"

Set the default request header, you can add authorization bypass login authentication;

Set Content-type to specify the requested content type;

Set CharSet to specify the requested character set, etc.;

6, add "HTTP request" sampler in "Thread Group"

7. Set "HTTP request"

In the HTTP Request Settings page, enter the details of the tested interface, including the request path, the corresponding request method, and the list of parameters sent with the request

8. Add Checkpoints: Add "response assertion" on "HTTP request" corresponding to the tested interface

9. set up checkpoints

The existence of a regular expression for the corresponding result is added to the Settings page.

10. Adding listeners

Easy to see the results after running

11. View "Aggregated report"

    • Label: The name of the HTTP request that is defined
    • Samples: Indicates how many requests were made in this test
    • Average: Average response time for access pages
    • Median: Accessing the median response time of a page
    • 90% Line: 90% response time to access the page
    • 95% Line: 95% response time to access the page
    • 99% Line: 99% response time to access the page
    • Min: Minimum response time for access pages
    • Max: Maximum response time for access pages
    • error%: Number of bad requests/total number of requests
    • Throughput: Number of requests completed per second
    • Kb/sec: The amount of data received from the server side per second

About 90% Line:

A group of numbers is arranged from small to large to find his 90th number (if 12), then 90% of the array will be less than or equal to 12.

The response time used in the performance test will also make sense, i.e. 90% request response time will not exceed 12 seconds.

The above steps complete the creation of a simple test case, and the complex test cases are expanded on this basis.

Using the interface test case developed with the JMeter tool, a subsystem is proposed to be placed in the same "test Plan", and the process test can be differentiated by the "thread Group", which makes it easy to set the number of different test data.

More independent interfaces can be uniformly placed within a group of threads and tested in sequence.  

Test of the process interface: if the interface to be tested can form a process, only the sampler of multiple "HTTP requests" is added sequentially, each request can extract the data that needs to be passed in the context as a parameter to ensure consistency of the data in the process.

Preliminary introduction of JMeter Application

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.