Jmeter scenario design

23 Views Asked by At

I have a file "District.csv" which has "10 agents" I want to create 110 subagents under all these "10 agents" as 11 subagents for each agent and write out to a file

like

Agent1,subagent1 Agent1,subagent1 Agent1,subagent1 Agent1,subagent1 Agent1,subagent1 Agent1,subagent1 Agent1,subagent1 Agent1,subagent1 Agent1,subagent1 Agent1,subagent1 Agent1,subagent1 Agent1,subagent1 Agent2,subagent2 Agent2,subagent2 Agent2,subagent2 Agent2,subagent2 Agent2,subagent2 Agent2,subagent2 Agent2,subagent2 Agent2,subagent2 . . . So on

can someone please help me to achieve it. please help me with JMX for this scenario if possible

Thanks in advance

I tried

Thread group - 10 thread loop controller - 11 Sampler - to create the agents ``post processor - to write out to a file

1

There are 1 best solutions below

0
Dmitri T On

If you have the file with 10 agents which looks like:

Agent1
Agent2
Agent3
...
Agent10

and would like to modify it to look like:

Agent1,subagent1
Agent1,subagent2
...
Agent1,subagent11
Agent2,subagent1
...
Agent10,subagent11

You can:

  1. Add setUp Thread Group to your test

  2. Add JSR223 Sampler to the setUp Thread Group

  3. Put the following code into "Script" area:

    def builder = new StringBuilder()
    
    def csvFile = new File('test.csv')
    
    def lines = csvFile.readLines()
    
    lines.each { line ->
        1.upto(11, {
            builder.append(line).append(',').append('subagent').append(it).append(System.getProperty('line.separator'))
        })
    }
    
    csvFile.text = builder.toString()
    

    the above code will replace the contents of your original CSV file with "subagents" added, you will be able to use it with i.e. CSV Data Set Config in the "normal" Thread Group