SRE + performance engineering: Improve collaboration to release performant applications faster
Shift left with observability to release quality apps faster. Join...
During your load test, you may want to log information related to your script. This is useful if you want to check data afterward, whether it was used or modified during your load test.
There are a few ways to log data during your tests:
var lock = new java.util.concurrent.locks.ReentrantLock();
var date = context.variableManager.getValue(“CurrentDate”);
if (date==null)
{
context.fail(“Variable ‘CurrentDate’ not found”);
}
function writeFile(text)
{
lock.lock();
var writer = new java.io.FileWriter(“c:\log.txt”,true);
writer.write(date+”;”+context.currentVU.id+”;”+text);
writer.write(“rn”);
writer.close();
lock.unlock();
}
Note: if you use it inside the JavaScript library, copy all the code inside the function; otherwise, the compilation won’t work. If you use all the code inside a NeoLoad JavaScript, you can leave it as is.
Pre-requisite: “CurrentDate” is a NeoLoad variable (see Variable manager, create it) that will display the current date. It’s optional and can be replaced with any variable needed.
Note: “context.currentVU.id” will display the instance of the VU; it’s also optional. And then insert this JavaScript to use the function:
var cpt = context.variableManager.getValue(“StringNameFooBar”);
if (cpt==null)
{
context.fail(“Variable ‘StringRandom’ not found”);
}
writeFile(cpt+”;was the value from my test”);
Note: “StringRandom” is a Neoload variable; it’s optional and can be replaced with any other variable needed.
For more information, see Use the Javascript API in Neoload documentation.
In NeoLoad, it is possible to write content to a file from the GUI interface of a specific response given during playback or test. The Response storage checkbox makes it possible to save the content of the response in a .bin file. This function stores the content of the response on the machine executing the virtual users to check it externally. Here’s how:
The goal of this technique is to capture an extraction and write this value to a file. NeoLoad has an advanced action, under the “Launchers” section, called “command line.”
Combine this technique with a shell script to better enhance the data manipulation should you need to. To use the command line, drag the action into your User Path, and add the required parameters. As you can see in the figure below, I’m calling the shell script and then pushing data from the extraction (variable) that I’m getting from the response.
Here is the simple shell script that is being called:
#!/bin/bash
echo $1 >>/Users/neotys/Desktop/nl_text.txt
[H2] Next steps: Review documentation or talk to us
Check out all of the content included within NeoLoad documentation.
Want to discuss further, contact support.
Shift left with observability to release quality apps faster. Join...
Explore common regression testing challenges faced by Agile teams –...
Ensure reliable, scalable application performance across on-prem,...
Ensure SAP data accuracy & reliability. Learn risks, key...
Watch this webinar to learn some advanced strategies for...