This shell script will allow you to run your local JMeter jmx files either using Amazon's EC2 service or you can provide it with a simple, comma-delimited list of hosts to use. Summary results are printed to the console as the script runs and then all result data is downloaded and concatenated to one file when the test completes ready for more detailed analysis offline.
By default it will launch the required hardware using Amazon EC2. Using AWS it is much easier and cheaper to scale your test over multiple slaves but if you need to you can also pass in a list of pre-prepared hostnames and the test load will be distributed over these instead. Using your own servers can be useful when the target server to be tested can not be easily accessed from a location external to your test network or you want to repeat a test iteratively.
The script does not use JMeter's Distributed Mode so you do not need to adjust the test parameters to ensure even distribution of the load; the script will automatically adjust the thread counts based on how many hosts are in use. As the test is running it will collate the results from each host in real time and display an output of the Generate Summary Results listener to the screen (showing both results host by host and an aggregated view for the entire run). Once execution is complete it will download each host's jtl file and collate them all together to give a single jtl file that can be viewed using the usual JMeter listeners.
~/Documents/WHERETOPUTMYSTUFF/
. This is where you store your testplan and any associated files./usr/local/
).example-project.zip
into ~/Documents/WHERETOPUTMYSTUFF/
. You now have a template / example directory structure for your project.INSTANCE_SECURITYGROUP="sg-123456"
The ID of your security group (or groups) created under your Amazon account. It must allow Port 22 to the local machine running this script.
PEM_FILE="euwest1"
Your Amazon key file.
PEM_PATH="/Users/oliver/.ec2"
The directory (not the full filepath) where the Amazon PEM file is located. Important: No trailing '/'!
/testing/myproject
then you should name the jmx file myproject.jmx
.count="1" ./path/to/jmeter-ec2.sh
Where '1' is the number of instances you wish to spread the test over. If you have provided a list of hosts using REMOTE_HOSTS
then this value is ignored and all hosts in the list will be used.percent=20 count="3" terminate="TRUE" setup="TRUE" env="UAT" release="3.23" comment="my notes" ./jmeter-ec2.sh'
[count] - optional, default=1
[percent] - optional, default=100. Should be in the format 1-100 where 20 => 20% of threads will be run by the script.
[setup] - optional, default=TRUE. Set to "FALSE" if a pre-defined host is being used that has already been setup (had files copied to it, jmeter installed, etc.)
[terminate] - optional, default=TRUE. Set to "FALSE" if the instances created should not be terminated.
[price] - optional, if specified spot instances will be requested at this price
AMI_ID="[A linix based AMI]"
Recommended AMIs are provided in the jmeter-ec2.properties file. Both Java and JMeter are installed by the script dynamically if not present.
INSTANCE_TYPE="m3.medium"
micro
type instances do work and are good for developing but they are not recommended for important test runs. Performance can be slow and you risk affecting test results.Note: Older generation instance types require a different type of AMI (paravirtual vs. hmv).
USER="ubuntu"
Different AMIs start with different basic users. This value could be 'ec2-user', 'root', 'admin' etc.
SUBNET_ID=""
The id of the subnet that the instance will belong to. So long as a default VPC exists for your account you do not need to set this.
RUNNINGTOTAL_INTERVAL="3"
How often running totals are printed to the screen. Based on a count of the summariser.interval property. (If the Generate Summary Results listener is set to wait 10 seconds then every 30 (3 * 10) seconds an extra row showing an aggregated summary will be printed.) The summariser.interval property in the standard jmeter.properties file defaults to 180 seconds - in the file included with this project it is set to 15 seconds, like this we default to summary updates every 45 seconds.
REMOTE_HOSTS=""
If you do not wish to use ec2 you can provide a comma-separated list of pre-defined hosts.
REMOTE_PORT=""
Specify the port sshd is running on for REMOTE_HOSTS
or ec2. Default 22.
ELASTIC_IPS=""
If using ec2, then you can also provide a comma-separated list of pre-defined elastic IPs. This is useful if your test needs to pass through a firewall.
JMETER_VERSION="apache-jmeter-2.13"
Allows the version to be chosen dynamically.
Thread Count
, this value must be numeric.copying install.sh to 1 server(s)...lost connection
?This happens when it is not possible for the script to connect over port 22 to the instance that was created by AWS. There are a number of reasons why this can happen.
First, can you telnet to the instance?Run the script to create a box but use:
count="1" terminate="FALSE"./path/to/jmeter-ec2.sh
Then, take the hostname of the instance just created and try:
telnet thehostname.com 22
If you see something like:
Trying thehostname.com...Connected to thehostname.comEscape character is '^]'.SSH-2.0-OpenSSH_6.6p1 Ubuntu-2ubuntu1
Then you DO have network access.
If you see:
Trying 123.456.789.123...
You DO NOT have network access.
File permissions on your PEM fileYour .pem files need to be secure. Use chmod 600 yourfile.pem
.
The USER
property is not correctDifferent AMIs and OSs expect you to log in using different users. Make sure this value is set correctly.
Install the latest version of the ec2-api-toolsCheck here and make sure you have the latest version installed. Use $ ec2-version
to check.
Your Security Group is not configured properlyThe INSTANCE_SECURITYGROUP_IDS
property needs to reference the exact ids of one or more security group that exists in the correct region and that contains a rule that allows inbound traffic on port 22 from the machine you are running the script from, or everywhere if you are running the script remotely or just want to rule this out (be sure to reduce this scope later once you've got things working)
Check local network settingsOften port 22 can be blocked by over-zealous local network security settings. You often see this with poor quality wifi services, the type where you have to fill out a marketing form to get access. You can sometimes get around this by using a vpn but often they block this too and then your only choice is to put down your flat white and leave.
By default this shell script uses on-demand instances. You can use spot instances by requesting an hourly price
for your EC2 instances.
count="3" price=0.0035 ./jmeter-ec2.sh'
Spot Instances allow you to name your own price for Amazon EC2 computing capacity. You simply bid on spare Amazon EC2instances and run them whenever your bid exceeds the current Spot Price, which varies in real-time based on supplyand demand. The Spot Instance pricing model complements the On-Demand and Reserved Instance pricing models,providing potentially the most cost-effective option for obtaining compute capacity, depending on your application.
Read more at http://aws.amazon.com/ec2/purchasing-options/spot-instances/
[price] - optional, if specified spot instances will be requested at this price
[count] - optional, default=1
If your price is too low spot requests will fail with a status price-too-low
.
To get the price history by instance type, use the ec2-describe-spot-price-history
command from AWS CLI :
For example to get current price for t1.micro instance running Linux :
```ec2-describe-spot-price-history -H --instance-type t1.micro -d Linux/UNIX -s `date +"%Y-%m-%dT%H:%M:%SZ"````
Vagrant allows you to test your jmeter-ec2 scripts locally before pushing them to ec2.
Use jmeter-ec2.properties.vagrant
as a template for local provisioning. This file is set up to use Vagrant's ssh key, ports, etc.
# backup your properties files just in case
cp jmeter-ec2.properties jmeter-ec2.properties.bak
# use the vagrant properties file
cp jmeter-ec2.properties.vagrant jmeter-ec2.properties
# start vm and provision defaultjre
vagrant up
# run your project
project="myproject" setup="TRUE" ./jmeter-ec2.sh
Vagrantfile
to meet any specific networking needs. See Vagrant's networking documentation for details.To find your key pairs go to your ec2 dashboard -> Networking and Security -> Key Pairs. Make sure this key pair is in the REGION you also set in the properties file.
To create or check your EC2 security groups go to your ec2 dashboard -> security groups.
Create a security group (e.g. called jmeter) that allows inbound access on port 22 from the IP of the machine where you are running the script.
It is not uncommon for an instance to fail to start, this is part of using the Cloud and for that reason this script will dynamically respond to this event by adjusting the number of instances that are used for the test. For example, if you request 10 instances but 1 fails then the test will be run using only 9 machines. This should not be a problem as the load will still be evenly spread and the end results (the throughput) identical. In a similar fashion, should Amazon not provide all the instances you asked for (each account is limited) then the script will also adjust to this scenario.
Any testplan should always have suitable pacing to regulate throughput. This script distributes load based on threads, it is assumed that these threads are setup with suitable timers. If not, adding more hardware could create unpredictable results.
JMeter-ec2 is free software: you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation, either version 3 of the License, or(at your option) any later version.
JMeter-ec2 is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details.
You should have received a copy of the GNU General Public Licensealong with JMeter-ec2. If not, see http://www.gnu.org/licenses/.
The source repository is at:https://github.com/oliverlloyd/jmeter-ec2
packageRabbitMQJmeter;importjava.io.IOException;importjava.util.concurrent.TimeoutException;importorg.apache.jmeter.config.Arguments;importorg.apache.jmeter.protocol.java.sampler.JavaSamplerContext;im
我无法使用Jmeter 4.0创建HTTP2请求。 我已经安装了最新的JDK和HTTP / 2协议采样器插件。 我还观察到:“penJDK8ClientALPNProcessor @ e23ec5a不适用于Java 10.0.2” 使用Java 9进行了尝试,但我得到了同样的东西。 PS:我已经尝试添加JVM_ARGS = ... 完整的堆栈跟踪为: java.util.concurrent.Ex
在Jmeter日常实践中,大家应该都遇到过接入传参需要加密的情况。以登陆为例,用户名和密码一般都需要进行加密传输,在服务端再进行解密,这样安全系数会更高,但在使用jmeter进行接口测试的时候,怎样发送加密的参数呢,下面以AES加密为例,来示范一下如何在jmeter中对参数进行加密。本教程较为初级,有高级的请绕路~ 一、AES加密算法调试(java+myeclipse) 首先要准备一个AES算法类
build.xml <?xml version="1.0" encoding="UTF-8"?> <project name="ant-jmeter-test" default="run" basedir="."> <property environment="env"/> <tstamp> <format property="time" pattern="yyyy_MM_dd_h
Overview 在Gatling这个Scala版的性能测试工具大热之前,Apache JMeter始终是最成熟的开源性能/稳定性测试工具。 Run me faster 要用Non-GUI的形式跑 jmeter -n -t demo.jmx -p demo.properties 调正JVM启动参数,默认最大只用512M内存,可以搞大点。 不要放显示结果的listener,只放一个“Generat
Apache JMeter 是 Apache 软件基金会的开源项目,它是功能和性能测试的工具,100% 的用 Java 实现。 Apache JMeter 是纯 Java 编写的应用程序,用于测试服务器应用程序。它可以用来: - 生成测试负载 - 测试性能 - 测试功能性的行为 它包括对 HTTP(S), JDBC, JMS, FTP, LDAP,TCP,本机调用等协议的支持,也可以与用户编写的代码轻松扩展。
jmeter-mms 是 JMeter 测试平台用来测试 MMS 彩信协议的插件。
phoenixframework平台的一个模块,对jmeter的深度定制,用于对web性能测试。 这个定制版的jmeter,只支持No-GUI方式执行,并且在执行过程中可以动态获取已启动的线程,处于等待的线程,已经停止的线程, 并且执行完成后可以获取到执行的结果数据,如tps,success,fail等。 获取方法: 活动线程:JMeterContextService.getThreadCount
我在JMeter中创建了一个脚本,它从CSV获取登录凭据。 用户名:pshah 密码:欢迎 当我执行脚本时,我可以在POST中看到值: 用户名:pshah 但密码:欢迎 我想知道原因”
我正在使用CSV数据集配置来读取CSV文件。 我有进口包裹吗?