FTP Delete

110 views
Skip to first unread message

gmar...@cocq.com.ar

unread,
Apr 23, 2015, 3:36:18 PM4/23/15
to jmeter-...@googlegroups.com
Since there is no FTP Delete option in the FTP Sampler

Is there any way to do a "Login - Upload - Download - Delete" FTP sequence in Beanshell?

Thanks in advance!

gli...@gmail.com

unread,
Apr 24, 2015, 7:13:40 AM4/24/15
to jmeter-...@googlegroups.com, gmar...@cocq.com.ar
Sure, it's possible, kindly find example code for deleting a file from FTP server below:

import org.apache.commons.net.ftp.FTPClient;

FTPClient client = new FTPClient();
client.connect("your_ftp_server_hostname");
client.login("your_username", "your_password");
boolean success = client.deleteFile("file_to_delete.extension");
log.info("Success: " + success);
if (!success) {
  SampleResult.setSuccessful(false);
  SampleResult.setResponseMessage("Failed to delete file");
}
client.disconnect();

Few recommendations:

  1. Use JMeter's FTP Sampler for upload and download, and scripting one for delete
  2. Use JSR223 Sampler and "groovy" language instead of Beanshell - this way you'll be able to achieve optimal performance. Beanshell isn't being actively developed and/or supported and Groovy scripts can be compiled into bytecode hence can be as fast as pure Java. See Beanshell vs JSR223 vs Java JMeter Scripting: The Performance-Off You've Been Waiting For! guide for explanation, details on installing groovy scripting engine and some usage tips. 
  3. If you're looking for the way of implementing the whole upload/download/delete sequence see FTPClient Javadoc for details. 
  4. This group is actually for JMeter Plugins related questions, you should ask generic questions in JMeter Forum group 


Reply all
Reply to author
Forward
Message has been deleted
0 new messages