Jmeter entry instance

Source: Internet
Author: User

This article has been published by the author Xia Jun authorized Netease cloud community.

Welcome to the Netease cloud community to learn more about the operation experience of Netease technology products.


This article briefly introduces the basic functions of jmeter based on examples and graphic methods, so that new users can quickly get started, hoping to improve the test efficiency in combination with specific test scenarios:

1. Introduction to jmeter

Jmeter is a free open-source testing tool developed in Java. It is mainly used for function testing and performance testing (stress testing/load testing), and jmeter is used to test restful APIs, very easy to use.

Official Website: http://jmeter.apache.org/


Ii. jmeter Installation and Use

Download and run jmeter

Http://jmeter.apache.org/

Decompress the package and run "bin/jmeter. Bat"

Jmeter supports Chinese characters. After jmeter is started, click Options-> choose language to select a language.


Iii. Use jmeter (actual example)

Eg: Get daily rise/fall data from [Netease Financial Management]-[Fund:

GET request: https://8.163.com/wyfund/getFundDailyGain.htm? Fundcode = 270001 & page = 1

In response, the daily ups and downs of the Fund are obtained. For example:

result": [{"fundCode": "270001","dataDate": "2016-09-12","unitNet": 0.8501,"cumulativeNet": 3.6661,"dailyGain": -0.0241},{"fundCode": "270001","dataDate": "2016-09-09","unitNet": 0.8711,"cumulativeNet": 3.6871,"dailyGain": -0.0023}]

1. Create a thread group. For example, select create control (right-click "test plan" and choose add> threads (users)> thread rent)

Note: The thread group must be created. All jmeter tasks must be processed by threads. All tasks must be created under the thread group.

2. Create an HTTPS request

For example, select create control (right-click "thread rent" and choose "add"> "sampler"> "http request)

Set GET requests: https://8.163.com/wyfund/getFundDailyGain.htm? Fundcode = 270001 & page = 1 ,:

3. Add the HTTP information header Manager

For example, right-click the HTTP request and choose add> Configure component> HTTP information header manager from the shortcut menu)

Parameter settings

4. Add view results tree

For example, select add control (right-click a thread lease and choose add> listener> View result tree)

View running results

Run and check the result:

5. Add assertion and assert results

For example, select add control (select HTTP request, right-click, and choose add> assertion> response assertion) to add the test value.

For example, select the control to add (right-click "thread group", choose "add"> listener ">" asserted result "), and view the result of the asserted execution.

After running, if the HTTP response does not contain the expected string, the test will be fail.

6. Use User-Defined variables

Use jmeter to define variables. For example, define a variable named fundcode. use $ {fundcode} when using it };

For example, select add control (right-click "thread group" and choose "add"> "configuration element"> "user-defined variable)

Then use this variable in the HTTP request.

Iv. jmeter simple stress testing

1. Use CSV Data Set config for parameterization

A new data.txt file is created. The parameter data is stored in the TXT file. Two data lines (fundcode and page) are separated by commas.

For example, select add control (right-click "thread rent", choose add> Configuration component> CSV Data Set config), and fill in the relevant data:

2. Add HTTP request.

GET request: http://8.163.com/wyfund/getFundDailyGain.htm? Fundcode = {fundcode} & page = {page}

For example, select add control (right-click "thread rent", choose add> sampler> HTTP request), and fill in the relevant data:

3. Use thread rent thread group to control the number of simulated users

Note:

A. Number of threads: one user occupies one thread, and 200 threads simulate 200 users.

B. ramp-up period (in seconds): Specifies how long it takes for a thread to start. If the number of threads is 200 and the preparation duration is 10, it takes one second to start 20 threads. That is, 20 threads are started every second.

C. Number of loops: the number of requests sent by each thread. If the number of threads is 200 and the number of loops is 10, each thread sends 10 requests. The total number of requests is 200*10 = 2000. If "forever" is selected, all threads will send requests until the script is stopped.


4. Add a summary report to view the test results.

For example, select add control (right-click "thread rent" and choose add> listener> Summary Report)

5. Run and view the result.

5. Use the jmeter recording script

Configure the web proxy and use the jmeter recording script:

1. For example, select add control (right-click "workbench", choose add> non-test element> HTTP Proxy Server), and configure port-Target Controller-group:

2. Set the proxy server of the Chrome browser.

3. access the website in the browser and record the request accordingly.

Note: The recorded scripts in jmeter are messy. You can set to ignore some requests. In addition, you can create and record the scripts in combination.



The Netease cloud free trial hall provides over 20 cloud products at zero cost!

For more information about Netease technologies, products, and operations, click.


Related Articles:
[Recommended] Introduction to Python SDK for Crawler development (1)

Jmeter entry instance

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.