<<
Home , ENV

Spirent TestCenter Automation Validating the environment and configuring the system variables – an overview

August 10 2016 SRE Chicago

Vijay Muthucumarasamy Principle Field Service Engineer

Spirent Communications PROPRIETARY AND CONFIDENTIAL 1 Agenda

 Spirent Automation and Supported Platforms  and Validation  Environment Set up and Verification • TCL • Python • Perl  Lab Server  HLTAPI  Sequencer  Q & A

Spirent Communications PROPRIETARY AND CONFIDENTIAL 2 Supported OS and API

1. Multi-threaded 2. If you are using Avalanche on Spirent TestCenter, Windows 2008 server is not officially supported this . 3. Running as a 32-bit application 4. Requires LabServer 5. Requires openssh-client package **** PLEASE Check the release notes for updated information

Spirent Communications PROPRIETARY AND CONFIDENTIAL 3 Spirent API Packages for Environment

Spirent Communications PROPRIETARY AND CONFIDENTIAL 4 Verify and Validate the OS & API

 Before the STC installation packages • Verify the Operating System - Kernel - CPU - Memory - Validate the requirement : Check the Spirent TestCenter releases and verify Spirent requirements

• Verify the API (TCL/Python/Perl) - Release version - Whether 32/64 bit platform - Whether need a Spirent Lab Server - Validate the requirement : Check the Spirent TestCenter releases and verify Spirent requirements

Spirent Communications PROPRIETARY AND CONFIDENTIAL 5 Operating System and Validation

 Verify Kernel version • CentOS/RedHat/Ubuntu - /etc/issue - cat /etc/redhat-release (CentOs/RedHat) - –r -> Kernel Release - uname –i / uname –m / uname –p -> OS platform whether 32bit or 64bit - uname –a (display all the information)

Memory and CPU - free -h -> Provides memory information - cat /proc/cpuinfo - cat /proc/meminfo /Dir - Find / -name “filename” - Find /dir//look/up -name "pattern"

Spirent Communications PROPRIETARY AND CONFIDENTIAL 6 TCL (Tool Command Language)

 Supported Versions • 8.4.13 • 8.5.9 • 8.5.14 • Both 32 bit and 64 bit (Lab Server is not mandatory from STC release v4.64)

 Verify TCL version • Info patchlevel - % info patchlevel 8.4.19  Verify whether the TCL platform (32 bit or 64 bit) • parray tcl_platform - % parray tcl_platform tcl_platform(byteOrder) = littleEndian tcl_platform(machine) = x86_64 tcl_platform(os) = Linux tcl_platform(osVersion) = 2.6.32-642.3.1.el6.x86_64 tcl_platform(platform) = tcl_platform(tip,268) = 1 tcl_platform(tip,280) = 1 tcl_platform(user) = spirent tcl_platform(wordSize) = 8

Spirent Communications PROPRIETARY AND CONFIDENTIAL 7 TCL and Environment Variables

 Windows • Spirent TCL installation - sure environment “path” variable has the TCL installation path as shown below « C:\Program Files (x86)\Spirent Communications\Spirent TestCenter 4.xx\TCL\bin; »

Spirent Communications PROPRIETARY AND CONFIDENTIAL 8 TCL and Environment Variables cont.…

 Windows • Active State TCL /Other - Make sure environment “path” variable has the TCL installation path « C:\Tcl\bin; » - Set up environment and pkgIndex.tcl * Create a System Variable STC_INSTALL_DIR and assign STC dir

* Under C:\Tcl\lib create a new folder named "stc" * Under the stc folder, create a new file named "pkgIndex.tcl" and edit/add the file as shown below: package ifneeded SpirentTestCenter 2.0 [list source [file $env(STC_INSTALL_DIR) SpirentTestCenter.tcl]] package ifneeded stc 2.0 [list source [file join $env(STC_INSTALL_DIR) SpirentTestCenter.tcl]] package ifneeded stclib 4.xx [list source [file join $env(STC_INSTALL_DIR) stclib.tcl]]

Spirent Communications PROPRIETARY AND CONFIDENTIAL 9 TCL and

 Linux • Active State TCL /Other - Set up .bash_profile (works for RedHat,CentOs and Ubuntu) for STC env. Variable # .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs # TCL installtion for STC export PATH=/opt/ActiveTcl-8.4.19-32/bin:$PATH #Set up LD_LIBRARY_PATH with Spirent Installation dir export LD_LIBRARY_PATH=/opt/Spirent_TestCenter_4.xx/Spirent_TestCenter_Application_Linux export STC_INSTALL_DIR=/opt/Spirent_TestCenter_4.xx/Spirent_TestCenter_Application_Linux - Set up environment with pkgIndex.tcl * Under /opt/ActiveTcl-8.4.19-32/lib, create a new folder named "stc" * Under the stc folder, create a new file named "pkgIndex.tcl" and edit it as shown: package ifneeded SpirentTestCenter 2.0 [list source [file join $env(STC_INSTALL_DIR) SpirentTestCenter.tcl]] package ifneeded stc 2.0 [list source [file join $env(STC_INSTALL_DIR) SpirentTestCenter.tcl]] package ifneeded stclib 4.xx [list source [file join $env(STC_INSTALL_DIR) stclib.tcl]]

Spirent Communications PROPRIETARY AND CONFIDENTIAL 10 TCL : Load STC package and verify

 Load the Spirent TestCenter Package C:\Users\vmuthucuma>tclsh % package require SpirentTestCenter 4.64 %

Spirent Communications PROPRIETARY AND CONFIDENTIAL 11 TCL : Change Spirent Environment Variable in Runtime

 How to run multiple STC versions at the same time? • The environment variable can be changed in the script this allows to change the environment variable for that specific run. • This is also applicable to any API including Python, Perl and also HLTAPI as well

• Windows - set auto_path [linsert $auto_path 0 "C:/Program Files (x86)/Spirent Communications/Spirent TestCenter x.xx/Spirent TestCenter Application"]

• Linux - set auto_path [linsert $auto_path 0 "/opt/Spirent_TestCenter_4.64/Spirent_TestCenter_Application_Linux/"]

Spirent Communications PROPRIETARY AND CONFIDENTIAL 12 Python

 Supported Versions • 2.6.6 • 2.7.5 • Both 32 bit and 64 bit (Lab Server is not mandatory from STC release v4.64) • 64 bit Only supported in Linux environment and not in Windows

 Verify Python version • python –V - C:\Users\vmuthucuma>python -V > Python 2.7.6

 Verify Python version whether 32bit or 64bit • import struct;print struct.calcsize("P") * 8 >>> import struct;print struct.calcsize("P") * 8 32 >>>

Spirent Communications PROPRIETARY AND CONFIDENTIAL 13 Python and Environment Variables

 Windows • Create a system environment variable “STC_PRIVATE_INSTALL_DIR” and set with Spirent Installation directory

• Copy “StcPython.py” from C:\Program Files (x86)\Spirent Communications\Spirent TestCenter 4.xx\Spirent TestCenter Application\API\Python to Python installation directory - C:\Python27

Spirent Communications PROPRIETARY AND CONFIDENTIAL 14 Python and Environment Variables

 Linux • Create a system environment variable “STC_PRIVATE_INSTALL_DIR” in .bash_profile and set with Spirent Installation directory export STC_PRIVATE_INSTALL_DIR=/opt/Spirent_TestCenter_4.xx/Spirent_TestCenter_Application_Linux

• Copy “StcPython.py” From /InstallationDir/Spirent_TestCenter_4.xx/Spirent_TestCenter_Application_Linux/API/Pyt hon To Python script directory example: /home/spirent/SpirentAPI

Spirent Communications PROPRIETARY AND CONFIDENTIAL 15 Python : Load STC package and verify

 Load the Spirent TestCenter Package [spirent@localhost Python]$ python Python 2.6.6 (r266:84292, Jul 23 2015, 15:22:56) [GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux2 "help", "copyright", "credits" or "license" for information. >>> from StcPython import StcPython >>> stc = StcPython() >>> print "SpirentTestCenter system version:\t", stc.get("system1", "version") SpirentTestCenter system version: 4.64.8676.0000 >>>

Spirent Communications PROPRIETARY AND CONFIDENTIAL 16 Perl

 Supported Versions • 5.8.8 • 5.8.9 • 5.14.x • Supported : Only running as 32-bit application

 Verify Perl version • perl –v - This provides version, subversion and architecture

 Verify Perl version whether 32bit or 64bit • perl -V:ivsize - If the returned value is 4, your Perl uses 32-bit integers - If the returned value is 8, your Perl uses 64-bit integers

• perl -V:archname - If the returned value includes x86_64, it's a 64-bit process - If the returned value includes x86 (but not x86_64), it's a 32-bit process.

Spirent Communications PROPRIETARY AND CONFIDENTIAL 17 Perl and Environment Variables

 Windows • Create a system environment variable “STC_PRIVATE_INSTALL_DIR” and set with Spirent Installation directory

• Copy “SpirentTestCenter.pm” from C:\Program Files (x86)\Spirent Communications\Spirent TestCenter 4.xx\Spirent TestCenter Application\API\Perl to C:\Perl\site\lib • Edit “SpirentTestCenter.pm” and CHANGE use lib "/home/user/Spirent_TestCenter_2.3x/"; To use lib $ENV{'STC_PRIVATE_INSTALL_DIR'};

Spirent Communications PROPRIETARY AND CONFIDENTIAL 18 Perl and Environment Variables

 Linux • Create a system environment variable “STC_PRIVATE_INSTALL_DIR” in .bash_profile and set with Spirent Installation directory export STC_PRIVATE_INSTALL_DIR=/opt/Spirent_TestCenter_4.xx/Spirent_TestCenter_Application_Linux

• Set the path variable for perl execution file in .bash_profile export PATH=/opt/ActivePerl-5.14/bin:$PATH

• Copy “SpirentTestCenter.pm” From opt/Spirent_TestCenter_4.xx/Spirent_TestCenter_Application_Linux\API\Perl To /opt/ActivePerl-5.14/site/lib or /perl_Installation/site/lib

• Edit “SpirentTestCenter.pm” and Change use lib "/home/user/Spirent_TestCenter_2.3x/"; To use lib $ENV{'STC_PRIVATE_INSTALL_DIR'};

Spirent Communications PROPRIETARY AND CONFIDENTIAL 19 Perl : Load STC package and verify

 Load the Spirent TestCenter Package • Create a Load_show_version.pl • Add the following #!/usr/bin/perl -w # load the STC package print "Loading the STC package...\n"; use strict; use SpirentTestCenter; my($stc); $stc = new StcPerl; # Retrieve and display the current API version. my $systemVersion = $stc->get("system1", "Version"); print "SpirentTestCenter system version:\t $systemVersion\n"; print " ...... END OF ...... \n"; • Run the script > perl Load_show_version.pl

Spirent Communications PROPRIETARY AND CONFIDENTIAL 20 Lab Server

 Advantages • Effectively use test resources by allowing users to connect and disconnect from a live test • Collaboratively debug with multiple users overseeing another user’s actions • Real-time GUI debugging of automation scripts • Support for both physical and virtual ports  API Requirement • STC v4.63 and older versions need Lab Server to support 64bit API for TCL and Python • STC v4.64 and latest support 64bit API without Lab Server - However, great to have a Lab Server to view Real-time automation scripts results via GUI • REST API - The HTTP request methods GET, POST, PUT, and DELETE are used with a URI identifying a resource or function to provide access to all Spirent TestCenter Automation functionality - Requires Lab Server

Spirent Communications PROPRIETARY AND CONFIDENTIAL 21 Lab Server and Environmental Variables

 Windows • The Lab Server environmental variables can be set in two ways 1. Create windows system environmental variables or

2. Set the variables and values at run time using “set” in a command window set STC_SERVER_ADDRESS=10.20.100.15 set STC_SESSION_NAME=__NEW_TEST_SESSION__ set STC_SESSION_SYNCFILES_ON_SEQ_COMPLETE=1 set STC_SESSION_TERMINATE_ON_DISCONNECT=1

Spirent Communications PROPRIETARY AND CONFIDENTIAL 22 Lab Server and Environmental Variables

 Linux • Again the variable can be set in two ways 1. Set the variable in the .bash_profile export STC_SERVER_ADDRESS=10.20.100.15 export STC_SESSION_NAME=__NEW_TEST_SESSION__ export STC_SESSION_SYNCFILES_ON_SEQ_COMPLETE=1 export STC_SESSION_TERMINATE_ON_DISCONNECT=1

2. Set the variables and values at run time using “export” as shown above

Spirent Communications PROPRIETARY AND CONFIDENTIAL 23 Lab Server and Session

 Creating a new session Package require SpirentTestCenter stc::perform CSTestSessionConnect -Host "

stc::perform CSTestSessionConnect -host 10.20.100.15 -TestSessionName "Demo" -OwnerId VijayM # Disconnect the session stc::perform CSTestSessionDisconnect -Terminate TRUE/FALSE Note: you can have one controller, so make sure the if a GUI open the Configuration as a controller then close the controller GUI. Otherwise the API do not connect to the session

Spirent Communications PROPRIETARY AND CONFIDENTIAL 24 HLTAPI (High Level Test API)

 Supported • OS : Windows and Linux • Scripting Languages : TCL, Perl, Python  Set up environment • TCL - Windows : Set up the following environment variable and values

STC_INSTALL_DIR=C:\Program Files (x86)\Spirent Communications\Spirent TestCenter_4.xx STC_TCL= C:\TCL_installation_Dir\bin\tclsh LD_LIBRARY_PATH=C:\Program Files (x86)\Spirent Communications\Spirent TestCenter_4.xx

- Linux : Set up the .bash_profile with the below environment variables and appropriate values as shown in the example below

export STC_INSTALL_DIR=/root/spirent/Spirent_TestCenter_4.xx/ export STC_TCL=/TCL_installation_Dir/bin/tclsh export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/STC_Installation_DirSpirent_TestCenter_4.xx/ • Download and Install STC API package (only for Linux) • Download HLTAPI package • Set up the pkgIndex.tcl – as shown before in the Tcl environment section

Spirent Communications PROPRIETARY AND CONFIDENTIAL 25 HLTAPI …..

• Create a folder stcHltapi under /TCL_Installation_dir/lib • Unzip the downloaded HLTAPI file • Copy the “SourceCode” folder to the stcHltapi folder just created

• Verify the installation

Spirent Communications PROPRIETARY AND CONFIDENTIAL 26 HLTAPI – Python & Perl

 Python • Copy the HLTAPI for Python library files (hltapiserver.srv and sth.py) from /SouceCode/hltapiForPython/ to your Python Script library • Run & Verify a sample script

 Perl • Copy the HLTAPI for Python library files (hltapiserver.srv and sth.pm) from /SouceCode/hltapiForPerl/ to your Perl Script library • Run & Verify a sample script

Spirent Communications PROPRIETARY AND CONFIDENTIAL 27 GUI to HLTAPI

 STC GUI support exporting configuration into Hltapi scipts: Tcl, Python or Perl via Custom Tools  How to register into Custom Tools • Complete the required set up in the previous Hltapi slides • Register using the command window : tclsh c:\Tcl\lib\stcHltapi\tools\toolRegister.tcl stcVersion - Example

• Launch the Spirent GUI (in this case 4.64) • Verify the custom tools: Tools -> Custom Tools

Spirent Communications PROPRIETARY AND CONFIDENTIAL 28 HLTAPI and Lab Server

 Set the below environment variables in the “System variable” in window or .bash_profile in Linux

STC_LAB_SERVER_ADDRESS= STC_SESSION_NAME=__NEW_TEST_SESSION__  Also you can connect through the Hltapi script as well sth::labserver_connect -server_ip 10.20.100.15 \ -create_new_session 1 \ -session_name SRE_Demo \ -user_name Tester

Spirent Communications PROPRIETARY AND CONFIDENTIAL 29 Export from GUI & Command Sequencer

 STC support save configuration into Scripts • In the GUI, the Command Sequencer should be programmed with action commands before save and run the script  Command Sequencer as a reference for commands • If you don’t know the attributes or how to use, then configure the specific commands in the GUI, export to tcl/perl/ruby and use as reference

Spirent Communications PROPRIETARY AND CONFIDENTIAL 30 Thank you

Spirent Communications PROPRIETARY AND CONFIDENTIAL 31