Search code examples
jmeterjmeter-5.0

JMeter - Replicate a set of Components dynamically


I have a JMeter script which performs the following (Screenshots attached):

1. SSH
2. Execute a command
3. Poll the command until the status becomes "Running"
4. Write the Results into a File

enter image description here

enter image description here

enter image description here

I need to replicate the steps 1-4 for all the rows in a csv file at once (in parallel). i.e. Suppose there are 10 rows in a csv file. Steps 1-4 should be executed for all the rows at once. Number of rows in a csv file is dynamic. They vary time to time.

Your help will be appreciated. Thanks for your Support.

Regards, Ajith


Solution

  • You can use __groovy() function in the "Number of threads" field of the Thread Group in order to kick off that many threads as there are lines in the CSV file:

    ${__groovy(new File('/path/to/your/file.csv').readLines().size(),)}
    

    enter image description here

    This way JMeter will kick off the number of threads equal to the number of lines in the CSV file.

    If you want additionally ensure that the threads are executing Samplers at exactly the same moment you can use Synchronizing Timer