spirent testcenter automation htapi programmer’s reference · spirent testcenter automation...

37
PN 71-008782 Rev A Spirent TestCenter Automation HLTAPI Programmer’s Reference October 2019

Upload: others

Post on 19-Mar-2020

15 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Spirent TestCenter Automation HTAPI Programmer’s Reference · Spirent TestCenter Automation HLTAPI Programmer's Reference 7 To dereference the customized path and run HLTAPI for

PN 71-008782 Rev A

Spirent TestCenter™ Automation

HLTAPI Programmer’s Reference

October 2019

Page 2: Spirent TestCenter Automation HTAPI Programmer’s Reference · Spirent TestCenter Automation HLTAPI Programmer's Reference 7 To dereference the customized path and run HLTAPI for

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.

Page 3: Spirent TestCenter Automation HTAPI Programmer’s Reference · Spirent TestCenter Automation HLTAPI Programmer's Reference 7 To dereference the customized path and run HLTAPI for

i

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

Page 4: Spirent TestCenter Automation HTAPI Programmer’s Reference · Spirent TestCenter Automation HLTAPI Programmer's Reference 7 To dereference the customized path and run HLTAPI for

Spirent TestCenter Automation HLTAPI Programmer's Reference 1

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

Page 5: Spirent TestCenter Automation HTAPI Programmer’s Reference · Spirent TestCenter Automation HLTAPI Programmer's Reference 7 To dereference the customized path and run HLTAPI for

Spirent TestCenter Automation HLTAPI Programmer's Reference 2

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 https://support.spirent.com.

Install Tcl

For Windows:

Get the Tcl package (.exe) from the CSC https://support.spirent.com 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 https://support.spirent.com 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.

Page 6: Spirent TestCenter Automation HTAPI Programmer’s Reference · Spirent TestCenter Automation HLTAPI Programmer's Reference 7 To dereference the customized path and run HLTAPI for

Spirent TestCenter Automation HLTAPI Programmer's Reference 3

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.)

Page 7: Spirent TestCenter Automation HTAPI Programmer’s Reference · Spirent TestCenter Automation HLTAPI Programmer's Reference 7 To dereference the customized path and run HLTAPI for

Spirent TestCenter Automation HLTAPI Programmer's Reference 4

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"

Page 8: Spirent TestCenter Automation HTAPI Programmer’s Reference · Spirent TestCenter Automation HLTAPI Programmer's Reference 7 To dereference the customized path and run HLTAPI for

Spirent TestCenter Automation HLTAPI Programmer's Reference 5

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__

Page 9: Spirent TestCenter Automation HTAPI Programmer’s Reference · Spirent TestCenter Automation HLTAPI Programmer's Reference 7 To dereference the customized path and run HLTAPI for

Spirent TestCenter Automation HLTAPI Programmer's Reference 6

Install HLTAPI for Perl

Prerequisites

You must have already installed Tcl and Spirent TestCenter successfully. See Install Tcl and Install

Spirent TestCenter and HLTAPI for more information.

Installation Steps

HLTAPI for Perl is based on HLTAPI for Tcl. It is specially designed for users who would like to use

HLTAPI in Perl environment. Complete the following steps to install HLTAPI for Perl:

1. Install Perl.

2. Under /SouceCode/hltapiForPerl/, copy the HLTAPI for Perl library files (hltapiserver.srv

and sth.pm) to your Perl library. Make sure the two files are in the same folder.

3. Run HLTAPI for Perl scripts.

To run HLTAPI for Perl at a customized production path:

Locate the following related components at the production path:

Spirent HLTAPI

volume/labtools/lib/Spirent_TestCenter-x.xx/Spirent_TestCenter_Application_Linux/HLTAPI/SourceCode

HLTAPI for Perl (JT) essentials (sth.pm, hltapiserver.srv)

/volume//volume/labtools/lib/Spirent_TestCenter-x.xx/Spirent_TestCenter_Application_Linux/HLTAPI/SourceCode /hltapiForPerl

SpirentHLTAPIforPerl.pm

/volume/labtools/lib/

Define variable x-spirent-hltapi 1 in the .params file.

Based on this variable, Spirent HLTAPI for the Perl environment is loaded in the

environment by calling function new SpirentHLTAPIforPerl().

For example:

rt0 {

system {

make "spirent";

x-spirent-hltapi 1;

}

}

Note: To run scripts on a specific version of Spirent HLTAPI, define variable

SPIRENT_TAPI_VERSION and specify a version. By default, the latest HLTAPI release will be

used.

Page 10: Spirent TestCenter Automation HTAPI Programmer’s Reference · Spirent TestCenter Automation HLTAPI Programmer's Reference 7 To dereference the customized path and run HLTAPI for

Spirent TestCenter Automation HLTAPI Programmer's Reference 7

To dereference the customized path and run HLTAPI for Perl locally:

1. Make sure Tcl, Perl, and Spirent HLTAPI are deployed on your local machine.

2. Define the following variables:

SPIRENT_HLTAPI_INSTALL_DIR: Path for HLTAPI source code.

SPIRENT_HLTAPI_FOR_PERL_DIR: Path for HLTAPI for Perl components.

Note: If you want to toggle back to the production environment, simply delete the environment

variables in step 2, and follow the steps to run HLTAPI for Perl at the production path.

Tips: The following steps are intended for the Tools team as a general guide to update an HLTAPI

GA version at the production path:

1. From the HLTAPI GA folder, copy the HLTAPI source code folder - SourceCode to the

following path:

/volume/labtools/lib/Spirent/HLTAPI/<HLTAPI_VERSION>/

2. From SourceCode/hltapiforperl/, copy SpirentHLTAPIforPerl.pm to the following location

and overwrite the existing folder:

/volume/labtools/lib/

Page 11: Spirent TestCenter Automation HTAPI Programmer’s Reference · Spirent TestCenter Automation HLTAPI Programmer's Reference 7 To dereference the customized path and run HLTAPI for

Spirent TestCenter Automation HLTAPI Programmer's Reference 8

Install HLTAPI for Python

Prerequisites

You must have already installed Tcl and Spirent TestCenter successfully. See Install Tcl and Install

Spirent TestCenter and HLTAPI for more information.

Installation Steps

HLTAPI for Python is based on HLTAPI for Tcl. It is specifically designed for users who would like

to use HLTAPI in Python environment. Use one of the following methods to install HLTAPI for

Python:

install manually

install using pip

To install HLTAPI for Python manually:

1. Install Python

2. Under /SouceCode/hltapiForPython/, copy the HLTAPI for Python library files

(hltapiserver.srv and sth.py) to your Python library. Make sure the two files are in the same

folder.

3. Add environment variable HLPYAPI_LOG and set it to a path that has full permission to store

the .hltlog file

4. Run HLTAPI for Python scripts. For example,

python example.py

To install HLTAPI for Python Using PIP:

Wheel is a built-package archive format that can greatly speed installation compared to building and

installing from source archives. The wheel package for HLTAPI is provided for users to install

HLTAPI for Python using pip. For more information on pip and wheel, refer to the pip reference

guide, wheel documents, PEP427, and PEP425.

To install the wheel package, you must distribute the wheel package on the Python Package Index

(PyPI) server, and then finish the pip install on the client side.

To install the wheel package on the PyPI server:

1. Install the PyPI server on the local server

2. pip install pypiserver

3. On the server, create the folder where you want to store the wheel package.

4. Example file name hltapi-4.57-py2.py3-none-any.whl

5. Start the PyPI server

pypi-server -p 8080 folder_location &

Page 12: Spirent TestCenter Automation HTAPI Programmer’s Reference · Spirent TestCenter Automation HLTAPI Programmer's Reference 7 To dereference the customized path and run HLTAPI for

Spirent TestCenter Automation HLTAPI Programmer's Reference 9

Example:

# step1:

[root@spirent xtapi]# pip install pypiserver

Downloading/unpacking pypiserver

Downloading pypiserver-1.1.9-py2.py3-none-any.whl (72kB): 72kB

downloaded

Installing collected packages: pypiserver

Successfully installed pypiserver

Cleaning up...

[root@spirent xtapi]#

# step2:

[root@spirent xtapi]# mkdir wheelpackage

[root@spirent xtapi]# cd wheelpackage

[root@spirent wheelpackage]# ls

hltapi-4.57-py2.py3-none-any.whl

[root@spirent wheelpackage]# pwd

/home/xtapi/wheelpackage

# step3:

[root@spirent wheelpackage]# pypi-server -p 7001

/home/xtapi/wheelpackage &

[1] 9182

To perform a pip installation on the client side, use one of the following options:

Install the HLTAPI package in the default path, under Python site-packages

pip install --extra-index-url http://10.61.44.84:7001/simple/hltapi

Note: No environment variable is required. You can start using HLTAPI for Python directly with from hltapi import sth.

Install the HLTAPI package in a specific location

pip install --extra-index-url http://10.61.44.84:7001/simple/ hltapi

--target=<path>

Note: You must set environment variable PYTHONPATH to the location you specified. For

example:

export PYTHONPATH=/home/xtapi/hltapi

Install a specific version of HLTAPI

pip install --extra-index-url

http://10.61.44.84:7001/simple/hltapi==version number

Upgrade to the latest version of HLTAPI

pip install --upgrade --extra-index-url

http://10.61.44.84:9001/simple/hltapi

Page 13: Spirent TestCenter Automation HTAPI Programmer’s Reference · Spirent TestCenter Automation HLTAPI Programmer's Reference 7 To dereference the customized path and run HLTAPI for

Spirent TestCenter Automation HLTAPI Programmer's Reference 10

Install the package without compilation of Python files

pip install --no-compile --extra-index-url

http://10.61.44.84:9001/simple/hltapi

Install the package using the trustedhost option

pip install --extra-index-url http://10.61.44.84:7001/simple/ --

trusted-host 10.61.44.84 hltapi

To uninstall pip on the client side:

pip uninstall hltapi

Example:

[root@IDC-RHEL-xTAPI wheel_demo]# pip install --extra-index-url

http://10.61.44.84:7001/simple/ hltapi

Downloading/unpacking hltapi

Downloading hltapi-4.57-py2.py3-none-any.whl (7.6MB): 7.6MB downloaded

Installing collected packages: hltapi

Successfully installed hltapi

Cleaning up...

[root@IDC-RHEL-xTAPI wheel_demo]# cd /usr/new/bin/lib/python3.4/site-

packages/

[root@IDC-RHEL-xTAPI site-packages]# ls hltapihltapi/ hltapi-

4.57.dist-info/

[root@IDC-RHEL-xTAPI site-packages]# ls hltapi

HLTAPI Logs

Log files help in analyzing and debugging, if there are issues with HLTAPI for Perl scripts.

The following log files are generated after you run a script named xxx:

Console logs (<xxx>.<pid>.putlog)

Note: This log file is environment specific.

HLT server log (<xxx>.<pid>.hltlog)

HLTAPI logs (sth::test_config)

<xxx>_logfile.txt

<xxx>_stcExport.txt

<xxx>_hltExport.txt

<xxx>_hlt2StcMapping.txt

Page 14: Spirent TestCenter Automation HTAPI Programmer’s Reference · Spirent TestCenter Automation HLTAPI Programmer's Reference 7 To dereference the customized path and run HLTAPI for

Spirent TestCenter Automation HLTAPI Programmer's Reference 11

Chapter 3 Save as HLTAPI

Introduction

This chapter provides instructions for the Save as HLTAPI function. It also addresses some

limitations. Save as HLTAPI is a one-step automation solution to create Spirent HLTAPI scripts.

Using an integrated GUI in Spirent TestCenter, Save as HLTAPI converts Spirent TestCenter

configurations (the configuration file in .xml or .tcc format) directly to Spirent HLTAPI scripts. The

generated scripts can be manually modified to address different testing needs. Save as HLTAPI

also provides the capability to generate iTest or Robot Framework test cases. This greatly reduces

script authoring time, making test automation even more efficient. The Command Line Interface

(CLI) mode of Save as HLTAPI is also available as a regular Spirent HLTAPI function. Note that all

instructions in this chapter apply only to the GUI mode. For more information on using the CLI

mode, refer to Save as HLTAPI CLI Mode in Spirent TestCenter Automation HLTAPI Command

Reference.

Script with Save as HLTAPI

You must have already installed Tcl and Spirent TestCenter. See Install Tcl and Install Spirent

TestCenter and HLTAPI for more information.

To generate HLTAPI scripts directly from Spirent TestCenter:

Configure the target function to test in Spirent TestCenter.

Click Tools > Custom Tools > Save as HLTAPI to open the Save as HLTAPI Wizard

window, as shown below:

Page 15: Spirent TestCenter Automation HTAPI Programmer’s Reference · Spirent TestCenter Automation HLTAPI Programmer's Reference 7 To dereference the customized path and run HLTAPI for

Spirent TestCenter Automation HLTAPI Programmer's Reference 12

Specify the name and the path for the Tcl file to be generated.

Customize the scripts by selecting or clearing checkboxes in the wizard window. The options

shown in the screen capture in step 2 are described in Options for the Save as HLTAPI

Wizard.

Click Generate and wait until the process is finished. You will be prompted to open the script

in the text editor.

Click Yes if you want to open the generated file in Notepad.

Click No if you want to open it later or in a different text editor.

Modify the scripts as necessary.

Options for the Save as HLTAPI Wizard

This section lists and describes each Save as HLTAPI option on in the Save as HLTAPI Wizard.

Scaling mode — Select to generate a HLTAPI script that configures multiple device blocks in one function by calling the emulation_*_config function once. This is only applicable to those protocols that support multiple device blocks in one function in Spirent HLTAPI, including ANCP, BFD, BGP, EOAM, FCoE, IGMP, IGMP Querier, ISIS, LDP, LLDP, MLD, MPLS-VPN, OSPF, PIM, PTP, RIP, RSVP, STP, and VPLS.

Scaling mode is used for doing a scaling test with Spirent HLTAPI when multiple device blocks are required. When you select this option, emulation_*_config is called once to create the number of device blocks specified in the Spirent TestCenter wizard. If you clear this option, emulation_*_config creates only one device block at a time.

HLTAPI for Tcl — Select to generate HLTAPI script in Tcl (default)

HLTAPI for Perl — Select to generate HLTAPI script in Perl

HLTAPI for Python — Select to generate HLTAPI script in Python

HLAPI for Robot — Select to generate Robot Framework test cases for HLTAPI

iTest test case — Select to generate iTest test cases

Include log command — Select to include the test_config function in the generated HLTAPI script

Include optimize command - select to include the test_control function in the generated HLTAPI script (default)

Include control commands - select to include the emulation_*_control function in the generated HLTAPI script (default)

Include result commands - select to include the emulation_*_info function in the generated HLTAPI script (default)

Include packet commands - select to include the packet_* function in the generated HLTAPI script

Include device_info command - select to include the device_info function in the generated HLTAPI script

Include traffic commands - select to include traffic functions in the generated HLTAPI scripts (default)

Output default options – select to only output arguments with no default values (default)

Page 16: Spirent TestCenter Automation HTAPI Programmer’s Reference · Spirent TestCenter Automation HLTAPI Programmer's Reference 7 To dereference the customized path and run HLTAPI for

Spirent TestCenter Automation HLTAPI Programmer's Reference 13

Support for Command Sequencer

Spirent TestCenter Command Sequencer enables you to specify the dynamic or interactive steps

that must occur as part of a test, and to facilitate the specification of pass/fail verdict criteria. With

Save as HLTAPI's support, you can save the Command Sequencer configurations to HLTAPI

scripts. In the generated scripts, there will be no output of original HLTAPI control and results

commands. Instead, procedures sth::sequencer_config and sth::sequencer_control

will be output as the Command Sequencer configurations. Procedure sth::sequencer_config

configures the Command Sequencer with native APIs of Spirent TestCenter, and procedure

sth::sequencer_control controls the Command Sequencer.

Refer to the sample script:

proc sth::sequencer_config {dhcp_handle} {

set dhcp_config_handle [stc::get dhcp_handle -xxconfig]

set Sequencer(1) [stc::create "Sequencer" -under $system1 ]

set Dhcpv4StartServerCommand(1) [stc::create

"Dhcpv4StartServerCommand"\

-under $Sequencer(1) -Name {DHCPv4: Start Server 1} ]

set Dhcpv4BindCommand(1) [stc::create "Dhcpv4BindCommand" \

-under $Sequencer(1) -Name {DHCPv4: Bind Sessions 2} ]

set Dhcpv4BindWaitCommand(1) [stc::create "Dhcpv4BindWaitCommand" \

-under $Sequencer(1) -ErrorOnFailure "TRUE" \

-Name {DHCPv4: Wait for Sessions to Bind 1} ]}

set cmd_ret1 [sth::sequencer_config $dhcp_handle]

set ctrl_ret1 [sth::sequencer_control start]

Notes:

If there are features or protocols that are not supported by HLTAPI or Save as HLTAPI, the device or protocol handles will still be output as ??? in the generated script of sth::sequencer_config. To make the Command Sequencer work, you must edit the code manually for the unsupported functions.

RFC-related functions already have their own implementation of Command Sequencer in HLTAPI. If Command Sequencer is configured for these functions, there will be no output of corresponding commands in the generated script.

sth::sequencer_control is an HLTAPI function that provides control options to the Command Sequencer commands in HLTAPI scripts. For more details, refer to the Sequencer Control function.

Page 17: Spirent TestCenter Automation HTAPI Programmer’s Reference · Spirent TestCenter Automation HLTAPI Programmer's Reference 7 To dereference the customized path and run HLTAPI for

Spirent TestCenter Automation HLTAPI Programmer's Reference 14

Limitations of Save as HLTAPI

Save as HLTAPI is a tool you use to improve the script generation of Spirent HLTAPI. However,

only HLTAPI-supported features can be automatically scripted. Also, the arguments of the high-

level APIs do not have a one-to-one correlation with Spirent Test Center's native API objects, so

some functions and arguments are not supported by Save as HLTAPI. In these cases, you can

modify the script manually.

These are the categories of unsupported arguments:

Action-related arguments such as -mode reset and interface_config -arp_cache_retrieve.

Arguments that can be functionally substituted by other supported arguments. For example, the supported argument emulation_ldp_config –cfi achieves the same functionality as the unsupported -vlan_cfi.

ATM-related arguments

Cisco-specific arguments unsupported by Spirent HLTAPI (Cisco-specific Arguments in each function)

Unsupported functions.

Refer to the table on the following pages for all supported functions.

Page 18: Spirent TestCenter Automation HTAPI Programmer’s Reference · Spirent TestCenter Automation HLTAPI Programmer's Reference 7 To dereference the customized path and run HLTAPI for

Spirent TestCenter Automation HLTAPI Programmer's Reference 15

Save as HLTAPI Supported Functions

Feature/Technology API Names Save As HLTAPI Support

ALARMS alarms_control

alarms_stats

No

No

ANCP emulation_ancp_config

emulation_ancp_control

emulation_ancp_stats

emulation_ancp_subscriber_lines_config

Yes

Yes

Yes

Yes

BFD emulation_bfd_config

emulation_bfd_control

emulation_bfd_info

Yes

Yes

Yes

BGP emulation_bgp_config

emulation_bgp_control

emulation_bgp_info

emulation_bgp_route_config

emulation_bgp_route_element_config

emulation_bgp_route_info

emulation_bgp_route_generator

Yes

Yes

Yes

Yes

Yes

Yes

No

Raw Device emulation_device_config Yes

DHCPv4/v6 Clients emulation_dhcp_config

emulation_dhcp_group_config

emulation_dhcp_control

emulation_dhcp_stats

Yes

Yes

Yes

Yes

DHCPv4/v6 Server emulation_dhcp_server_config

emulation_dhcp_server_control

emulation_dhcp_server_relay_agent_config

emulation_dhcp_server_stats

Yes

Yes

Yes

Yes

802.1x emulation_dot1x_config

emulation_dot1x_control

emulation_dot1x_stats

Yes

Yes

Yes

EOAM emulation_oam_config_msg

emulation_oam_config_topology

emulation_oam_control

emulation_oam_info

Yes

Yes

Yes

Yes

EFM emulation_efm_config

emulation_efm_control

emulation_efm_stat

Yes

Yes

Yes

FC fc_config fc_control

fc_stats

No

No

No

FCoE fcoe_config

fcoe_control

fcoe_stats fip_traffic_config

fcoe_traffic_config

Yes

Yes

Yes

Yes

Yes GRE emulation_gre_config Yes

40/100G pcs_error_config pcs_error_control

random_error_config random_error_control

forty_hundred_gig_l1_results

No

No

No

No

No HTTP emulation_http_profile_config

emulation_http_config

emulation_http_phase_config

emulation_http_control

emulation_http_stats

Yes

Yes

Yes

Yes

Yes

Page 19: Spirent TestCenter Automation HTAPI Programmer’s Reference · Spirent TestCenter Automation HLTAPI Programmer's Reference 7 To dereference the customized path and run HLTAPI for

Spirent TestCenter Automation HLTAPI Programmer's Reference 16

Feature/Technology API Names Save As HLTAPI Support

IGMP Querier emulation_igmp_querier_config

emulation_igmp_querier_control

emulation_igmp_querier_info

Yes

Yes

Yes

IGMP emulation_igmp_config

emulation_igmp_control

emulation_igmp_group_config

emulation_igmp_info

Yes

Yes

Yes

Yes

IPv6 Auto Config emulation_ipv6_autoconfig

emulation_ipv6_autoconfig_control

emulation_ipv6_autoconfig_stats

Yes

Yes

Yes

IPTV emulation_iptv_config

emulation_iptv_channel_block_

config

emulation_iptv_channel_viewing_

profile_config

emulation_iptv_viewing_behavior_

profile_config

emulation_iptv_control

emulation_iptv_stats

Yes

Yes

Yes

Yes

Yes

Yes

ISIS emulation_isis_config

emulation_isis_control

emulation_isis_topology_route_config

emulation_isis_lsp_generator

emulation_isis_info

Yes

Yes

No

No

Yes

L2TP l2tp_config

l2tp_control

l2tp_stats

Yes

Yes

Yes

L2TPv3 l2tpv3_config

l2tpv3_control

l2tpv3_stats

Yes

Yes

Yes

LACP emulation_lacp_config

emulation_lacp_control

emulation_lacp_info

Yes

Yes

Yes

LDP emulation_ldp_config

emulation_ldp_control

emulation_ldp_info

emulation_ldp_route_config

emulation_lsp_switching_point_tlvs_config

Yes

Yes

Yes

Yes

Yes

LLDP emulation_lldp_config

emulation_lldp_optional_tlv_config

emulation_lldp_dcbx_tlv_config

emulation_lldp_control emulation_lldp_info

Yes

Yes

Yes

Yes

Yes

MLD emulation_mld_config

emulation_mld_group_config

emulation_mld_control emulation_mld_info

Yes

Yes

Yes

Yes

Micro BFD emulation_micro_bfd_config

emulation_micro_bfd_control

emulation_micro_bfd_info

No

No

No

MPLS IP VPN emulation_mpls_ip_vpn_provider_port_config

emulation_mpls_ip_vpn_cust_port_config

emulation_mpls_ip_vpn_config

emulation_mpls_ip_vpn_control

emulation_mpls_ip_vpn_info

No

No

No

No

No

Page 20: Spirent TestCenter Automation HTAPI Programmer’s Reference · Spirent TestCenter Automation HLTAPI Programmer's Reference 7 To dereference the customized path and run HLTAPI for

Spirent TestCenter Automation HLTAPI Programmer's Reference 17

Feature/Technology API Names Save As HLTAPI Support

MPLS-TP emulation_mpls_tp_config

emulation_mpls_tp_port_config

emulation_mpls_tp_control

emulation_lsp_ping_info

emulation_mplstp_y1731_oam_control

emulation_mplstp_y1731_oam_info

No

No

No

No

No

No

MPLS-VPN emulation_mpls_l2vpn_pe_config

emulation_mpls_l2vpn_site_config

emulation_mpls_l3vpn_pe_config

emulation_mpls_l3vpn_site_config

No

No

No

No

Multicast emulation_multicast_group_config

emulation_multicast_source_config

emulation_mcast_wizard_config

Yes

Yes

No

MVPN emulation_mvpn_provider_port_config

emulation_mvpn_customer_port_config

emulation_mvpn_config

emulation_mvpn_control

emulation_mvpn_info

No

No

No

No

No

OSPF emulation_ospf_config

emulation_ospf_control

emulation_ospf_lsa_config

emulation_ospf_tlv_config

emulation_ospf_topology_route_config

emulation_ospfv2_info

emulation_ospfv3_info

emulation_ospf_route_info

Yes

Yes

Yes

No

No

Yes

Yes

Yes

OpenFlow emulation_openflow_config

emulation_openflow_control

emulation_openflow_stats

emulation_openflow_switch_config

emulation_openflow_switch_control

emulation_openflow_switch_stats

No

No

No

No

No

No

Packet Capture packet_config_buffers

packet_config_triggers

packet_config_filter packet_control

packet_info

packet_stats

Yes

Yes

Yes

Yes

Yes

Yes

PCEP emulation_pcep_config

emulation_pcep_control

No

No

PIM emulation_pim_config

emulation_pim_control

emulation_pim_group_config

emulation_pim_info

Yes

Yes

Yes

Yes

PING emulation_ping No

PPP ppp_config

ppp_stats

Yes

Yes

PPPoX pppox_config pppox_control

pppox_stats

Yes

Yes

Yes

PPPoX Server pppox_server_config

pppox_server_control

pppox_server_stats

Yes

Yes

Yes

PTP emulation_ptp_config

emulation_ptp_control

emulation_ptp_stats

Yes

Yes

Yes

Page 21: Spirent TestCenter Automation HTAPI Programmer’s Reference · Spirent TestCenter Automation HLTAPI Programmer's Reference 7 To dereference the customized path and run HLTAPI for

Spirent TestCenter Automation HLTAPI Programmer's Reference 18

Feature/Technology API Names Save As HLTAPI Support

RFC 2544 test_rfc2544_config

test_rfc2544_control

test_rfc2544_info

rfc2544_asymmetric_config

rfc2544_asymmetric_control

rfc2544_asymmetric_profile

rfc2544_asymmetric_stats

Yes

Yes

Yes

Yes

Yes

Yes

RFC 3918 test_rfc3918_config test_rfc3918_control

test_rfc3918_info

Yes

Yes

Yes

RIP emulation_rip_config emulation_rip_control

emulation_rip_route_config emulation_rip_info

Yes

Yes

Yes

Yes

RSVP emulation_rsvp_config emulation_rsvp_control

emulation_rsvp_info emulation_rsvp_tunnel_config

emulation_rsvpte_tunnel_control

emulation_rsvp_tunnel_info

Yes

Yes

Yes

Yes

Yes

Yes Session arp_control

connect

device_info

interface_config

interface_control

interface_stats cleanup_session

labserver_connect

labserver_disconnect link_config

load_xml

start_devices

stop_devices

get_handles

sequencer_control

No

Yes

Yes

Yes

No

No

Yes

No

No

Yes

No

No

No

No

Yes SIP emulation_sip_config

emulation_sip_control

emulation_sip_stats

Yes

Yes

Yes

STP emulation_stp_config

emulation_mstp_region_config

emulation_msti_config

emulation_stp_control

emulation_stp_stats

Yes

Yes

Yes

Yes

Yes

Testing Utility test_config

test_control

save_xml

system_settings_

Yes

Yes

No

Yes

SyncE emulation_synce_config

emulation_synce_control

emulation_synce_stats

No

No

No

Traffic traffic_config

traffic_config_ospf

imix_config

traffic_control

traffic_stats

drv_stats

create_csv_file

Yes

Yes

No

Yes

Yes

No

No

Video emulation_video_config

emulation_video_server_streams_config

emulation_profile_config

emulation_client_load_phase_config

emulation_video_control

emulation_video_clips_manage

emulation_video_stats

Yes

Yes

Yes

Yes

Yes

Yes

Yes

Page 22: Spirent TestCenter Automation HTAPI Programmer’s Reference · Spirent TestCenter Automation HLTAPI Programmer's Reference 7 To dereference the customized path and run HLTAPI for

Spirent TestCenter Automation HLTAPI Programmer's Reference 19

Feature/Technology API Names Save As HLTAPI Support

VQA emulation_vqa_host_config

emulation_vqa_config

emulation_vqa_port_config

emulation_vqa_global_config

emulation_vqa_control

emulation_vqa_stats

Yes

Yes

Yes

Yes

Yes

Yes

VXLAN emulation_vxlan_config

emulation_vxlan_control

emulation_vxlan_stats

No

No

No

VXLAN EVPN Overlay emulation_vxlan_evpn_overlay_port_config

emulation_nonvxlan_evpn_overlay_port_config

emulation_vxlan_evpn_overlay_wizard_config

emulation_6pe_6vpe_provider_port_config

emulation_vxlan_evpn_overlay_control

emulation_vxlan_evpn_overlay_stats

No

No

No

No

No

No

VPLS emulation_l2vpn_pe_config

emulation_vpls_site_config

Yes

Yes

6PE/6VPE emulation_6pe_6vpe_provider_port_config

emulation_6pe_6vpe_cust_port_config

emulation_6pe_6vpe_config

emulation_6pe_6vpe_control

emulation_6pe_6vpe_info

No

No

No

No

No

Page 23: Spirent TestCenter Automation HTAPI Programmer’s Reference · Spirent TestCenter Automation HLTAPI Programmer's Reference 7 To dereference the customized path and run HLTAPI for

Spirent TestCenter Automation HLTAPI Programmer's Reference 20

Chapter 4 Spirent HTLAPI Wrapper

Introduction

This section describes Spirent HLTAPI Wrapper and its sample usages. A list of supported

functions is also provided. The target audience is test specialists who want to run automation

testing with Spirent TestCenter using another vendor's HLTAPI scripts.

Spirent HLTAPI Wrapper allows users to run scripts that have been written for HLTAPI products

from other vendors, to run on Spirent TestCenter. Using Spirent HLTAPI Wrapper, many scripts can

be migrated from other vendors’ test systems to Spirent TestCenter, depending on several factors:

the amount of commonality in HLTAPI implementations

where differences exist, the commands and arguments which can be mapped by the Spirent HLTAPI Wrapper to Spirent’s HLTAPI

the existence of native API commands in scripts (the Spirent HLTAPI wrapper can only map HLTAPI commands, not native API commands)

When the Spirent HLTAPI Wrapper does not map commands and/or arguments to Spirent’s

HLTAPI Wrapper, it may still be possible to migrate scripts to Spirent TestCenter, In such cases,

please contact Spirent Global Services for assistance.

Note: Unless otherwise stated, "vendor's HLTAPI" and "vendor specific" refer to HLTAPI from a

vendor other than Spirent, and the use of "HLTAPI Wrapper" refers to Spirent HLTAPI Wrapper

throughout this document.

Argument Processing

Spirent HLTAPI Wrapper divides a vendor's HLTAPI arguments into groups and handles them

differently.

Group 1: Common Arguments between Spirent HLTAPI and Other HLTAPIs

This is the major group of arguments. The argument naming and the functionality are the same for

Spirent HLTAPI and the vendor's HLTAPI. Spirent HLTAPI Wrapper maps the arguments directly

without extra processing. You can find the related description of these arguments in the Arguments

section under the specific function.

Group 2: Vendor Specific Arguments Processed by HLTAPI Wrapper

These arguments are specific to a vendor's HLTAPI but affect the testing with Spirent TestCenter.

They are processed by Spirent HLTAPI Wrapper. For detailed information on this category of

arguments, refer to the corresponding section under the specific Spirent HLTAPI function.

Group 3: Vendor Specific Arguments Ignored by HLTAPI Wrapper

These arguments are specific to a vendor's HLTAPI, but do not affect the testing with Spirent

TestCenter. They will not be processed by HLTAPI Wrapper. Therefore, they will not appear in the

converted scripts of Spirent HLTAPI. For a list of such arguments, refer to the corresponding

section under the specific Spirent HLTAPI function.

Page 24: Spirent TestCenter Automation HTAPI Programmer’s Reference · Spirent TestCenter Automation HLTAPI Programmer's Reference 7 To dereference the customized path and run HLTAPI for

Spirent TestCenter Automation HLTAPI Programmer's Reference 21

This is a snippet from the trace log, from which you can see how Spirent HLTAPI Wrapper finishes

the arguments conversion.

2017-05-19_14:13:16

{::vendor::interface_config -vlan_id_count 1 \

-gateway_step 0.0.1.0\

-intf_mode ethernet -phy_mode fiber

-intf_ip_addr_step 0.0.1.0\

-vlan_id_step 1 -data_integrity 0 -vlan 1 -duplex full\

-src_mac_addr 0000.6f01.0102 -connected_count 1\

-intf_ip_addr 111.1.1.2 -mode config -vlan_id 50\

-transmit_mode advanced -port_handle port1\

-speed ether10000lan -autonegotiation 1\

-port_rx_mode auto_detect_instrumentation

-gateway 111.1.1.1}

enter

2017-05-19_14:13:16

{::sth::interface_config -gateway_step 0.0.1.0 \

-intf_mode Ethernet\

-phy_mode fiber -intf_ip_addr_step 0.0.1.0 \

-vlan_id_step 1\

–vlan 1 -src_mac_addr 0000.6f01.0102

-intf_ip_addr 111.1.1.2\

-vlan_id 50 -mode config\

-vlan_user_priority 0 -port_handle port1\

-speed ether10000 -autonegotiation 1\

-gateway 111.1.1.1 -enable_ping_response 1\

Page 25: Spirent TestCenter Automation HTAPI Programmer’s Reference · Spirent TestCenter Automation HLTAPI Programmer's Reference 7 To dereference the customized path and run HLTAPI for

Spirent TestCenter Automation HLTAPI Programmer's Reference 22

Using Spirent HLTAPI Wrapper

To use HLTAPI Wrapper, prepare the target scripts in a vendor's HLTAPI, and replace its HLTAPI

package with that of Spirent HLTAPI Wrapper and Spirent HLTAPI, as shown below:

##############################################################Load package

SpirentHltApiWrapper and SpirentHltApi

##############################################################

package require SpirentHltApiWrapper package require SpirentHltApi

HLTAPI Wrapper will finish the rest of the operation automatically. See Supported

Protocols/Functions for a list of functions supported by Spirent HLTAPI Wrapper.

Useful Environment Variables

This section provides a list of environment variables relevant to HLTAPI Wrapper.

TCLLIBPATH

The search path for Tcl packages. It is recommended that you add the root path for the

Spirent library.

EASY_BASEDIR

ATS-defined location of the logs and results for the current job. This path is used when

the STC_LOG_PATH is not defined.

SPIRENT_VERSION

Specifies the HLTAPI Wrapper version to use. This version is mapped to

array ::spirent::spirent_version, which defines the mapping between

SPIRENT_VERSION and the version of Spirent HLTAPI Wrapper. The

::spirent::spirent_version array is defined in the pkgIndex.tcl file located in

the root Spirent library directory. If this is not defined, then the latest version of Spirent

HLTAPI Wrapper will be used.

SPIRENT_OPTIONS

A list of the optional parameters listed below. The value is a Tcl keyed list. For example:

{STC_LAB_SERVER_ADDRESS 10.1.1.1

STC_LOG_PATH "/path/"

STC_LOG_ENABLE TRUE}

STC_LAB_SERVER_ADDRESS

Specifies the address for the Spirent TestCenter Virtual LabServer (vLS). If set, a

session will be created on the specified vLS.

Page 26: Spirent TestCenter Automation HTAPI Programmer’s Reference · Spirent TestCenter Automation HLTAPI Programmer's Reference 7 To dereference the customized path and run HLTAPI for

Spirent TestCenter Automation HLTAPI Programmer's Reference 23

STC_LAB_SERVER_USER

Specifies the username for the Virtual LabServer session, if

STC_LAB_SERVER_ADDRESS is defined. The $::tcl_platform (user) value is used if

this variable is not defined. The Virtual LabServer session ID is formed using the

following command:

sessionname – user

STC_LAB_SERVER_SESSIONAME

Specifies the session name to use for the Virtual LabServer session, if

STC_LAB_SERVER_ADDRESS is defined. The last part of the EASY_BASEDIR

environment variable (the job name) is used if this variable is not defined. The Virtual

LabServer session ID is formed using the following command:

sessionname - user

STC_LAB_SERVER_TERMINATE

Controls when a Virtual LabServer session will terminate. By default, the session will

remain running until the cleanup_session command is called, where it will change to

ON_LAST_DISCONNECT. The options are CANCEL, ON_CLIENT_DISCONNECT,

ON_LAST_DISCONNECT, and ON_LAST_CONTROLLER_DISCONNECT. Use

CANCEL if you want the session to remain running after cleanup_session is called. Any

existing session with the same session ID will be automatically terminated when a new

session is started, regardless of this setting.

STC_LOG_ENABLE

Enables/disables Spirent HLTAPI Wrapper logging. The default value is false (disable).

Note: The Spirent TestCenter BLL and chassis logs are always generated, regardless of

this setting.

Page 27: Spirent TestCenter Automation HTAPI Programmer’s Reference · Spirent TestCenter Automation HLTAPI Programmer's Reference 7 To dereference the customized path and run HLTAPI for

Spirent TestCenter Automation HLTAPI Programmer's Reference 24

Supported Protocols/Functions

This list contains the functions that are supported by HLTAPI Wrapper. There are many

implementations of functions by different vendors, and inclusion in the list does not mean the

wrapper supports all implementations of the wrapper from all vendors. Nor does it mean that every

argument for the listed function is supported. For assistance and clarification, please contact

Spirent using the "Contact Us" section of this document.

ANCP

BFD

BGP

DHCP Client

DHCP Server

EFM

GRE

IGMP

IGMP Querier

ISIS

LACP

LDP

MLD

Multicast

EOAM

OSPF

PIM

RIP

RSVP

FCoE

L2TP

Packet Capture

PPP

PPPOX

Session

Note: The vendor specific functions ::get_port_list_from_connect and

::capture_packet are also supported by Spirent HLTAPI Wrapper.

Page 28: Spirent TestCenter Automation HTAPI Programmer’s Reference · Spirent TestCenter Automation HLTAPI Programmer's Reference 7 To dereference the customized path and run HLTAPI for

Spirent TestCenter Automation HLTAPI Programmer's Reference 25

Chapter 5 Spirent TestCenter Python API Support

Introduction

This chapter provides instructions and examples for using Spirent TestCenter Native Python

commands in Spirent HLTAPI. The following native Python APIs are supported:

apply()

config()

connect()

create()

delete()

disconnect()

get()

perform()

release()

reserve()

sleep()

subscribe()

unsubscribe()

waitUntilComplete()

log()

help()

For more information on Spirent TestCenter Python APIs, refer to Spirent TestCenter Automation

Programmer's Reference.

Prerequisites

Python API support requires that you install Python, Spirent TestCenter, and Spirent HLTAPI for

Python. Refer to the Spirent TestCenter Hardware and Software Release Notes for detailed

information on supported software applications and versions.

Page 29: Spirent TestCenter Automation HTAPI Programmer’s Reference · Spirent TestCenter Automation HLTAPI Programmer's Reference 7 To dereference the customized path and run HLTAPI for

Spirent TestCenter Automation HLTAPI Programmer's Reference 26

Sample Usages

The following commands show the general steps to call Spirent TestCenter Python APIs in HLTAPI

for Python:

import sth #To import sth.py

from sth import StcPython #To import StcPython classes

stc=StcPython() #To create an instance

stc.apply() #To call a native Python function

The following example creates a streamblock using native Python API stc.create() and gets the

values for load and loadunit of the same streamblock:

import sth

from sth import StcPython

stc=StcPython()

device = "10.62.224.123"

port_list = ['1/1','1/2']

intStatus = sth.connect (device=device,

port_list = port_list,

break_locks = 1,

offline = 1)

hsb = stc.create("streamblock", under="port1", load="10",

loadunit = "PERCENT_LINE_RATE")

getRet = stc.get(hsb1,"load","loadunit")

Page 30: Spirent TestCenter Automation HTAPI Programmer’s Reference · Spirent TestCenter Automation HLTAPI Programmer's Reference 7 To dereference the customized path and run HLTAPI for

Spirent TestCenter Automation HLTAPI Programmer's Reference 27

Chapter 6 Integration with Robot Framework

Introduction

This chapter provides information on Spirent HLTAPI’s integration with Robot Framework, a generic

test automation framework for acceptance testing and acceptance test-driven development (ATDD).

The target audience is users who wish to write Robot Framework test cases for Spirent HLTAPI.

Prerequisites

You must have already installed Tcl, Python, Spirent TestCenter, and HLTAPI for Python

successfully. See Install Tcl, Install Spirent TestCenter and HLTAPI, and Install HLTAPI for Python

for more information.

Install Robot Framework

To install the Robot Framework:

Install Robot Framework using pip using the following command:

pip install robotframework

For more information on pip install, refer to https://pip.pypa.io/en/stable/installing/.

In the command line, input the following command to check if Robot Framework is installed

successfully:

robot –-version

In the HLTAPI installation folder, locate the resource file spirentHltApi.robot, and add the

path to environment variable PYTHONPATH, for example:

PYTHONPATH:C:\Tcl\lib\spirentHltApi\hltapiForPython

Test the installation by running a Robot Framework test case.

For example:

robot hlapiGen_ancp.robot

Page 31: Spirent TestCenter Automation HTAPI Programmer’s Reference · Spirent TestCenter Automation HLTAPI Programmer's Reference 7 To dereference the customized path and run HLTAPI for

Spirent TestCenter Automation HLTAPI Programmer's Reference 28

Use HLTAPI with Robot Framework

To use Robot Framework with Spirent HLTAPI, make sure the following components are included in

the HLTAPI release package:

\SourceCode\hltapiForPython\spirentHltApi.robot

Resource file containing keywords defined by Spirent HLTAPI

\SourceCode\hltapiForPython\sth.py

Spirent HLTAPI library in Python

\SampleScripts\hltapiForRobot

Sample Robot Framework scripts for your reference

\UserDoc\hltapi_keywords.html

Keywords documentation that contains descriptions for keywords and arguments defined by

Spirent HLTAPI

Robot Framework test cases are created using test case tables in test case files. Such a file

automatically creates a test suite from all the test cases it contains. Refer to Robot Framework

documentations for more details.

The screen capture shows a typcial Robot Framework test suite for HLTAPI:

*** Settings ***

Documentation

Resource spirentHltApi.robot # Import the resource file

that contains original

keywords defined by Spirent

*** Variables *** # Create user-defined variables

*** Keywords *** # Create user-defined keywords

*** Test Cases *** # Keywords driven test cases

There are two ways to write Robot Framework test cases for HLTAPI:

To generate scripts manually:

We recommend you use RIDE, or PyCharm. Both are open-source IDEs that support Robot Framework. Features such as auto-complete and resource file loading are supported. For more information on their installations and usages, refer to their websites:

RIDE https://github.com/robotframework/RIDE.

Pycharm https://www.jetbrains.com/pycharm/

Page 32: Spirent TestCenter Automation HTAPI Programmer’s Reference · Spirent TestCenter Automation HLTAPI Programmer's Reference 7 To dereference the customized path and run HLTAPI for

Spirent TestCenter Automation HLTAPI Programmer's Reference 29

This is a screen capture showing RIDE to create test cases:

Page 33: Spirent TestCenter Automation HTAPI Programmer’s Reference · Spirent TestCenter Automation HLTAPI Programmer's Reference 7 To dereference the customized path and run HLTAPI for

Spirent TestCenter Automation HLTAPI Programmer's Reference 30

To generate scripts automatically:

Make sure Save as HLTAPI is successfully installed. Before you generate Robot Framework test cases using Save as HLTAPI, you must either configure the target function that you want to test in the Spirent TestCenter application, or load an existing XML configuration file. Follow the steps below to generate Robot Framework test cases using Save as HLTAPI:

In the Save as HLTAPI Wizard window, select the HLTAPI for Robot radio button, as

shown below:

Customize output scripts as necessary. Refer to Save as HLTAPI for detailed descriptions of

the options.

In the Save script to text box, specify the name and the path for the .robot file to be

generated.

Click Generate to generate the Robot Framework test cases. The Robot scripts will display.

Page 34: Spirent TestCenter Automation HTAPI Programmer’s Reference · Spirent TestCenter Automation HLTAPI Programmer's Reference 7 To dereference the customized path and run HLTAPI for

Spirent TestCenter Automation HLTAPI Programmer's Reference 31

Chapter 7 Integration with Spirent iTest

Introduction

This chapter provides steps for integrating Spirent iTest with HLTAPI and Spirent TestCenter. The

target audience is iTest users who wish to leverage Spirent TestCenter and Spirent HLTAPI to

generate iTest cases.

Prerequisites

You must have already installed Tcl, Spirent TestCenter, and HLTAPI for Tcl successfully. See

Install Tcl, and Install Spirent TestCenter and HLTAPI for more information.

Important: The following procedures only apply to Windows.

Install and Configure iTest RT

Spirent iTest run time is required to provide the sequencer service that is used to generate iTest

test cases. To work with Save as HLTAPI, iTest RT 4.40 or higher is required.

After unzipping the iTestRT release package into C:\iTestRT, you can run the sequencer service

using the following methods:

To launch iTestRT automatically, use either of the following two methods:

Add the iTestRT installation path to system environment variable PATH, so that Save as HLTAPI will know the location of iTestRT.

Open the configuration file C:\Tcl\lib\HLTAPI\tools\iTest\sequencerService.cfg, and edit the line below to point to iTest RT:

ITEST_RT_LAUNCHER=C:\iTestRT\itestrt.bat

Note: When launched automatically, iTestRT listens at port 7979, and Save as HLTAPI will connect

the sequencer service via URL: http://localhost:7979/ito/sequencer/v0/scripts.

To launch iTestRT manually (Use only when your Tcl version greater than or equal to 8.4.19):

Launch iTestRT to listen at a specific port, for example, port 7980, by using the following

command:

iTestRT.bat --itoServicesEnable --itoServicesBaseUrl

http://localhost:7980

Edit the following line in configuration file

c:\Tcl\lib\HLTAPI\tools\iTest\sequencerService.cfg to connect Save as iTest with iTestRT

service.

SEQUENCER_SERVICE_URL=http://localhost:7980/ito/sequencer/v0/

scripts

Note: If you want to run iTestRT from another PC, replace localhost with the address of the remote

machine.

Page 35: Spirent TestCenter Automation HTAPI Programmer’s Reference · Spirent TestCenter Automation HLTAPI Programmer's Reference 7 To dereference the customized path and run HLTAPI for

Spirent TestCenter Automation HLTAPI Programmer's Reference 32

Generate iTest Test Cases in Save as HLTAPI GUI

You must configure the target function to test in Spirent TestCenter, before you can generate iTest

cases using Spirent TestCenter and Save as HLTAPI. After you finish the configuration, use the

following steps to generate iTest test cases using Save as HLTAPI.

In the Save as HLTAPI Wizard window, select the iTest test case radio button.

Customize output scripts as necessary using checkboxes in the wizard window. Refer to

Save as HLTAPI for detailed descriptions of the options.

Click Generate to generate the iTest test case.

Open the generated iTest test case, as shown in the screen capture. Make sure the

interpreter in use is C:\Tcl\bin\, or you may experience execution errors.

Page 36: Spirent TestCenter Automation HTAPI Programmer’s Reference · Spirent TestCenter Automation HLTAPI Programmer's Reference 7 To dereference the customized path and run HLTAPI for

Spirent TestCenter Automation HLTAPI Programmer's Reference 33

Generate iTest Test Cases in CLI mode

In addition to the GUI mode, Save as HLTAPI also supports CLI mode, using a regular HLTAPI

function sth::hlapi_gen. Set the -output_type to TESTCASE to generate an iTest test case.

For more information of the CLI mode, refer to the Spirent Test Center Automation HLTAPI

Command Reference manual.

The following example shows how to use an existing HLTAPI configuration file to generate an iTest

case in Tcl shell:

package require SpirentHltApi

sth::hlapi_gen -config_file <config file> \

-output <output file> \

-output_type TESTCASE \

-test_control 1 \

-test_config 1 \

-test_run 1 \

-test_result 1 \

-pkt_capture 0 \

-device_info 1 \

-scaling_test 0

The output file with extension .fftc can be opened in Spirent iTest.

Page 37: Spirent TestCenter Automation HTAPI Programmer’s Reference · Spirent TestCenter Automation HLTAPI Programmer's Reference 7 To dereference the customized path and run HLTAPI for

Spirent TestCenter Automation HLTAPI Programmer's Reference 34

References

Getting Started with Spirent TestCenter

Provides details on how to install Spirent TestCenter chassis and modules and how to obtain license keys. This manual is included on the Spirent TestCenter Application DVD and is available in the Knowledge Base on the Spirent Communications support website (https://support.spirent.com)

iTest User Documentation

Installation and configuration documents for iTest are available in PDF format on the Spirent Knowledge Base (https://support.spirent.com).

Robot Framework Documentation

Provides detailed information on Robot Framework (http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html)

Spirent Test Center Automation HLTAPI Command Reference

Provides detailed information on how to use Spirent HTLAPI. You can find this guide in HLTAPI_ReleasePackage > UserDoc

Tcl’s website: http://www.tcl.tk/