2

In JMeter (5.1.1) I have a summary report that I'm trying to save as a timestamped file. The filename value looks like the following:

D:\Load Tests\example.com\Results\${__time(yyyy-MM-dd-HH-mm-ss,)}_summary.csv

However, rather than create the file with the result of the __time() function e.g. 2019-07-22-10-24-03_summary.csv, it's actually generating a filename called ${__time(yyyy-MM-dd-HH-mm-ss,)}_summary.csv.

I've tried creating a user-defined variable called timestamp with the value ${__time(yyyy-MM-dd-HH-mm-ss,)} and referencing it with ...\${timestamp}_summary.csv but this similarly results in $(timestamp)_summary.csv.

I saw a JMeter Archive post regarding a similar question to mine from 2006 where it's implied that listener filenames are resolved too early for functions and variables to be used, but I'm hoping that JMeter has been able to overcome this hurdle in the 13 years since then.

Is it possible to use variables for listener filenames in JMeter GUI and set them dynamically like the timestamp above?

If not, is there an alternative method of doing this using Groovy? Where would this be - in a setup thread JR223 sampler perhaps? I have tried this and seemingly managed to programatically change the filename, but no file was saved.

Update with answer:

I just needed to reverse the path delimiters from \ to /.

D:/Load Tests/example.com/Results/${__time(yyyy-MM-dd-HH-mm-ss,)}/summary.csv
Dan Atkinson
  • 11,391
  • 14
  • 81
  • 114

3 Answers3

2

I usually don't write long answers, but you touch a bit of a sore point,

Listeners are classic example of Can't Live with You, Can't Live Without You

JMeter mindset is load testing (although can be used for functional tests)

Therefore, the moto/best practice is You shouldn't use it

Use CLI mode: jmeter -n -t test.jmx -l test.jtl

Use as few Listeners as possible; if using the -l flag as above they can all be deleted or disabled.

Don't use "View Results Tree" or "View Results in Table" listeners during the load test, use them only during scripting phase to debug your scripts.

But...in the same document it suggest it for testing/debugging

Create a simple Test Plan containing the JSR223 Sampler and Tree View Listener. Code the script in the sampler script pane, and test it by running the test.

Basically/In the end, you need to save first jtl file using -l myresults.jtl

And then convert it to CSV using JMeterPluginsCMD, example:

JMeterPluginsCMD.bat --generate-csv test.csv --input-jtl results.jtl --plugin-type ResponseTimesOverTime

Or do it the JMeter way with creating a dashboard

jmeter -g <log file> -o <Path to output folder>
Community
  • 1
  • 1
Ori Marko
  • 56,308
  • 23
  • 131
  • 233
  • Thank you. This test plan is for confirming functionality changes whilst porting from one language to another. I reused an existing (load testing) plan which had no listeners and hence no problem. In this case, I have to support a number of users who can figure out the JMeter GUI but not the CLI. Creating a dashboard definitely seems like the way to go here, and I'll look into this. – Dan Atkinson Jul 24 '19 at 12:48
  • I have accepted this answer now and have awarded the bounty. I had a short holiday and implemented the dashboard without any issues. The users prefer this as they can see the data in a more user-friendly fashion. Thanks again. – Dan Atkinson Aug 02 '19 at 15:01
2

I come across this issue and figure out that it works when you specify your path with the slash, instead of backlash. For example:

D:\Load Tests\example.com\Results\${__time(yyyy-MM-dd-HH-mm-ss,)}_summary.csv

Doesn't work. But:

./Load Tests/example.com/Result/${__time(yyyy-MM-dd-HH-mm-ss,)}_summary.csv

Will work.

majita
  • 1,278
  • 14
  • 24
mnhvu84
  • 36
  • 2
  • Thanks! I came back to look at a different test and this did the trick for me! I did have the change the path to the following though - `**D:**/Load Tests/example.com/Results/${__time(yyyy-MM-dd-HH-mm-ss,)}/summary.csv` (note the drive letter). I also moved each set of results into their own directory by date which makes multiple runs easier to clean up. – Dan Atkinson Jun 12 '20 at 13:22
-1

You should not be using any Listeners in your tests as it violates JMeter Best Practices

Use as few Listeners as possible; if using the -l flag as above they can all be deleted or disabled.

you should be running JMeter in non-GUI mode like:

jmeter -n -t test.jmx -l summary.jtl

If you want to amend the summary.jtl filename to include timestamp - you can use date and time commands combination like:

jmeter -n -t test.jmx -l %date:~-4%-%date:~4,2%-%date:~7,2%-%time:~0,2%-%time:~3,2%-%time:~6,2%_summary.jtl

Demo:

enter image description here

Dmitri T
  • 159,985
  • 5
  • 83
  • 133
  • Thank you for the reply although I'm not sure if it's particularly feasible to switch users to using CLI over GUI purely for best practice reasons. Is it possible to use timestamps in filenames within the scope of my question (ie using the GUI)? – Dan Atkinson Jul 22 '19 at 10:09
  • Okay. Well thank you but the answer as provided isn't of any use to me. For what it's worth, best practices are guidelines rather than hard and fast requirements. – Dan Atkinson Jul 22 '19 at 10:16