API load testing from different servers with unique AUTH_TOKEN - jmeter

I want to test an API endpoint which requires AUTH header and I want to run them from different servers, so they'll hit different threads. However, I don't know how to do this because AUTH tokens should be different on each of this test servers. Is there a way to organize it using JMeter with redline13 specifically?

Parameterize your server and Auth_Token with a cvs file and upload the JMX and csv file to Redline13 to run the load test
Create a csv file and map IP address with Auth Token.
2.Add a header config manager to your http request , you can use ${variablename} to replace ip and authtoken as shown below
Result:
For more info on running a JMeter test please read this article

Sounds like an use case for CSV Data Set Config, if you have a CSV file which looks like:
ip,token
10.20.30.40,foo
10.10.99.4,bar
.etc
Add CSV Data Set Config to your Test Plan and provide your CSV file name there
In HTTP Request sampler put ${ip} into "Server Name or IP" field
Add HTTP Header Manager as a child of your HTTP Request sampler and configure it to send AUTH header with the value of ${token}
That's it, each JMeter thread (virtual user) will read the next line of the CSV file and therefore request will go to the specified server with the specified header.

Related

How to use user defined variable in Jmeter as server name or Ip while writing scripts using Transaction controller and Test script controller

When I am using the Jmeter while recording the script, I want to use a user-defined variable which is the website address. When an HTTP request is created by the Test script recorder, the Server name or IP is created automatically, but what I want is to set those server names manually using a variable.
How can I do that?
I don't know how you're recording your test, but when you create the recording test plan from the Recording Template it asks you for the protocol and hostname and populates them in the HTTP Request Defaults so you basically have server name in one place only and in the HTTP Request samplers it can be empty.
If you want to have it as a variable you can define one in the User Defined Variales configuration element and replace the value in the HTTP Request Defaults with the JMeter Variable reference.

HTTP Authorization Manager

I'm new to JMeter.
My web app is using windows authentication. As soon as you access the page, it logs you in without the need to enter credentials (No way to log out either). I was able to use HTTP Authorization Manager + HTTP Request Sampler to access the page.
My next step is to cycle through 5 test accounts against the same HTTP Request. Unfortunately, it doesn't look like HTTP Authorization Manager supports multiple logins for the same url. Running the test, it only uses the first set of credentials.
I tried using CVS DataSet Config, but the url does not support Post or Get method for login.
Any suggestions on how I would be able to create multiple logins for a HTTP Request Sampler? If it cannot be done with the HTTP Request Sampler, any alternative samplers I should use instead?
Thanks
Figured out I was able to include variables within the HTTP Authorization Manager.
Combined it with the CSV Data Set Config and it works as expected!

Jmeter CSV data set config run script correct even after providing incorrect username and password

I want to run performance testing using 100 users by using JMeter CSV data set config, I have added 100 different users in CSV file which are incorrect.
when i run the script in run properly, i was expecting it should show me the error than username and password is incorrect
JMeter automatically treads HTTP Status codes below 400 as successful, it doesn't do any extra checks.
So if your application responds with HTTP Status Code below 400 JMeter won't fail the sampler. If you need to test whether is user logged in or not add Response Assertion as a child of the relevant HTTP Request sampler and configure it to test whether response contains something which indicates logged in user, i.e. Welcome text or something like that or vice versa, that it doesn't contain elements of login page.
See How to Use JMeter Assertions in Three Easy Steps article to learn more about conditionally failing JMeter samplers using Assertions.

How to test with jMeter against basic auth protected domain?

I am running a staging cluster of apache/nginx webservers where the domain has basic authentication restricted access. My goal is to test performance of the cluster with jmeter.
In order to pass the authentication I have added the HTTP Authentication controler of jmeter. This works, BUT every request shows two logentries at apache. One 200 and one 401. This is normal behavior as of the first request the user must be authenticated. Unfortunatelly, jmeter does this on every request.
How can I make sure that each thread/user only requests access once. Or even better, how could I grant jmeter access with without every user needing to authenticat. I believe that this will impact the test results.
Thank you for any hint on this.
It sounds like a JMeter bug as given proper "Authorization" header is provided there shouldn't be WWW-Authenticate challenge. If you could file it via JMeter Bugzilla or flag it via JMeter Users Mailing List that would be great
In the meantime you can work it around using one of the following approaches:
Inject credentials directly into URL - in case of JMeter into "Path" input field like:
http://username:password#host.domain/path
Use Beanshell Scripting to construct proper "Authorization" header on-the-fly. In order to do so:
Make sure that HTTP Header Manager is present. If not - add it on Test Plan level or as a child of the HTTP Request which needs to be authenticated
add Beanshell PreProcessor as a child of HTTP Request which needs to be authenticated
Provide username and password separated by space via "Parameters" input
Put the following code into the PreProcessor's "Script" area
import org.apache.jmeter.protocol.http.util.Base64Encoder;
import org.apache.jmeter.protocol.http.control.Header;
String encodedCredentials = Base64Encoder.encode(bsh.args[0] + ":" + bsh.args[1]);
sampler.getHeaderManager().add(new Header("Authorization", "Basic " + encodedCredentials));
You shouldn't be receiving any 401 codes anywhere anymore.

how we can send the CSV data values in the http header manager?

I am using J meter tool, I need to send the user name along with the HTTP header data so that I can see in the access log which user is failing. I tried adding the variable in the header Manager: user name : ${variable}
The variable i am reading form config data file when I run this I don't even see the variable send in the request in the access logs.
Can any one please help!
First of all, you can not have spaces in HTTP Headers.
You'll have to change your user name header name to something like username or user-name elsewise your request will be rejected by HTTP server (if not earlier)
See Using JMeter's HTTP Header Manager guide for details.

Resources