How to synchronize JMeter Thread groups by using user defined variable - jmeter

I am inexperienced in JMeter. What I want to do is to synchronize JMeter Thread groups. With respect to "How to synchronize JMeter Thread groups", I would like to ask an account of how to 'set a UserDefined Variable "Group1_done==true" as the last step'.
I defined user defined variable with initial value but I did not set it value later. How can I set it value in any step?

You may set value for variable / property even in HTTP Request Sampler:
Your while loop will look like:
Thread Group 1
. . .
. . .
[execute your test logic here]
. . .
HTTP Request
// last step
${__setProperty(group1_done,TRUE,)}
. . .
Condition expression for WHILE cycle in 3rd Thread Group:
${__P(group1_done,)} && ${__P(group2_done,)

Related

How to execute specific HTTP request using robotframework

below command will execute all the HTTP request under the jmx file but i want to execute specific threadgroup or HTTP request in jmeter using robot framework.
Below keyword will execute all the threadgroup and HTTP request,
Run Jmeter /home/sadha/Documents/apache-jmeter-5.4.1/bin/jmeter.sh /home/sadha/Documents/apache-jmeter-5.4.1/bin/HTTP Request.jmx ${logPath} -Jvendor=${vendor} -Jurl=${url} -Jport=${port}
For Thread Group - if you dynamically define the number of threads using __P() function in 2 thread groups like:
in Thread Group 1: ${__P(thread.group.1.users,)}
in Thread Group 2: ${__P(thread.group.2.users,)}
you will be able to provide the desired number of threads via -J command-line argument like:
Run thread group 1 with 100 users, don't run thread group 2: /home/sadha/Documents/apache-jmeter-5.4.1/bin/jmeter.sh /home/sadha/Documents/apache-jmeter-5.4.1/bin/HTTP Request.jmx ${logPath} -Jvendor=${vendor} -Jurl=${url} -Jport=${port} -Jthread.group.1.users=100 -Jthread.group.2.users=0
Run thread group 2 with 100 users, don't run thread group 1: /home/sadha/Documents/apache-jmeter-5.4.1/bin/jmeter.sh /home/sadha/Documents/apache-jmeter-5.4.1/bin/HTTP Request.jmx ${logPath} -Jvendor=${vendor} -Jurl=${url} -Jport=${port} -Jthread.group.1.users=0 -Jthread.group.2.users=100
Run both thread groups with 100 users each: /home/sadha/Documents/apache-jmeter-5.4.1/bin/jmeter.sh /home/sadha/Documents/apache-jmeter-5.4.1/bin/HTTP Request.jmx ${logPath} -Jvendor=${vendor} -Jurl=${url} -Jport=${port} -Jthread.group.1.users=100 -Jthread.group.2.users=100
The same approach can be applied to the HTTP Request samplers, if you put them under the Switch Controller and use __P() function as the switch value like ${__P(request,)}:
if you pass -Jrequest="Request 1" - it will execute Request 1
if you pass -Jrequest="Request 2" - it will execute Request 2
etc.
More information:
Configuring JMeter
Overriding Properties Via The Command Line
Apache JMeter Properties Customization Guide

How to set -JlopCount = <Forever> in Jmeter non-GUI mode?

Goal is to set the following and run a test plan with a "Thread Group" and "CSV Data Set Config" with 1000 lines/user accounts. So in 20 mins i want 10 threads to go through my 1000 line long csv file.
I set these settings in GUI mode and it does what i want:
Thread Group .
num of threads - 10 .
LoopCount=Forever .
scheduler=on .
duration=7200 .
"CSV Data Set Config"
Recycle on EOF? - False
Stop thread of EOF? - False
Sharing mode=All Threads
The problem is that i can't reproduce these setting from non_gui mode. I run it as follows and it only goes through # of csv lines equaling the # of threads set. So if i set 20 threads it will go through 20 lines of a file and exit.
-Jseconds=1200
-JthreadCount=20
-JcsvFile=../../user_files/j2kUsers.csv
-JloopCount=???
Use -1 as the property value, Thread Group has a Loop Controller under the hood and as per documentation:
The value -1 is equivalent to checking the Forever toggle.
You can also put the values to user.properties file like:
seconds=1200
threadCound=20
etc.
to avoid entering the values each time you run the script, the values van be overriden via -J command line argument at any time.
More information: Apache JMeter Properties Customization Guide

Jmeter - Testing with 100 User while reading Links from CSV file

I just started using Jmeter recently.
What I want:
I want to run a test of 100 users by getting links from CSV file.
How I am doing:
I created a Test-Plan, Added Thread Group, CSV Data Config (Child to Thread group), HTTP Request.
Given Values:
HTTP Request Default: Url Address (Tried with both HTTP & without HTTP in protocol section)
Thread Group: User: 100
Loop: Forever
CSV Data Set Config: File Name (Full Path, the file is not in bin folder)
Variable Name: Path
Recycle on EOF: False
Stop Thread on EOF: True
HTTP Request: IP Address:
Path: ${Path}
CSV File:
Path
Link1
Link2
Link3
What I am getting: Well the test is executing but it executing all link only once (one User), it not going for 100 User
Note: I am running the TestPlan from Command Mode
Thanks for your Time
If you want each user to go through all links in the CSV file you need to amend Sharing Mode setting of the CSV Data Set Config to Current Thread
You can verify the behavior by adding __threadNum() function as request prefix/postfix

How can I test 50 threads and 60 threads ,for slave 1 and slave 2 respectively from jmeter non gui command?

Scenario :
I have 2 slave machines configured , I want to send 50 users for slave 1, 60 users for slave 2 . I am using non GUI jmeter from command .
IP Address example :
Slave 1 : 1.0.0.1
Slave 2 : 2.0.0.2
Jmeter test plan configuration variables:
Number of threads :${__P(threads1,)}
Ramp-up period : ${__P(threads2,)}
Loop Count : ${__P(threads3,)}
I tried following command on jmeter start, but its not working as per expected:
jmeter -n -t POC1.jmx -R 1.0.0.1,2.0.0.2 -Gthreads1=50 -Gthreads2=1 -Gthreads3=1, -Gthreads1=60 -Gthreads2=1 -Gthreads3=1
Please help me if I am wrong in above command , please tell me how can I send 50 user threads , ramp up period 1 and loop count 1 for slave 1 and 60 user threads ramp up period 1 and loop count 1 for slave 2.
You won't be able to do it the above way as:
All remote slaves are executing the same test plan
You can pass global properties via -G command-line argument, so all the remote clients will be having the same properties set
The solution is to use different user.properties on different slaves, like:
Define amount of virtual users in your Test Plan using __P() function like:
${__P(threads,)}
On first slave add the next line to user.properties file (lives in JMeter's "bin" folder)
threads=50
On second slave add the next line to user.properties file
threads=60
Restart JMeter on slaves
You can also pass threads property value via -J command line argument while starting JMeter servers like:
On first slave
jmeter -Jthreads=50 -s -j jmeter-slave1.log .....
On second slave
jmeter -Jthreads=60 -s -j jmeter-slave2.log .....
See Apache JMeter Properties Customization Guide for more information on using JMeter properties, setting and overriding them

JMeter : Run all tests in a file

I have around 4 files named:
Test_1.csv
Test_2.csv
...
Each line in each test file has the following format:
method;request
Where, method is the URL that I call and request is the request I make to it. Everything is configured to pick up these values and form URLs.
However, first Test_1.csv must run, then Test_2.csv must run and so on. To do that, I have created 5 thread groups in the following hierarchy:
Test Plan
|
+- Step 1
|
+- HTTP request
+- CSV Data Set Config <- Reads from Test_1.csv
+- Uniform Random Timer
+- Step 2
|
+- HTTP request
+- CSV Data Set Config <- Reads from Test_2.csv
+- Uniform Random Timer
And I have also selected the Run thread groups consecutively option in my test plan. Each thread group is configured for 20 threads. Now, what I want it to do is that, Step 1 should run each and every test in Test_1.csv, then Step 2 should execute and run each and every line in Test_2.csv. However, what is happening is that, Step 1 runs the first 20 lines from Test_1.csv and then Step 2 starts, runs 20 tests and continues. Then, after all steps are done, Step 1 runs again and runs the very same 20 lines from Test1.csv. I want it to just run once, loop through all the lines in the test file and then quit and hand over control to the next thread.
How do I go about this?
Try to use the following schema:
Test Plan
Thread Group #1
Number of Threads: N
. . .
While Controller
Condition: ${__javaScript("${request}"!="<EOF>",)} - until the EOF
CSV Data Set Config
Filename: [path to your file with test-data] - Test_1.csv in this case
Variable Names: method,request
HTTP Request
Uniform Random Timer
. . .
Thread Group #2
. . .
[same for Test_2.csv]
Thread Group #3
. . .
[same for Test_3.csv]
jMeter Plugins' ParameterizedController can help you call parts of your test plan like you call functions in a regular programming language. More importantly, you can parametrise those calls with variables.

Resources