Further to this question Unable to print the individually reporting status using Label of JSR223 Sampler in HTML Dashboard Report of JMeter. I am executing a test plan on the server where I have moved files from source to destination folder.
Below is the destination folder hierarchy:
/sourceFolder/filesThatNeedToBeMoved to /destinationFolder/Input/
/destinationFolder/Input/FilesThatAreMovedByMEfromSourceFolder
/destinationFolder/Output/FilesThatAreMovedAutomaticallyFromInputTOOutputByServer
On the server-side, The destination folder has two subfolders i.e. INPUT and OUTPUT, when files are moved or copy in the destination folder INPUT then those files get automatically deleted by the server and moves to the destination folder OUTPUT. I just want to calculate the time of processing of files that are moved from INPUT to OUTPUT folder automatically by the server.
How Can I achieve this using Jmeter? Below I have shared my groovy script where I have written logic for moving the files from source to destination folder INPUT. And unable to calculate the time between INPUT To OUTPUT folder.
Can we run the script until the specific files get deleted from the INPUT folder or not?
import org.apache.jmeter.services.FileServer
log.info("############################################################# START #############################################################");
def SOURCE = vars.get('source');
log.info("SOURCE IS : " + SOURCE);
def DESTINATION = vars.get('destination');
def DATA = vars.get('data');
def SMS = vars.get('sms');
def VOICE = vars.get('voice');
def baseDestinationFolder = new String(DESTINATION);
log.info(baseDestinationFolder);
def dataDestFolder = baseDestinationFolder + DATA;
def SMSDestFolder = baseDestinationFolder + SMS;
def VoiceDestFolder = baseDestinationFolder + VOICE;
log.info("dataDestFolder : " + dataDestFolder);
log.info("SMSDestFolder : "+SMSDestFolder);
log.info("VoiceDestFolder : " + VoiceDestFolder);
File sourceFolder = new File(SOURCE);
log.info("******* SOURCE FOLDER IS ******** : " + sourceFolder);
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 #############################################################");