⼆、配置项⽬参数
点击项⽬名进⼊该项⽬,点击配置按钮进⼊配置页:
勾选参数化构建过程,点击添加参数,选择所需参数的填写⽅式,如选择String Parameter对应字符串输⼊,choice对应下拉框选项,填写 1)⾃⾏定义的字段名; 2)如有默认值可填写; 3)添加对字段含义的描述
点击增加构建步骤,选择Execute shell,添加执⾏shell脚本
cd /home/dev_root/qa/test_software/apache-jmeter-4.0/bin
if[-e /home/dev_root/qa/jmeter_load_test/result.jtl ]
then
rm /home/dev_root/qa/jmeter_load_test/result.jtl
fi
if[-e /home/dev_root/qa/jmeter_load_test/result ]
then
rm -r /home/dev_root/qa/jmeter_load_test/result
web端登录mkdir /home/dev_root/qa/jmeter_load_test/result
fi
source /etc/profile
if[[ ${evn_name}=='Online']]
then
if[[ ${file_name}=='separate_step']]
then
file='separate_step.jmx'
elif[[ ${file_name}=='bigeye']]
then
file='bigeye.jmx'
else
file='testAi.jmx'
fi
fi
exefile='test_script.jmx'
cp /home/dev_root/qa/jmeter_load_test/${file}/home/dev_root/qa/jmeter_load_test/test_script.jmx
cp /home/dev_root/qa/jmeter_load_test/${exefile}/home/dev_root/qa/jmeter_load_test/${exefile}.tmp
sed -i 's/<stringProp name=\"'ThreadGroup.num_threads\"'>5</<stringProp name=\"'ThreadGroup.num_threads\"'>'${thread_num}'</g'/home/dev_root/qa/ jmeter_load_test/${exefile}
sed -i 's/<stringProp name=\"'ThreadGroup.duration\"'>120</<stringProp name=\"'ThreadGroup.duration\"'>'${duration}'</g'/home/dev_root/qa/jmeter_loa d_test/${exefile}
./jmeter -n -t /home/dev_root/qa/jmeter_load_test/${exefile}-l /home/dev_root/qa/jmeter_load_test/result.jtl -e -o /home/dev_root/qa/jmeter_load_test/resul t_${BUILD_NUMBER}
cp -r /home/dev_root/qa/jmeter_load_test/result_${BUILD_NUMBER}/home/dev_root/qa/test_software/apache-tomcat-8.5.31/webapps/JmeterTestResult sleep 3
sed -i 's/<stringProp name=\"'ThreadGroup.num_threads\"'>'${thread_num}'</<stringProp name=\"'ThreadGroup.num_threads\"'>5</g'/home/dev_root/qa/ jmeter_load_test/${exefile}
sed -i 's/<stringProp name=\"'ThreadGroup.duration\"'>'${duration}'</<stringProp name=\"'ThreadGroup.duration\"'>120</g'/home/dev_root/qa/jmeter_loa d_test/${exefile}
cd /home/dev_root/qa/jmeter_load_test
sed "s/JmeterTestResult\/result\/index.html/JmeterTestResult\/result_${BUILD_NUMBER}\/index.html/
g" content_bak.html >content.html
python jmeter_mail.py ${to_mails} ${evn_name}
cp /home/dev_root/qa/jmeter_load_test/${exefile}.tmp /home/dev_root/qa/jmeter_load_test/${exefile}
其中最关键的是: ./jmeter -n -t jmeter⽂件名 -l 结果⽂件 -e -o 结果存放⽬录
-t :执⾏测试⽂件所在的位置及⽂件名
-n :⾮GUI 模式执⾏JMeter
-r :远程将所有agent启动⽤在分布式测试场景下,不是分布式测试只是单点就不需要-r
-l :指定⽣成测试结果的保存⽂件, jtl ⽂件格式
-e :测试结束后,⽣成测试报告
-o :指定测试报告的存放位置
-o 指定的⽂件及⽂件夹,必须不存在,否则执⾏会失败
配置完成后点击开始构建。构建过程中可点击当前构建的console output查看实时控制台输出,如有明显问题可随时停⽌压测。
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论