My Jmeter test plan is setting a token variable using a Regular Expression Extractor (a Post-Processor element), but upon a while this variable is not expanded in its value and as consequent ${token} is sent to the REST API under actual test.
I added Constant Delay Timer elements in between each request a user (thread) sends and it seems to overcome the problem to a great extend but not entirely. I still get some Bad Request from the API side.
I provide a screen capture
And a second screen capture showing the full test plan (or a large portion of it)
Can someone please explain why this happening and somehow resolve it ?
It might be the case your Regular Expression Extractor fails to find the value therefore it falls back to the default (undefined) value of ${token}
My expectation is that under the load your application cannot properly respond, to wit response doesn't contain the token. You can double check it using Debug Sampler and View Results Tree listener combination.
You can temporarily enable saving of response data by adding the next lines to user.properties file:
jmeter.save.saveservice.output_format=xml
jmeter.save.saveservice.response_data=true
and next time you run your test in command-line non-GUI mode JMeter will keep response data for all samplers. You should be able to examine the responses and add a Response Assertion to ensure that the token is present in the POST LOGIN sampler response data
Related
I have a script in which I have 30 to 40 http samplers and say for sampler number 10 I'm getting like 80% samplers response as blank or null, due to which rest of the samplers below it are also getting impacted as the result of variable not getting extracted in the post processor.
The response time at the 90th% for the 10th sampler is around 25sec.
I want to know is there any thing which I can do in the script to avoid this blank issue or is it something which app server is sending as the result of not able to bear the load.
Will changing the response timeout in the HTTP request default to higher value say 5 Min will resolve the issue?
Please help
Thanks.
You might be interested in Extractor Success Assertion plugin which checks whether the variable(s) declared in the PostProcessor(s) still have(s) default value(s) and if nothing has been extracted - it fails the relevant Sampler.
So you could use any other "Action to be taken after a Sampler error" than Continue in your Thread Group to decide whether you want to start new iteration or stop the thread/test when the response is blank.
Extractor Success Assertion plugin can be installed (and kept up-to-date) using JMeter Plugins Manager
Measuring the load time of an ( web-based application)
When a user clicks on a link, the web-based Application sends a Request to the server
I have tried to take the above post request and loop it under While loop controller with a condition.
But the while loops just loops forever.
There are following possible origins for these requestId dynamic variable:
It may be present in response URL as the result of a redirection
It may be present in response headers
It may be present in response body
It is generated on the client side (browser) using JavaScript
In first 3 cases you need to correlate the value using a suitable post-processor, in 4th case you need to replicate the JavaScript code which is generating the value using JSR223 PreProcessor and Groovy language
We cannot comment anything on your While Controller issue apart from very obvious statement that the While Controller will execute its child(ren) until the variable or function which you put in the "Condition" are resolves to true, the evaluation result including any nested variables can be observed using i.e. Debug Sampler
I have extracted the value from the response and passing it through the next request. When I perform the test with minimum users e.g. up to 100 to 200 extracted values are passed to the next request properly. but during the scaling up the load to 500 to 1000, the variable name displayed as is in the request, not the extracted value. what would the reason and how to handle this?. because of this I am getting 502 bad gateway error.
If JMeter fails to extract the value from the response most probably it means that there is no value in the response, my expectation is that under the load your application fails to respond properly therefore extraction fails.
502 bad gateway error doesn't have anything in common with the variable extraction, it indicates that your application is experiencing issues under the load
with regards to "how to handle this" - store the response data for the previous sampler, it can be done by adding Simple Data Writer or Flexible File Writer as a child of that sampler, this way you will be able to inspect the output and figure out what's wrong with it.
If you want to save response data for all samplers - move the listener to the same level as the samplers or above, see Scoping Rules user manual chapter for more details.
Alternatively you can add next lines to user.properties file:
jmeter.save.saveservice.output_format=xml
jmeter.save.saveservice.response_data=true
jmeter.save.saveservice.samplerData=true
jmeter.save.saveservice.requestHeaders=true
jmeter.save.saveservice.responseHeaders=true
jmeter.save.saveservice.url=true
More information: How to Save Response Data in JMeter
I have made a TestPlan in JMeter. I want to test a failure scenario i.e. the test should pass if failure happens. How can I do this in JMeter?
I have added a Thread group, a configuration, an httprequest and a tree listener.
When I run the test (send a signin request of an invalid user), I get ab error from server (200 OK with error message as message body).
I can't find where (and how) I should check the response. Is it in Listeners?
The JMeter builtin solution is Assertions
Assertions are used to perform additional checks on samplers, and are processed after every sampler in the same scope. To ensure that an Assertion is applied only to a particular sampler, add it as a child of the sampler.
In a general case, Response Assertion with your expected text/regex
response assertion control panel lets you add pattern strings to be compared against various fields of the request or response. The pattern strings are:
Contains, Matches: Perl5-style regular expressions
Equals, Substring: plain text, case-sensitive
You also have more specific assertions as JSON Assertion
component allows you to perform validations of JSON documents
JMeter provides Assertions so you can conditionally fail the request if it doesn't contain the data you expect to be there and contains the data which should not be there.
For example this configuration checks the response for absence of error line:
Demo:
More information: How to Use JMeter Assertions in Three Easy Steps
Currently, I am recording a script in jmeter by which I am adding a record in a website , but a problem is that while recording a script I am able to add a record in a website, but once recording has been done and after that if I will run a script again then, a script is not adding a record in a website.
can you please help me with this?
In the absolute majority of cases you will not be able to replay the recorded script without performing correlation.
Modern web applications widely use dynamic parameters for session management or CSRF protection so once you record your test you get "hardcoded" values and they need to be dynamic.
Assuming all above my expectation is that your test doesn't add record due to failed login or something like that. Inspect requests and responses using View Results Tree listener - this will allow you to identify which exact step is failing.
The process of implementing the correlation looks as follows:
Identify the element which looks to be dynamic either manually inspecting request parameters and look for "suspicious" patterns or record your test one more time and compare the recorded scripts looking for the parameters which differ
Inspect previous response and extract the dynamic value using a suitable post-processor. For HTML response times the best option is CSS Selector Extractor. It will allow you to extract the dynamic parameter value and store in into a JMeter Variable
Replace hardcoded recorded value with the variable from the step 2
Repeat for all dynamic parameters
Don't forget to add HTTP Cookie Manager to your Test Plan.