Setting up Avalanche Automation on Linux

The Avalanche product comes with a fully-featured TCL API for several operating systems: Windows, Linux and FreeBSD. Coupled with the “GUI to TCL” feature of the Windows thick client (Avalanche Commander) it’s a very powerful automation tool. The typical use case is “write a test case in the GUI, export it to TCL and execute it from a Linux Virtual Machine” (through a cron task for instance or a Continuous Integration process). This article provides a step-by-step guide on how to do just that on CentOS/RHEL 6.x.


You will need the following files in order to proceed:

  • Some kind of TCL 8.5 threaded binary. I typically use ActiveState’s. Make sure to use version 8.5.x with the threaded module.
  • A working Java Virtual Machine (JVM). OpenJDK works just fine, you don’t have to use the official JVM from Oracle. You need version 6 (7 is not supported yet).
  • The Avalanche API for Linux, which you can get from our Support website under Avalanche/RHEL (it will still work with Debian).

I will use a sudoer user called ‘bench’ in the examples.

Preparing the system

First, let’s install the TCL shell and extract the Avalanche API. I will store both under /opt.

[bench@localhost ~]$ tar -xvzf ActiveTcl8.
[bench@localhost ~]$ sudo ./ActiveTcl8.
[stuff happening, use all default values]
Now let’s extract the API and move it under /opt/spirent/api :
[bench@localhost ~]$ tar -xvzf Layer_4_7_Auto_Linux_4.46.tar.gz
[bench@localhost ~]$ sudo mkdir /opt/spirent/
[bench@localhost ~]$ sudo mkdir /opt/spirent/api
[bench@localhost ~]$ sudo mv -f Layer_4_7_Auto_Linux_4.46/Layer_4_7_Application_Linux/ /opt/spirent/api/

We also need to create a directory where to store the licenses of the load generators (if you use an appliance other than the C1 or C100-MP you can skip this step) and also a directory where we’ll put all the tests (this can be anywhere of your liking, I’m putting it under the home of the user).

[bench@localhost ~]$ sudo mkdir /opt/spirent/licenses
[bench@localhost ~]$ mkdir ~/spirent/
[bench@localhost ~]$ mkdir ~/spirent/tests

Now let’s add the path to the TCL interpreter in that user’s PATH environment variable:

[bench@localhost ~]$ vi ~/.bash_profile

In that file, append the path to Active TCL 8.5, like so:

export PATH

Let’s reload the profile to make sure it’s working:

[bench@localhost ~]$ source ~/.bash_profile 
[bench@localhost ~]$ echo $PATH
Avalanche TCL scripts rely on a couple of environment variables so we also need to put them in to the user’s profile. The first one is SPIRENT_TCLAPI_ROOT, the second one is SPIRENT_TCLAPI_LICENSEROOT. Edit the profile again and add these lines at the end:
export SPIRENT_TCLAPI_ROOT=/opt/spirent/api/Layer_4_7_Application_Linux/TclAPI
export SPIRENT_TCLAPI_LICENSEROOT=/opt/spirent/licenses

We need to install the Java Runtime Environment (JRE) version 1.6. OpenJDK works just fine:

[bench@localhost ~]$ sudo yum install java-1.6.0-openjdk.x86_64

Last but not least we need to install the Session Manager daemon. This is a middleware that interfaces itself between the GUI/TCL scripts and the Avalanche backend. Its main function is to ensure backward compatibility of scripts, but also to track the sessions between a front end (TCL, GUI) and the backend.

A Shell script will set everything up for you. First we need to make all the scripts executable, then run the main one. Note: you need to run this as root or a sudoer!

[root@localhost ~]# cd /opt/spirent/api/Layer_4_7_Application_Linux/service/bin/
[root@localhost bin]# cdmod +x ./*
[root@localhost bin]# ./
[root@localhost bin]# ./
You can tell that everything was setup correctly if you can see the daemon listening on port 9194:
[root@localhost bin]# netstat -tap | grep 9194  
tcp        0      0 *:9194                      *:*                         LISTEN      10309/java

We are now all set to run Avalanche TCL tests on this machine!

Generating TCL Tests

There are two ways to get Avalanche TCL tests: you can write them yourself or export a GUI test to TCL. In this document we will do the later. Open an Avalanche Commander, load a test then go to File > Generate Tcl Test. You should get this window:

GUI to TCL window

Most of the settings should be self-explanatory. The “Portable Test” box means that instead of using absolute paths to point to licenses and the API directory, the script will instead look for environment variables (this is why we set them earlier in this article). This way you can very easily generate from Windows and execute them on Linux.

Simply press “Generate TCL Test” and the appropriate files will be generated under a sub-directory using the {ProjectName}-{TestName} naming convention. Some files will be generated, copy them all to the Linux system.

Once this is done we can execute the test by invoking the “test.tcl” script:

[bench@localhost ~]$ cd spirent/tests/ABR_LabManager-Smooth_OneArm/
 [bench@localhost ABR_LabManager-Smooth_OneArm]$ tclsh test.tcl 
 Avalanche initialization is complete
 Tcl API root: '/opt/spirent/api/Layer_4_7_Application_Linux/TclAPI'
 Login as default user ... – done
 Connect to '' ... – done
 Using license 'Bundle_C100_3100Bx2_4.30' ... – done
 Reserve port '' ... – done
 Preparing test...
 Creating httpbodies node Default... – done
 Creating actionlists node Default... – done
 Creating certificates node server... – done
 Creating loads node 10_Users... – done
 Creating transactions node Default... – done
 Creating adaptivestreaming node demo... – done
 Creating adaptivestreaming node ms_smooth... – done
 Creating networkprofile node Smooth_OneArm... – done
 Creating pppoeparams node Default... – done
 Creating ppparams node Default... – done
 Creating authentications node Default... – done
 Creating ddosconfig node Smooth_OneArm... – done
 Creating clientsubnets node Default... – done
 Creating userprofiles node Default... – done
 Creating configuration node Smooth_OneArm... – done
 Configuring ThreatEx ... – done
 Run test 'Smooth_OneArm' in project 'ABR_LabManager' in Full mode... – done
 Dividing test across load generators...
 Uploading the 'Smooth_OneArm' test...
 Starting 'Smooth_OneArm' test...
 Running 'Smooth_OneArm' test...
 Merging test results...
 Finished running 'Smooth_OneArm' test.
 Copy results from '/home/Spirent/data/user/bench/workspaces/.temp1417701088148/projects/ABR_LabManager/results/Smooth_OneArm/2014_12_04_14_51_43' to '/home/bench/spirent/tests/ABR_LabManager-Smooth_OneArm/results' ... – done
 Releasing port '' ... – done
 Deleting test 'Smooth_OneArm' ... – done
 Deleting project 'ABR_LabManager' ... – done
 Logout ... – done
 [bench@localhost ABR_LabManager-Smooth_OneArm]$

And that’s all there is to it!


About acastaner

I'm the EMEA Technical Lead for Application & Security at Spirent. I specialize in layer 4-7 technologies, Cloud, Programming and CyberSecurity.
This entry was posted in Tutorial and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s