Created attachment 25502 [details] Relative paths for results file In the View Results tree GUI component we can enter a filename for the results of our script. Unfortunately if we enter a relative path, this is interpreted as relative to the jmeter/bin folder. A more intuitive approach would load it relative to the same folder as the script that we are running. I have attached a patch for this RFE. See also: bug43389 Regards
The version of JMeter I used was taken from SVN revision: 946591
Created attachment 25503 [details] Added a minor correction to the log output
(In reply to comment #0) > In the View Results tree GUI component we can enter a filename for the results > of our script. Unfortunately if we enter a relative path, this is interpreted > as relative to the jmeter/bin folder. Actually it is relative to the JMeter launch directory. This defaults to the jmeter/bin directory, but can be anywhere else.
Hello Sebb and thx for the reply :) Yes I agree with you that currently the path is relative to the launch directory and not necessarily jmeter/bin. But as I mentioned in bug43389 if I am working on different scripts I have to start JMeter every time I change scripts to change the launch directory. When using source control systems, files are organized in a structured way relative to the scripts rather than the jmeter launch directory. This is why I still believe that paths should be relative to the scripts.
The patch changes the behaviour of JMeter in an incompatible way, so cannot be applied as it stands. There needs to be some way for the user to select whether the filename is relative to the launch directory or to the script file. One way to do this would be to make the new behaviour dependent on a property, which defaults to false.
This idea sounds good. Is there a class in jmeter that deals with jmeter properties specifically, or can I use standard java code such as: Properties props = new Properties(); props.load(new FileInputStream("jmeter.properties")); relativePath = props.getProperty("relative.path");
Have a look at JMeterUtils
Created attachment 25947 [details] New patch using a jmeter property This patch allows result files to be loaded and written with a path relative to the script or launch directory. The behavior is controlled by a property set in the jmeter.properties.
Thx for the tip Sebb. I have set the property name (PATH_RELATIVE_TO) in the ResultCollector class, but I believe this can probably be used in other classes. Maybe it is better if it is placed elsewhere. Additionally it looks to me like the name I used for the property may not follow the jmeter name conventions. Maybe something like jmeter.path.relative.to is more convenient? I leave this up to you to decide.
ResultCollector is probably OK, as most files written by JMeter will be created by that class. Can't think of any other files created by JMeter (apart from jmeter.log, which is opened before the JMX file location is known). I hope to take a look at including the patch next week.
Any reason for not including this one? I may have a bit of time next week to work on it if anything else is missing.
I now think the simplest might be to support a file name prefix that means "relative to the JMX file", for example "!/" or perhaps "~/". So "!/output.jtl" would be relative to the JMX location. Just in case someone needs to create a file in a directory with the name "~" or "!", the prefix could be overriden at startup using a JMeter property. One way to do this would be to add a file name normalisation method to FileServer, which one would need to call anyway to get the base location.
URL: http://svn.apache.org/viewvc?rev=1028515&view=rev Log: Bug 49365 - Allow result set to be written to file in a path relative to the loaded script Modified: jakarta/jmeter/trunk/bin/examples/CSVSample.jmx jakarta/jmeter/trunk/bin/jmeter.properties jakarta/jmeter/trunk/src/core/org/apache/jmeter/reporters/ResultCollector.java jakarta/jmeter/trunk/src/core/org/apache/jmeter/reporters/ResultSaver.java jakarta/jmeter/trunk/src/core/org/apache/jmeter/services/FileServer.java jakarta/jmeter/trunk/xdocs/changes.xml jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml jakarta/jmeter/trunk/xdocs/usermanual/listeners.xml
This issue has been migrated to GitHub: https://github.com/apache/jmeter/issues/2371