We would like to have a simple way to save a specific string (simple or multiple rows) to a file like from JMeter without writing a complicated BeanShell script If it's too complicated to have a SAMPLER for it, please create a function for this like ${__StringToFile(<string>,<file>)}
Contract: ${__stringToFile(<file path>, <sync_id>, <string to write>)} sync_id used to synchronize simultaneous calls that write to the same file Questions: - This means we would be flushing on every call, should we add a parameter ? - Should we use a lock based on file name to synchronize simultaneous calls that write to the same file, or should we add a mandatory sync_id used
wouldn't flushing to the file every call cause a performance bottleneck? I could definitely see this being useful when building a test, but idk if it is something I would use for full blown performance test. That being said I don't see any reason we couldn't make a sampler that could write a string that uses "user defined variables" to a given file. That way they can take any data they captured from a sampler and write it to a file.
(In reply to Brian Wolfe from comment #2) > wouldn't flushing to the file every call cause a performance bottleneck? Yes, that's why I was proposing a parameter to control this: - false : would mean flush smartly (on thread or test end) - true : flush on every write > I could definitely see this being useful when building a test, I agree that for data validation it is very useful. > but idk if it > is something I would use for full blown performance test. > > That being said I don't see any reason we couldn't make a sampler that could > write a string that uses "user defined variables" to a given file. That way > they can take any data they captured from a sampler and write it to a file. It is definitely possible today using JSR223 Sampler to do it. Do you mean create a sampler called "Write to file" ? We could alternatively add a class to Java Request
Yes. A Write to File sampler would be really nice. During a test we can compute a dynamic value for a variable and we need a simple way to put this value into a file (of course, we will specify the filename). The data whithin the file will be used as input data in next step or next JMX script. If it's easier to develop this as a function like you mention: ${__stringToFile(<file path>, <sync_id>, <string to write>)} then this is fine also. If we want to create different files we can use timestamp as filename or UUID, so don't worry about the file being overwritten. Best regards, Sebi
PR contributed: https://github.com/apache/jmeter/pull/454 @UbikLoadPack Team
Author: pmouawad Date: Sat Apr 13 08:25:35 2019 New Revision: 1857453 URL: http://svn.apache.org/viewvc?rev=1857453&view=rev Log: Bug 63219 - New function "__StringToFile" to save a string into a file Contributed by UbikLoadPack (https://ubikloadpack.com) Bugzilla Id: 63219 Added: jmeter/trunk/src/functions/org/apache/jmeter/functions/StringToFile.java (with props) jmeter/trunk/test/src/org/apache/jmeter/functions/TestStringtoFile.java (with props) Modified: jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties jmeter/trunk/xdocs/changes.xml jmeter/trunk/xdocs/usermanual/functions.xml
Tested on Relase: r1857470 It works. Thank you very much!
Verified the issue on JMeter 5.2.1 (production). It works.
This issue has been migrated to GitHub: https://github.com/apache/jmeter/issues/5027