Getting started - Paxterra/TestON GitHub Wiki
TestON could be run on Linux as well as Windows platform
###Configuring Linux to run TestON :
Requirements: 1)A Linux 2.6.26 or greater kernel compiled with network namespace support enabled (see INSTALL for additional information.) 2)python 2.6 or higher versions.
Install python package configObj. It can be installed by following either of the way:
-
$ sudo pip install configObj
-
Provided the local copy of configobj-4.7.2 package in /lib/ directory.
-
Install this package by running:
python setup.py install
-
Note: pox and mininet components must be installed for the drivers to work. It is recommended that you have a openflow Virtual Machine installed as it is easier.
Clone TestON package from https://github.com/Paxterra/TestON.git
Please configure mail server details before going to start working with TestON
- Open core/utilities.py file inside TestON Framework
- Check def send_mail(self) and configure the mail server and your credentials as mention below: 233: msg['From'] = '[email protected]' 250: smtp = smtplib.SMTP('Hostname/IP') 252: smtp.login('[email protected]','password')
Start the teston command-line by running the cli.py in bin directory.
Finally, launch the test from the teston command-line.
Get full details about the CLI in TestON Interactive CLI
openflow@ETH-Tutorial:~/TestON/bin$ ./cli.py
teston>run PoxTest logdir /home/openflow/ mail [email protected]
You can always start learning by trying out a few examples under ~/examples/ directory. When running an example, use this command
openflow@ETH-Tutorial:~/TestON/bin$ ./cli.py
teston>run Topology example 1 mail [email protected]
###Configuring Windows to run TestON :
Requirements: 1)Windows XP SP2 or later releases 2)python 2.7.6
Install python package configObj. If TestON is placed in D: drive, then the installation command to be run under the path - D:\TestON\lib\configObj-4.7.2 is python setup.py install
Follow the link to download the latest TestON package - https://github.com/Paxterra/TestON/archive/TestON-2.0.0.zip
Please configure mail server details before going to start working with TestON
- Open core\utilities.py file inside TestON Framework
- Check def send_mail(self) and configure the mail server and your credentials as mention below: 233: msg['From'] = '[email protected]' 250: smtp = smtplib.SMTP('Hostname/IP') 252: smtp.login('[email protected]','password')
Setting environment variable : System Properties--> Environment Variables, create new Variable under 'System Variables' with name: Python and value: C:\Python27
Start the teston command-line by running the cli.py in bin directory.
Finally, launch the test from the teston command-line.
Get full details about the CLI in TestON Interactive CLI
D:\TestON\bin\ python cli.py
teston>run PoxTest logdir D:\ mail [email protected]
or simply
_teston>run Test_Name
1 . Create the package under tests directory test_name.
2 . Create three files named as test_name.params, test_name.topo and test_name.py under the test test_name.
3 . Define topology in test_name.topo.
Please refer the sample format for topology:
4 . Define the test parameters and CASE or STEP level parameters in test_name.params file.
Please refer the sample format for params:
5 . Define your test cases in test_name.py
In topo file the component definition is specified as:
<TOPOLOGY>
<COMPONENT>
<Mininet1>
<host> 192.168.56.101 </host>
<user> openflow </user>
</Mininet1>
</COMPONENT>
</TOPOLOGY>
The usage of this component in the test script is as follows: main.Mininet1.checkIP(main.params['CASE1']['destination'])
Here Mininet1 is of Mininet (Corresponding driver in the drivers).
Please refer the sample test script: Test Script
Note: The class name for the test script should be same as the test_name.
1 . CASE level parameters:
<CASE1>
<destination> h2 </destination>
</CASE1>
This CASE level parameters can be accessed as follows: main.params['CASE1']['destination']
Please refer the CASE level parameters usage example : CASE params
2 . STEP level parameters :
<CASE1>
<STEP1>
<host> h2 </host>
</STEP1>
</CASE1>
This STEP level parameters can be accessed as follows: main.params['CASE1']['STEP1']['host']
Please refer the CASE level parameters usage example : STEP params
3 . TOPOLOGY level parameters :
<TOPOLOGY>
<COMPONENT>
<Mininet1>
<host> 192.168.56.101 </host>
<user> openflow </user>
</Mininet1>
</COMPONENT>
</TOPOLOGY>
This TOPOLOGY level parameters can be accessed as follows: main.topology['localhost']
There are three ways to specify the log directory path
1 . Default path will be the /logs/test_name_time/
2 . Providing the command line option --logdir "/path/to/logdirectory"
3 . Parameterise in the test_name.params file as 'logdir' = '/path/to/logdirectory'
After execution of the test, there will be three types of logs :
test_name_time.log – Detailed, verbose log of everything that the script does.
test_name_time.rpt – Summary report of testcase results.
component_name.SESSION – Log of all commands/APIs run on this component with response.
Component Drivers – Connects and provides interfaces to various components in the OpenFlow/SDN topology.
The three main methods of a component driver are connect, disconnect and execute. Usually, while writing a custom driver, the user might entirely skip writing these methods and use them from the parent component class or call the equivalent super component method, followed by any logic that is specific to this component.
As a reference to write a custom driver, please refer the link for Mininet driver.
In this example, the Mininet driver inherits from the abstract Emulator driver which in turn inherits from the CLI driver. The Mininet driver reuses the execute and disconnect API from the CLI driver. The connect API is the only API that is redefined.
class Mininet(Emulator):
def __init__(self):
super(Emulator, self).__init__()
self.handle = self
def connect(self,user_name, ip_address, pwd,options):
self.handle = super(Mininet, self).connect(user_name, ip_address, pwd)
Here the connect will call the super (clidriver) connect.
Driver specific methods/functions can be specified using the simple execute command of (clidriver).
def pingall(self):
'''
Verifies the reachability of the hosts using pingall command.
'''
if self.handle :
main.log.info("Checking reachabilty to the hosts using pingall")
response = self.execute(cmd="pingall",prompt="mininet>",timeout=120)
pattern = 'Results\:\s0\%\sdropped\s\(0\/\d+\slost\)\s*$'
if utilities.assert_matches(expect=pattern,actual=response,
onpass="All hosts are reaching",
onfail="Unable to reach all the hosts"):
return main.TRUE
else:
return main.FALSE
else :
main.log.error("Connection failed to the host")
-
Create a driver_name.py file under "/drivers/common/cli/.."
Note: In this example, the driver is placed under cli->emulator (folder path) hierarchy. If the user wishes to create a driver that is integrated with an API library, then the same can be created under api-emulator(folder path)
-
Create class name as driver_name.
Note : Naming convention for the module name is lower case letters. Naming convention for the Class name "StudlyCaps". And test's Topology file , component 'type'= 'StudlyCaps'.
-
Create function in driver_name class named as connect with suitable return type. It will facilitate the connection for component or remote host used for driver.
-
Create more functions /api in driver_name class with suitable defined parameters. It will facilitate the connection for component or remote host used for driver.
More documentation for writing drivers will be added in the future.