Configuring and using JMeter for interface testing and stress testing

Source: Internet
Author: User
Tags http cookie http request
1. JMeter Introduction

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.

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. 2. Download and installation of JMeter

The use of JMeter requires a Java environment, which requires the installation of the JDK first;

Download JMeter Toolkit, unzip and enter the Bin folder, click Jmeter.bat to run;

Downloadable plugins, with more professional components.
In http://jmeter-plugins.org/downloads/all/ Download Jmeterplugins-standard-1.1.3.zip, unzip and put Jmeterplugins-standard.jar under Xxx\apache\jmeter\lib\ext 3. Interface test method

1. What is interface testing?

Interface testing is a test of the interface between components of a test system. Interface testing is primarily used to detect the interaction points between external systems and systems, as well as within each subsystem. The focus of testing is to examine the exchange of data, the transfer and control of management processes, and the mutual logical dependencies between systems.

2. Preparing the data

Gets the name of the parameter and the method to get the value for the test URL.

method, IP, test URL, test header, test body, and benchmark test implementation for each request

Write the items in the test case to the software. (1) Creating thread groups

(2) Modify thread group name

(3) Adding a component to a thread group

1.HTTP Cookie Manager
Because many Web sites are required to log in before they can operate, the cookie generated after login to verify the identity of the user, when testing with the software needs to pass verification, so we need to add this manager to manage the cookie, its value is shared by the entire thread (also can be shared by the entire test plan), Cookies are made in the browser.

2.HTTP Request Default Value
The common values for each interface in the test case can be set using the HTTP request defaults component statistic setting, eliminating the hassle of having to fill out each request, and its value being shared by the entire thread (or by the entire test plan).

3. User-defined variables
The subsequent use of the variable is added to the user-defined variable, and subsequent operations simply refer to the variable name, whose value is shared by the entire thread (and can be shared by the entire test plan).

4.HTTP Request
The component to be used to send the HTTP request.

5.HTTP Information Header Manager
When sending an HTTP request to join the information header with this component, such as all requests in a thread group require information headers, you can upgrade this manager to the entire thread group share or the entire test plan share.

6. Responding to assertions
After sending the request, it is necessary to judge whether a test is OK by the comparison of the response result, which is feasible by man-made judgment, but when the number of requests is large, the human judgment is inefficient, and adding "response assertion" can improve the efficiency (multiple assertions may be added when the Datum has multiple judgments).

7. View the result tree
Used to view test results.

8. Other components
(1) Regular expression extractor
Some of the information in a response return data can be extracted and used for subsequent operations.
(2) Debug Sampler
For debugging the entire test
(3) CSV Data Set Config
A component that is parameterized by a file. (4) Start testing

After adding all kinds of components and data, we can test the results of each request by looking at the result tree.
4. Pressure test method (1) Thread Group

(2) Constant throughput Timer (fixed throughput controller)

(3) Aggregation report


(4) Listener

Listener Jp@gc-transactions per Second

Listener Jp@gc–perfmon Metrics Collector
(5) Run stress test using non-GUI interface

Non-GUI stress test steps:

In GUI interface set concurrency number, test time, etc., add each component, save the test plan, and close the software;

Use the non-GUI interface to start the stress test with instructions;
Instructions for example: D:\Program files\apache-jmeter-3.1\bin>jmeter-n-T testplan.jmx-l listener.jtl

Open the Jmeter.bat and load "LISTENER.JTL" in the aggregation report component to view the aggregated report;

Load "LISTENER.JTL" in the monitor to see the graphs.

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.