The slides describes how Robot Framework provides synergy in test automation, making a lot of
automation processes flexible and simple for testing network protocols(in this case BGP).
3. Introduction
Robot Framework is a Pythonbased, extensible keyworddriven
test automation framework for endtoend acceptance testing and
acceptancetestdriven development (ATDD).
It can be used for testing distributed, heterogeneous applications,
where verification requires touching several technologies and
interfaces.
Robot Framework is operating system and application
independent.
It empowers testers to automate and manage complex workflow
scripts efficiently.
Robot Framework is open source software released under
Apache License 2.0.
Implemented with Python
– Runs also on Jython (JVM) and IronPython (.NET)
– Can be extended natively using Python or Java
– Other languages supported via a remote interface
4. Why Robot?
Ease of use
Logging and Failure Analysis
& Flexibility
Robot is keyword driven
Robot is highly extensible
Robot integrates with development tools
Robot has robust reporting
Multiple Operating Systems support
Reusable/custom keywords
Maintainability is easy
Extensive set of standard, external libraries
5. High Level Architecture
Robot Framework has a modular
architecture that can be extended with
bundled and selfmade test libraries.
When test execution is started, the
framework first parses the test data. It
then utilizes keywords provided by the
test libraries to interact with the
system under test. Libraries can
communicate with the system either
directly or using other test tools as
drivers.
Test execution is started from the
command line. As a result you get
report and log in HTML format as well
as an XML output. These provide
extensive look into what your system
does.
Test data Syntax
Test Library API
Application Interface
TEST DATA
ROBOT FRAMEWORK
TEST LIBRARIES
SYSTEM UNDER TEST
TEST TOOLS
6. Test libraries provide the actual testing
capabilities to Robot Framework by
providing keywords.
There are several standard libraries that
are bundled in with the framework, and
galore of separately developed external
libraries that can be installed based on your
needs
Standard Libraries
Builtin
Operating System
Process
Telnet
Remote
Screenshot
External Libraries
Selenium2Library
HTTP
FTP
Rammbock
SSH
Django
Android
IOS
Test Libraries
7. Important libraries for automating router
implementation
Rammbock
Rammbock is unique library which help developing automation test cases to a Networking
domain based application. Rammbock is a simple python based library that will help to
automate the generation of simple TCP/IP or UDP based packets.
SSH
With the SSH library an automation script can connect to a remote UNIX or a LINUX machine
and execute any commands remotely.
Telnet
Makes it possible to connect to Telnet servers and
execute commands on the opened connections.
Operating System
The operating systems library provides the
flexibility execute any OS command in the
environment or the machine the script is being
executed
8. Protocol testing using Robot Framework (BGP)
Border Gateway Protocol (BGP) is a standardized exterior gateway protocol designed to exchange
routing and reachability information among autonomous systems (AS) on the Internet.BGP is the
routing protocol of the global Internet, as well as for Service Provider private networks.Thus checking
whether BGP is working as per respective standard is of prime importance.
Automated protocol testing is the best bet to boost the efficiency and broaden the scope of testing.
What can be the best, other than ROBOT FRAMEWORK ????
Robot Framework can be used to automate test cases in a quick and proficient fashion.Its powerful
features such as Ease of use, Flexibility, Extensive Libraries, and Robust reporting, make it a wonderful
tool in hands of a network manager entrusted a task to test the network.
Thus we have developed test suite with tests for configuring BGP and testing it.
We use a Network Emulation tool called GNS3
GNS3 provides a realtime network simulation for predeployment testing without
the need for network hardware.
Let’s you create dynamic network maps for troubleshooting and proof of concept
(POC) testing
9. Design Requirements
CPU Speed : 2.1Ghz
RAM : 4GB
OS : Ubuntu
Other Softwares Required:
Network Emulator GNS3 1.5.2
with Cisco router IOS image :c7200p-adventerprisek9_sna-mz
Python 2.7.12
Robot Framework 3.0
12. *** Settings ***
Metadata Version 1.0
... More Info For more information about Robot Framework see http://robotframework.org
... Author Payal Jain
... Date 19 Dec 2016
... Executed At ${HOST}
... Test Framework Robot Framework Python
Documentation A test suite with tests for configuring BGP.
... Topology:-
... _________________________
| R1 AS2 |
... | / |
... | / |
... | R2 R3 |
... | | | |
|________| ______ |_________|
________| |_________
... | AS1 | | AS3 |
| | | |
... | R4 | | R5 |
... |_______ | |________ |
Testplan Goals:-
... 1. Configure IP addresses as per the topology.
... 2. Each Router should have a loopback0 interface.
... 3. Configure OSPF within AS2 to advertise the loopback0 interfaces.
... Don't advertise or run OSPF on the links interconnecting AS1 and AS3.
... 4. Configure IBGP between R2 and R3. Source the BGP updates from the loopback0 interfaces.
... 5. Enable BGP synchronisation.
... 6. Configure EBGP between R2 and R4.
... 7. Configure EBGP between R3 and R5.
... 8. Advertise the loopback0 interfaces on R4 and R5.
... 9. Ensure AS1 and AS3 can communicate with each other without removing the BGP synchronisation command.
Resource Resource.robot
Suite Setup Setup Actions
Suite Teardown Teardown Actions
Sample Test_Case File
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.
The following settings in the Setting table can be used to customize the test suite:
Documentation
Used for specifying a test suite documentation
Metadata
Used for setting free test suite metadata as namevalue pairs.
Suite Setup, Suite Teardown
Specify suite setup and teardown.
13. *** Test Cases ***
Bring_up Phase
Configure IP addresses as per the topology
Configure ip address
Set loopback interface
Configure OSPF within AS2 to advertise the connected networks
Enable OSPF in devices present in AS2 and set the ospf neighbors
Configure IBGP and source the BGP updates from the loopback0 interfaces
Enable BGP and advertise the updates from the loopback interface
Enable BGP Synchronisation
Enable synchronisation between border routers
Configure EBGP and source the BGP updates from the loopback0 interfaces
Enable BGP and advertise networks connected outside the autonomous system
Advertise loopback interface on AS1 and AS3
Operational Phase
Check if ip addresses is set and interface is up
Ensure that different autonomous systems can communicate with each other
Check if OSPF neighbors are established
Redistribute in order to make routes available in IBGP table
Check if all routes are learnt by devices
Establish route between R2 and R3
Redistribute routes from OSPF into BGP
.......Sample Test_Case File
This includes the testcases to implement testplan goals.The testsuite contains two main critical tests:
Bring_Up Phase : Tests to configure the device under test(DUT) as per the testplan
Operational Phase : Tests to check the operability of a DUT as per the configuration done in bringup phase
14. *** Settings ***
Documentation Resource file containing all the PYTHON API implementations.
Library setup_actions.py
Library Devices.py
Library OSPF.py
Library IBGP.py
Library operational_ph.py
Library String
Variables variable.py
*** Variables ***
@{Devices} = R1 R2 R3 R4 R5
${ELEMENT}
*** Keywords ***
Setup Actions
Log To Console Setup Actions done here
Log To Console Connecting to all devices and enabling password and hostname
Run Keyword and Continue On Failure connect_all enable
Teardown Actions
Log To Console Teardown Actions done here
Log To Console Unconfiguring IP_Address
Run Keyword and Continue On Failure set_IP R1 ${Links_of_R1} unconfigure
Log To Console IP_Address unconfigured in R1
Run Keyword and Continue On Failure set_IP R2 ${Links_of_R2} unconfigure
Log To Console IP_Address unconfigured in R2
Run Keyword and Continue On Failure set_IP R3 ${Links_of_R3} unconfigure
Log To Console IP_Address unconfigured in R3
Run Keyword and Continue On Failure set_IP R4 ${Links_of_R4} unconfigure
Log To Console IP_Address unconfigured in R4
Run Keyword and Continue On Failure set_IP R5 ${Links_of_R5} unconfigure
Log To Console IP_Address unconfigured in R5
Log To Console Disabling password and unsetting hostname
Run Keyword and Continue On Failure connect_all disable
The higherlevel structure of resource files is the same as that of test case files
User keywords and variables in test case files and test suite initialization files can only be used in files where they are created, but resource files provide a
mechanism for sharing them.
Sample Resource file
15. import pexpect
import getdata
import time
import execute
import Device
class OSPF_Configuration:
def Configure_ospf(self,Device,process_id,Networks_connected,Area,Action):
with open('pr2.json') as data_file:
device_data = json.load(data_file)
hostname = device_data['Device_Details'][Device]['Hostname']
child = Device.connect(Device)
if (child):
Device.flushBuffer(10,child)
child.sendcontrol('m')
flag = child.expect([hostname+'>',hostname+'#','Router>','Router#',pexpect.EOF,pexpect.TIMEOUT],timeout=50)
print 'flag =%d' % flag
if flag==0 or flag==2:
self.Login(Device,child)
if Action == 'enable':
if (isinstance(Networks_connected,list)):
for NID in Networks_connected:
print NID
configs = """
configure terminal
router ospf %s
network %s area %s
end
""" % (process_id,NID,Area)
commands = configs.split('n')
execute.execute(child,command)
child.sendcontrol('m')
child.sendline('exit')
Child.sendcontrol('m')
Sample Python Library
This defines the implementation of user keywords.
21. Test_SetupInitial configuration in devices
A test setup is something that is executed before a test case.
Example: Set up the initial configurations of device under test(DUT) such as establishing Telnet connection & setting up the password and
hostname.