Spirent TestCenter Automation HTAPI Programmer’s Reference

[Pages:37]Spirent TestCenterTM Automation HLTAPI Programmer's Reference

October 2019

PN 71-008782 Rev A

SPIRENT 27349 Agoura Road Calabasas, CA 91301 USA

? 2019 Spirent. All Rights Reserved.

All of the company names and/or brand names and/or product names referred to in this document, in particular, the name "Spirent" and its logo device, are either registered trademarks or trademarks of Spirent plc and its subsidiaries, pending registration in accordance with relevant national laws. All other registered trademarks or trademarks are the property of their respective owners.

The information contained in this document is subject to change without notice and does not represent a commitment on the part of Spirent. The information in this document is believed to be accurate and reliable; however, Spirent assumes no responsibility or liability for any errors or inaccuracies that may appear in the document.

Table of Contents

Chapter 1 Introduction ................................................................................................................ 1 Chapter 2 Spirent HLTAPI ........................................................................................................... 2

Introduction .......................................................................................................................................................... 2 Install Tcl.............................................................................................................................................................. 2 Install Spirent TestCenter and HLTAPI ............................................................................................................... 3 Run Scripts under LabServer Mode (Optional) ................................................................................................... 5 Install HLTAPI for Perl ......................................................................................................................................... 6 Install HLTAPI for Python .................................................................................................................................... 8 HLTAPI Logs ..................................................................................................................................................... 10

Chapter 3 Save as HLTAPI ........................................................................................................ 11

Introduction ........................................................................................................................................................ 11 Script with Save as HLTAPI............................................................................................................................... 11 Options for the Save as HLTAPI Wizard ........................................................................................................... 12 Support for Command Sequencer ..................................................................................................................... 13 Limitations of Save as HLTAPI .......................................................................................................................... 14

Chapter 4 Spirent HTLAPI Wrapper .......................................................................................... 20

Introduction ........................................................................................................................................................ 20 Argument Processing ........................................................................................................................................ 20 Using Spirent HLTAPI Wrapper......................................................................................................................... 22 Useful Environment Variables ........................................................................................................................... 22 Supported Protocols/Functions ......................................................................................................................... 24

Chapter 5 Spirent TestCenter Python API Support ................................................................. 25

Introduction ........................................................................................................................................................ 25 Prerequisites ...................................................................................................................................................... 25 Sample Usages ................................................................................................................................................. 26

Chapter 6 Integration with Robot Framework .......................................................................... 27

Introduction ........................................................................................................................................................ 27 Prerequisites ...................................................................................................................................................... 27 Install Robot Framework.................................................................................................................................... 27 Use HLTAPI with Robot Framework.................................................................................................................. 28

Chapter 7 Integration with Spirent iTest .................................................................................. 31

Introduction ........................................................................................................................................................ 31 Prerequisites ...................................................................................................................................................... 31 Install and Configure iTest RT ........................................................................................................................... 31 Generate iTest Test Cases in Save as HLTAPI GUI......................................................................................... 32 Generate iTest Test Cases in CLI mode ........................................................................................................... 33

References ................................................................................................................................... 34

i

Chapter 1 Introduction

The Spirent TestCenter Automation HLTAPI Programmer's Reference document functions as a complementary document to the Spirent Test Center Automation HLTAPI Command Reference. It provides installation and configuration instructions for Spirent HLTAPI. It also provides information on Spirent HLTAPI related features, which include:

Save as HLTAPI Spirent HLTAPI's Integration with Robot Framework Spirent HLTAPI's Integration with Spirent iTest Spirent HLTAPI Wrapper Spirent TestCenter Python API Support

The target audience is test specialists who run automation tests using Spirent HLTAPI, or any of the features listed above. It is assumed users of this manual should have the following knowledge and experience:

Familiarity with the operating system on your PC or workstation (Microsoft? Windows? or Linux?)

Moderate familiarity with test equipment Working knowledge of data communications theory and practice Ability to program with the Tcl, Python, or Perl scripting languages Moderate familiarity with third-party platforms such as Robot Framework or Spirent iTest

Spirent TestCenter Automation HLTAPI Programmer's Reference

1

Chapter 2 Spirent HLTAPI

Introduction

This chapter provides instructions for installing Spirent High Level Test API (HLTAPI). Starting with release 4.81, Spirent HLTAPI is distributed as an integrated component of Spirent TestCenter, and will automatically be installed when you install Spirent TestCenter.

To install the HLTAPI environment, complete the following steps:

Install Tcl Install Spirent TestCenter and HLTAPI Run Scripts under LabServer mode (optional) Install HLTAPI for Perl (optional) Install HLTAPI for Python (optional) Important: For complete information on all supported operating systems and languages mentioned in this document, it is important to refer to the Spirent TestCenter Hardware and Software Release Notes document. This document is available as a Related Resource on the Downloads page of the Spirent Customer Service Center (CSC) website .

Install Tcl

For Windows: Get the Tcl package (.exe) from the CSC and install it under C:\Tcl or other preferred directory. Make sure the installed Tcl contains IP packages, which are required by the Save as HLTAPI tool. For Linux/Unix: Get the Tcl package (.tar) from the CSC and install it under /root/tcl or other preferred directory. Make sure the installed Tcl contains IP packages, which are required by the Save as HLTAPI tool.

Spirent TestCenter Automation HLTAPI Programmer's Reference

2

Install Spirent TestCenter and HLTAPI

Complete the following steps to install Spirent TestCenter and HLTAPI:

Download and Install the Spirent TestCenter software. Refer to Getting Started with Spirent TestCenter for the procedures to install Spirent TestCenter software. Add two new environment variables: STC_INSTALL_DIR and STC_TCL, and add the Spirent TestCenter installation path to environment variable LD_LIBRARY_PATH, for example:

For Windows

STC_INSTALL_DIR=C:\Program Files (x86)\Spirent Communications\Spirent TestCenter [x.xx]\ Spirent TestCenter Application

STC_TCL= C:\tcl\bin\tclsh

LD_LIBRARY_PATH=C:\Program Files (x86)\Spirent Communications\Spirent TestCenter [x.xx]

For Linux/Unix:

-bash-3.00$ export STC_INSTALL_DIR=/root/spirent/Spirent_TestCenter[x.xx]/Spirent Test Center Application

-bash-3.00$ export STC_TCL=/root/tcl/bin/tclsh

-bash-3.00$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/root/spirent/ Spirent_TestCenter_[x.xx]/

Test the Installation. Launch Tcl shell and input package require SpirentTestCenter to get the installed version of Spirent TestCenter, and package require SpirentHltApi to get the installed version of Spirent HLTAPI, as shown below. (The screen capture serves as an example. The actual version number may differ.)

Spirent TestCenter Automation HLTAPI Programmer's Reference

3

Connect to the Spirent TestCenter chassis using Telnet, and type in the login user/password; for example, admin/spt_admin.

Input the version command to get the firmware version of your Spirent TestCenter chassis. The Spirent TestCenter software in use must be of the same version as the firmware version of your Spirent TestCenter chassis.

Notes: The above procedures apply to both 32-bit and 64-bit environments. If you want to install Spirent

HTLAPI on a 64-bit machine, you must install 64-bit Spirent TestCenter and Tcl applications accordingly. If you observe any issues regarding Tcl package not found, use the teacup command in the Tcl shell to update the required standard Tcl packages, as shown below:

%teacup install ip

%teacup install Tclx

If you are using HLTAPI for Python or HLTAPI for Perl, alone with TCLLIBPATH, you must set the following environment variables:

For Windows:

PERL5LIB { C:\Program Files (x86)\Spirent Communications\Spirent TestCenter x.xx\Spirent TestCenter Application\HltAPI\SourceCode\hltapiForPerl}

PYTHONPATH {C:\Program Files (x86)\Spirent Communications\Spirent TestCenter x.xx\Spirent TestCenter Application/HltAPI/ SourceCode\hltapiForPython }

For Linux:

export PERL5LIB ="/volume/labtools/lib/Spirent/Spirent_TestCenter_x.xx/Spirent_TestCe nter_Application_Linux/HltAPI/SourceCode/hltapiForPerl"

export PYTHONPATH ="volume/labtools/lib/Spirent/Spirent_TestCenter_x.xx/Spirent_TestCen ter_Application_Linux/HltAPI/SourceCode/hltapiForPython"

Spirent TestCenter Automation HLTAPI Programmer's Reference

4

Run Scripts under LabServer Mode (Optional)

After the installations are finished, use the following steps if you want to run a script under the LabServer mode. We recommend you use this mode with Linux/Unix operating systems.

Start the Spirent Virtual LabServer (vLS). Refer to Getting Started with Spirent TestCenter Appendix A for the procedures to install and configure the Spirent Virtual LabServer. Set up the Spirent TestCenter client. There are two methods to use Virtual LabServer: Use HLTAPI API sth::labserver_connect/labserver_disconnect in your script. See the

example below:

# To connect to the LabServer

sth::labserver_connect

-server_ip 10.61.30.137 \

-create_new_session 1 \

-session_name Demo1 \

-user_name Tester

The detailed usage can be found in the Spirent Test Center Automation HLTAPI Command Reference manual. Launch existing scripts on the Spirent TestCenter client and run them on a server remotely. To do this, you must make the following changes: 1) Set STC_LAB_SERVER_ADDRESS to the IP address or the host name of the server

PC

2) Set STC_SESSION_NAME to __NEW_TEST_SESSION__

Spirent TestCenter Automation HLTAPI Programmer's Reference

5

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download