Bug 49365 - Allow result set to be written to file in a path relative to the loaded script
Summary: Allow result set to be written to file in a path relative to the loaded script
Status: RESOLVED FIXED
Alias: None
Product: JMeter - Now in Github
Classification: Unclassified
Component: Main (show other bugs)
Version: Nightly (Please specify date)
Hardware: PC Linux
: P2 enhancement (vote)
Target Milestone: ---
Assignee: JMeter issues mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-31 08:55 UTC by Luciana Moreira
Modified: 2010-10-28 18:02 UTC (History)
2 users (show)



Attachments
Relative paths for results file (1.76 KB, text/plain)
2010-05-31 08:55 UTC, Luciana Moreira
Details
Added a minor correction to the log output (1.73 KB, text/plain)
2010-05-31 10:00 UTC, Luciana Moreira
Details
New patch using a jmeter property (3.64 KB, patch)
2010-08-26 03:34 UTC, Luciana Moreira
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Luciana Moreira 2010-05-31 08:55:12 UTC
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
Comment 1 Luciana Moreira 2010-05-31 09:06:24 UTC
The version of JMeter I used was taken from SVN revision: 946591
Comment 2 Luciana Moreira 2010-05-31 10:00:44 UTC
Created attachment 25503 [details]
Added a minor correction to the log output
Comment 3 Sebb 2010-06-01 11:47:19 UTC
(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.
Comment 4 Luciana Moreira 2010-06-02 10:25:33 UTC
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.
Comment 5 Sebb 2010-06-02 11:54:18 UTC
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.
Comment 6 Luciana Moreira 2010-08-25 05:51:33 UTC
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");
Comment 7 Sebb 2010-08-25 17:21:11 UTC
Have a look at JMeterUtils
Comment 8 Luciana Moreira 2010-08-26 03:34:50 UTC
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.
Comment 9 Luciana Moreira 2010-08-26 03:39:09 UTC
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.
Comment 10 Sebb 2010-08-26 06:28:44 UTC
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.
Comment 11 Luciana Moreira 2010-10-22 08:49:33 UTC
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.
Comment 12 Sebb 2010-10-22 09:52:58 UTC
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.
Comment 13 Sebb 2010-10-28 18:02:41 UTC
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
Comment 14 The ASF infrastructure team 2022-09-24 20:37:44 UTC
This issue has been migrated to GitHub: https://github.com/apache/jmeter/issues/2371