Using AJAX script with JMeter - ajax

I am currently working to create test samples for an in-house Java web site using Jmeter for performance testing.
After creating / recording some scripts and re-running them, I found that some scripts are failing (not HTTP failures, the response code was 200 so it was a successful HTTP Response, but looks like server side failures) with an error "Unexpected error occurred, Page is closed". I could not figure out exact reason even after enabling high traces for this application.
I found that this web site is using lot of AJAX Requests for every sample I have collected (or most of them) and they are all recorded with samples ending with ".js". After doing a lot of google search about this issue with Jmeter, I found that Jmeter does not run Javascripts as this is not a browser.
Fair enough, went through some more details and read many solutions that talk about using Selenium web driver to run java scripts and can be used with jmeter to tackle this issue. But none of them talks about exact implementation of webdriver for running javascripts (or Ajax scripts) and having Jmeter running HTTPS Samples.
My Question is two fold:
1) How else I could debug my Jmeter scripts to confirm these errors are caused by Ajax scripts and nothing else and if not Ajax issues, what else is causing this "page closed error"
2) and how do I run web driver for Java scripts and JMeter running http samples in the same test scripts?
Any help or pointers towards a related document is really appreciated. Currently I am completely stuck and don't have any solutions that I could find reading through manuals.

In fact you have 2 choices:
Use WebDriver Sampler to perform real browser testing (this might be very resource intensive as real browsers consume a lot of CPU and RAM)
Use JMeter to execute AJAX calls. JMeter cannot execute JavaScript, but JavaScript-driven HTTP requests can be recorded using i.e. HTTP(S) Test Script Recorder and replayed as JMeter HTTP Request samplers. You will need to apply some custom configuration in order to execute AJAX requests in parallel, check out How to Load Test AJAX/XHR Enabled Sites With JMeter article for details.

Related

Important - Jmeter -UI endpoint - response time deferring from developer tool response time

For performance testing testing Jmeter UI - endpoint - response time deferring from developer tool loading time
Ex Jmeter - endpoint response time is 615 Ms where in developer tool shows (Load: 13.30 s) Finish: 18.98 s
Note : Jmeter capturing 35 backend call/ Developer tool capturing 104 backend call
why jmeter couldn't capture all developer tool backend calls?
why jmeter couldn't capture all developer tool backend calls? do we have any solution for this issue
As per JMeter project main page:
JMeter is not a browser, it works at protocol level. As far as web-services and remote services are concerned, JMeter looks like a browser (or rather, multiple browsers); however JMeter does not perform all the actions supported by browsers. In particular, JMeter does not execute the Javascript found in HTML pages. Nor does it render the HTML pages as a browser does (it's possible to view the response as HTML etc., but the timings are not included in any samples, and only one sample in one thread is ever displayed at a time).
So apart from configuring JMeter to behave like a real browser when it comes to handling embedded resources, cookies, think times and so on you need to pay attention to the nature of the requests which are being called when you open the page in the browser.
If the request is created by JavaScript, i.e. it's an AJAX call JMeter won't make the request automatically when you open the page. However you can record it using JMeter's HTTP(S) Test Script Recorder and run after the main request. The cumulative response time can be measured using Transaction Controller
Check the Retrieve All Embeded Resources in Advanced tab of the http sampler and see what is the difference.
Times will be always slightly different between dev tools and Jmeter or between JMeter and other performance tools like Gatling for example.

Non Http Response code: url fail to respond Jmeter

Today i got issue Non Http Response code when run script on Jmeter. My script run over some steps (Login - view) but got this issue and have log that issue at NoHttpResponseException.
I'm using Jmeter version 3.3. And I think that maybe this issue from server side, not by my script.
Does anyone fix this issue before? Please support me to resolve it.
This status code is being returned when an Exception occurs during HTTP Request sampler execution. There are hundreds or thousands of possible exceptions and even more potential causes for them.
If it occurs only under the load - most probably it's a server side error and you need to check the application under test logs and monitoring software results to identify the cause
It might be something described in the Connection Reset since JMeter 2.10 ?
It might be the case your JMeter script is badly designed/implemented and you're sending garbage instead of proper HTTP request
So try to collect as much information as you can:
Application under test and JMeter logs (it includes any middleware such as reverse proxies, load balancers, databases, etc.)
Application under test and JMeter machines health metrics (CPU, RAM, Network, Disk, Swap)
Network layer information, i.e. HTTP Request and response details.
Also be aware that according to JMeter Best Practices you should always be using the latest version of JMeter so consider upgrading to JMeter 5.0 (or whatever is the current latest JMeter version available at Downloads page) as soon as it will be possible.

Jmeter - How to load test ajax web applications by multiple users with cache

I have been using Jmeter for performance testing my web application. I have recorded the jmeter script by excluding js,css and other static content files.
While running the script, Jmeter doesnt execute javascript files so ajax XHR request are not sent. To overcome this i have recorded the script with js, css and other static content and it recorded all the Ajax xhr request too. But the performance results seems to be different from the browser loading time. Also i need to use cache during my performance testing.
Below is how my test plan will look like,
Included Retrieve all embedded resources in HTTP Request manager.
Concurrent pool size is 6
I have added HTTP cookie manager and Cache manager.
I have added a loop controller (This is for caching, jmeter will cache the files on first iteration and it will use the cached files
after that)
The problem i am facing is that the time taken for rest call are double the time shown in the browser console for single user. I have tried all other combinations but always i am getting higher time than the browser console.
I have tried to use the Selenium webdriver plugin to simulate the browser behavior but it doesnt seems to be using the cache. (https://www.blazemeter.com/blog/how-load-test-ajaxxhr-enabled-sites-jmeter)
Is there any other way to solve this problem? I want to take the metrics with cache so kindly suggest me any solution that must include cache. Or is there any other tool similar to jmeter that could solve this issue. My goal is to take web page load time with cache for 'n' number of users.
PS : I am even interested to write any scripts in jmeter but the scripts should not overload the performance of jmeter.
Thanks in advance.
You should not be recording calls to embedded resources (images, scripts, styles, fonts, etc.) as if you record them - they will be executed sequentially while real browsers do this in parallel. So remove recorded requests for the embedded resources and "tell" JMeter to download them (and do it in parallel) using HTTP Request Defaults
You should be recording AJAX requests, however real browsers execute them in parallel while JMeter runs them sequentially. In order to make JMeter's behavior closer to real browser you need to put these AJAX calls under the Parallel Controller
You can install the Parallel Controller extension using JMeter Plugins Manager
Jmeter and caching are unrelated - everything that happens after data went over the wire is out of scope by design. You should only ever simulate requests that you expect NOT to be cached. So this is the feasible part: drop all requests that you expect the browser to cache from the Jmeter script (or move them outside the loop). On the load time of XHR: the browser will most certainly use HTTP keepAlive. Result is that all requests except the very first skip the setup and teardown phase of TCP sockets and are much faster - esp. when the request itself is small and quick. You can simulate this in JMeter also by checking the KeepAlive option AND selecting http commons as implementation. You can read up on this in the docs here: http://jmeter.apache.org/usermanual/component_reference.html#HTTP_Request

Angular 4 performance & stress test

I am looking for a way to performance and stress test my SPA.
I prefer an open source(free) tool to do so.
I have searched quite a lot(https://www.blazemeter.com/blog/how-load-test-ajaxxhr-enabled-sites-jmeter) about the possibility to use Jmeter but i am still not sure if it is possible as this is an SPA and Jmeter works on the protocol level.
JMeter is not a browser as such it will not:
play URLs called through javascript.
report time taken in UI by javascript to display it
But the good news is that you can record all requests at HTTP protocol level,
all requests will be nested inside a Transaction Controller.
JMeter will play them sequentially and not in parallel.
So:
response time will be sum of Main + child requests response time
Load simulation will not be highly impacted as parallelism due to load testing will be simulated
There is also JMeter Webdriver Sampler that allows you to use a Real Browser
So by combining both approach you should be able to:
- Simulate load on your target application
- Have an idea of User Experience response times through JMeter Webdriver Sampler
You can install both plugins using JMeter-Plugins plugin manager plugin.
Note there is a 3rd party plugin that provides parallel execution if you want the parallel execution but I'm not sure it's needed:
https://github.com/Blazemeter/jmeter-bzm-plugins/blob/master/parallel/Parallel.md

Jmeter & browser concurrent requests showing different results?

When I have given 500 concurrent users load via jmeter my server throwing error message but the same time I have called same request via browser showing proper response. How it is possible? Is there any settings in jmeter for avoiding same.
It is hard to say what can go wrong without seeing your JMeter configuration, full server response, JMeter and application under test logs and network dump for browser and JMeter.
The whole idea of performance testing is mimicking real user as close as possible, so you need at least
Add HTTP Request Defaults and set JMeter to:
Download embedded resources
Use concurrent pool of 2-5 threads
Add HTTP Cookie Manager
Add HTTP Cache Manager
Add HTTP Header Manager
Correlate any dynamic parameters
Simulate any specific application behaviour (i.e. AJAX calls)
etc.
In addition to above recommendations: ideally given "good" JMeter you shouldn't see any "response messages", you should see a number of errors in final report so double check you:
Run JMeter in non-GUI mode
Storing only those metrics which are absolutely required
Follow other recommendations from 9 Easy Solutions for a JMeter Load Test “Out of Memory” Failure
beside, what Dmitri described above, I would also check the actual throughput the server returns in either cases.
Throughput depends a lot on the timers you configured in Jmeter to simulate think time.
Jmeter has no rendering and no javascript engine, so each thread is much much faster than a real browser.

Resources