Spirent TestCenter Automation - support-kb.spirent.com · Spirent Automation and Supported...

31
1 Spirent Communications PROPRIETARY AND CONFIDENTIAL Spirent TestCenter Automation Validating the environment and configuring the system variables an overview Vijay Muthucumarasamy Principle Field Service Engineer August 10 2016 SRE Chicago

Transcript of Spirent TestCenter Automation - support-kb.spirent.com · Spirent Automation and Supported...

Page 1: Spirent TestCenter Automation - support-kb.spirent.com · Spirent Automation and Supported Platforms ... END OF TEST ... resource or function to provide access to all Spirent TestCenter

1Spirent Communications PROPRIETARY AND CONFIDENTIAL

Spirent TestCenter Automation Validating the environment and configuring the

system variables – an overview

Vijay Muthucumarasamy

Principle Field Service Engineer

August 10 2016

SRE Chicago

Page 2: Spirent TestCenter Automation - support-kb.spirent.com · Spirent Automation and Supported Platforms ... END OF TEST ... resource or function to provide access to all Spirent TestCenter

2Spirent Communications PROPRIETARY AND CONFIDENTIAL

Agenda

Spirent Automation and Supported Platforms

Operating System and Validation

Environment Set up and Verification

• TCL

• Python

• Perl

Lab Server

HLTAPI

Command Sequencer

Q & A

Page 3: Spirent TestCenter Automation - support-kb.spirent.com · Spirent Automation and Supported Platforms ... END OF TEST ... resource or function to provide access to all Spirent TestCenter

3Spirent Communications PROPRIETARY AND CONFIDENTIAL

Supported OS and API

1. Multi-threaded

2. If you are using Avalanche on Spirent TestCenter, Windows 2008 server is not officially supported at this time.

3. Running as a 32-bit application 4. Requires LabServer 5. Requires openssh-client package

**** PLEASE Check the release notes for updated information

Page 4: Spirent TestCenter Automation - support-kb.spirent.com · Spirent Automation and Supported Platforms ... END OF TEST ... resource or function to provide access to all Spirent TestCenter

4Spirent Communications PROPRIETARY AND CONFIDENTIAL

Spirent API Packages for Linux Environment

Page 5: Spirent TestCenter Automation - support-kb.spirent.com · Spirent Automation and Supported Platforms ... END OF TEST ... resource or function to provide access to all Spirent TestCenter

5Spirent Communications PROPRIETARY AND CONFIDENTIAL

Verify and Validate the OS & API

Before install 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

Page 6: Spirent TestCenter Automation - support-kb.spirent.com · Spirent Automation and Supported Platforms ... END OF TEST ... resource or function to provide access to all Spirent TestCenter

6Spirent Communications PROPRIETARY AND CONFIDENTIAL

Operating System and Validation

Verify Kernel version

• CentOS/RedHat/Ubuntu

- cat /etc/issue

- cat /etc/redhat-release (CentOs/RedHat)

- uname –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

Find File/Dir

- Find / -name “filename”

- Find /dir/path/look/up -name "pattern"

Page 7: Spirent TestCenter Automation - support-kb.spirent.com · Spirent Automation and Supported Platforms ... END OF TEST ... resource or function to provide access to all Spirent TestCenter

7Spirent Communications PROPRIETARY AND CONFIDENTIAL

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) = unix

tcl_platform(tip,268) = 1

tcl_platform(tip,280) = 1

tcl_platform(user) = spirent

tcl_platform(wordSize) = 8

Page 8: Spirent TestCenter Automation - support-kb.spirent.com · Spirent Automation and Supported Platforms ... END OF TEST ... resource or function to provide access to all Spirent TestCenter

8Spirent Communications PROPRIETARY AND CONFIDENTIAL

TCL and Environment Variables

Windows

• Spirent TCL installation

- Make sure environment “path” variable has the TCL installation path as shown below

« C:\Program Files (x86)\Spirent Communications\Spirent TestCenter 4.xx\TCL\bin; »

Page 9: Spirent TestCenter Automation - support-kb.spirent.com · Spirent Automation and Supported Platforms ... END OF TEST ... resource or function to provide access to all Spirent TestCenter

9Spirent Communications PROPRIETARY AND CONFIDENTIAL

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 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]]

Page 10: Spirent TestCenter Automation - support-kb.spirent.com · Spirent Automation and Supported Platforms ... END OF TEST ... resource or function to provide access to all Spirent TestCenter

10Spirent Communications PROPRIETARY AND CONFIDENTIAL

TCL and Environment Variable

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]]

Page 11: Spirent TestCenter Automation - support-kb.spirent.com · Spirent Automation and Supported Platforms ... END OF TEST ... resource or function to provide access to all Spirent TestCenter

11Spirent Communications PROPRIETARY AND CONFIDENTIAL

TCL : Load STC package and verify

Load the Spirent TestCenter Package

C:\Users\vmuthucuma>tclsh

% package require SpirentTestCenter

4.64

%

Page 12: Spirent TestCenter Automation - support-kb.spirent.com · Spirent Automation and Supported Platforms ... END OF TEST ... resource or function to provide access to all Spirent TestCenter

12Spirent Communications PROPRIETARY AND CONFIDENTIAL

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/"]

Page 13: Spirent TestCenter Automation - support-kb.spirent.com · Spirent Automation and Supported Platforms ... END OF TEST ... resource or function to provide access to all Spirent TestCenter

13Spirent Communications PROPRIETARY AND CONFIDENTIAL

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

>>>

Page 14: Spirent TestCenter Automation - support-kb.spirent.com · Spirent Automation and Supported Platforms ... END OF TEST ... resource or function to provide access to all Spirent TestCenter

14Spirent Communications PROPRIETARY AND CONFIDENTIAL

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

Page 15: Spirent TestCenter Automation - support-kb.spirent.com · Spirent Automation and Supported Platforms ... END OF TEST ... resource or function to provide access to all Spirent TestCenter

15Spirent Communications PROPRIETARY AND CONFIDENTIAL

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

Page 16: Spirent TestCenter Automation - support-kb.spirent.com · Spirent Automation and Supported Platforms ... END OF TEST ... resource or function to provide access to all Spirent TestCenter

16Spirent Communications PROPRIETARY AND CONFIDENTIAL

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

Type "help", "copyright", "credits" or "license" for more information.

>>> from StcPython import StcPython

>>> stc = StcPython()

>>> print "SpirentTestCenter system version:\t", stc.get("system1", "version")

SpirentTestCenter system version: 4.64.8676.0000

>>>

Page 17: Spirent TestCenter Automation - support-kb.spirent.com · Spirent Automation and Supported Platforms ... END OF TEST ... resource or function to provide access to all Spirent TestCenter

17Spirent Communications PROPRIETARY AND CONFIDENTIAL

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.

Page 18: Spirent TestCenter Automation - support-kb.spirent.com · Spirent Automation and Supported Platforms ... END OF TEST ... resource or function to provide access to all Spirent TestCenter

18Spirent Communications PROPRIETARY AND CONFIDENTIAL

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'};

Page 19: Spirent TestCenter Automation - support-kb.spirent.com · Spirent Automation and Supported Platforms ... END OF TEST ... resource or function to provide access to all Spirent TestCenter

19Spirent Communications PROPRIETARY AND CONFIDENTIAL

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'};

Page 20: Spirent TestCenter Automation - support-kb.spirent.com · Spirent Automation and Supported Platforms ... END OF TEST ... resource or function to provide access to all Spirent TestCenter

20Spirent Communications PROPRIETARY AND CONFIDENTIAL

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 TEST ......................................\n";

• Run the script

> perl Load_show_version.pl

Page 21: Spirent TestCenter Automation - support-kb.spirent.com · Spirent Automation and Supported Platforms ... END OF TEST ... resource or function to provide access to all Spirent TestCenter

21Spirent Communications PROPRIETARY AND CONFIDENTIAL

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

Page 22: Spirent TestCenter Automation - support-kb.spirent.com · Spirent Automation and Supported Platforms ... END OF TEST ... resource or function to provide access to all Spirent TestCenter

22Spirent Communications PROPRIETARY AND CONFIDENTIAL

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

Page 23: Spirent TestCenter Automation - support-kb.spirent.com · Spirent Automation and Supported Platforms ... END OF TEST ... resource or function to provide access to all Spirent TestCenter

23Spirent Communications PROPRIETARY AND CONFIDENTIAL

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

Page 24: Spirent TestCenter Automation - support-kb.spirent.com · Spirent Automation and Supported Platforms ... END OF TEST ... resource or function to provide access to all Spirent TestCenter

24Spirent Communications PROPRIETARY AND CONFIDENTIAL

Lab Server and Session

Creating a new session

Package require SpirentTestCenter

stc::perform CSTestSessionConnect -Host "<LabServerIP" -CreateNewTestSession TRUE

Connecting to a existing session

Package require SpirentTestCenter

stc::perform CSTestSessionConnect -Host "<LabServerIP" -TestSessionName MySession -OwnerId

MyId

Example:

\

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

Page 25: Spirent TestCenter Automation - support-kb.spirent.com · Spirent Automation and Supported Platforms ... END OF TEST ... resource or function to provide access to all Spirent TestCenter

25Spirent Communications PROPRIETARY AND CONFIDENTIAL

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

Page 26: Spirent TestCenter Automation - support-kb.spirent.com · Spirent Automation and Supported Platforms ... END OF TEST ... resource or function to provide access to all Spirent TestCenter

26Spirent Communications PROPRIETARY AND CONFIDENTIAL

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

Page 27: Spirent TestCenter Automation - support-kb.spirent.com · Spirent Automation and Supported Platforms ... END OF TEST ... resource or function to provide access to all Spirent TestCenter

27Spirent Communications PROPRIETARY AND CONFIDENTIAL

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

Page 28: Spirent TestCenter Automation - support-kb.spirent.com · Spirent Automation and Supported Platforms ... END OF TEST ... resource or function to provide access to all Spirent TestCenter

28Spirent Communications PROPRIETARY AND CONFIDENTIAL

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

Page 29: Spirent TestCenter Automation - support-kb.spirent.com · Spirent Automation and Supported Platforms ... END OF TEST ... resource or function to provide access to all Spirent TestCenter

29Spirent Communications PROPRIETARY AND CONFIDENTIAL

HLTAPI and Lab Server

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

Linux

STC_LAB_SERVER_ADDRESS=<lServer_IP>

STC_SESSION_NAME=__NEW_TEST_SESSION__

Also you can connect through the Hltapi script as wellsth::labserver_connect

-server_ip 10.20.100.15 \

-create_new_session 1 \

-session_name SRE_Demo \

-user_name Tester

Page 30: Spirent TestCenter Automation - support-kb.spirent.com · Spirent Automation and Supported Platforms ... END OF TEST ... resource or function to provide access to all Spirent TestCenter

30Spirent Communications PROPRIETARY AND CONFIDENTIAL

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

Page 31: Spirent TestCenter Automation - support-kb.spirent.com · Spirent Automation and Supported Platforms ... END OF TEST ... resource or function to provide access to all Spirent TestCenter

31Spirent Communications PROPRIETARY AND CONFIDENTIAL

Thank you