Testing SFTP in StormRunner Load

New Member.
0 0 1,172

If you need to use SFTP (Secure Shell File Transfer Protocol) to generate load in StormRunner Load (SRL), you can choose any protocol with which you are familiar. For example: Java, TruAPI, .NET, JMeter, etc. (Refer to https://admhelp.microfocus.com/srl/en/latest/Content/Storm/t_manage_scripts.htm for additonal details about the supported protocols in SRL.)

Below is a simple example to demonstrate how to perform SFTP testing with the Java protocol:

  1. In VuGen, create a new “Java Vuser” script.

    sftp 1.png


  1. From Maven repository, download the latest jsch (which is a pure Java implementation of SSH2) jar file. (The latest version is currently 0.1.55.) 
  1. In VuGen, right click the Extra Files node in Solution Explorer and select Add Files to Script… to add the downloaded jsch-0.1.55.jar.sfpt 2.png

    If you want to use key-based authentication, you can also add your key file into the script. 

  1. Configure settings for your SFTP server (for example: host, port, username, etc.). In the example below, settings are added into the ‘Additional Attributes’ section in Runtime Settingssfpt 3.png


  1. Update “Actions” to read your SFTP settings and import com.jcraft.jsch.*sfpt 4.png


  1. You are now ready to add codes to implement real SFTP steps. For demonstration purposes, we’ll only show a very basic flow: connect to the SFTP server and then download a file. 

    6.1 Connect SSH session
          JSch jsch = new JSch();
          Session session = jsch.getSession(username, server, port);

    If you need to use key based authentication, you can use “addIdentity” to configure it.
          JSch jsch = new JSch();   
           Session session = jsch.getSession(username, server, port);

    If you encounter an error related to an unknown host, you can disable it with the code below.
           Properties config = new Properties();
           config.put("StrictHostKeyChecking", "no"); 

    6.2 Connect SFTP
    Once an SSH session is successfully created, an SFTP connection can be established.
          Channel channel = session.openChannel("sftp");
          lr.output_message("connected to " + server);
          lr.end_transaction("connect server", lr.AUTO);

          ChannelSftp sftp = (ChannelSftp)channel;

    6.3 Download the file
    With the above ‘sftp’, we can easily perform various ftp operations (for example: cd, get, put, etc.).
          SecureRandom srand = new SecureRandom();
           int rand = srand.nextInt(10000000);
           sftp.get(target_dir + "/" + filename, filename + "." + rand, null, ChannelSftp.OVERWRITE);

    This downloads the file and saves it into the current directory with a unique identifier as the name suffix.

    6.4 Cleanup

    For detailed usage of jsch, refer to http://www.jcraft.com/jsch/examples/ and http://www.docjar.org/docs/api/com/jcraft/jsch/package-index.html.
  1. Replay and debug your script in VuGen to make sure it works as expected. 
  1. Once the script is ready, use the menu options “File” > “Manage Zip Files” > “Export to Zip File…” to create the script zip file and then upload it to SRL. 

That’s it!

If you want to try SRL, go to http://software.microfocus.com/srl.

The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.