Azure-Samples / jmeter-aci-terraform

Scalable cloud load/stress testing pipeline solution with Apache JMeter and Terraform to dynamically provision and destroy the required infrastructure on Azure.
MIT License
119 stars 99 forks source link

Distinguishing between workers #75

Closed dsteindo closed 2 years ago

dsteindo commented 2 years ago

Hi there,

I need some help with some specific task.

We need to run 4 worker nodes with each 500 threads = unique users The users will be calculated based on the current thread number and node_index. Also users are unique as we calculate the offset based on the number of users per node and node index.

Here is the script if someone is interested image

This works fine when running locally with following command for first node:

jmeter -n -t loadtest.jmx -l testresults.jtl -Jnode_index=0 -Jusers_per_node=500

for second node

jmeter -n -t loadtest.jmx -l testresults.jtl -Jnode_index=1 -Jusers_per_node=500

How can I make this work with this terraform setup? I need to make sure that every user is unique across all nodes and ideally I do not need to maintain some CSV, as we have the need to vary between test cases and go up to 10000 users as well.

Thank you in Advance!

devlie commented 2 years ago

If all you need is to vary the node_index param, you can probably use the ${count.index} like what the sample did with the worker name.

resource "azurerm_container_group" "jmeter_workers" {
  count               = var.JMETER_WORKERS_COUNT
  name                = "${var.PREFIX}-worker${count.index}"
dsteindo commented 2 years ago

Thank you for your reply @devlie We updated the main.tf file section resource "azurerm_container_group" "jmeter_workers"

    commands = [
      "/bin/sh",
      "-c",
      "cp -r /jmeter/* .; /entrypoint.sh -s -J server.rmi.ssl.disable=true -Djava.rmi.server.hostname=$(ifconfig eth0 | grep 'inet addr:' | awk '{gsub(\"addr:\", \"\"); print $2}') -Jnode_index=${count.index} -Jusers_per_node=${var.USERS_PER_NODE}",
    ]

works as a charm :)