How to perform Manual step in JMeter and resume test - jmeter

Can I perform a test that will stop in some step, and after I perform something manually in my system I will tell Jmeter to resume running the test?
is it possible in JMeter to pause a test in the middle and then to resume it?

I don't know about out of the box solution in JMeter, so you need to add such logic yourself.
For example you can do a While controller with a variable set to true at start, inside loop read from file until it's value is false and then exit loop and resume test. You can even use StringFromFile function as ${__StringFromFile(flagResume.txt,,,)}
In your manual operations add to file the value false, and then the JMeter test will resume.

What is the nature of the task you need to do manually? I'm pretty much sure that it is doable via JMeter itself, JMeter Plugins or Groovy Scripting.
If I'm wrong or you have a very specific scenario one of possible solutions would be adding Constant Throughput Timer to your Test Plan and define desired Requests per Minute rate using JMeter Property via __P() function
Whenever you need to "stop" the test you can set the "throughput" property to 0 using i.e. Beanshell Server

Related

JMeter override timers / reduce timer for certain step in larger scope

I am running a JMeter scenario which has a certain think time applied for the entire scenario.
During one small loop in this scenario, I wish to decrease the think time between each sampler. E.g., if the default scenario think time, for all samplers, is 500ms, I wish to make this one small loop have a think time of only 100ms.
It does not seem like this is possible, but I also don't see any other questions asking this. Does anyone know of a workaround to accomplish what I am trying for?
This line in the JMeter docs suggests that this is not possible:
Note that timers are processed before each sampler in the scope in which they are found; if there are several timers in the same scope, all the timers will be processed before each sampler.
https://jmeter.apache.org/usermanual/component_reference.html#timers
You can do the following:
Declare a JMeter Variable to hold the default think time somewhere in User Defined Variables
In all Constant Timers (or in the one if it's applied to all the Samplers) set it to use the JMeter Variable from the step 1:
Before entering your "small loop" add a JSR223 PostProcessor to the last Sampler and put the following code into "Script" area:
vars.put('think-time', '100')
In the above code vars stands for JMeterVariables class instance, see Top 8 JMeter Java Classes You Should Be Using with Groovy article for more information if needed.
Before exiting the "small-loop" do the reverse thing and restore the original value of the think time

JMeter: thread switching between variables for preset time periods throughout a test run

I have a script with a once only loop where a thread uses reg expression extractor to get a variable into an array. After the once only loop, the thread selects a random instance of that variable and then continues with that instance of the variable for the entire test run.
It would be more realistic for the script to do the following:
Jmeter thread uses variable_1 for x seconds, switch to variable_2 for x seconds, switch to variable_3 for x seconds
Variables_1,2,3,x coming from the reg ex array should be selected randomly
x seconds could be 300, 600, 1200 and selected randomly
Is this something that can be accomplished with JMeter controllers/functions or would it require something along the lines of custom beanshell code?
It can be done using ForEach Controller & Runtime Controller.
For Each controller is to iterate the variables one by one.
Under Runtime controller, you keep all your samplers to be executed for the duration.
Test Plan:
For Each Controller config:
Runtime Controller config:
I would recommend reconsidering your approach as this way you test won't be repeatable. The whole idea of testing is that when you run the test 2 or more times - you should get the same results, elsewise if you discover a product issue you won't be able to reproduce it to ensure that it is fixed.
Coming back to your question: yes it can be done via JMeter Test Elements without having to go into scripting. Take a look at __chooseRandom() function available via JMeter Plugins project. The easiest way of installing JMeter Plugins and keeping them up-to-date is using JMeter Plugins Manager

Disable/Enable all Test Action controllers in JMeter test

I have placed many DIFFERENT think times (pauses) in JMeter test. In this way I am trying to simulate real user think times, because at different places user will need different times to think/wait. Sometimes he will need 5 sec to figure out his next action, and sometimes he will need 15 sec. As I manage to check Test Action Controllers are the only way for me to do this. BUT, my problem is that while I am creating/repairing test I don't want to wait for all these pauses when I run the test just to check whether my change is passing. I want some way to easily disable all Test Action controllers during creation of test, and then when I want to run real test with bunch of concurrent threads then just to easily enable all pauses.
You first modify your Test Action this way:
Set sleep to 0
Add as a child to each one a Timer with pause you want
Then
There is a menu called Start no pause in the GUI which is here exactly for this need:
http://www.ubik-ingenierie.com/blog/jmeter-new-gui-features-to-increase-your-productivity/
There is also since 3.0 a "Validation Mode" that you can acces by right click on Thread Group and select validate
https://jmeter.apache.org/changes.html
I believe the easiest way of doing it is running your test via Taurus tool. It has possibility to enable/disable Test Elements basing on their names so you will be able to switch your Test Actions samplers on and off.
See Modifications for Existing Scripts chapter for more details.
Example Taurus YAML config to disable Test Action samplers. Save it as i.e. test.yml in the same folder your .jmx script lives
---
scenarios:
modification_example:
script: test.jmx # Name of your original JMeter test script
modifications:
disable: # Names of the tree elements to disable
- Test Action
execution:
- scenario: modification_example
Running bzt test.yml -gui command will open JMeter GUI with modifications applied.
Taurus entry level information: Navigating your First Steps Using Taurus
Don't waste your time trying "Run no pauses" and "Validate" options, the guy doesn't seem to know how does JMeter work.
All right, here's JMeter-only solution via Beanshell Sampler
import org.apache.jmeter.gui.GuiPackage;
import org.apache.jmeter.gui.tree.JMeterTreeNode;
import org.apache.jmeter.sampler.TestAction;
GuiPackage guiInstance = GuiPackage.getInstance();
guiInstance.getTreeModel().getTestPlan();
List testactionlist = guiInstance.getTreeModel().getNodesOfType(TestAction.class);
for (Object testAction : testactionlist) {
JMeterTreeNode testActionSampler = (JMeterTreeNode) testAction;
testActionSampler.setEnabled(false);
}
I used Test Actions because I did not understand how timers are working. I thought they are always applied to all samplers (which is not true). I can easily accomplish what I want with constant timer. So using test actions wasn't a must. I will just add constant timer to specific sampler and it will be applied only to this sampler. Sorry if I made confusion with a way I asked the question :(
If you open the test in any text editor you will see all the test actions like
you can easyly find & replace all " testname="Test Action" enabled="true" " to enabled="false"

pause and resume jmeter execution

I am looking for an option to pause and resume JMeter execution (single/multiple threads).
1. Pausing and Resuming through command line
2. From the Jmeter UI
3. By coding in some language in a sampler of Jmeter
4. Using a JMeter plugin
Any of the above methods is fine.
Any thoughts and solutions are greatly appreciated.
I would suggest going for Constant Throughput Timer
Despite word "constant" in its name, you can use i.e. JMeter Property via __P() function as "Target Throughput" value.
Command-line: you can pass this property value via -J command-line argument like:
in JMeter define i.e. throughput property as: ${__P(throughput,)}
"tell" property value to JMeter as jmeter -Jthroughput=100 -n -t ....
There is no way to do it from JMeter GUI without restarting the test. In general it is not recommended to run JMeter test in GUI mode.
You can also amend the property value during the runtime
for example from Beanshell Test Elements using the following script:
props.put("throughput", "300");
using Beanshell Server
I'm pretty much sure that you'll receive a number of suggestions to use Test Action sampler from not very competent people who didn't bother to familiarize themselves with documentation which states:
TargetCurrent Thread / All Threads (ignored for Pause)
So please don't waste your time on the Test Action sampler
I suggest you follow the suggestion made by Oliver E. on user mailing list:
http://mail-archives.apache.org/mod_mbox/jmeter-user/201607.mbox/%3cCAK4Z_0AJ2c0_L==ByfgZ16FGgkyT5S9UnzboOaj3qc9PU94LSQ#mail.gmail.com%3e
Regarding your questions:
1/ follow 1 + 3 as per Dmitri Answers
2/ not possible yet :)
3/ Follow mailing list answer
4/ Not possible

How to stop jmeter during runtime based on coditions?

I wanted to stop jmeter if my conditional logic is false,suppose if one of my conditions gets failed then i need to stop immediately all my threads(jmeter) during run time,so that is there any way stop it running time through code not manually(not thru action to be taken after a sampler error)
Thanks,
in advance
There is 2 options for you:
If your condition can be expressed in If Controller, then use standard Test Action Component to stop test
If you want to stop test when response time or error rate increases some threshod, then use custom AutoStop Component

Resources