BreakingPoint Automation Series: Tcl 101
Automation has been the key agent of change in the tech industry and it’s dictating how things will be done in the future. As a test tool, BreakingPoint is no stranger to automation. It supports test automation through Tcl and RESTful APIs. Users can design a basic skeleton through an intuitive GUI and then, through automation, can create thousands of unique variants of the same test or run it as a regression. In this blog series, we will cover some of those automation techniques and tips and tricks to efficiently use Tcl and RESTful APIs, along with different features of BreakingPoint like applications, attacks, performance, and scalability.
This introductory blog will cover the basics of running a BreakingPoint test and, as we move along in the series, we will explore more advanced options that showcase the flexibility and breadth of BreakingPoint automation and the variety of interesting scenarios that you can achieve with it.
You can achieve automation in BreakingPoint in two different ways, directly and through a downloaded BreakingPoint shell.
To run just a few commands, there are no prerequisites. You can literally SSH into the BreakingPoint hardware and execute commands to interact with it. Below is an example of few commands that you can execute in any Linux-based environment to execute a quick pre-created test.
$ %ssh <Chassis-IP>@<Username> <Username>@10.200.119.244's password: bps> bpsh Active BPS connection available as $bps % set chassisInstance [$bps getChassis] ::bps::BPSConnection::bPSConnection0::chassisClient0 % #The Below commands reserves the first two ports in the first card of the Chassis. % set cardNumber 1 % set firstPort 0 % set secondPort 1 % $chassisInstance reservePort $cardNumber $clientPort % $chassisInstance reservePort $cardNumber $ serverPort % #The command will create a test variable that will run a new test called “HelloWorld” using the template “AppSim” % set testRunInstance [$bps createTest -name "HelloWorld" -template AppSim] ::bps::BPSConnection::bPSConnection0::HelloWorld % #The below command will set status variable with the test overall status % set status [$testInstance run] passed
Direct commands executed to run a quick automated test
Downloaded BreakingPoint Shell Execution
The second way is to create and execute a complete Tcl file on the downloaded BreakingPoint TCL shell. You can download the Tcl binary version from the BreakingPoint WebUI “Downloads” dropdown as shown below. You’ll find shell versions for Windows (bpsh-win32.exe), Linux (bpsh-linux-x86), or Mac (bpsh-mac.app).
Downloading the BreakingPoint Tcl Shell through the WebUI
Below is a sample script that will execute a new test called “HelloWorld” using the pre-existing template “AppSim”. The Tcl scripts give you the flexibility to create complex test scenarios, edit parameters on-the-fly, create fully automated test scripts, and integrate as part of regular regressions.
#The below will contain the IP and desired credentials that will be used when running the test set bpsIP <IP-Of-Chassis> set bpsPass <UserName-For the Chassis> set bpsUser <PassWord - For the Chassis> #The Next three commands selects the card number and ports where to run the test set CardSlot <Integer: Position of the Card position like 1> set port1 <First Port Number Ex: 1> set port2 <2nd Port Number Ex 2> #Connecting to the box from the shell. set bps [bps:connect $bpsIP $bpsUser $bpsPass] #Reserving the ports to run the test on this particular Chassis. set chassisInstance [$bps getChassis] $chassisInstance reservePort $cardSlot $port1 $chassisInstance reservePort $cardSlot $port 2 #Creating the HelloWorld test based on an existing template AppSim. set testInstance [$bps createTest -name "HelloWorld" -template AppSim] #Running the created test. Setting the status variable to the output. set status [$testInstance run] #If the tests criteria are met (in this case if more than 95% of the session succeeded), test will report Pass puts "Test finished with status $status" ~ "helloWorld.tcl" [New] 26L, 105C written
Sample Tcl Script that is executed through the BreakingPoint shell
Another method to download the BreakingPoint Tcl shell is by downloading directly to the chassis web link over HTTP. This is useful if you want to get the Tcl shell from a script. Below is an example of both using wget to download the BreakingPoint shell for Linux and then executing the created “helloWorld.tcl” script.
$ #The below command will download the BPS TCL Shell from your bps machine $ wget http://<Your_BPS_IP_or_DNS>/ui/tcl/bpsh-linux-x86--2017-06-05 15:08:10-- http://<Your_BPS_IP_or_DNS>/ui/tcl/bpsh-linux-x86 Connecting to Your_BPS_IP_or_DNS:80... connected. HTTP request sent, awaiting response... 200 OK Length: 3742712 (3.6M) Saving to: "bpsh-linux-x86" 100% [==================================================================================================================================>] 3,742,721 11.2M/s in 0.3s 2017-06-05 150810 (11.2MB/s) - "bpsh-linux-x86" saved [3742712/3742712] $ #The below command will provide execution permission and run the newly created tcl script. $ sudo chmod 755 bpsh-linux-x86 $ ./bpsh-linux-x86 helloWorld.tcl Test finished with status passed
Downloading a BreakingPoint shell and then executing a pre-created Tcl script
Analyzing Test Runs and Statistics
You can use automation to analyze stats at run-time and get excerpts from the reports of a test execution easily, although there is a lot of flexibility in the usage and we will dedicate another blog to this topic to cover most of the use cases. For now, you can just use the BreakingPoint GUI to see the execution results as shown in the below screens.
Test Results showing the report of the HelloWorld test that we ran
The BreakingPoint showing the run-time statistics of the “HelloWorld” test
Automation in testing has been key to achieving test results that are not possible otherwise, like automated regressions and sanity checks, integrated DUT automations, automated results/stat analysis and pass/fail criteria determination, hundreds of variants of same tests, dynamic modification of tests based on previous result analysis. This blog series aims to uncover all major facets of BreakingPoint automation and how you can leverage them:
- Running tests using Tcl
- Running tests using REST and creating variants
- Executing multi-vector application and security scenarios
- Analyzing runtime stats and dynamic test configuration modifications
- Creating regression tests to measure device under test (DUT) performance
- Interacting with DUT during test runs
Follow this automation series for the information you need to get the most from your BreakingPoint testing.