The Landslide Tcl API allows you to perform almost all the tasks that may be performed in the GUI-based environment from a scripted Tcl interface. The Tcl interface allows you to perform some additional tasks that cannot be executed from the GUI environment.
The Landslide Tcl API can either be installed as a complete standalone application or the packages and libraries can be integrated into an existing Tcl 8.4 (32-bit) or Tcl 8.6 (64-bit) environments. Follow the installation instructions for either option on the Landslide Home Page under the Tcl API link - Install/Upgrade Instructions.
The Landslide Tcl API provides support for 64-bit or 32-bit Tcl/Java on Linux, MAC and Windows. Other variations are possible, but user must compile their own Tcl/TclJBlend libraries. We provide source tarball and instructions to aid users with the build.
Java Runtime Environment 11 (1.11.0) is required for the Landslide TCL API. Java 11 is recommended. Recent Java 11 Windows®, Linux®, and Mac™ JRE installers are supplied with the system on the Troubleshoot Clients page / http://TASIP/clienthelp.html.
The 32-bit and 64-bit JRE for common OSs can be downloaded from the Landslide Home Page.
The Java Web Start Plug-in is bundled as part of the Java Runtime Environment (JRE).
The Landslide serves up local copies of the Windows, Linux, and Mac OS X versions. Versions for other operating systems and architectures can be found at Java Homepage / Manual Java Downloads (Requires License),
or at one of the open source builder website, like https://adoptium.net/temurin/releases/ (Open Source).
All Java versions can be downloaded from Oracle's Java Website (Requires License).
If any of the file links return 404/not found, i.e. are not available from the Landslide homepage, contact Support for copies.
We now provide a Python wrapper class to access our Tcl API from Python. The script is lsApi.py located in the Tcl API root directory, and was created/tested using Python 2.7.
Click or see below for additional Python details.
The Landslide Tcl API includes Global Commands, Objects, and Perform Functions. You use the Global Commands to retrieve, query, open, save, delete and perform functions on the API objects. The API Objects correlate to the objects you would see in the GUI, such as test sessions (TestSession), test cases (Tc/TestCase), DMFs (Dmf), SUTs (Sut), test servers (Ts/TsInfo/TsConfig), etc.
To learn about each command provided and how to interact with the API Objects, read the following sections in the order listed below.
The Landslide Client can be used as a wizard to help create Tcl scripts and to understand all the commands required to configure tests. Follow these instructions:
Use the GUI to create and save the initial test sessions, DMFs, and/or MEs.
Press Shift+Alt+A from the Test Session / DMF Window / ME Window to save as Tcl file.
NOTES:
From the DMF Window, press Shift+Alt+A to display the Save DMF as Tcl window. From the ME Window, press Shift+Alt+A to display the Save ME as Tcl window.
|
Alternatively, Retrieve the object from the Tcl API using the ls::retrieve command.
Call the ls::perform SaveAsTcl function on the object to generate a Tcl script with all the Tcl commands required to create the objects without the GUI.
The generated file could then be sourced from Tcl to create the object.
% set test [ls::retrieve TestSession -userLibraryName sms ip_app_node]
java0x3
% ls::perform SaveAsTcl $test C:/WorkDocs/test1.tcl
% source test1.tcl
The following is an example of how you would use the Tcl API to login, open, and run a saved Test Session.
Automation:~/demotclapi$ ./landslidetclapi
% source landslidetclapi.tcl
Starting Java with Max Heap=256m
% ls::login 10.71.30.30 sms a1b2c3d4
java0x1
% ls::perform ListLibraryItems TestSession -userLibraryName sms
ColorTest {GGSN Nodal_superuser} GGSNNODE_test_new_1 ip_app_node {ip_app_node ipsec} ip_app_node1 nethost PCF PGWNodal PGWNode PGWNpde SGWNodal SGWNodalSGSN SGWNode sms_ggsn_nodal tr6451_simtr4255ggsnNode_and_DNSserver tr6451_tr4255ggsnNodal
% set test [ls::retrieve TestSession -userLibraryName sms ip_app_node]
java0x3
% ls::perform Run -TestSession $test
% ls::get $test -TestStateOrStep
STARTING
% ls::get $test -TestStateOrStep
RUNNING
% ls::perform Stop -TestSession $test
% ls::get $test -TestStateOrStep
STOPPING
% ls::get $test -TestStateOrStep
COMPLETE
%
To run it in your own python environment or script :
start in the Tcl API directory,
or cd to the Tcl API directory before importing,
or add the Tcl API directory to your PYTHONPATH.
Then from python, then you can import our module, lsApi.py.
NOTES:
|
user@dan:~/api$ python
Python 2.7.9 (default, Mar 1 2015, 12:57:24)
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from lsapi import LsApi
>>> ls = LsApi(jre_path='/home/ddiolosa/api/jre1.8.0_40')
>>> ls.tcl('ls::help')
'Usage: ls::help commands\n ls::help <COMMAND>\n ls::help TEST_CASE_HANDLE TC_PARAMETER_NAME\n'
>>> ls.tcl('ls::login 10.71.30.110 sms a1b2c3d4')
'java0x2'
>>> ls.tcl('ls::isConnected')
'1'
>>> ls.tcl('ls::perform ListLibraryItems TestSession -libraryid 342')
'aim_com_aol ALU-SGWNodal4.11.1.1.1-2-localNH-1 ALU-SGWNodal4.11.1.1.1-2-localNH-1a-10k ALU-SGWNodal4.11.1.1.1-2-localNH-1a-10subs {ASN CR test} CR-406950883-startPaused-SessionIterations-fixed-11.6.0.15 CR367745787 Dan deleteme {LAPI Test} MME_B2B_with_Studio_Traffic MME_B2B_with_Studio_Traffic_new MME_B2B_with_Studio_Traffic_new_Automation {MME_B2B_with_Studio_Traffic_No Automation} {MME_B2B_with_Studio_Traffic_No Automation_Antivir} {MME_B2B_with_Studio_Traffic_No Automation_udp} MME_CR369805968 {MSC Node SMS test} net2phone_test {Regression test} {Regression test1} SGWNodals-3tc-25kper-C70-PGWNode-C77-toALU7750-2x SGWNodals-3tc-25kper-C70-PGWNode-C77-toALU7750-2y WF5.1.1.1.1.18-Ver1.3-None-PassFail-29Mins'
>>>
There are two objects in the module, LsApi and LsApiShell, the difference just being in how a Tcl command is parsed. Unless you have issues, use LsApi.
Both objects have a .tcl() method that takes the Tcl command as first argument, and optional keyword argument of timeout_s as second argument. By default the timeout for the command is 10 seconds, if you are executing a long running command, you should increase the timeout.
To change the timeout value, update the constant TIMEOUT_S in the lsApi.py file to increase/decrease the default from 10 seconds to a new value.
You are basically getting a window into the Tcl, if you want variables to stay in memory, you must set them inside Tcl:
>>> ls.tcl('set test [ls::create TestSession]')
This way will not be maintained in the Tcl memory:
>>> test = ls.tcl('ls::create TestSession')