In a JSR223 PreProcessor I define two properties:
props.put("DATAFILE_PATH", "pathtofile");
props.put("ENV", "env_test");
Then in CSV Data Set Config object I use:
Filename : props.get("DATAFILE_PATH")
File encoding : UTF-8
...
However, I'm facing this error:
java.lang.IllegalArgumentException: File props.get("DATAFILE_PATH") must exist and be readable
CSV Data Set Config is Configuration element which is executed before pre processors (or other element)
Execution order
0.Configuration elements
1.Pre-Processors
So you can't update this property using pre processor, only by defining such property before execution as different answers suggesting, using user defined variables or adding property to execution
Related
In script I used org.apache.commons.io.FileUtils.writeStringToFile(new java.io.File('result33.csv'), 'User,Items per page,Pagination / Activity,Time to load(ms)' + newline, 'UTF-8', true) now I want to pass user value and time to load value dynamically (Actually I calculated those value in my script) so how to pass this value in above function?
and can you please provide how to pass variable(which used in script) and its value in Flexible File Writer
You have WDS.vars shorthand which provides read/write access to JMeterVariables class instance so you can do:
var foo = WDS.vars.get('foo')
to read the foo variable value from JMeter Variables
or
WDS.vars.put('foo', 'bar')
to create a JMeter Variable called foo with the value of bar
In order to be able to use the variables in the Flexible File Writer you need to declare them via sample_variables property, i.e. add the next line to user.properties file (lives in "bin" folder of your JMeter Installation)
sample_variables=foo
and next time you start JMeter you will be able to refer the variable as variable#0
if you have 2 variables like:
sample_variables=foo,bar
the first one will be variable#0, the second one will be variable#1, etc.
More information: Using the JMeter Flexible File Writer Plugin
I am trying to deploy a springboot application on kubernetese. I have stored all environment variable in config map and trying to read value from there. There are certain properties where we need to read int values.
In our code, it looks something like this :
application.properties :
TOKEN_RETRY_COUNT=3
As we have to read it from ConfigMap, we have updated our application.properties as mentioned below:
Update application.properties :
TOKEN_RETRY_COUNT=${STARGATE_TOKEN_RETRY_LIMIT}
Config Maps
The values are configured are like this in the Config Maps. I had to put double quotes as it wasn't allowed without any quote.
"STARGATE_TOKEN_RETRY_LIMIT": "3",
Now, when I am trying to read these values after deploying it on kubernetese, I am getting below error :
For STARGATE_TOKEN_RETRY_LIMIT :
Failed to convert value of type 'java.lang.String' to required type 'int'; nested exception is java.lang.NumberFormatException: For input string: "STARGATE_TOKEN_RETRY_LIMIT"
For now, I had updated code to take this value as String and then parse it as int but this is not ideal way. There should be some standard way to take different types.
If we can't handle different type in Config Maps, then what what would be ideal way to pass different application properties for Springboot application on kubernetese ?
I don't think the issue is related to the property value (3) being specified as a string ("3"). If you read the error message carefully you will see that the NumberFormatException is caused by an attempt to parse STARGATE_TOKEN_RETRY_LIMIT (literally) to a an int. Probably there is something wrong with the way the config map is passed to the application/container.
We have the following snippet in one of our Spring Batch XML files:
<int-file:outbound-channel-adapter
id="out" directory="c:\test"
filename-generator-expression="headers['msg.number']+'.xml'"
channel="in"/>
We would like to add access a value stored in a property file from within filename-generator-expression
The property can be accessed elsewhere in the XML as follows: attribute="${property.name}"
Th question is, how to access it from within filename-generator-expression.
This is obviously wrong:
filename-generator-expression="${property.name} + headers['msg.number']+'.xml'"
What is the correct solution?
Thanks very much
Using BIRT designer 3.7.1, it's easy enough to define a report for an XML file data source; however, the input file name is written into the .rptdesign file as constant value, initially. Nice for the start, but useless in real life. What I want is start the BIRT ReportEngine via the genReport.bat script, specifying the name of the XML data source file as parameter. That should be trivial, but it is surprisingly difficult...
What I found out is this: Instead of defining the XML data source file as a constant in the report definition you can use params["datasource"].value, which will be replaced by the parameter value at runtime. Also, in BIRT Designer you can define the Report Parameter (datasource) and give it a default value, say "file://d:/sample.xml".
Yet, it doesn't work. This is the result of my Preview attempt in Designer:
Cannot open the connection for the driver: org.eclipse.datatools.enablement.oda.xml.
org.eclipse.datatools.connectivity.oda.OdaException: The xml source file cannot be found or the URL is malformed.
ReportEngine, started with 'genReport.bat -p "datasource=file://d:/sample.xml" xx.rptdesign' says nearly the same.
Of course, I have made sure that the XML file exists, and tried different spellings of the file URL. So, what's wrong?
What I found out is this: Instead of defining the XML data source file as a constant in the report definition you can use params["datasource"].value, which will be replaced by the parameter value at runtime.
No, it won't - at least, if you specify the value of &XML Data Source File as params["datasource"].value (instead of a valid XML file path) at design time then you will get an error when attempting to run the report. This is because it is trying to use the literal string params["datasource"].value for the file path, rather than the value of params["datasource"].value.
Instead, you need to use an event handler script - specifically, a beforeOpen script.
To do this:
Left-click on your data source in the Data Explorer.
In the main Report Design pane, click on the Script tab (instead of the Layout tab). A blank beforeOpen script should be visible.
Copy and paste the following code into the script:
this.setExtensionProperty("FILELIST", params["datasource"].value);
If you now run the report, you should find that the value of the parameter datasource is used for the XML file location.
You can find out more about parameter-driven XML data sources on BIRT Exchange.
Since this is an old thread but still usefull, i ll add some info :
In the edit datasource, add some url to have sample data to create your dataset
Create your dataset
Then remove url as shown
add some script
How can I declare a variable name by using the value of a property?
For example, I have the property propertyName with the value propertyValue. I want to declare a variable with the name propertyValue.
I've tried like ${${__P(variableName)}} but such constructions doesnt work.
You may need to evaluate the property name, using the ${__V()} function.
Thus, you'd probably end up with something like ${__V(${__P(propertyName)})} which would only declare a variable with a null value.
Basics on properties & command line:
if you need to pass variables through the command line, properties are indeed the correct choice.
The flag to set a property is -JpropertyName The function to read a property is ${__P(propertyName)}
For full details, see:
http://wiki.apache.org/jakarta-jmeter/JMeterFAQ#How_do_I_pass_parameters_into_my_Test_scripts.3F_I_want_to_be_able_to_use_the_same_script_to_test_with_different_numbers_of_threads_and_loops.2C_and_I_don.27t_want_to_have_to_change_the_script_each_time.
Give up using properties files, try using Variables From CSV plugin. It is pretty simple and robust way to have variables loaded from file.
Property files are great!!! For my requirement, I have created a simple config element for JMeter to read property files.
Please check here.
http://www.testautomationguru.com/jmeter-property-file-reader-a-custom-config-element.