1
votes

The test scripts on GUI works perfect but not in the non-GUI mode.Image showing Terminal test execution

Explanation: I have 3 thread groups in the test plan, where the first Thread Group creates 3 .csv files and are expected to feed the data in the CSV files into the second Thread Group.

For few test runs, Non-GUI mode worked great but then, the tests Intermittently like this [Terminal showing test run], doesn't create the CSV files at all and also, sometimes, third Thread Group doesn't execute at all.

The problem I noticed is:

  1. During the NOn-GUI tests the files are not been creating, so that's the reason the next Thread groups weren't able to pick up and use the variables inside CSV file and also

  2. The second One could be: I'm saving folder and file paths in the ${__setProperty(prop_folder_Path,${File_Path})} and getting the prop. ${__property(prop_folder_Path)} in another Thread Group -> Sometimes this property function Doesn't work and files are saving in /bin Directory

    Is there a way to use ${__property(prop_folder_Path)} value in BeanShell POStProcessor ?

I believe whatever works in the GUI should work same in the Non-GUI too, AM I right?

I Just noticed that output files are creating in /bin folderas shown here while running the tests in NOn-GUI

Any suggestions to fix this. Thank you

1
how do you expect to get a useful answer with so little info provided?Kiril S.
I've edited the POST if you're interested to answer. Thank youJalVI
From your latest explanation sounds like you have some relative paths in your script (e.g. you specified file name, but not file path). You should never use relative paths in automation, since it's relative to current system path and is not reliable. Always provide an absolute path in the folder where both, current interactive user, and the user who starts tool non-interactively (not always the same user) have permissions. E.g. not a home directory of the user...Kiril S.
@Kiril S thanks for looking back and your response: Here's how i designed paths import org.apache.jmeter.services.FileServer; //gets path of current jmeter's script String path = FileServer.getFileServer().getBaseDir()+File.separator+"Output"; File f = new File(path ); f.mkdirs(); vars.put("v_folder_path",path); And I appened the path + file.separator + "new_file_name.csv" I believe this makes less manual work and asily trackable. I've executed the tests for quite some test runs and they were successful.,JalVI
Hmm I don't think your assumption '//gets path of current jmeter's script ' is correct. Looking at the code, FileServer.getFileServer().getBaseDir() is the same as System.getProperty("user.dir") by default, and as far as I can tell is only changed to script path by GuiPackage class, which might explain difference in behaviour you are observing between gui and non-gui. But why are you using the function/location that you don't control? Isn't it better to stick to system defaults, like System.getProperty("java.io.tmpdir")?Kiril S.

1 Answers

0
votes

My expectation is that your ".csv" files creation fails somewhere somehow therefore 2nd thread group is not able to operate due to missing files.

JMeter doesn't have any build-in functionality to write something into the file so I think you implemented some custom logic using i.e. JSR223 Scripting which doesn't work. The reasons could be in:

  1. If you're running JMeter from another folder the .csv files can be created in a different location, try using full paths just in case.
  2. Non-GUI mode tends to be faster than GUI mode so it might be the case of multithreading issue i.e. when multiple threads are trying to write data into the same file concurrently and clash or produce not well-formed data.

In both cases the answer will live in jmeter.log file, check it for any suspicious entries and fix the causes.


In general using files to pass data between thread groups is not the best idea, I would recommend doing it in-memory instead, for example:

  1. In 1st Thread Group use __setProperty() function to convert your data which you store in CSV file into JMeter Properties like:

    ${__setProperty(foo,bar,)}
    
  2. In 2nd Thread Group use __P() function to read the data like:

    ${__P(foo,)}
    

More information: Knit One Pearl Two: How to Use Variables in Different Thread Groups