CloudTest – Anything is po-ssh-ible with Java

The need for a POC

I came across a situation where I needed to time an SSH call to a UNIX server and wanted to see if CloudTest was a viable option to perform this testing. SOASTA CloudTest gives you the capability to run Java code within a Clip. There is a short tutorial on how to use Java code in CloudTest available on the CloudLink forum. I read through the document and got to work on my proof of concept project!

Sending an SSH message with Java

The first step was to figure out how to send an SSH method through Java.  To be honest, it had been some time since I used Java, so off we go to our favorite search engine!


A few quick clicks later, I found example code for a Java implementation of ssh2 called JSch (Java Secure Channel).  The provided code is exactly what I needed to connect to an sshd server.  The next step was downloading a Java IDE.  I chose Eclipse Standard 4.4 which you can find on the Eclipse download site.

Prepping your Eclipse IDE for use with CloudTest

One key requirement that wasn’t mentioned specifically in the CloudTest documentation was the need to use Java 6 to build any code planned for use in the tool.  You most likely have a newer version of Java (7 or 8) so you’ll need to download and install Java JRE 1.6 on your computer.

Create a Java Package and Export a Runnable JAR

Once you have the appropriate JRE installed, we need to create a Java Package, import the example code for JSch, and export everything to a Runnable JAR file for CloudTest to use.  The steps below will walk you through the process:

  1. Open Eclipse JDE and Create a New Java Project
  2. Create a new Java Package
  3. Create a new Java Class
  4. Navigate to the Project Properties and add an External Jar to the Java Build Path.  Navigate to where you downloaded the jsch-0.1.47.jar file and add it to your project
  5. Add the example Java code into your new Class.  In my example, I added the import statements above the Class definition and make the SSH connection code part of the Class Constructor.  The main function was left blank for now. Note: Make sure you have a UNIX box available to test against and that you are able to SSH to it from your machine and from your CloudTest machine.  Enter your log-on information in the user, host, and password variables.  I used a Linux server on AWS for testing purposes.
  6. Test your code in Eclipse before uploading to CloudTest.  You should see the SSH connection and ls –l command in the Console tab before moving on to the next step.
  7. Navigate to File -> Export in Eclipse.  Select Runnable JAR File and make sure you select to “Extract required libraries into the generated JAR.”  This makes sure the JSch jar is available within CloudTest.  Note the location of your saved JAR file, we will be uploading this to CloudTest next.

Now we are ready to import everything into CloudTest!

Import Java code to CloudTest and implement in a Clip

  1. In your CloudTest instance, create a new Custom Module and import your JAR file.
  2. Next, create a new Script and add the newly created Custom Module to the Script.  Add the following code to your script to allow calls to your Java functions.  It is extremely important to put Packages. in front of your package name if you did not follow standards when naming the package (we did not).
    Code below

    //import the java code from the custom module 
    // create the java object and call it 
    var exampleVar = new SSH_for_CloudTest(); 
    $context.result.postMessage($context.result.LEVEL_ERROR, "An error happened.", err); 
  3. Save the Script and create a new Test Clip which calls the Script
  4. Play your Clip in a Composition and make sure it runs successfully

Notes: I recommend logging onto your UNIX server and monitoring the SSH logs to verify your Script is working as expected.



CloudTest scripts use JavaScript in their Scripts, but also supports the ability to create and use custom Java code.  This makes CloudTest extremely powerful and flexible!

The following key information contributed to helping me make a working solution

  • Compile code in Java 6
  • Export a Runnable JAR file
  • Use Package. In front of import statement
  • Make sure UNIX box is available on the network and will allow SSH from CloudTest IP address

Go forth, code in Java, and expand your CloudTest capabilities!


By Terri Calderone, Principal Consultant of Performance Testing Services at Orasi Software

Terri Calderone has worked in the Performance Testing industry for over 10 years. Her role as a Principal Consultant at Orasi incorporates tool installation/configuration, performance testing, system analysis, continuous integration, process improvement, and new technologies. In her free time, she enjoys trying new recipes in the kitchen, swing dancing, and occasionally home brewing beer.

Leave a comment