5
votes

I have read through the similar posts with the same question as mine, but there wasn't enough detail for me to figure it out. So I was wondering if someone could correct what I'm doing wrong. And as the question states I want to run a single Thread Group from a Test plan using the CLI.

So my Test Plan contains 4 Thread Groups. Each Thread Group is the exact same except the Cookie Manager in each Thread Group contains a different value for a specific Cookie. So when I run from the command line I want to tell JMeter to only Execute Thread Group 1 or 2 or 3 etc... What I read so far is that you can use a While Controller and a Variable to accomplish this, but I can't seem to get it to work.

My Test Plan Looks like this:

 
+ Test Plan - Logging-In
   + Thread Group - Server 1 Login
       - While Controller (*with variable "server1ThreadActive")
       - HTTP Request Defaults
       - Cookie Manager
       + HTTP Request - Load Homepage
       + HTTP Request - Load Login Page
       + HTTP Request - Login Form
       + HTTP Request - Do something
       + HTTP Request - Do something else
       + HTTP Request - Logout
   + Thread Group - Server 2 Login
       - While Controller (*with variable "server2ThreadActive")
       - HTTP Request Defaults
       - Cookie Manager
       + HTTP Request - Load Homepage
       + HTTP Request - Load Login Page
       + HTTP Request - Login Form
       + HTTP Request - Do something
       + HTTP Request - Do something else
       + HTTP Request - Logout

So the Test Plan above has 2 more of the exact same Thread Groups for Server 3 and 4 as you could imagine... Do I have the While loops configured in the correct locations?

--FIRST TRY--

While Controllers: 1st I had the conditions set to this below for each respective Thread:

   Condition (function or variable) = "${__P(server1ThreadActive)}" == "false"

Command Line: Then to try and execute only Thread for Server 2 I would use this on the CLI:

   jmeter -n -t Server_Login.jmx -Jserver1ThreadActive=true

RESULT: This resulted in all 4 Threads executing when I only was trying to run Server 2 Thread.

--SECOND TRY--

While Controllers: 2nd I had the conditions set to this below for each respective Thread:

   Condition (function or variable) = ${__P(server1ThreadActive)}

Command Line: Then to try and execute only Thread for Server 2 I would use this on the CLI, assuming that without a value assignment in while controller it defaults to true, so I set all vars to false except the one I want to run:

   jmeter -n -t Server_Login.jmx -Jserver1ThreadActive=false -Jserver3ThreadActive=false -Jserver4ThreadActive=false

RESULT: This resulted in all 4 Threads executing when I only was trying to run Server 2 Thread.

There was a few other things that I tried as well but I am assuming they were wrong too since I had the same result. I had also tried adding a User Defined Variables section and creating 4 vars, but couldn't figure that out either... I even tried creating a file called "Server_Login.properties" and inserted those variable names, one on each line with the value set to false for each one, and included it on the command-line with the -S option, but no such luck...

Could anyone tell me where I am going wrong with this? Any thoughts or suggestions would be greatly appreciated!

Thanks in Advance,
Matt

1

1 Answers

5
votes

Please check here for more details.

http://www.testautomationguru.com/jmeter-manage-test-plan/


If the thread user count is 0, JMeter will not execute the thread group at all.

So, You can decide the thread group you want to run by using variables for the Thread Group - User count.

Using Properties:

Have a properties file with below property & value (to execute only the thread group 2)

threadgroup1.users=0
threadgroup2.users=10
threadgroup3.users=0
threadgroup4.users=0

In the Thread Group - number of threads fields, use ${__P(threadgroup1.users)}

command line option to pass the property file,

 jmeter -n -t /path/to/test.jmx -l /path/to/log.jtl -p /path/to/file.properties

Using User Defined Variables:

Just create a user defined variable & with appropriate values.

Please access it in the test directly using ${threadgroup1.users}