Jmeter - Testing with 100 User while reading Links from CSV file - jmeter

I just started using Jmeter recently.
What I want:
I want to run a test of 100 users by getting links from CSV file.
How I am doing:
I created a Test-Plan, Added Thread Group, CSV Data Config (Child to Thread group), HTTP Request.
Given Values:
HTTP Request Default: Url Address (Tried with both HTTP & without HTTP in protocol section)
Thread Group: User: 100
Loop: Forever
CSV Data Set Config: File Name (Full Path, the file is not in bin folder)
Variable Name: Path
Recycle on EOF: False
Stop Thread on EOF: True
HTTP Request: IP Address:
Path: ${Path}
CSV File:
Path
Link1
Link2
Link3
What I am getting: Well the test is executing but it executing all link only once (one User), it not going for 100 User
Note: I am running the TestPlan from Command Mode
Thanks for your Time

If you want each user to go through all links in the CSV file you need to amend Sharing Mode setting of the CSV Data Set Config to Current Thread
You can verify the behavior by adding __threadNum() function as request prefix/postfix

Related

Login test using Taurus

Test login action using Taurus
execution:
-
concurrency: 5
ramp-up: 5
hold-for: 1m
scenario: Buyer-logs-in
scenarios:
Buyer-logs-in:
variables:
baseurl: http://localhost:3000
default-address: ${baseurl}
data-sources:
- path: './login.csv'
delimeter: ','
variable-names: userName, password
keepalive: true
retrieve-resources: false
requests:
- url: 'http://localhost:3000/login'
label: login
method: POST
body:
user[email]: {userName}
user[password]: {password}
assert:
- contains:
- 200
subject: http-code
- url: 'http://localhost:3000/action'
label: page1
method: GET
assert:
- contains:
- 200
subject: http-code
This is my sample Taurus code to simulate login and measure peformance.
In my app, only one user can login at a time and my csv file has 2 users. The test still works when I set a concurrency of 5 and Taurus says 5 users logged in. How is that possible. When the same user logs in again he will be kicked out of the first browser where he logged in. So with 2 user logins, how does Tuarus simulate 5 users?
With that asked, does taurus really login using the credentials i give in the csv file? Or should I use selenium/Taurus to simulate it?
What really confused me was when I deleted all users in csv file, the test still did not gave me 200 for the login and page1.
TIA
If you don't specify executor Taurus will use jmeter as default, it means that your YAML config will be translated into Apache JMeter test plan
You can see the generated test plan by running bzt your-test.yaml -gui command
data-sources is translated to CSV Data Set Config which looks like:
it means that each thread (virtual user) will pick up the new value from the CSV file each iteration like:
virtual user 1 - iteration 1 - 1st line
virtual user 2 - iteration 1 - 2nd line
virtual user 3 - iteration 1 - 1st line
virtual user 1 - iteration 2 - 2nd line
etc.
I don't think so, you're reading the credentials from the CSV file but not using it anywhere, the correct syntax for JMeter Variables is ${variable_name_here} so you need to set the login request body to:
user[email]: ${userName}
user[password]: ${password}
as long as you properly configure JMeter to behave like a real browser there is no need to use Selenium
You might be getting false positive results because your Response Assertion doesn't do a lot of useful job, JMeter automatically considers HTTP Status Codes below 400 as successful. So instead of checking status code I would rather recommend verifying that the use is logged in, i.e. "Welcome" message is there or API response has some specific text for successful login and/or doesn't contain errors.

parametrize to csv file url in JMeter

I configured this in following steps: in this moment I prepare following csv file:
protocol $url
${dev} http://10.200.XXX.XX/{$url}
${trial} trial.mycompany.io{$url}
${product} product.mycompany.io{$url}
then I add to my Test Plan -> Config element - CSV Data Set Config, and then I add Switch Controller,
and I have WebSocket Samplers by Peter Doornbosch and I dont have HTTP Samplers and WebSocket Samplers;
In Switch Controller I add HTTP Request and WebSocket request-response Sampler. In HTTP request I set
protocol:http,
server name or IP: localhost,
port number 8080.
HTTP request method POST,
path: ${URL}, and
parameters Add: Name: Value ${protocol} ws://{$URL} ${protocol} http://{$URL}
and in WebSocket request-response Sampler I set: use existing connection
do I correctly set the parameterization of the url variable, do I do something wrong, how to correct it, what to change?
Your understanding of parameterization in JMeter seems to be vague, as far as I get your idea your CSV file should look like:
protocol, url
http, some-http-host/some-http-path
ws, some-websocket-host/some-websocket-path
http, some-http-host/some-other-http-path
etc.
Then you should be able to use it in the CSV Data Set Config as
Switch Controller will allow you to choose either HTTP Request or WebSocket samplers depending on ${protocol} variable value so when ${protocol} is equal to http - only children of the http Simple Controller will be executed and ws will not be run and vice versa, when ${protocol} is ws - only ws samplers are being kicked off and http are not executed.
And in Samplers you can refer the values from the CSV file as ${protocol} and ${url} correspondingly
Open cmd prompt, change the path to the jmeter bin folder.
Now write jmeter command to run:
jmeter -n -t testing.jmx
If you want to log the results then use -l with a file name for output, So the command will be changed to
jmeter -n -t testing.jmx -l results.jtl

How do I make jmeter use the different hostname/port for different threads of same test plan

In my test scenario I have to test 2 urls with different host and port under same test plan. Is it possible to do so
You can make variable as property and send to jmeter script
Add to Test Plan In User define variables 2 rows:
baseUrl with Value ${__P(baseUrl,localhost)}
port with Value ${__P(port,8080)}
localhost and 8080 are default values you can change it
and when you execute add the values you want e.g.:
jmeterw.cmd ... -JbaseUrl=192.168.0.33 -Jport=80
Define your host and port combinations in a CSV endpoints.csv file like:
somehost,someport
someotherhost, someotherport
and put the CSV file to the "bin" folder of your JMeter installation
Add CSV Data Set Config to your test plan and configure it like:
Set HTTP Request sampler to use ${host} and ${port} variables defined via the CSV Data Set Config
That's it, on each iteration (or virtual user hit) the next line will be picked up from the endpoints.csv file.
See Using CSV DATA SET CONFIG article for more information on parameterising JMeter tests using CSV files.

Details about which user from csv failed response assertion in Jmeter

I am using JMeter to webUI performance testing. I have a list of users in csv with passwords. I am using response assertion to check failed password scenario.
How to record which user from csv is failed?
I would recommend going for Sample Variables property. For example, if you defined a ${username} which holds the user name from the CSV you can get it added to JMeter .jtl results file by adding the next line to user.properties file:
sample_variables=username
If you need to store more variables - provide them separated by commas:
sample_variables=username,password
Remember that:
JMeter restart is required to pick the property up
You can pass it via -J command line argument as well like:
jmeter -Jsample_variables=username,password -n -t test.jmx -l results.jtl
See Apache JMeter Properties Customization Guide for more information on different JMeter properties types and ways of working with them

JMeter CSVRead in Non Gui Mode does not read the file

I use JMeter 2.11.
I build my Test with nesting files and so on. With CSV Data Set it did not work. But i found a solution with the JMeter function __CSVRead and it works fine in GUI mode.
Now I have to run this test in non-GUI mode and it does not work.
I try to read a CSV file with some urls and want to send a normal HTTP request zu this adress.
in my HTTP request I set for server name: ${__CSVRead(${file},0)} Port: 7080
In GUI mode he can read the file in non-GUI not. I don´t know why.
Result in the log:
1406123833303,1077,asd,Non HTTP response code: org.apache.http.conn.HttpHostConnectException,Non HTTP response message: Connection to http://:7080 refused,jp#gc - Ultimate Thread Group 1-1,text,false,2213,0
Please don´t say I have to take "CSV Data Set" it really doesn´t work with it ;)
My expectation that in GUI mode you're using relative path in your ${file} variable.
The easiest option is switch to using full path instead of relative.
Alternatively you can check where JMeter expects CSV file to be present and copy it over. It can be done, i.e. using Beanshell Sampler with the following code:
import org.apache.jmeter.services.FileServer;
File file = new File(FileServer.getFileServer().getBaseDir() + System.getProperty("file.separator") + vars.get("file"));
if (!file.exists()) {
ResponseMessage = "Failed to locate " + vars.get("file") + " file under " + FileServer.getFileServer().getBaseDir() + " folder";
IsSuccess = false;
log.error(ResponseMessage);
SampleResult.setStopTestNow(true);
}
The code above checks existence of file with the name stored in ${file} variable under current JMeter working directory and if the file isn't there sampler will fail and the test will be stopped.

Resources