"Original" Shell to write a simple jmeter automated pressure test script

Source: Internet
Author: User

In the company to do stress testing also quite a long time, every test before the environment data preparation need to spend a long time, so has been considering the whole process can be automated, so the time to write an automated script, of course, the script is very primitive, the code is not perfect, there are many need to change the place, Subsequent re-optimization. If there is any mistake or improper in the text, also hope to advise.

First, design ideas

1. Initialize the database (import users, clear data, etc.)

2. Initializing the cache (using the Redis cache optimization System)

3. Perform stress test

II. directory Structure

Catalogue Interpretation:

apache-jmeter-3.0 for JMeter Program directory

Asserts.log Assertion Log

auto_jmeter.sh script file (starting this project is executing it)

Jmeter.log jmeter Boot Log

The code is as follows (by convention, all the code involved in the company has been modified)

#!/bin/Bashset-Elc_all=CLANG=Cunset Tzfile_path="./"Host="192.168.0.32"username="Test"Password="test.123"dbname="Test"Jmeter_path="./apache-jmeter-3.0/bin/jmeter.sh"Jmx_path="./APACHE-JMETER-3.0/JMXS/TERMPLAN_DQ.JMX"Jtl_path="./apache-jmeter-3.0/jtls/' Date +%y%m%d-%h%m '. JTL"Sql_path="./sqlfiles/"#now=`Date+Date+%y%m%d-%h%M ' ############### -######### #数据库初始化 ############### -######functionInit_data () {Echo "=========== begins initializing related data ============="MySQL-h${host}--default-character-set=utf8-u${username}-p${password} ${dbname}-E"DELETE from T_user WHEREID>50000; DELETE from T_person WHEREID>50000; SELECT Count (*) AS'Total pre-test appointments'from t_test_table; "CD ${sql_path} sql_name=`ls`         forfile_nameinch${sql_name[@]} Do                if[-F"$file _name"]; Then#command="Source $file _name"MySQL-h${host}--default-character-set=utf8-u${username}-p${password} ${dbname}-E"Source ${file_name}"                Else                        Echo-E"\033[31;31m SQL file does not exist!!! \033[0m"                fi         DoneCD.. MySQL-h${host}--default-character-set=utf8-u${username}-p${password} ${dbname}-E"SELECT Count (*) as'number of new users'From T_user WHEREID>50000; "        Echo "========== initialization of related data is complete ============"}############### -######### #缓存初始化 ############### -######functionInit_cache () {Echo "============= start initializing the cache ==============="        Echo "============== Initialization (kiwi) ================"Curl"http://127.0.0.1:10000/Test/test. Action"        Echo-E"\n========== Initialize frozen cache (Kiwi) ============"Curl"http://127.0.0.1:10000/Test/test/zen.action"        Echo-E"\n============ has completed initializing the cache =============="}############### -######### #执行jmeter脚本 ############### -######functionAuto_jmeter () {SH${jmeter_path}-n-t ${jmx_path}-L ${jtl_path}}############### -######### #查询数据 (too much data does not work because caching to the database takes a long time) ############### -######functionSelect_data () {Echo "============ start querying related data =============="MySQL-h${host}--default-character-set=utf8-u${username}-p${password} ${dbname}-E"        SelectCOUNT (*) as'total number of post-test appointments'From t_Test_table; Quit"        Echo "============ Related data query complete =============="        Echo-E"\033[36;36m============ stress test execution completed ==============\033[0m"}############################################# #init_datainit_cacheauto_jmeterSleep TenSelect_data

Iv. results of implementation such as

V. Legacy ISSUES

1, jmeter pressure does not go, despite the addition of 1000 threads, but the actual concurrency of about 20, this in the previous document has data presentation.

2, Support output HTML report, need to implement, pressure test report more intuitive. How to output the correct test report is very important.

Wait a minute

The above problem resolution will continue to update

"Note" Welcome to discuss, welcome reprint, but reproduced please indicate the source.

"Original" Shell to write a simple jmeter automated pressure test script

Related Article

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.