How to execute Thread Groups in order - jmeter

My Test plan in look like this:
Test Plan
|- Thread Group A
| |- HTTP request 1
|- Thread Group B
| |- HTTP request2
| |- HTTP request3
|- Thread Group C
| |- HTTP request4
| |- HTTP request5
|- Thread Group D
| |- HTTP request6
when i run it, it don't execute threads in order! (B -> A-> D -> C)
How can i fix it please ?

By default JMeter executes Thread Groups simultaneously, if you want JMeter to execute them one by one - tick Run Thread Groups consecutively at Test Plan level
You can also consider using Inter-Thread Communication Plugin in order to setup some custom rules for requests execution in case if request in one thread group needs to be executed after specific request in another thread group.

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

Adding Job Array elements in Slurm after submission

I'm trying to use a Slurm-operated cluster to run LS-Dyna (a finite-element simulation program with a limited number of licenses available on my cluster). I am trying to write my batch scripts so that I do not waste processing time due to this license limit (as well as to improve legibility when running 'squeue' commands) by using job arrays -but I'm having trouble making that work.
I want to run identical Bash scripts in a variety of FEM meshes, each of which I have organized into different subfolders.
Given this folder structure on my cluster...
cluster root
|
...
|
|-+ my scratch space's root
|
|-+ this project
|
|--+ lat_-5mm
| |- runCurrentLine.bash
| |- other files
|
|--+ lat_-4.75mm
| |- runCurrentLine.bash
| |- other files
|
|--+ lat_-4.5mm
| |- runCurrentLine.bash
| |- other files
|
...
|
|--+ lat_5mm
| |- runCurrentLine.bash
| |- other files
|
|
|-sendDynaRuns.bash
|-other dependencies
...I'm trying to submit "runCurrentLine.bash" in each folder by running the following script in my login node.
#!/bin/bash
iter=0
for foldernow in */; do
# change to subdirectory for current line iteration
cd "./${foldernow}";
# make Slurm and user happy
echo "sending LS Dyna simulation for ${pos}mm line..."
sleep 1
# first line only: send batch, and get job ID
if [ "${iter}" == 0 ];then
# send the batch...
jobID=$(sbatch -J "Dyna" --array="${iter}"%15 runCurrentLine.bash)
# ...ensure that Slurm's output shows on console (which includes the job ID)...
echo "${jobID}"
# ...and extract the job ID and save as a variable
jobID=$(echo "${jobID}" | grep -Eo '[+-]?[0-9]+([.][0-9]+)?')
# subsequent lines: add current line to job array
else
scontrol update --jobid="${jobID}" --array="${iter}"%15 runCurrentLine.bash
fi
# prepare to move onto next position
iter=$((iter+1))
cd ../
done
This setup properly sends the batch job for the first line, at -0.25mm*. However, for the second line onwards, it doesn't seem to do the same thing... This is what I end up getting on my console:
*: I intended the "lat_xmm" folders to be numerically ordered, but Unix doesn't seem to recognize that
$ ./sendDynaRuns.bash
sending LS Dyna simulation for -0.25mm line...
Submitted batch job 1081040
sending LS Dyna simulation for 0.25mm line...
sbatch: error: Batch job submission failed: Invalid job id specified
sending LS Dyna simulation for -0.5mm line...
sbatch: error: Batch job submission failed: Invalid job id specified
I know that runCurrentLine.bash runs just fine if I manually send it as a batch (and it runs to completion within the time limit I specified in-file, mainly since it doesn't have to compete with other lines for open licenses). What should I do to be able to get my code to work?
Thank you in advance!
As state by #Poshi, you cannot add jobs to an existing array.
I would create a submission script like this one:
#!/bin/bash
#SBATCH --array=1-<nb of folders>%15
# ALL OTHER SLURM SBATCH DIRECTIVES HERE
folders=(lat_*)
foldernow=${folders[$SLURM_TASK_ARRAY_ID]}
cd $foldernow && ./runCurrentLine.bash
The only drawback is that you need setup explicitly the number of jobs the array based on the number of folders.

How do you make a threadGroup time not be taken in consideration of the total time

I have the following scenario:
Thread group1 - this sends requests to a server (lots of threads and iterations)
HTTP Request
Thread group2 - 1 thread 1 iterations
JSR223 sampler (has a while loop which periodically check if a number is 0) and collects some times
The scenario ends when threadgroup 2 finishes
I run the above scenario using the non GUI mode and i am interested in the RPS. (as shown below 222.0/s), but only for the first threadGroup.
summary = 50002 in 00:03:29 = 222.0/s Avg: 4151 Min: 38 Max: 797601 Err: 0 (0.00%)
Now, when the last threadGroup ends i will have:
summary = 50003 in 00:09:12 = 90.7/s Avg: 4136 Min: 38 Max: 797601 Err: 0 (0.00%)
The RPS is now low only because the last threadGroup takes very long to finish.
Is there any way the time from the last threadGroup can not be taken into consideration of the total time ? Or maybe another approach to this problem.
You can use jmeter.reportgenerator.sample_filter property in order to exclude your JSR223 Sampler from the report.
Run your test in command-line non-GUI mode like:
jmeter -n -t test.jmx -l result.jtl
The command to generate FULL results would look like:
jmeter -g result.jtl -o ALL-RESULTS
It will create ALL-RESULTS folder holding information on all the samplers
The command to generate results WITHOUT JSR223 Sampler would be:
jmeter -Jjmeter.reportgenerator.sample_filter="^((?!JSR223 Sampler).)*$" -g result.jtl -o FILTERED-RESULTS
It will create FILTERED-RESULTS folder with HTTP Request sampler only (or whatever else samplers, only JSR223 Sampler(s) will be excluded.
More information:
Generating Report Dashboard
Configuring JMeter
Apache JMeter Properties Customization Guide

Run thread groups concurrently but evenly distributed over time

I have a Test plan with several Thread Groups (TG) which have a different Loop Count.
Test Plan
|--TG 1: loop count=5
|--TG 2: loop count=10
|--TG 3: loop count=3
These thread groups are executed concurrently. However because the loop count of threads differ, some threads are finished while others are still running. What I would like is for JMeter to manage the execution of each Thread Group based on a ratio of the the highest Loop Count in the Test plan in order to create a more even time distribution and ensure all Thread Groups roughly end at the same time. For instance:
Test Plan
|--TG 1: loop count=5, execute every 2 occurrences of TG 2
|--TG 2: loop count=10
|--TG 3: loop count=3, execute every 3.3 occurrences of TG 2
In terms of execution, things would look like this:
[round 1] TG1: run | TG2: run | TG3: run
[round 2] TG1: wait | TG2: run | TG3: wait
[round 3] TG1: run | TG2: run | TG3: wait
[round 4] TG1: wait | TG2: run | TG3: run
etc...
Can I configure JMeter to acheive this, if so how?

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