0
votes

We have ftp server with few directories and files under it, I am able to connect through browser and access directories successfully. However when used the same server:port with credentials not able to connect. Tried using JSR233 sampler also to list the files, but no success.

please guide.

TestPlan: FTP request defaults (Server IP and port:21)>get(RETR) --Thread Group ---FTP request (nothing added as remote file since just want to get list of files/directories) ---JSR233 sampler with below script

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

def ftpClient = new FTPClient()
ftpClient.connect("xx.xx.xx.xx", 21)
ftpClient.login("'abc", "tesst")

ftpClient.listFiles().each {
log.info(it.getName())
}

log.info("---")

for FTP request getting an error as below: Response message: java.io.FileNotFoundException: (The system cannot find the path specified) Request is going as: ftp://xx.xx.xx.xx:21/ (Ascii) ->
for JSR233 sampler: shows success without any response, files are list listed even in jmeter log also.

Please suggest how to achieve this.

Added screen shot of jmeter.log and .jmx file.

jmeter.log info

[![FTP req defaults[![FTP req![JSR233 sampler[![res msg: The system cannot find the path specified) [JSR233 results]2]3]4]5

2

2 Answers

0
votes

Able to get results in the Jmeter log file now, there was extra ' in the credentials going.

0
votes

You might need to call FTPClient.changeWorkingDirectory() method before listing files as your abc user.

Prior to doing anything else you might want to test whether you connected to the FTP server or not by calling ftpClient.isConnected() method

Also be aware that FTPClient.login() method returns true if login is successful and false otherwise.

According to the Load Testing FTP and SFTP Servers Using JMeter article your code needs to be amended like:

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

def ftpClient = new FTPClient()
ftpClient.connect('xx.xx.xx.xx', 21)
if (ftpClient.isConnected()) {
    if (ftpClient.login('abc', 'tesst')) {
        ftpClient.changeWorkingDirectory('/path/to/the/folder/with/files/') // navigate to the folder which content you want to list

        ftpClient.listFiles().each {
            log.info(it.getName())
        }
    } else {
        log.error('Failed to login')
    }
} else {
    log.error('Failed to connect')
}

If none of the above hints will help post update your question with the jmeter.log file contents.