jmeter cache doesn't clear in the next iteration - performance

I've faced the problem that JMeter doesn't clear the cache and extract variables in the next loop iteration, ruining the following request in the next loop.
problem itself
I tried check-box 'Clear cache each iteration.
Then I turned off the cache manager at all, but at the beginning of the next loop, I noticed that variables were left from the previous one.
1-2
I even ad the pre-processor at the beginning of the scenario to remove all variables and clear the cache. Didn't help.
3

JMeter does clear the cache, here is the evidence:
As you can see
when the box is ticket both requests download embedded resources
when the box is not ticked 2nd request only fetches HTML DOM, no requests to embedded resources are made
So most probably your expectations regarding how HTTP caching should work are a little bit wrong.
Also JMeter doesn't "clear" any defined variables so you might see "old" values during the next iteration, if you have Logic Controllers which rely on certain variables presence - you need to reset the values manually somehow.

Have spoken with my colleague about it and he said that it's well-known bug in JMeter.
More details are described here:
https://groups.google.com/g/jmeter-plugins/c/3RU_O9JXiYw/m/aovwl1SuAQAJ?utm_medium=email&utm_source=footer&pli=1

Related

Jmter, duplicate list of sample result

I had recorded the script using blaze meter plugin, and using ultimate thread group, I am not able to figure out:
Why there is delay in sending first request? I have not set any delayed and start-time is also for 1 second
Also in my result tree I am seeing multiple http requests called. What am I doing wrong here?
We are not telepathic enough to guess why do you have the "delay" without seeing your test plan, most probably there is something like "Think-Time" or other Timer there
having non-zero "Thread Delay" value. This is to simulate real user using the real browser. Real users don't hammer the application under test non-stop, they need some time to "think" between operations so most probably this delay is due to the timer action
If you look at Defaults configuration element at the "Advanced" tab there is a setting instructing JMeter to download so-called "Embedded Resources". In the main HTML response there are multiple referenced elements like images, scripts, styles, fonts, sounds, etc. and JMeter parses the main HTML response, extracts these resources from there and downloads them as this is what real browsers do.

How to clear cache for a sampler in JMeter

I have a jmeter script where I need to open a page multiple times. Hence, I kept this action under loop controller. What I observed is the response time of loading page is decreasing for every iteration. This could be due to caching. Can anyone help me on how to clear cache for this sampler after every iteration (I am referring to loop controller iteration here not thread group one).
Your requirement doesn't really make a lot of sense as well-behaved JMeter test should represent a real user using a real browser and real browsers caching strategy assumes minimizing the amount of downloaded assets by obeying Cache-Control headers
If you're aware of this good practice and still want to discard the cache for each iteration:
Add JSR223 PreProcessor as a child of the HTTP Request sampler which cache you want to clear
Put the following code into "Script" area:
sampler.getCacheManager().clear()
You can use HTTP Cache Manager in JMeter and check this checkbox to Clear cache each iteration?. You can follow the page to learn more about this. This applies to all the requests in the current thread. I know this is not what you are looking for but JMeter has only this option as UI setting.
Another way can be to use Beanshell PreProcessor to intercept the request and clear the cache on the run.
import org.apache.jmeter.protocol.http.control.CacheManager;
CacheManager clearCache = ctx.getCurrentSampler().getProperty("HTTPSampler.cache_manager").getObjectValue();
clearCache.clear();

Can I cache a cfldap query?

If I cannot, is there a scope that will make the same cfldap query available to all users? I'm just trying to cut down on the number of times it is called, since it's a cross-server call.
Step 1 - write some code that gets your ldap data and persists it somewhere. This could be a database, text file, or perhaps even a ColdFusion variable in the server scope.
Step 2 - Schedule that code to run at whatever frequency is good enough for your requirements.
The reason I mentioned server scope instead of application is that I'm not sure how hard it is to write application variables using scheduled jobs. I've never had a reason to try.

JMeter - Why is my variable being re-evaluated midway through my test?

I posted this question originally in a much more complicated way, but I've reproduced the issue more simply now so I'm extensively editing my post.
I have a simple Test Plan to exercise an API.
The first thing it does is create a session with a simple HTTP POST. We then extract the session ID from the response using the JSON Path Extractor plugin:
This reads the newly created session's ID into a variable called id_JSON, and subsequent PUT requests use the session ID in their path, i.e. /api/sessions/${id_JSON}/account.
This generally works well, but I have noticed that intermittently, id_JSON will suddenly have the default value NOT_FOUND. Samples will fail and when I look at the request, I can see that it was trying to hit /api/sessions/NOT_FOUND/account instead of a valid ID. What's really confusing me right now is that this will happen after requests have already successfully referenced ${id_JSON} and generated a valid path. It seems like this should be impossible, unless the value of id_JSON was being dynamically checked or looked up repeatedly - otherwise how is it coming up with a different value from one request to the next?
It seems that if any Sample fails, for any reason, subsequent requests in the same thread iteration all fail with id_JSON having the default value NOT_FOUND.
Do I need to declare or manage the variable id_JSON in any special way to ensure that it will get the value of the session ID and retain it throughout the thread iteration, until the next iteration overwrites it with the next session ID?
The Extractor is a Post Processor, meaning it is applied after each sampler. So in you case it will run on the First Get and the 4 Puts.
So what you are noticing is absolutely regular, and if a Sampler fails, the extractor will fail to extract the ID and put NOT_FOUND in value.
If you are sure it does not change, then just put the Post Processor as a child of the first HTTP Request called "Create Session", it will then only run for it and the variable will not change anymore.
You can read more on this at:
http://jmeter.apache.org/usermanual/test_plan.html#scoping_rules
"Go to next loop iteration" operates on Thread Group level.
Using any nested loop controllers doesn't increment global iteration counter. You can test it with either:
${__BeanShell(vars.getIteration();)} function - if you use vanilla JMeter
iterationNum function - if you use JMeter Plugins
So if you move your "looping" on Thread Group level and remove nester Loop Controller(s) (or set their loop count to 1) your approach should work as you expect it to do.

jMeter Multiple HTTP Requests

I want to test a fully functioning website for load using a constant, known number of users - to that end I'm trying to recreate the "Retrieved All Embedded Resources" functionality for a web-page, only manually, because I really don't know if it fetches all resources grabbed by JS. So the first question is - how do I check to see what these subsequent fetches retrieve?
Second question is - how do I make the multiple requests atomic, like "Retrieve All Embedded Resources"? I need to use "Constant Throughput Timer" for making sure the number of vusers is constant, but:
When using "Retrieve All Embedded Resources", this counts as one request, and one thread handles it right (hopefully, again - can't tell what goes on beyond the scenes)
When using a recorded session with numerous elements, each element is one action and occupies the queue (counts as 1 sample for Constant Throughput Timer). Therefore, it's not atomic.
I guess I can count the elements and define them as number of samples for throughput per minute, but this won't do in the long run.
First of all, jmeter does not execute any javascript in the pages retrieved. Clicking "Retrieve all embedded resources" does the following if you check the documentation:
Tell JMeter to parse the HTML file and send HTTP/HTTPS requests for all images, Java applets, JavaScript files, CSSs, etc. referenced in the file.
So it will check the current sample for any references and retrieve those, but it will not run any scripts that are retrieved.
If you want to check which resources jmeter is actually retrieving you could run for example Fiddler to check which requests are being made.
You can use Transaction Controller to consider all embedded resources requests and master request as one sample, aggregate time will be logged and reported.

Resources