newbie to jmeter.
i am trying to test the file upload portion of my site
I need to test multiple upload file types.
so for i have working
-- http request sampler to login
-- http request sampler to upload the file using "Send files with the request" (This is where i have the absolute path tothe upload file. where i would like to put a variable)
-- another http sampler to validate the upload
This all works fine. Now i want to loop through different scenarios based on the the thread count
int idx = ctx.getThreadNum();
I load some values for that loop based on idx
the part i can not get working is uploading a file specific to the thread idx
to hack this to get it working i have Swith controllers for each thread id that uploads a different file. this is problematic as each thread i want to add, i will have to add a new switch controller. This can not be the correct way to do it.
I appreciate any help
Just use __threadNum() function in the "File Path" input like:
The function returns current thread number (starting with 1) so you will be able to upload different files with different threads.
By the way, int idx = ctx.getThreadNum(); returns thread numbers starting from 0, maybe that's why your test doesn't work as expected.
See How to Use JMeter Functions articles series for comprehensive information on above and other useful JMeter functions.
Related
Txt file is showing empty when i am trying to save Correlated value to CSV or Txt file using JMeter plugin HTTP Simple Table Server?
please find the steps i did
Step 1: File initialization kept in setUp Thread Group
Initialization
Step 2: correlated value is in Ultimate thread group, so i have placed adding in thread group end
using below help
POST : http://hostname:port/sts/ADD
POST Parameters : FILENAME=file.txt,LINE=D0001123,ADD_MODE=[FIRST,LAST],UNIQUE=[FALSE,TRUE]
For Adding using
not throwing any errors but file is showing empty
I believe you need to call SAVE endpoint in order to flush the dataset to the file
You may find approach with Flexible File Writer and Sample Variables easier to use
Using jMeter to set up a soak / load test that needs to run each request with different data. The structure I currently have is
Thread Group (2 Users, 2 Loops)
- Simple controller
-- Java Sampler (Custom Plugin) to convert CSV Formula data into NewThreadData.csv (as variable)
-- Java Sampler (Custom Plugin) to create directory of files created with NewThreadData.csv merged into a template
-- While Controller Condition - js NewThreadData column not = EOF
--- CSV Data Set Config NewThreadData.csv (Recycle False / Stop of EOF False) - filename passed as variable
--- JMS PUblisher with the FileName a variable using the filename column from within NewThreadData.csv
My problem is the on the second loop, the data is updated in NewThreadData.csv, but the CSV in the while loop never runs again.
Appears that the CSV Data Set Config "knows" it has been run, regardless of the actual CSV data.
Questions
How can I get the CSV Data Set Config to be rerun / re executed in this scenario?
Are there undocumented variables or means of getting the config to reprocess?
Is there a way to spawn a new thread on each iteration rather than reusing the existing thread, as the CSV does execute once for each "User"[thread]. I also tried Stop on EOF : True, but that stopped the second loop.
Aim is to eventually ramp up the user count and the number of loops (changing to forever); with there being about about 100 different combinations of data to be inserted on each loop. The formula I am using has time and thread number to give me data uniqueness along with other data that is dynamically created from a formula. Recycle on EOF is not feasible as I need to regenerate the csv contents on each loop. A super-csv I don't think is feasible to cover the load and soak scenarios.
Thanks in anticipation. Andrew
I don't think it's possible to "reset" the CSV Data Set Config, it's a configuration element hence once it reads the file in its current state it will "stick" to its content.
If you're manipulating file content dynamically I would rather recommend going for __CSVRead() function instead which is evaluated in the runtime just where it's placed therefore it doesn't reserve file and it "rewinds" to the beginning of the file when the last line is read.
More information: How to Pick Different CSV Files at JMeter Runtime
CSV Data Set Config element is executed first and only once even though you have placed it within the while controller. Hence CSV Data Set Config element is not suitable for your requirement.
You could use JSSR223 Pre-processor to work with the dynamic CSV files using a supported programming language/script (Java , Groovy)
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.
I have a back end application (only back end) which sends data to customers by WebSocket.
I testing this application using JMeter. In Jmeter I added plugin WebSocket Sampler by Peter..
Previously I am sending this data to customers by Postman.
In my Json file incluge data about event, in which customers can subscribe. I have one question: How can I do it, that data, which is send in postman (in json file) will be send in JMeter?
Is it correctly way to read my json file in Jmeter?
If not: Why not and how I can improve this?
How I can the best to process data - to variable from my json file?
There is __FileToString() function, you can kill two birds with one with it, to wit:
Read a file from the file system
Store file contents into a JMeter Variable
For example the following expression:
${__FileToString(file.json,,myVar)}
will read file.json from JMeter's "bin" folder and store its contents into ${myVar} JMeter Variable:
If you have multiple JSON files and want multiple JMeter threads to send different files - the easiest way is going for Directory Listing Config plugin (can be installed using JMeter Plugins Manager)
in attachmnent I show, what I set this
enter image description here
enter image description here
what is wrong and how is the easiest way to improve this?
I'm not understand exactly, how I can add ${__FileToString(file.json,,myVar)} and variable myVar,
and how exactly must be set FileToString and myVar in Thread group, as what of type test plan?
how improve exactly?
OK I set this, and in View Result Three in ERR in Response Body is correctly return body json, so I dont know, why is **ERR* name
It is correctly? and if not, why is wrong and how I can improve this?
I'm trying to run around 15000 soap requests through JMeter. I have 15000 individual soap files in a folder.
I know that the WebService(SOAP) Request component has the option to point to a folder.
But, the problem is that the files in the folder will get picked up and run randomly and a file can get run multiple times.
This is not ideal because each request has a unique correlation id and if a file get's run twice, the second run will fail due to a duplicated correlation id.
Is there anyway, I could tell jmeter to run the files only once?
Also, as certain soap requests are dependent upon other request having already run, the ability to run these in a specified order would be desirable. Is this possible?
These seem like common problems that should have already been solved. But, I can't find much on google.
Do you guys have any ideas?
I would use the JSR223 Sampler to run a script (e.g. Groovy) to iterate through the files in the directory and store the text of each file in a String.
See, for example, this other answer about using a Groovy script to iterate a list of values.
You could put the data into a csv file and read it in using a CSV Data Set Config. If you need unique values over multiple threads then you have to create multiple files, one per thread.
You could also put the data in a database and use a JDBC Config/Sampler to access it, making sure to either a: delete the data after it is read, or b: mark it as 'read' using a flag. Both methods would prevent the same record being read twice by different threads.
If you need to run requests in order you should structure the test plan as such, requests will be made sequentially, top to bottom.