Easy way to create jMeter cluster with terraform on your AWS infrastructure.
- Create jMeter script (I suggest you to use jMeter UI for that purposes)
- Generate ssh keys - e.g. you can use ssh-keygen tool
ssh-keygen -t rsa -C "loadServer" -P '' -f loadServer
- Create terraform main.tf - here's example you can use.
N.B. Please see variables.tf for full reference on terraform-aws-jmeter variables - at least be sure to change instance types as you can't do much with micro instances.
provider "aws" {
region = "${var.aws_region}"
access_key = "${var.aws_access_key}"
secret_key = "${var.aws_secret_key}"
}
module "jmeter_cluster" {
source = "github.com/r4dx/terraform-aws-jmeter"
aws_region = "${var.aws_region}"
slave_ssh_public_key_file = "ssh/loadServer.pub"
master_ssh_private_key_file = "ssh/loadServer"
master_ssh_public_key_file = "ssh/loadServer.pub"
jmx_script_file = "script.jmx"
}
- Use this commands to create infrastructure
# terraform get
# terraform apply
- Ssh on master node and start the load test - N.B. You can get master node public ip using
terraform show
command.
# ssh -i "loadServer" ec2-user@<MASTER_PUBLIC_IP>
[ec2-user@<HOSTNAME> ~]$ cd /jmeter-master/
[ec2-user@<HOSTNAME> jmeter-master]$ python master_start.py
N.B. It requires some time to start slave nodes and in case they're didn't for some reason, you can do it manually by SSHing to slave nodes and executing /apache-jmeter-3.0/bin/jmeter-server
command
6. You can destroy the infrastructure with terraform destroy
terraform-aws-jmeter creates one master instance and autoscaling group with jmeter workers. Both master and workers share the same security group which allows all ingress and egress communications inside the group, only ssh ingress connections for other world. It allows egress communications for all ports for outside world as well though to make sure jmeter can access resource it's testing. Master and workers instances are bootstrapped with jMeter 3 (N.B. only jMeter 3 is currently supported) and ready to work - master automatically discovers workers by searching for instances in autoscaling group.
Here's the graph generated by terraform - I've removed provider.aws node for better readability.
HashiCorp Terraform