Jmeter - Using GET/POST with single call - jmeter

For the purpose of my test, i need to test the same endpoint is capable of using both GET/POST http method. What is the easiest way, how i can do it without creating duplicates of the script?

You can normally parameterize the HTTP request method by creating a simple CSV file with the following contents:
method
GET
POST
once done you can add a CSV Data Set Config element and set it up like:
and in your HTTP Request sampler just use ${method} JMeter Variable
That's it, you can now run your request and it will hit the endpoint twice using different methods:

Related

How to extract data from AMQP request in JMeter

I have used AMQP Publisher to publish the message in RabbitMQ then I use AMQP Consumer as listener. In the View Results Tree the messages from the queue in shown in the request tab of AMQP Consumer. My question is how to extract data from that request. I tried following the Bean Shell Post Processor but it seems it will only work on Http request. I tried to use JSR223 Post Processor and XPath extractor but it doesn't work as well. Any help?
I wanted to extract the documentId from the request. Here is the Request pattern.
I have already tried following links:
Extracting value from jmeter post request
how to extract value from request in Jmeter
How to extract the values from request input xml in jmeter
The statement that you tried something without sharing the code doesn't make sense
Posting JSON data or code as image is not the best idea
Any reason to extract data from the request? Normally people know everything about the request hence don't require to extract anything from it. Even if they do - they should normally able to store the request data into a JMeter Variable and apply the relevant Post-Processor to it.
Whatever, just in case here is the solution:
Add JSR223 PostProcessor (if you really want to do this using the Post-Processor) as a child of the request
Put the following code into "Script" area:
vars.put('foo', com.jayway.jsonpath.JsonPath.read(sampler.getArguments().getArgument(0).value,'$..documentId')[0])
That's it, you should be able to access the extracted value as ${foo} where required.
References:
JsonPath: Getting Started
Apache Groovy - Why and How You Should Use It

How can I add Post https request in bzm-Parallel controller

How can I add Post https request in bzm-Parallel controller.
I want to add/combine 4 https Post requests which uploads 4 files at a time using bzm-parallel controller.
I tried simply putting normal post/upload request in 'bzm-parallel controller' but it didn't workout.
also the provided csv data configuration is not working if I use bzm-parallel Controller getting file not found exception.
${path} Variable provided in CSV not picking while execution.
Given your HTTP Request works per se it should work under the Parallel Controller as well. Double check that you can perform the upload using single thread and inspect request and response details using View Results Tree listener. Once request will be successful - put it under the Parallel Controller.
Be aware that Parallel Controller was developed primarily to overcome JMeter's limitation with regards to impossibility to kick off extra threads to mimic i.e. AJAX requests. It is not the best option for your use case, I would recommend consider using Synchronizing Timer instead.

how to change http method in data driven testing in jmeter using java

Does anyone know how to use java to change the HTTPrequest methods in Jmeter. I see a version of it but they use python. thanks
You can define whatever JMeter Variable you want in the "Method" input of the HTTP Request sampler like:
Given you properly define this ${METHOD} variable value you should be able to parameterise the HTTP Method by using external data sources, i.e. via CSV Data Set Config

JMeter leaving protocol in HTTP request sampler empty

I'm using JMeter v3.2 and I put up a really simple test plan for testing something. I have a csv file where I save all URLs acquired by a crawler. The URLs are just normal (http://something.com).
After reading those in from the CSV Config and writing them into my HTTP request sampler I get the following issue. The problem comes with the default protocol of JMeter which turns my request URL into this:
GET http://[http://something.com/]/.
Is there a way to turn that off?
Never put anything but ip address or hostname into Server Name or IP input of the HTTP Request sampler.
If you are getting the whole URL from CSV file - use Path input instead like:
Demo (as per View Results Tree listener)
See Using CSV DATA SET CONFIG guide to learn more about parameterisation of your JMeter test with CSV files.

Randomizing http request path in Jmeter

Currently my jmeter tests have a few GET http requests. In the request, i've got data filled in the "path" field.
I'm looking for a way to randomize Jmeter so it will call an array of "paths", however i can't seem to figure this out. Anyone have any tips?
thanks!
JMeter's test element most commonly used for parametrization and data-driven testing is CSV Data Set Config
There are built-in JMeter Functions which can be used to get data from external sources
__StringFromFile
__CSVRead
There is a chooseRandom function available via JMeter Plugins

Resources