Spirent TestCenter™ Automation HLTAPI ’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 ...... 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 on your PC or workstation (Microsoft® Windows® or ®) 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 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/: 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.

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 ()\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

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.

Spirent TestCenter Automation HLTAPI Programmer's Reference 6

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// 2. From SourceCode/hltapiforperl/, copy SpirentHLTAPIforPerl.pm to the following location and overwrite the existing folder: /volume/labtools/lib/

Spirent TestCenter Automation HLTAPI Programmer's Reference 7

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 &

Spirent TestCenter Automation HLTAPI Programmer's Reference 8

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

Spirent TestCenter Automation HLTAPI Programmer's Reference 9

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 (..putlog) Note: This log file is environment specific. HLT server log (..hltlog) HLTAPI logs (sth::test_config) _logfile.txt _stcExport.txt _hltExport.txt _hlt2StcMapping.txt

Spirent TestCenter Automation HLTAPI Programmer's Reference 10

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

Spirent TestCenter Automation HLTAPI Programmer's Reference 11

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)

Spirent TestCenter Automation HLTAPI Programmer's Reference 12

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

Spirent TestCenter Automation HLTAPI Programmer's Reference 13

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.

Spirent TestCenter Automation HLTAPI Programmer's Reference 14

Save as HLTAPI Supported Functions

Feature/Technology API Names Save As HLTAPI Support

ALARMS alarms_control No alarms_stats No

ANCP emulation_ancp_config Yes emulation_ancp_control Yes emulation_ancp_stats Yes emulation_ancp_subscriber_lines_config Yes

BFD emulation_bfd_config Yes emulation_bfd_control Yes emulation_bfd_info Yes

BGP emulation_bgp_config Yes emulation_bgp_control Yes emulation_bgp_info Yes emulation_bgp_route_config Yes emulation_bgp_route_element_config Yes emulation_bgp_route_info Yes emulation_bgp_route_generator No Raw Device emulation_device_config Yes

DHCPv4/v6 Clients emulation_dhcp_config Yes emulation_dhcp_group_config Yes emulation_dhcp_control Yes emulation_dhcp_stats Yes

DHCPv4/v6 Server emulation_dhcp_server_config Yes emulation_dhcp_server_control Yes emulation_dhcp_server_relay_agent_config Yes emulation_dhcp_server_stats Yes

802.1x emulation_dot1x_config Yes emulation_dot1x_control Yes emulation_dot1x_stats Yes EOAM emulation_oam_config_msg Yes emulation_oam_config_topology Yes emulation_oam_control Yes emulation_oam_info Yes EFM emulation_efm_config Yes emulation_efm_control Yes emulation_efm_stat Yes

FC fc_config fc_control No fc_stats No No FCoE fcoe_config Yes fcoe_control Yes fcoe_stats fip_traffic_config Yes fcoe_traffic_config Yes Yes GRE emulation_gre_config Yes

40/100G pcs_error_config pcs_error_control No random_error_config random_error_control No forty_hundred_gig_l1_results No No HTTP emulation_http_profile_config Yes No emulation_http_config Yes emulation_http_phase_config Yes emulation_http_control Yes emulation_http_stats Yes

Spirent TestCenter Automation HLTAPI Programmer's Reference 15

Feature/Technology API Names Save As HLTAPI Support

IGMP Querier emulation_igmp_querier_config Yes emulation_igmp_querier_control Yes emulation_igmp_querier_info Yes

IGMP emulation_igmp_config Yes emulation_igmp_control Yes emulation_igmp_group_config Yes emulation_igmp_info Yes

IPv6 Auto Config emulation_ipv6_autoconfig Yes emulation_ipv6_autoconfig_control Yes emulation_ipv6_autoconfig_stats Yes

IPTV emulation_iptv_config Yes emulation_iptv_channel_block_ Yes config emulation_iptv_channel_viewing_ Yes profile_config emulation_iptv_viewing_behavior_ Yes profile_config

emulation_iptv_control Yes emulation_iptv_stats Yes

ISIS emulation_isis_config Yes emulation_isis_control Yes emulation_isis_topology_route_config No emulation_isis_lsp_generator No emulation_isis_info Yes

L2TP l2tp_config Yes l2tp_control Yes l2tp_stats Yes

L2TPv3 l2tpv3_config Yes l2tpv3_control Yes l2tpv3_stats Yes LACP emulation_lacp_config Yes emulation_lacp_control Yes emulation_lacp_info Yes

LDP emulation_ldp_config Yes emulation_ldp_control Yes emulation_ldp_info Yes emulation_ldp_route_config Yes emulation_lsp_switching_point_tlvs_config Yes

LLDP emulation_lldp_config Yes emulation_lldp_optional_tlv_config Yes emulation_lldp_dcbx_tlv_config Yes emulation_lldp_control emulation_lldp_info Yes Yes

MLD emulation_mld_config Yes emulation_mld_group_config Yes emulation_mld_control emulation_mld_info Yes Yes

Micro BFD emulation_micro_bfd_config No emulation_micro_bfd_control No emulation_micro_bfd_info No

MPLS IP VPN emulation_mpls_ip_vpn_provider_port_config No emulation_mpls_ip_vpn_cust_port_config No emulation_mpls_ip_vpn_config No emulation_mpls_ip_vpn_control No emulation_mpls_ip_vpn_info No

Spirent TestCenter Automation HLTAPI Programmer's Reference 16

Feature/Technology API Names Save As HLTAPI Support

MPLS-TP emulation_mpls_tp_config No emulation_mpls_tp_port_config No emulation_mpls_tp_control No emulation_lsp_ping_info No emulation_mplstp_y1731_oam_control No emulation_mplstp_y1731_oam_info No

MPLS-VPN emulation_mpls_l2vpn_pe_config No emulation_mpls_l2vpn_site_config No emulation_mpls_l3vpn_pe_config No emulation_mpls_l3vpn_site_config No

Multicast emulation_multicast_group_config Yes emulation_multicast_source_config Yes emulation_mcast_wizard_config No

MVPN emulation_mvpn_provider_port_config No emulation_mvpn_customer_port_config No emulation_mvpn_config No emulation_mvpn_control No emulation_mvpn_info No

OSPF emulation_ospf_config Yes emulation_ospf_control Yes emulation_ospf_lsa_config Yes emulation_ospf_tlv_config No emulation_ospf_topology_route_config No emulation_ospfv2_info Yes emulation_ospfv3_info Yes emulation_ospf_route_info Yes

OpenFlow emulation_openflow_config No emulation_openflow_control No emulation_openflow_stats No emulation_openflow_switch_config No emulation_openflow_switch_control No emulation_openflow_switch_stats No

Packet Capture packet_config_buffers Yes packet_config_triggers Yes packet_config_filter packet_control Yes packet_info Yes packet_stats Yes Yes PCEP emulation_pcep_config No emulation_pcep_control No

PIM emulation_pim_config Yes emulation_pim_control Yes emulation_pim_group_config Yes emulation_pim_info Yes

PING emulation_ping No PPP ppp_config Yes ppp_stats Yes

PPPoX pppox_config pppox_control Yes pppox_stats Yes Yes PPPoX Server pppox_server_config Yes pppox_server_control Yes pppox_server_stats Yes

PTP emulation_ptp_config Yes emulation_ptp_control Yes emulation_ptp_stats Yes

Spirent TestCenter Automation HLTAPI Programmer's Reference 17

Feature/Technology API Names Save As HLTAPI Support test_rfc2544_config Yes RFC 2544 test_rfc2544_control Yes test_rfc2544_info rfc2544_asymmetric_config Yes rfc2544_asymmetric_control Yes rfc2544_asymmetric_profile Yes rfc2544_asymmetric_stats Yes

RFC 3918 test_rfc3918_config test_rfc3918_control Yes test_rfc3918_info Yes Yes RIP emulation_rip_config emulation_rip_control Yes emulation_rip_route_config emulation_rip_info Yes Yes Yes RSVP emulation_rsvp_config emulation_rsvp_control Yes emulation_rsvp_info emulation_rsvp_tunnel_config Yes emulation_rsvpte_tunnel_control Yes emulation_rsvp_tunnel_info Yes Yes Yes Session arp_control No connect Yes device_info Yes interface_config Yes interface_control No interface_stats cleanup_session No labserver_connect Yes labserver_disconnect link_config No load_xml No start_devices stop_devices Yes get_handles No sequencer_control No No No emulation_sip_config Yes SIP Yes emulation_sip_control Yes emulation_sip_stats Yes

STP emulation_stp_config Yes emulation_mstp_region_config Yes emulation_msti_config Yes emulation_stp_control Yes emulation_stp_stats Yes

Testing Utility test_config Yes test_control Yes save_xml No system_settings_ Yes

SyncE emulation_synce_config No emulation_synce_control No emulation_synce_stats No

Traffic traffic_config Yes traffic_config_ospf Yes imix_config No traffic_control Yes traffic_stats Yes drv_stats No create_csv_file No emulation_video_config Yes Video emulation_video_server_streams_config Yes emulation_profile_config emulation_client_load_phase_config Yes emulation_video_control Yes emulation_video_clips_manage Yes emulation_video_stats Yes Yes

Spirent TestCenter Automation HLTAPI Programmer's Reference 18

Feature/Technology API Names Save As HLTAPI Support

emulation_vqa_host_config Yes VQA emulation_vqa_config emulation_vqa_port_config Yes emulation_vqa_global_config Yes emulation_vqa_control Yes emulation_vxlan_config No VXLAN emulation_vqa_stats Yes emulation_vxlan_control YesNo emulation_vxlan_stats No VXLAN EVPN Overlay emulation_vxlan_evpn_overlay_port_config No emulation_nonvxlan_evpn_overlay_port_config No emulation_vxlan_evpn_overlay_wizard_config No emulation_6pe_6vpe_provider_port_config No emulation_vxlan_evpn_overlay_control No emulation_vxlan_evpn_overlay_stats No VPLS emulation_l2vpn_pe_config Yes emulation_vpls_site_config Yes

6PE/6VPE emulation_6pe_6vpe_provider_port_config No emulation_6pe_6vpe_cust_port_config No emulation_6pe_6vpe_config No emulation_6pe_6vpe_control No emulation_6pe_6vpe_info No

Spirent TestCenter Automation HLTAPI Programmer's Reference 19

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.

Spirent TestCenter Automation HLTAPI Programmer's Reference 20

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\

Spirent TestCenter Automation HLTAPI Programmer's Reference 21

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.

Spirent TestCenter Automation HLTAPI Programmer's Reference 22

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.

Spirent TestCenter Automation HLTAPI Programmer's Reference 23

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.

Spirent TestCenter Automation HLTAPI Programmer's Reference 24

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.

Spirent TestCenter Automation HLTAPI Programmer's Reference 25

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

Spirent TestCenter Automation HLTAPI Programmer's Reference 26

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

Spirent TestCenter Automation HLTAPI Programmer's Reference 27

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/

Spirent TestCenter Automation HLTAPI Programmer's Reference 28

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

Spirent TestCenter Automation HLTAPI Programmer's Reference 29

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.

Spirent TestCenter Automation HLTAPI Programmer's Reference 30

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.

Spirent TestCenter Automation HLTAPI Programmer's Reference 31

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.

Spirent TestCenter Automation HLTAPI Programmer's Reference 32

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 \ -output \ -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.

Spirent TestCenter Automation HLTAPI Programmer's Reference 33

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/

Spirent TestCenter Automation HLTAPI Programmer's Reference 34