JMeter - HashMap / LoopController Exception log - jmeter

What is the main cause of the following error log?
2015/09/09 10:47:42 ERROR - jmeter.threads.JMeterThread: Test failed!
java.lang.StackOverflowError at
java.util.LinkedHashMap$EntryIterator.(LinkedHashMap.java:412)
at java.util.LinkedHashMap.newEntryIterator(LinkedHashMap.java:419)
at java.util.HashMap$EntrySet.iterator(HashMap.java:1078) at
java.util.Collections$SynchronizedCollection.iterator(Collections.java:1632)
at
org.apache.jmeter.testelement.AbstractTestElement.recoverRunningVersion(AbstractTestElement.java:499)
at
org.apache.jmeter.control.GenericController.reInitialize(GenericController.java:131)
at
org.apache.jmeter.control.GenericController.nextIsNull(GenericController.java:257)
at
org.apache.jmeter.control.GenericController.next(GenericController.java:175)
at
org.apache.jmeter.control.GenericController.nextIsAController(GenericController.java:229)
at
org.apache.jmeter.control.GenericController.next(GenericController.java:180)
at
org.apache.jmeter.control.GenericController.nextIsAController(GenericController.java:226)
at
org.apache.jmeter.control.GenericController.next(GenericController.java:180)
at
org.apache.jmeter.control.GenericController.nextIsAController(GenericController.java:226)
at
org.apache.jmeter.control.GenericController.next(GenericController.java:180)
at
org.apache.jmeter.control.LoopController.next(LoopController.java:123)
at
org.apache.jmeter.control.LoopController.nextIsNull(LoopController.java:151)
{repeats for the next ~ 900 lines}
My test plan looks as follows:
Testplan
- Authentication Transaction Controller
- Forever Loop
- Random Order Controller
- Simple Controller A
- Only Once Controller
- Parameterized Controller
- Module Controller (to "Simple Controller 1")
- For Each Loop (loops variables set by "BeanShell Post Processor 1")
- Module Controller (to "Simple Controller 2")
- Simple Controller B
- Simple Controller C
Disabled Thread Group
- Simple Controller 1
- Transaction Controller
- HTTP Request
- BeanShell Post Processor 1 (for JSON Extraction)
- Simple Controller 2
- Transaction Controller
- HTTP Request
- BeanShell Post Processor 2 (for JSON Extraction)
Note: I am handling with user variables a lot.

My expectation is that the problem lives somewhere in your Beanshell PostProcessors, for instance there is some code which causes endless loop or something. If you could post response and Beanshell PostProcessor code I could be more specific. For now I can recommend the following:
Consider switching from Beanshell PostProcessors to JSONPath Extractor if extracting JSON is their only duty
If not - in general it isn't recommended to use Beanshell as it has some known performance problems and it's abandoned for > 10 years. Switch to JSR223 Post Processors and groovy language instead. Groovy is even more Java-compatible than Beanshell so if you didn't use anything Beanshell-specific you won't have to rewrite a single line of code. See Beanshell vs JSR223 vs Java JMeter Scripting: The Performance-Off You've Been Waiting For! for Beanshell versus JSR223 benchmark, installation instructions for groovy scripting engine and scripting best practices.

Related

In Jmeter vars vs props for while controller

Before test, I added x variables to TestPlans,
After I run test as 10 thread 10 seconds ramp up
In while controller for condition that
${__javaScript("${x}" != "",)}
In beanshell:
vars.put("x","");
Normally, each thread occured 1 second, First thread changed x variable as "", therefore another threads don't meet if condition. why do threads get looped though ?
Note: Other threads did not start testing when using property instead of variable.
As per JMeter documentation:
Properties are not the same as variables. Variables are local to a thread; properties are common to all threads
so when you do vars.put("x",""); you change x variable value only for the current thread, other threads have their own values of the x variable.
If you want to amend the value so it would be visible for all threads - you will have to:
Change vars.put("x",""); to props.put("x","");
In the While Controller ${__javaScript("${__P(x,)}" != "",)}
Also: since JMeter 3.1 it's recommended to use JSR223 Test Elements and Groovy language for scripting so it worth considering migrating (the same applies to __javaScript() function in the While Controller), more information: Beanshell vs. JSR223 vs. Java For JMeter: Complete Showdown

JMETER - How can I pass 2 condition in a while loop on Jmeter

How can I pass 2 condition in a while loop on Jmeter. The conditions are
The request should run in loop till "Pass" response comes.
While loop should run only for 1 minute.
Condition 1 is working fine. However condition 2 is unable to implement.
I have tried running the While Loop inside a Runtime Controller. But the issue is, if the response "Pass" comes before 1 min, the rest of the test stops.
Tried other way round (Runtime inside While Loop) leading to numerous execution of the request, even after receiving "Pass" response.
Will appreciate any leads on this. Thanks
Add a JSR223 Sampler just before the While Controller and store the current time into a JMeter Variable using the following code:
SampleResult.setIgnore()
vars.putObject('whileLoopStart', System.currentTimeMillis())
Use the following __groovy() function as the While Controller's condition:
${__groovy(!vars.get('your_variable').equals('Pass') && ((System.currentTimeMillis() - vars.getObject('whileLoopStart')) < 60000),)}
This way the While Controller will run until:
either your_variable is not equal to Pass
or 60 seconds pass
whatever comes the first
More information on Groovy scripting in JMeter: Apache Groovy - Why and How You Should Use It
This could be another solution.
You can achieve the desired outcome with the following components.
Runtime Controller
If Controller
Flow Control Action
Set the Runtime (duration) in the Runtime Controller
Set the first condition you already have in While Controller in the If Controller
Click the Break Current Loop to exist from the Run Time controller

JMeter structure warmup

My project structure in JMeter is now:
But there are some limitations:
A lot of duplicate transaction/module controllers
The only once controller is not working with the UltimateThreadGroup
Its not possible to use the setUp thread, because the cache is not shared between threads
The time from the warmup is different, i cant use the offset in my Synthesis Report
What is a better structure to skip the warmup (first threadrun) from my results?
If you want to just remove 1st execution of each sampler for each thread (virtual user) you can play the following trick:
Add JSR223 PostProcessor as a child of the request you want to ignore (or according to JMeter Scoping Rules if you want to remove the first execution of other samplers)
Put the following code into "Script" area:
if (vars.getIteration() == 1) {
prev.setIgnore()
}
where:
vars - is a shorthand for JMeterVariables class and getIteration() function returns the current Thread Group loop number
prev - is a shorthand for the SampleResult class and setIgnore() function tells JMeter to discard the result

Jmeter how to simulate a failure based on results of a condition fro Post Processor

I have a situation where I check the response data and if there is a specific variable exist then I like to simulate a test failure even though that HTTP req code was 200. For example in Bean Post Processor I have:
if ( (prev.getResponseDataAsString().indexOf(Z2) >= 0) || (matches > 1) ){
System.out.println(ctx.getCurrentSampler().getName() +" --> Failed ....")
}
I know how to do it when I want to set the result to success (prev.setResponseOK();) how do I do it if I want to set it to fail? so the GUI shows red and not green?
Thank you
See in JSR223 Sampler
Unlike the BeanShell Sampler, the JSR223 Sampler does not set the ResponseCode, ResponseMessage and sample status via script variables. Currently the only way to changes these is via the SampleResult methods:
SampleResult.setSuccessful(true/false)
prev is a SampleResult object so you can mark it as failed:
prev.setSuccessful(false)
prev - (SampleResult) - gives access to the previous SampleResult
Sounds like a use case for a Response Assertion which you can use in order to conditionally set pass/fail criteria for a Sample basing on presence/absence of certain patterns in the response data.
Here is an example of failed HTTP Request sampler with 200 status code due to absence of the anticipated data in the response:
See How to Use JMeter Assertions in Three Easy Steps for more details.
With regards to JMeter Best Practices which you're violating by the way by using Beanshell PostProcessor:
You should be using built-in JMeter test elements where possible
If you have to go for scripting make sure to choose the most performing option which is unfortunately not Beanshell

Thrift API load test

I am new into Apache Jmeter. Basically I want to load test our couple of thrift APIs but have no clue where to start with. It is in java where api takes 2 parameter and then send java object as response.
Any pointer would be very helpful.
JMeter isn't especially for it but it's flexible enough to support your use case.
There is an extensibility mechanism which uses BeanShell. JMeter provides BeanShell Sampler which is capable of invoking Java code, including using external jars.
Simple usage:
Start with empty JMeter project
Create a Thread Group with all defaults (you can play with number of threads, ramp-up, etc)
Add a BeanShell Sampler with following code:
Thread.sleep(2000L);
Add View Results Tree listener
Save and run
You should see a green triangle (or triangles) basing on your number of threads and loops) with output like following:
Thread Name: Thread Group 1-1
Sample Start: 2013-11-02 14:48:11 GMT+03:00
Load time: 5030
Latency: 0
Size in bytes: 0
Headers size in bytes: 0
Body size in bytes: 0
Sample Count: 1
Error Count: 0
Response code: 200
Response message: OK
If you use any of techniques to analyze results, i.e.
JMeter embedded listeners like Aggregate Report, Summary Report, Graph Resuls, etc.
Storing results to CSV file and opening them with Excel or equivalent (see jmeter.properties file under /bin directory of your JMeter installation. Properties prefix is "jmeter.save.saveservice."
JMeter Ant Task (see Test.jmx and build.xml in /extras folder under your JMeter installation)
JMeter Results Analysis Plugin
You'll see your request(s) success rate, min/max/average times (something like 2 seconds I guess) and some more information (depending on your configuration).
Particular your use case assumes
IMPORTANT Placing thrift (or whatever) jars under lib/ext folder (or you won't be able to access your APIs
importing classes you need to test somewhere in BeanShell Sampler
import yourpackage.YourClass;
Invoking methods you want to test from BeanShell Sampler
(optional) do some assertions on responses. i.e.
if (yourresponse != yourexpectedresponse){
IsSuccess=false;
ResponseMessage= "Test Failed";
}
Hope this helps
You can use JSR223 Sampler + Groovy (add groovy-all.jar in jmeter/lib) and look at this client example, see NonblockingClient code for an example:
http://www.javacodegeeks.com/2012/03/apache-thrift-quickstart-tutorial.html
Make your groovy code call a least the following at end:
SampleResult.setSuccessful(true/false)
SampleResult.setResponseCode("code")
SampleResult.setResponseMessage("message")
See:
http://jmeter.apache.org/usermanual/component_reference.html#JSR223_Sampler
And of course, ensure you add the required dependencies in jmeter/lib.
I have writtena CustomThriftSampler for JMeter to load test HBase through thrift service. You can get the details about it at my blog - http://1-st.blogspot.in/2013/12/load-testing-thrift-services-custom.html . Couldn't create a generalized code. Anyway its simple and starightforward java code. Anyone could try it. If time permit I shall write a generalised code and commit to github!!

Resources