I am executing a test plan where I have moved the files from source to destination one by one by using for each loop in JSR223 Sampler of JMeter. I am unable to print each fIle's status that has been moved from source to destination in the HMTL dashboard report. Currently I have used the Label property of JSR223 Sampler like this - SampleResult.setSampleLabel("Source: " + '${source}' + "::" + "Destination: " + '${destination}' + '${data}');
here ${source} represents the source path of the folder, ${destination} represents the destination folder path, and ${data} is just appended at the end of the ${destination} folder path.
My groovy script is:
import org.apache.jmeter.services.FileServer
log.info("############################################################# START #############################################################");
def baseDestinationFolder = new String('${destination}');
log.info(baseDestinationFolder); // /home/solitera/CDRs/Input/
def dataDestFolder = baseDestinationFolder + '${data}';
def SMSDestFolder = baseDestinationFolder + '${sms}';
def VoiceDestFolder = baseDestinationFolder + '${voice}';
log.info("dataDestFolder : " + dataDestFolder); // /home/test/CDRs/Input/DATA/
log.info("SMSDestFolder : "+SMSDestFolder); // /home/test/CDRs/Input/SMS/
log.info("VoiceDestFolder : " + VoiceDestFolder); // /home/test/CDRs/Input/VOICE/
File sourceFolder = new File('${source}');
File[] datafiles = sourceFolder.listFiles();
for (File inputFile : datafiles){
def fileName = "" + inputFile.getName();
log.info("fileName : " + fileName);
def finalPath;
if(fileName.contains("data")){
SampleResult.setSampleLabel("Source: " + '${source}' + "::" + "Destination: " + '${destination}' + '${data}');
log.info( "The Sample Label is : " + SampleResult.getSampleLabel() );
finalPath = dataDestFolder + fileName;
}else if(fileName.contains("voice")){
SampleResult.setSampleLabel("Source: " + '${source}' + "::" + "Destination: " + '${destination}' + '${voice}');
log.info( "The Sample Label is : " + SampleResult.getSampleLabel() );
finalPath = VoiceDestFolder + fileName;
}else if(fileName.contains("sms")){
SampleResult.setSampleLabel("Source: " + '${source}' + "::" + "Destination: " + '${destination}' + '${sms}');
log.info( "The Sample Label is : " + SampleResult.getSampleLabel() );
finalPath = SMSDestFolder + fileName;
}
log.info("finalPath is : " + finalPath);
def newFile = new File(finalPath);
newFile << inputFile.text
}
log.info("############################################################# END #############################################################");
Currently in my source folder there are three CSV files that I have moved to the destination folder but it prints only the name of one file path and gives me the response time of all three files. Is anyone please help me how can I get the individual response time of each file?