Data access in Jmeter using CSV file - jmeter

I have a .csv data file with data like:
Row-1: A
Row-2: B
Row-3: C
When I run the script with 1 user 3 iterations, it is taking the same value A for all 3 iterations. What do I need to do if I would like to use value A for iteration-1 and value B for iteration-2 & etc.? It did not make any difference between placing the data file inside the thread group or outside the thread group.
Please could someone help?
Thanks,
N

In current form your question cannot be answered comprehensively, the missing bits are:
What test element/function do you use for reading the values from the CSV file. The recommended option is CSV Data Set Config
What controller is used for creating the "iterations"
CSV Data Set Config needs to be placed inside that controller
Sharing mode of the CSV Data Set Config needs to be set to "All Threads"

Related

How to update xml file within .ini file while simulation running in omnet++?

I am using NesTing library within omnet++. For scheduling of switch gates a gate control list is defined within a xml file which is loaded by the .ini file. For example,
**.n5.eth[3].queue.gateController.initialSchedule = xmldoc("schedules.xml", "/schedule/switch[#name='n5']/port[#id='3']/schedule")
**.n6.eth[1].queue.gateController.initialSchedule = xmldoc("schedules.xml", "/schedule/switch[#name='n6']/port[#id='1']/schedule")
**.n6.eth[2].queue.gateController.initialSchedule = xmldoc("schedules.xml", "/schedule/switch[#name='n6']/port[#id='2']/schedule")
I would like to change the parameters of that 'schedules.xml' file dynamically and want that the updated file will be re-read by the configuration file so that the updated GCL will be implemented. I can ofcourse, give some more information to clear my question if needed.
I believe NesTing is not prepared to change the parameters and scheduling on the fly. So you cannot do that.

Set the Thread Group Loop count dynamically

I have a folder where many files containing different SOAP requests. I want to run all of them. how ever this files count might vary when new requests are added and some are removed. So I want to set the loop count to the number of files in the folder. So that the user will not have to know the exact count. IS anyone has come across similar scenario and got a solution ?
Thank you in advance.
You can work it around with some scripting as:
Add a Beanshell Sampler to your test plan
Put the following code into the Beanshell Sampler's "Script" area:
File folder = new File("/path/to/your/folder");
File [] files = folder.listFiles();
int loops = files.length; =
vars.put("loops", String.valueOf(loops));
Add Loop Controller after the Beanshell Sampler
Put ${loops} into "Loop Count" input field
See How to use BeanShell: JMeter's favorite built-in component guide for comprehensive information on scripting in JMeter.

jMeter CSV_Data_Set config and XML dynamic binding

I am primarily using JMeter -CSV_Data_Config element to bind csv data with a XML template as shown below.
This works beautifully when the data in the excel cells are static ie.. know set of columns. eg. 6 cols in csv file bind to 6 variables in XML file.
Lets say end user decides to have 15 cells of data in the csv file. Can i make the jMeter script dynamic to add new XML elements eg.Item with new attributes based on the number of cells in the csv file ?
I think a beanShell script might help if not ? not sure how .. any help -much appreciated !
Personally I would use the following approach for getting data from CSV file with unknown number of columns:
User Defined Variables (defined variable N with the value of 0)
While Controller
Counter (Start: 1, Increment: 1, Reference Name: N)
Samplers with data-driven logic
and use the following line as condition for the While Controller
${__javaScript("${__CSVRead(/path/to/your/file.csv,${N})}"!="",)}
See __CSVRead() function documentation for more details.

Best way of structure data in properties file

I am developing a web application and I need some parameters from properties files. These parameters have the following structure:
parameter1.field = Field 1
parameter1.value = Value 1
parameter2.field = Field 2
parameter2.value = Value 2
...
I personally don't like this data structure, and I'd like to organize them in a more simple way, like this:
parameter1 = Field1,Value 1
parameter2 = Field2,Value 2
...
My question is if there is any other way to organize information in a properties file for data like these, for example, in an array structure or something similar.
Thank you very much in advance
You can use a JSON file instead, which allows you for a more complicated structure.
There is no standard way to represent non-flat structures in a properties file, and everything that you do would be a custom solution.

How to unimport a file from vbscript?

How do I unimport a file from vbscript? Because the file I imported has a lot of global variables, which coincides with the other file I want to import.
I just want to import 1 file at a time in order to prevent overlapping of global variables. How do I achieve that? Thanks.
All data made available to a current script context MUST be unique. If you use 'ExecuteGlobal statement' in the main context, routine or function then all data is available globally. Use 'Execute statement' to make data available in a current context.
http://msdn.microsoft.com/en-us/library/342311f1(VS.85).aspx

Resources