Can we pass a command line argument to property file reader in jmeter - testing

I have a config.property file that contains all the property values to be used in jmeter, so i am using property file reader plugin to read the property file, here the problem is i don't want to hard code the path to config.properties file in property file reader so i want it to pass as command line argument but it is not working
command i am executing is
.\jmeter -JPROPERTY_FILE=<file_location> -n -t <path_to_jmx> -l <path_to_jtl> -j <path_to_log>

In the File Path of Property File Reader, replace:
${PROPERTY_FILE}
By using __P function:
${__P(PROPERTY_FILE)}
Your mistake is that you’re using Variable syntax for a property.
See:
http://jmeter.apache.org/usermanual/functions.html#__P
http://jmeter.apache.org/usermanual/functions.html#functions

You should be using __P() function like ${__P(PROPERTY_FILE)} or even __property() function like ${__property(PROPERTY_FILE,PROPERTY_FILE)}. The latter one automatically stores the retrieved value into a JMeter Variable so you won't have to additionally declare it under User Defined Variables of the Test Plan
Instead of using custom plugins I would suggest going for built-in JMeter functionality, there is -q command-line argument which allows loading and arbitrary .properties file so you will not have to install the plugin, care about order of Configuration Elements, etc.

Related

Call Command from Mupen64Plus dll using RUNDLL32 through Command Prompt

I'm using the Nintendo 64 emulator, Mupen64Plus.
It has a file called mupen64plus-ui-console.exe used to launch games through command-line. It also accepts keyboard shortcuts to perform commands, but it is limited.
Mupen64Plus Commands/Functions
This wiki page shows a list of all commands that can be called, I think from the mupen64plus.dll.
RUNDLL32
I read how to pass commands to a dll like this:
RUNDLL32.EXE <dllname>,<entrypoint> <optional arguments>
Calling a Command with RUNDLL32
I'm trying to call M64CMD_STATE_LOAD with cmd.exe, to load a save file.
Info from Wiki:
Command Functions Prototype m64p_error CoreDoCommand(m64p_command
Command, int ParamInt, void *ParamPtr)
ParamInt Ignored ParamPtr Pointer to string containing state file path
and name, or NULL
This command will attempt to load a saved state file. If ParamPtr is
not NULL, this function will load a state file from a full pathname
specified by this pointer. Otherwise (ParamPtr is NULL), it will load
from the current slot.
I have the Mupen64Plus emulator running a game. I then open cmd.exe and paste in this line.
RUNDLL32.EXE "C:\Path\To\mupen64plus.dll", CoreDoCommand M64CMD_STATE_LOAD 1 "C:\Path\To\MySave.m64p"
Problem
It accepts the command, I get no errors, but the save file isn't loaded.
Questions
Are the arguments being passed wrong?
Does the mupen64plus.dll not have hooks into the currently running mupen64plus-ui-console.exe?
Is it loading the save file into nothing?
Is it not possible to do it this way?

Jmeter dynamic URL property with variable not substituted

I have a simple Jmeter test where I have a property to set the URL. The PATH in the Jmeter test is set to the following.
${__P(GET_URL,)}
This works well for all URLs that I have been working with, except for the ones where I need to pass a variable in the URL component.
For example, it works for http://server:port/getemployeelist when I run the test with -JGET_URL=/getemployeelist
Then I created a CSV config element to populate the variable EMP_ID.
Then if I run the test with -JGET_URL=/getemployee/${EMP_ID}, the EMP_ID variable is not getting substituted. Jmeter test gives me an error as follows:
java.net.URISyntaxException: Illegal character in path at index xx: https://://getemployee/${EMP_ID}
Appreciate any help/pointers.
It will not work this way, JMeter doesn't know anything about ${EMP_ID} at the time it is being started, you need to append this ${EMP_ID} to HTTP Request sampler "Path" in the runtime
Start JMeter as:
jmeter -JGET_URL=/getemployee/
Use CSV Data Set Config to read the EMP_ID from the CSV File
In the HTTP Request sampler use construction like /${__P(GET_URL,)}/${EMP_ID} to combine JMeter Property specified via -J command line argument and JMeter Variable originating from the CSV file.
If anything goes wrong first of all check jmeter.log file - it normally contains enough troubleshooting information. If there is nothing suspicious - use Debug Sampler and View Results Tree listener combination to inspect requests and response details, variables and properties names and values, etc.
Had asked this question a while back. Thought of posting the solution which I eventually ended up implementing. In the solution, I created a template jmx with a substitution variable for the HttpSampler.path and then replace the path at runtime. Following are the key points from the scripting done.
This turned out to be a simpler solution that worked for all kinds of API call patterns.
Created a template jmx (jmeter_test_template) with the following line.
<stringProp name="HTTPSampler.path">#PATH#</stringProp>
This jmx has CSV config element to populate variable "EMP_ID". To create this file, just create a new test with any URL and then save it as a template and replace the URL with substitution variable #PATH#.
Created a wrapper script like run_any_api.sh with usage,
sh run_any_api.sh URL=http://server:port/myapp/employees/${EMP_ID}
In the wrapper script, this URL is replaced in place of the token.
sed "s/#PATH#/$URL" jmeter_test_template.jmx > jmeter_test_template.current_test.jmx
jmeter -t jmeter_test_template.current_test.jmx
Last but not the least, please remember to cleanup the temporary jmx,
rm jmeter_test_template.current_test.jmx

Setting sample_variables property at runtime

Is there a way to specify a list of variables to be saved in the output file at runtime and not in jmeter.properties file?
I am currently specifying the list of variables to be saved in sample_variables, in jmeter.properties file, but this does not allow specifying different set of output variables for each JMeter script, unless I keep updating jmeter.properties file.
You can pass sample_variables (as well as any other property) via -J command line argument like:
jmeter -Jsample_variables=foo -n -t script1.jmx
jmeter -Jsample_variables=bar,baz -n -t script2.jmx
Also, as per Managing Properties chapter of JMeter User manual:
When you need to modify jmeter properties, ensure you don't modify jmeter.properties file, instead copy the property from jmeter.properties and modify its value in user.properties file.
See Apache JMeter Properties Customization Guide article for comprehensive information on different JMeter properties types and ways of working with them
I am not aware of the way to change sample_variables at runtime. The only workaround I know of is to have BeanShell Listener (or alternatively one of the programmable sampler/pre-/post-processors), which writes into its own file. E.g.:
String filename = "myfile.txt";
String message = "At " + System.currentTimeMillis() + " data is " + vars.get("myVar");
FileOutputStream f = new FileOutputStream(filename, true);
PrintStream p = new PrintStream(f);
this.interpreter.setOut(p);
print(message);
f.close();
You can also add conditions when the variable should be saved (e.g. only after specific sampler or only when the value have changed). From my experience the solution with BeanShell Listener is not expensive resources-wise, since it will be 1 thread regardless of number of running threads. Solution with programmable pre-/post-processor is usually more expensive, unless you only save variables rarely.

Command-line properties file reference overriding mule-app.xml

I have placed variables in a few .properties files and have successfully created a mule.env variable in mule's mule-app.properties file to reference which of those files to use. I am trying to allow a command-line argument override the mule.env variable so that a specified properties file can be used. I also like having the mule.env variable exist in mule-app.properties file as a default value in case nothing is set via the command-line. But it seems that the existing mule-app.properties file overrides the command-line argument.
The mule-app.parameters file contains a variable like this:
mule.env=dev
While a command-line argument looks like this:
-Dmule.env=prod
A property placeholder looks for the properties file like so:
<context:property-placeholder location="classpath:${mule.env}.properties" />
The result that I prefer is that the property placeholder finds the prod.properties file rather than the dev.properties file when the mule app starts with the command line argument; however, it still uses the dev.properties file.
If I remove the variable from the mule-app.properties file, the command-line argument works fine.
I prefer that the command-line overrides the what is in the mule-app.properties file. Is that possible? What have I done incorrectly?
For this purpose You have to set the property in the Mule wrapper.conf:
Navigate to [Mule standalone]/conf folder.
Open wrapper.conf in a any text editor.
Add the following script under # GC settings: wrapper.java.additional.15=-­Denv=prod
Notes: make sure the number is correct. In this example the last number in that file is: wrapper.java.additional.14

Using a variable in a batch script for SQLLDR

Hi i am trying to set a variable in my .bat file and i want to use the variable in sqlldr code to state the file (infile)
This is what i have in my bat file for the variable:
set directroy_name= D:\Folder\Folder\Folder\File.csv
Then in my command file i have
load data
infile '%directory_name%'
When ever i try to run the .bat file from the command prompt i just receive the SQL_Loader_500: unable to ope file (%directory_name%.dat
I know the files in the correct location?
any ideas why its doing this?
No, you can't do that - you're expecting the Oracle executable to understand Windows environment variable syntax. If it did that it would have to deal with $ variables in Unix, etc.
You can just pass the file name on the command line instead. In your control file omit the INFILE altogether, then when you call SQL*Loader add a a DATA command-line argument:
sqlldr user/password CONTROL=your.ctl DATA=%directory_name% ...
Assuming your variable is just oddly named and does have a full file path as you've shown.
If it's present, the INFILE argument will be overridden by the command-line argument, so you could include a default fixed value if you wanted to, I suppose.
You also appear to have a typo; you set directroy_name, but then use directory_name, which will have no value. You need to change that to:
set directory_name= D:\Folder\Folder\Folder\File.csv