Merge branch 'devl/cleanup'
diff --git a/TestON/drivers/common/api/controllerdriver.py b/TestON/drivers/common/api/controllerdriver.py
index f6b941f..5ac112f 100644
--- a/TestON/drivers/common/api/controllerdriver.py
+++ b/TestON/drivers/common/api/controllerdriver.py
@@ -1,14 +1,14 @@
#!/usr/bin/env python
-'''
-Created on 29-Nov-2012
+"""
+Created on 29-Nov-2012
-@author: Anil Kumar (anilkumar.s@paxterrasolutions.com)
+author:: Anil Kumar ( anilkumar.s@paxterrasolutions.com )
TestON is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
+ ( at your option ) any later version.
TestON is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -16,15 +16,17 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with TestON. If not, see <http://www.gnu.org/licenses/>.
+ along with TestON. If not, see <http://www.gnu.org/licenses/>.
-'''
+"""
import sys
-sys.path.append("../")
+sys.path.append( "../" )
from drivers.common.apidriver import API
-class Controller(API):
+
+class Controller( API ):
# The common functions for emulator included in emulatordriver
- def __init__(self):
- super(API, self).__init__()
-
+
+ def __init__( self ):
+ super( API, self ).__init__()
+
diff --git a/TestON/drivers/common/api/fvtapidriver.py b/TestON/drivers/common/api/fvtapidriver.py
index 620b3e9..8203166 100644
--- a/TestON/drivers/common/api/fvtapidriver.py
+++ b/TestON/drivers/common/api/fvtapidriver.py
@@ -1,14 +1,14 @@
#!/usr/bin/env python
-'''
+"""
Created on 26-Oct-2012
-@author: Anil Kumar (anilkumar.s@paxterrasolutions.com)
+author:: Anil Kumar ( anilkumar.s@paxterrasolutions.com )
TestON is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
+ ( at your option ) any later version.
TestON is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -16,18 +16,18 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with TestON. If not, see <http://www.gnu.org/licenses/>.
+ along with TestON. If not, see <http://www.gnu.org/licenses/>.
fvtapidriver is the basic driver which will handle the fvtapidriver functions
-'''
-'''
+"""
+"""
There are two changes required in flowvisor-test framework :
1. In ~/flowvisortests/tests/templatetest.py line : 15 comment 'basic_logger = None'
2. In ~/flowvisortests/tests/testutils.py line : 50 specify config file path CONFIG_FILE = "~/flowvisor-test/tests/tests-base.json"
-'''
+"""
import pexpect
import struct
import fcntl
@@ -35,12 +35,12 @@
import signal
import re
import sys
-sys.path.append("../")
+sys.path.append( "../" )
from common.apidriver import API
import logging
-sys.path.append(path+"/lib/flowvisor-test/tests")
-sys.path.append(path+"/lib/flowvisor-test/src/python/")
+sys.path.append( path + "/lib/flowvisor-test/tests" )
+sys.path.append( path + "/lib/flowvisor-test/src/python/" )
import templatetest
import testutils
@@ -53,29 +53,30 @@
import __builtin__
config_default = {
- "param" : None,
- "fv_cmd" : "/home/openflow/flowvisor/scripts/flowvisor.sh",
- "platform" : "local",
- "controller_host" : "127.0.0.1",
- "controller_port" : 6633,
- "timeout" : 3,
- "port_count" : 4,
- "base_of_port" : 1,
- "base_if_index" : 1,
- "test_spec" : "all",
- "test_dir" : ".",
- "log_file" : "/home/openflow/fvt.log",
- "list" : False,
- "debug" : "debug",
- "dbg_level" : logging.DEBUG,
- "port_map" : {},
- "test_params" : "None"
+ "param": None,
+ "fv_cmd": "/home/openflow/flowvisor/scripts/flowvisor.sh",
+ "platform": "local",
+ "controller_host": "127.0.0.1",
+ "controller_port": 6633,
+ "timeout": 3,
+ "port_count": 4,
+ "base_of_port": 1,
+ "base_if_index": 1,
+ "test_spec": "all",
+ "test_dir": ".",
+ "log_file": "/home/openflow/fvt.log",
+ "list": False,
+ "debug": "debug",
+ "dbg_level": logging.DEBUG,
+ "port_map": {},
+ "test_params": "None"
}
-def test_set_init(config):
+
+def test_set_init( config ):
"""
Set up function for basic test classes
- @param config The configuration dictionary; see fvt
+ config: The configuration dictionary; see fvt
"""
global basic_port_map
global basic_fv_cmd
@@ -84,88 +85,89 @@
global basic_config
global baisc_logger
- basic_fv_cmd = config["fv_cmd"]
- basic_timeout = config["timeout"]
- basic_port_map = config["port_map"]
+ basic_fv_cmd = config[ "fv_cmd" ]
+ basic_timeout = config[ "timeout" ]
+ basic_port_map = config[ "port_map" ]
basic_config = config
-class FvtApiDriver(API,templatetest.TemplateTest):
- def __init__(self):
- super(API, self).__init__()
+class FvtApiDriver( API, templatetest.TemplateTest ):
+
+ def __init__( self ):
+ super( API, self ).__init__()
print 'init'
-
- def connect(self,**connectargs):
+ def connect( self, **connectargs ):
for key in connectargs:
- vars(self)[key] = connectargs[key]
-
- self.name = self.options['name']
- connect_result = super(API,self).connect()
- self.logFileName = main.logdir+"/"+self.name+".session"
- config_default["log_file"] = self.logFileName
- test_set_init(config_default)
- __builtin__.basic_logger = vars(main)[self.name+'log']
- __builtin__.basic_logger.info("Calling my test setup")
- self.setUp(basic_logger)
+ vars( self )[ key ] = connectargs[ key ]
- (self.fv, self.sv, sv_ret, ctl_ret, sw_ret) = testutils.setUpTestEnv(self, fv_cmd=basic_fv_cmd)
-
- self.chkSetUpCondition(self.fv, sv_ret, ctl_ret, sw_ret)
+ self.name = self.options[ 'name' ]
+ connect_result = super( API, self ).connect()
+ self.logFileName = main.logdir + "/" + self.name + ".session"
+ config_default[ "log_file" ] = self.logFileName
+ test_set_init( config_default )
+ __builtin__.basic_logger = vars( main )[ self.name + 'log' ]
+ __builtin__.basic_logger.info( "Calling my test setup" )
+ self.setUp( basic_logger )
+
+ ( self.fv, self.sv, sv_ret, ctl_ret, sw_ret ) = testutils.setUpTestEnv(
+ self, fv_cmd=basic_fv_cmd )
+
+ self.chkSetUpCondition( self.fv, sv_ret, ctl_ret, sw_ret )
return main.TRUE
- def simplePacket(self,dl_src):
- dl_src = vars(testutils)[dl_src]
- return testutils.simplePacket(dl_src = dl_src)
-
- def genPacketIn(self, in_port, pkt):
- return testutils.genPacketIn(in_port=in_port, pkt=pkt)
-
- def ofmsgSndCmp(self, snd_list, exp_list, xid_ignore=True, hdr_only=True):
- return testutils.ofmsgSndCmp(self, snd_list, exp_list, xid_ignore, hdr_only)
-
- def setRule(self,sv,rule,num_try) :
- return testutils.setRule(self,sv,rule,num_try)
-
- def chkFlowdb(self,controller_number,switch_number,exp_count,exp_rewrites) :
- return testutils.chkFlowdb(self,controller_number,switch_number,exp_count,exp_rewrites)
-
- def chkSwitchStats(self, switch_number, ofproto, exp_snd_count, exp_rcv_count):
- return testutils.chkSwitchStats(self, switch_number, ofproto, exp_snd_count, exp_rcv_count)
-
- def chkSliceStats(self,controller_number,ofproto,exp_snd_count,exp_rcv_count) :
- return testutils.chkSliceStats(self,controller_number,ofproto,exp_snd_count,exp_rcv_count)
-
- def recvStats(self,swId,typ) :
- return testutils.recvStats(self,swId,typ)
-
- def ofmsgSndCmpWithXid(self,snd_list,exp_list,xid_ignore,hdr_only) :
- return testutils.ofmsgSndCmpWithXid(self,snd_list,exp_list,xid_ignore,hdr_only)
-
- def genPacketOut(self,xid,buffer_id,in_port,action_ports,pkt) :
- return testutils.genPacketOut(self,xid,buffer_id,in_port,action_ports,pkt)
-
- def genFlowModFlush(self) :
+ def simplePacket( self, dl_src ):
+ dl_src = vars( testutils )[ dl_src ]
+ return testutils.simplePacket( dl_src=dl_src )
+
+ def genPacketIn( self, in_port, pkt ):
+ return testutils.genPacketIn( in_port=in_port, pkt=pkt )
+
+ def ofmsgSndCmp( self, snd_list, exp_list, xid_ignore=True, hdr_only=True ):
+ return testutils.ofmsgSndCmp( self, snd_list, exp_list, xid_ignore, hdr_only )
+
+ def setRule( self, sv, rule, num_try ):
+ return testutils.setRule( self, sv, rule, num_try )
+
+ def chkFlowdb( self, controller_number, switch_number, exp_count, exp_rewrites ):
+ return testutils.chkFlowdb( self, controller_number, switch_number, exp_count, exp_rewrites )
+
+ def chkSwitchStats( self, switch_number, ofproto, exp_snd_count, exp_rcv_count ):
+ return testutils.chkSwitchStats( self, switch_number, ofproto, exp_snd_count, exp_rcv_count )
+
+ def chkSliceStats( self, controller_number, ofproto, exp_snd_count, exp_rcv_count ):
+ return testutils.chkSliceStats( self, controller_number, ofproto, exp_snd_count, exp_rcv_count )
+
+ def recvStats( self, swId, typ ):
+ return testutils.recvStats( self, swId, typ )
+
+ def ofmsgSndCmpWithXid( self, snd_list, exp_list, xid_ignore, hdr_only ):
+ return testutils.ofmsgSndCmpWithXid( self, snd_list, exp_list, xid_ignore, hdr_only )
+
+ def genPacketOut( self, xid, buffer_id, in_port, action_ports, pkt ):
+ return testutils.genPacketOut( self, xid, buffer_id, in_port, action_ports, pkt )
+
+ def genFlowModFlush( self ):
return testutils.genFlowModFlush()
-
- def genPhyPort(self,name,addr,port_no) :
- return testutils.genPhyPort(name,addr,port_no)
-
- def disconnect(self,handle):
+
+ def genPhyPort( self, name, addr, port_no ):
+ return testutils.genPhyPort( name, addr, port_no )
+
+ def disconnect( self, handle ):
response = ''
- '''
+ """
if self.handle:
self.handle = handle
- response = self.execute(cmd="exit",prompt="(.*)",timeout=120)
+ response = self.execute( cmd="exit",prompt="(.*)",timeout=120 )
else :
- main.log.error("Connection failed to the host")
+ main.log.error( "Connection failed to the host" )
response = main.FALSE
- '''
- return response
-
- def setUp(self,basic_logger):
+ """
+ return response
+
+ def setUp( self, basic_logger ):
self.logger = basic_logger
- #basic_logger.info("** START TEST CASE " + str(self))
+ # basic_logger.info( "** START TEST CASE " + str( self ) )
if basic_timeout == 0:
self.timeout = None
else:
@@ -174,13 +176,12 @@
self.sv = None
self.controllers = []
self.switches = []
-
- def close_log_handles(self) :
- self.tearDown()
- vars(main)[self.name+'log'].removeHandler(self.log_handler)
- #if self.logfile_handler:
+
+ def close_log_handles( self ):
+ self.tearDown()
+ vars( main )[ self.name + 'log' ].removeHandler( self.log_handler )
+ # if self.logfile_handler:
# self.logfile_handler.close()
-
+
return main.TRUE
-
diff --git a/TestON/drivers/common/apidriver.py b/TestON/drivers/common/apidriver.py
index 254ab1b..7de283c 100644
--- a/TestON/drivers/common/apidriver.py
+++ b/TestON/drivers/common/apidriver.py
@@ -1,14 +1,14 @@
#!/usr/bin/env python
-'''
-Created on 22-Nov-2012
+"""
+Created on 22-Nov-2012
-@author: Anil Kumar (anilkumar.s@paxterrasolutions.com)
+author:: Anil Kumar ( anilkumar.s@paxterrasolutions.com )
TestON is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
+ ( at your option ) any later version.
TestON is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -16,29 +16,37 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with TestON. If not, see <http://www.gnu.org/licenses/>.
+ along with TestON. If not, see <http://www.gnu.org/licenses/>.
-'''
-
-import struct, fcntl, os, sys, signal
-import sys, re
-sys.path.append("../")
+"""
+import struct
+import fcntl
+import os
+import sys
+import signal
+import sys
+import re
+sys.path.append( "../" )
from drivers.component import Component
-class API(Component):
- '''
+
+
+class API( Component ):
+
+ """
This will define common functions for CLI included.
- '''
- def __init__(self):
- super(Component, self).__init__()
-
- def connect(self):
- '''
+ """
+ def __init__( self ):
+ super( Component, self ).__init__()
+
+ def connect( self ):
+ """
Connection will establish to the remote host using ssh.
It will take user_name ,ip_address and password as arguments<br>
- and will return the handle.
- '''
- super(API, self).connect()
-
- return main.TRUE
+ and will return the handle.
+ """
+ super( API, self ).connect()
+
+ return main.TRUE
+
diff --git a/TestON/drivers/common/cli/dpclidriver.py b/TestON/drivers/common/cli/dpclidriver.py
index 1e7015c..057a3f1 100644
--- a/TestON/drivers/common/cli/dpclidriver.py
+++ b/TestON/drivers/common/cli/dpclidriver.py
@@ -1,147 +1,190 @@
-'''
-Driver for blank dataplane VMs. Created for SDNIP test.
-'''
-
+"""
+Driver for blank dataplane VMs. Created for SDNIP test.
+"""
import time
import pexpect
-import struct, fcntl, os, sys, signal
+import struct
+import fcntl
+import os
+import sys
+import signal
import sys
import re
import json
-sys.path.append("../")
+sys.path.append( "../" )
from drivers.common.clidriver import CLI
-class DPCliDriver(CLI):
- def __init__(self):
- super(CLI, self).__init__()
+class DPCliDriver( CLI ):
- def connect(self,**connectargs):
+ def __init__( self ):
+ super( CLI, self ).__init__()
+
+ def connect( self, **connectargs ):
for key in connectargs:
- vars(self)[key] = connectargs[key]
+ vars( self )[ key ] = connectargs[ key ]
-
- self.name = self.options['name']
- self.handle = super(DPCliDriver,self).connect(user_name = self.user_name, ip_address = self.ip_address,port = self.port, pwd = self.pwd)
+ self.name = self.options[ 'name' ]
+ self.handle = super( DPCliDriver, self ).connect( user_name=self.user_name,
+ ip_address=self.ip_address,
+ port=self.port,
+ pwd=self.pwd )
if self.handle:
return self.handle
- else :
- main.log.info("NO HANDLE")
+ else:
+ main.log.info( "NO HANDLE" )
return main.FALSE
- def create_interfaces(self, net, number, start):
- '''
+ def create_interfaces( self, net, number, start ):
+ """
Creates a number,specified by 'number,' of subinterfaces on eth0. Ip addresses start at 'net'.'start'.1.1 with a 24 bit netmask. Addresses increment sequentially in the third quad,
therefore all interfaces are in different subnets on the same machine. When the third quad reaches 255, it is reset to 1 and the second quad is incremented.
Every single ip address is placed in a file in /tmp titled 'ip_table{net}.txt'
The file is used by 'pingall_interfaces()' as a fping argument
This method returns true if all interfaces are created without a hitch, and false if a single interface has issues
- '''
+ """
+ self.handle.sendline( "" )
+ self.handle.expect( "\$" )
- self.handle.sendline("")
- self.handle.expect("\$")
+ self.handle.sendline( "rm /tmp/local_ip.txt" )
+ self.handle.expect( "\$" )
+ self.handle.sendline( "touch /tmp/local_ip.txt" )
+ self.handle.expect( "\$" )
- self.handle.sendline("rm /tmp/local_ip.txt")
- self.handle.expect("\$")
- self.handle.sendline("touch /tmp/local_ip.txt")
- self.handle.expect("\$")
-
- main.log.info("Creating interfaces")
+ main.log.info( "Creating interfaces" )
k = 0
intf = 0
while number != 0:
- k= k + 1
+ k = k + 1
if k == 256:
k = 1
start = start + 1
number = number - 1
intf = intf + 1
- ip = net+"."+str(start)+"."+str(k)+".1"
- self.handle.sendline("sudo ifconfig eth0:"+str(intf)+" "+ip+" netmask 255.255.255.0")
+ ip = net + "." + str( start ) + "." + str( k ) + ".1"
+ self.handle.sendline(
+ "sudo ifconfig eth0:" + str(
+ intf ) + " " + ip + " netmask 255.255.255.0" )
- i = self.handle.expect(["\$","password",pexpect.TIMEOUT,pexpect.EOF], timeout = 120)
- if i == 0:
- self.handle.sendline("echo "+str(ip)+" >> /tmp/local_ip.txt")
- self.handle.expect("\$")
- elif i == 1:
- main.log.info("Sending sudo password")
- self.handle.sendline(self.pwd)
- self.handle.expect("\$")
- else:
- main.log.error("INTERFACES NOT CREATED")
- return main.FALSE
+ i = self.handle.expect( [
+ "\$",
+ "password",
+ pexpect.TIMEOUT,
+ pexpect.EOF ],
+ timeout=120 )
+ if i == 0:
+ self.handle.sendline(
+ "echo " + str( ip ) + " >> /tmp/local_ip.txt" )
+ self.handle.expect( "\$" )
+ elif i == 1:
+ main.log.info( "Sending sudo password" )
+ self.handle.sendline( self.pwd )
+ self.handle.expect( "\$" )
+ else:
+ main.log.error( "INTERFACES NOT CREATED" )
+ return main.FALSE
- def pingall_interfaces(self, netsrc, netstrt, netdst, destlogin, destip):
- '''
- Copies the /tmp/ip_table{net}.txt file from the machine you wish to ping, then runs fping with a source address of {netsrc}.{netstrt}.1.1 on the copied file.
+ def pingall_interfaces( self, netsrc, netstrt, netdst, destlogin, destip ):
+ """
+ Copies the /tmp/ip_table{ net }.txt file from the machine you wish to ping, then runs fping with a source address of { netsrc }.{ netstrt }.1.1 on the copied file.
Check every single response for reachable or unreachable. If all are reachable, function returns true. If a SINGLE host is unreachable, then the function stops and returns false
If fping is not installed, this function will install fping then run the same command
- '''
+ """
+ self.handle.sendline( "" )
+ self.handle.expect( "\$" )
- self.handle.sendline("")
- self.handle.expect("\$")
-
- self.handle.sendline("scp "+str(destlogin)+"@"+str(destip)+":/tmp/local_ip.txt /tmp/ip_table"+str(net)+".txt")
- i = self.handle.expect(["100%","password",pexpect.TIMEOUT], timeout = 30)
+ self.handle.sendline( "scp " + str( destlogin ) + "@" +
+ str( destip ) + ":/tmp/local_ip.txt /tmp/ip_table" +
+ str( net ) + ".txt" )
+
+ i = self.handle.expect( [
+ "100%",
+ "password",
+ pexpect.TIMEOUT ],
+ timeout=30 )
+
if i == 0:
- main.log.info("Copied ping file successfully")
+ main.log.info( "Copied ping file successfully" )
elif i == 1:
- self.handle.sendline(self.pwd)
- self.handle.expect("100%")
- main.log.info("Copied ping file successfully")
+ self.handle.sendline( self.pwd )
+ self.handle.expect( "100%" )
+ main.log.info( "Copied ping file successfully" )
elif i == 2:
- main.log.error("COULD NOT COPY PING FILE FROM "+str(destip))
+ main.log.error( "COULD NOT COPY PING FILE FROM " + str( destip ) )
result = main.FALSE
return result
-
- self.handle.sendline("")
- self.handle.expect("\$")
- main.log.info("Pinging interfaces on the "+str(netdst)+" network from "+str(netsrc)+"."+str(netstrt)+".1.1")
- self.handle.sendline("sudo fping -S "+str(netsrc)+"."+str(netstrt)+".1.1 -f /tmp/ip_table"+str(netdst)+".txt")
+ self.handle.sendline( "" )
+ self.handle.expect( "\$" )
+
+ main.log.info( "Pinging interfaces on the " + str( netdst ) +
+ " network from " + str( netsrc ) + "." +
+ str( netstrt ) + ".1.1" )
+ self.handle.sendline( "sudo fping -S " + str( netsrc ) + "." +
+ str( netstrt ) + ".1.1 -f /tmp/ip_table" +
+ str( netdst ) + ".txt" )
while 1:
- i = self.handle.expect(["reachable","unreachable","\$","password",pexpect.TIMEOUT,"not installed"], timeout=45)
+ i = self.handle.expect( [
+ "reachable",
+ "unreachable",
+ "\$",
+ "password",
+ pexpect.TIMEOUT,
+ "not installed" ],
+ timeout=45 )
if i == 0:
result = main.TRUE
elif i == 1:
- main.log.error("An interface was unreachable")
+ main.log.error( "An interface was unreachable" )
result = main.FALSE
return result
elif i == 2:
- main.log.info("All interfaces reachable")
+ main.log.info( "All interfaces reachable" )
return result
elif i == 3:
- self.handle.sendline(self.pwd)
+ self.handle.sendline( self.pwd )
elif i == 4:
- main.log.error("Unable to fping")
+ main.log.error( "Unable to fping" )
result = main.FALSE
return result
elif i == 5:
- main.log.info("fping not installed, installing fping")
- self.handle.sendline("sudo apt-get install fping")
- i = self.handle.expect(["password","\$",pexpect.TIMEOUT], timeout = 60)
+ main.log.info( "fping not installed, installing fping" )
+ self.handle.sendline( "sudo apt-get install fping" )
+ i = self.handle.expect(
+ [ "password",
+ "\$",
+ pexpect.TIMEOUT ],
+ timeout=60 )
if i == 0:
- self.handle.sendline(self.pwd)
- self.handle.expect("\$", timeout = 30)
- main.log.info("fping installed, now pinging interfaces")
- self.handle.sendline("sudo fping -S "+str(netsrc)+"."+str(netstrt)+".1.1 -f /tmp/ip_table"+str(netdst)+".txt")
+ self.handle.sendline( self.pwd )
+ self.handle.expect( "\$", timeout=30 )
+ main.log.info( "fping installed, now pinging interfaces" )
+ self.handle.sendline(
+ "sudo fping -S " + str(
+ netsrc ) + "." + str(
+ netstrt ) + ".1.1 -f /tmp/ip_table" + str(
+ netdst ) + ".txt" )
elif i == 1:
- main.log.info("fping installed, now pinging interfaces")
- self.handle.sendline("sudo fping -S "+str(netsrc)+"."+str(netstrt)+".1.1 -f /tmp/ip_table"+str(netdst)+".txt")
+ main.log.info( "fping installed, now pinging interfaces" )
+ self.handle.sendline(
+ "sudo fping -S " + str(
+ netsrc ) + "." + str(
+ netstrt ) + ".1.1 -f /tmp/ip_table" + str(
+ netdst ) + ".txt" )
elif i == 2:
- main.log.error("Could not install fping")
+ main.log.error( "Could not install fping" )
result = main.FALSE
return result
- def disconnect(self):
+ def disconnect( self ):
response = ''
try:
- self.handle.sendline("exit")
- self.handle.expect("closed")
+ self.handle.sendline( "exit" )
+ self.handle.expect( "closed" )
except:
- main.log.error("Connection failed to the host")
+ main.log.error( "Connection failed to the host" )
response = main.FALSE
return response
diff --git a/TestON/drivers/common/cli/emulator/flowvisordriver.py b/TestON/drivers/common/cli/emulator/flowvisordriver.py
index 66946bd..d0e6ea5 100644
--- a/TestON/drivers/common/cli/emulator/flowvisordriver.py
+++ b/TestON/drivers/common/cli/emulator/flowvisordriver.py
@@ -1,14 +1,14 @@
#!/usr/bin/env python
-'''
+"""
Created on 26-Mar-2013
-@author: Anil Kumar (anilkumar.s@paxterrasolutions.com)
+author:: Anil Kumar ( anilkumar.s@paxterrasolutions.com )
TestON is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
+ ( at your option ) any later version.
TestON is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -16,12 +16,11 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with TestON. If not, see <http://www.gnu.org/licenses/>.
+ along with TestON. If not, see <http://www.gnu.org/licenses/>.
FlowVisorDriver is the basic driver which will handle the Mininet functions
-'''
-
+"""
import pexpect
import struct
import fcntl
@@ -30,150 +29,197 @@
import re
import sys
import core.teston
-sys.path.append("../")
+sys.path.append( "../" )
from drivers.common.cli.emulatordriver import Emulator
from drivers.common.clidriver import CLI
-class FlowVisorDriver(Emulator):
- '''
- FlowVisorDriver is the basic driver which will handle the Mininet functions
- '''
- def __init__(self):
- super(Emulator, self).__init__()
- self.handle = self
- self.wrapped = sys.modules[__name__]
- def connect(self, **connectargs):
- #,user_name, ip_address, pwd,options):
- # Here the main is the TestON instance after creating all the log handles.
+class FlowVisorDriver( Emulator ):
+
+ """
+ FlowVisorDriver is the basic driver which will handle the Mininet functions
+ """
+ def __init__( self ):
+ super( Emulator, self ).__init__()
+ self.handle = self
+ self.wrapped = sys.modules[ __name__ ]
+
+ def connect( self, **connectargs ):
+ #,user_name, ip_address, pwd,options ):
+ # Here the main is the TestON instance after creating all the log
+ # handles.
for key in connectargs:
- vars(self)[key] = connectargs[key]
-
- self.name = self.options['name']
- self.handle = super(FlowVisorDriver, self).connect(user_name = self.user_name, ip_address = self.ip_address,port = None, pwd = self.pwd)
-
+ vars( self )[ key ] = connectargs[ key ]
+
+ self.name = self.options[ 'name' ]
+ self.handle = super(
+ FlowVisorDriver,
+ self ).connect(
+ user_name=self.user_name,
+ ip_address=self.ip_address,
+ port=None,
+ pwd=self.pwd )
+
self.ssh_handle = self.handle
-
- # Copying the readme file to process the
- if self.handle :
- self.execute(cmd='\r',prompt='\$',timeout=10)
- self.options['path'] = '/home/openflow/flowvisor/scripts/'
+
+ # Copying the readme file to process the
+ if self.handle:
+ self.execute( cmd='\r', prompt='\$', timeout=10 )
+ self.options[ 'path' ] = '/home/openflow/flowvisor/scripts/'
#self.handle.logfile = sys.stdout
- self.execute(cmd='cd '+self.options['path'],prompt='\$',timeout=10)
- main.log.info("Starting FlowVisor ")
-
- response = self.execute(cmd='./flowvisor.sh &',prompt='---\sSetting\slogging\slevel\sto\sNOTE',timeout=10)
-
+ self.execute(
+ cmd='cd ' +
+ self.options[ 'path' ],
+ prompt='\$',
+ timeout=10 )
+ main.log.info( "Starting FlowVisor " )
+
+ response = self.execute(
+ cmd='./flowvisor.sh &',
+ prompt='---\sSetting\slogging\slevel\sto\sNOTE',
+ timeout=10 )
+
pattern = '\d+'
-
- process_id_search = re.search("\[\d+\]\s+(\d+)", str(response))
+
+ process_id_search = re.search( "\[\d+\]\s+(\d+)", str( response ) )
self.fvprocess_id = "None"
if process_id_search:
- self.fvprocess_id = process_id_search.group(1)
-
- utilities.assert_matches(expect=pattern,actual=response,onpass="FlowVisor Started Successfully : Proceess Id :"+self.fvprocess_id,onfail="Failed to start FlowVisor")
- main.log.info(response)
+ self.fvprocess_id = process_id_search.group( 1 )
+
+ utilities.assert_matches(
+ expect=pattern,
+ actual=response,
+ onpass="FlowVisor Started Successfully : Proceess Id :" +
+ self.fvprocess_id,
+ onfail="Failed to start FlowVisor" )
+ main.log.info( response )
#import time
- #time.sleep(10)
- #response = self.execute(cmd='./start_visualizer.sh & \r',prompt='\$',timeout=10)
-
+ # time.sleep( 10 )
+ #response = self.execute( cmd='./start_visualizer.sh & \r',prompt='\$',timeout=10 )
+
return main.TRUE
- else :
- main.log.error("Connection failed to the host "+self.user_name+"@"+self.ip_address)
- main.log.error("Failed to connect to the FlowVisor")
+ else:
+ main.log.error(
+ "Connection failed to the host " +
+ self.user_name +
+ "@" +
+ self.ip_address )
+ main.log.error( "Failed to connect to the FlowVisor" )
return main.FALSE
- def removeFlowSpace(self,id):
+
+ def removeFlowSpace( self, id ):
if id == "all":
flow_space = self.listFlowSpace()
- flow_ids = re.findall("\,id=\[(\d+)\]", flow_space)
- for id in flow_ids :
- self.removeFlowSpace(id)
- else :
- self.execute(cmd="clear",prompt="\$",timeout=10)
- self.execute(cmd="./fvctl.sh removeFlowSpace "+id,prompt="passwd:",timeout=10)
- self.execute(cmd="\n",prompt="\$",timeout=10)
- main.log.info("Removed flowSpace which is having id :"+id)
-
+ flow_ids = re.findall( "\,id=\[(\d+)\]", flow_space )
+ for id in flow_ids:
+ self.removeFlowSpace( id )
+ else:
+ self.execute( cmd="clear", prompt="\$", timeout=10 )
+ self.execute(
+ cmd="./fvctl.sh removeFlowSpace " +
+ id,
+ prompt="passwd:",
+ timeout=10 )
+ self.execute( cmd="\n", prompt="\$", timeout=10 )
+ main.log.info( "Removed flowSpace which is having id :" + id )
+
return main.TRUE
-
- def addFlowSpace(self,**flowspace_args):
+
+ def addFlowSpace( self, **flowspace_args ):
temp_string = None
for key in flowspace_args:
- if temp_string :
- temp_string = temp_string +','+ key+'='+flowspace_args[key]
- else :
+ if temp_string:
+ temp_string = temp_string + ',' + \
+ key + '=' + flowspace_args[ key ]
+ else:
temp_string = ''
- temp_string = temp_string + key+'='+flowspace_args[key]
-
- src_search = re.search('dl_src', temp_string)
- if src_search :
- flowspace = "any 100 dl_type=0x806,nw_proto=6,"+temp_string +" Slice:SSH=4"
- else :
- flowspace = "any 100 dl_type=0x800,nw_proto=6,"+temp_string +" Slice:SSH=4"
-
- '''
+ temp_string = temp_string + key + '=' + flowspace_args[ key ]
+
+ src_search = re.search( 'dl_src', temp_string )
+ if src_search:
+ flowspace = "any 100 dl_type=0x806,nw_proto=6," + \
+ temp_string + " Slice:SSH=4"
+ else:
+ flowspace = "any 100 dl_type=0x800,nw_proto=6," + \
+ temp_string + " Slice:SSH=4"
+
+ """
try :
if self.dl_src and self.nw_dst:
flowspace = "any 100 dl_type=0x806,dl_src="+self.dl_src+",nw_dst="+self.nw_dst+" Slice:"+self.Slice+"=4"
except :
try :
if self.nw_src and self.tp_dst:
- flowspace = "any 100 dl_type=0x800,nw_proto=6,nw_src="+self.nw_src+",tp_dst="+self.tp_dst+" Slice:"+self.Slice+"=4"
+ flowspace = "any 100 dl_type=0x800,nw_proto=6,nw_src="+self.nw_src+",tp_dst="+self.tp_dst+" Slice:"+self.Slice+"=4"
except :
try :
if self.nw_src and self.tp_src:
flowspace = "any 100 dl_type=0x800,nw_proto=6,nw_src="+self.nw_src+",tp_src="+self.tp_dst+" Slice:"+self.Slice+"=4"
except :
- main.log.error("Please specify flowspace properly")
- '''
-
- #self.execute(cmd="clear",prompt="\$",timeout=10)
- self.execute(cmd="./fvctl.sh addFlowSpace "+flowspace,prompt="passwd:",timeout=10)
- self.execute(cmd="\n",prompt="\$",timeout=10)
- sucess_match = re.search("success\:\s+(\d+)", main.last_response)
- if sucess_match :
- main.log.info("Added flow Space and id is "+sucess_match.group(1))
+ main.log.error( "Please specify flowspace properly" )
+ """
+ # self.execute( cmd="clear",prompt="\$",timeout=10 )
+ self.execute(
+ cmd="./fvctl.sh addFlowSpace " +
+ flowspace,
+ prompt="passwd:",
+ timeout=10 )
+ self.execute( cmd="\n", prompt="\$", timeout=10 )
+ sucess_match = re.search( "success\:\s+(\d+)", main.last_response )
+ if sucess_match:
+ main.log.info(
+ "Added flow Space and id is " +
+ sucess_match.group( 1 ) )
return main.TRUE
- else :
+ else:
return main.FALSE
-
-
-
- def listFlowSpace(self):
- self.execute(cmd="clear",prompt="\$",timeout=10)
- self.execute(cmd="./fvctl.sh listFlowSpace ",prompt="passwd:",timeout=10)
- self.execute(cmd="\n",prompt="\$",timeout=10)
+
+ def listFlowSpace( self ):
+ self.execute( cmd="clear", prompt="\$", timeout=10 )
+ self.execute(
+ cmd="./fvctl.sh listFlowSpace ",
+ prompt="passwd:",
+ timeout=10 )
+ self.execute( cmd="\n", prompt="\$", timeout=10 )
flow_space = main.last_response
- flow_space = self.remove_contol_chars( flow_space)
- flow_space = re.sub("rule\s(\d+)\:", "\nrule "+r'\1'+":",flow_space)
- main.log.info(flow_space)
-
+ flow_space = self.remove_contol_chars( flow_space )
+ flow_space = re.sub(
+ "rule\s(\d+)\:",
+ "\nrule " +
+ r'\1' +
+ ":",
+ flow_space )
+ main.log.info( flow_space )
+
return flow_space
-
- def listDevices(self):
- #self.execute(cmd="clear",prompt="\$",timeout=10)
- #self.execute(cmd="./fvctl.sh listDevices ",prompt="passwd:",timeout=10)
- #self.execute(cmd="\n",prompt="\$",timeout=10)
+
+ def listDevices( self ):
+ # self.execute( cmd="clear",prompt="\$",timeout=10 )
+ #self.execute( cmd="./fvctl.sh listDevices ",prompt="passwd:",timeout=10 )
+ # self.execute( cmd="\n",prompt="\$",timeout=10 )
devices_list = ''
- last_response = re.findall("(Device\s\d+\:\s((\d|[a-z])(\d|[a-z])\:)+(\d|[a-z])(\d|[a-z]))", main.last_response)
-
- for resp in last_response :
- devices_match = re.search("(Device\s\d+\:\s((\d|[a-z])(\d|[a-z])\:)+(\d|[a-z])(\d|[a-z]))", str(resp))
+ last_response = re.findall(
+ "(Device\s\d+\:\s((\d|[a-z])(\d|[a-z])\:)+(\d|[a-z])(\d|[a-z]))",
+ main.last_response )
+
+ for resp in last_response:
+ devices_match = re.search(
+ "(Device\s\d+\:\s((\d|[a-z])(\d|[a-z])\:)+(\d|[a-z])(\d|[a-z]))",
+ str( resp ) )
if devices_match:
- devices_list = devices_list+devices_match.group(0)+"\n"
+ devices_list = devices_list + devices_match.group( 0 ) + "\n"
devices_list = "Device 0: 00:00:00:00:00:00:00:02 \n Device 1: 00:00:00:00:00:00:00:03"
- main.log.info("List of Devices \n"+devices_list)
-
+ main.log.info( "List of Devices \n" + devices_list )
+
return main.TRUE
-
-
- def disconnect(self):
-
+
+ def disconnect( self ):
+
response = ''
- main.log.info("Stopping the FlowVisor")
+ main.log.info( "Stopping the FlowVisor" )
if self.handle:
- self.handle.sendline("kill -9 "+str(self.fvprocess_id))
- else :
- main.log.error("Connection failed to the host")
+ self.handle.sendline( "kill -9 " + str( self.fvprocess_id ) )
+ else:
+ main.log.error( "Connection failed to the host" )
response = main.FALSE
- return response
+ return response
diff --git a/TestON/drivers/common/cli/emulator/lincoedriver.py b/TestON/drivers/common/cli/emulator/lincoedriver.py
index 2cb7c98..944eded 100644
--- a/TestON/drivers/common/cli/emulator/lincoedriver.py
+++ b/TestON/drivers/common/cli/emulator/lincoedriver.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
-'''
+"""
This driver handles the optical switch emulator linc-oe.
Please follow the coding style demonstrated by existing
@@ -13,8 +13,7 @@
shreya@onlab.us
OCT 20 2014
-'''
-
+"""
import traceback
import pexpect
import struct
@@ -25,117 +24,122 @@
import sys
import core.teston
import time
-sys.path.append("../")
+sys.path.append( "../" )
from math import pow
from drivers.common.cli.emulatordriver import Emulator
from drivers.common.clidriver import CLI
-class LincOEDriver(Emulator):
- '''
- LincOEDriver class will handle all emulator functions
- '''
- def __init__(self):
- super(Emulator, self).__init__()
+
+class LincOEDriver( Emulator ):
+
+ """
+ LincOEDriver class will handle all emulator functions
+ """
+ def __init__( self ):
+ super( Emulator, self ).__init__()
self.handle = self
- self.wrapped = sys.modules[__name__]
+ self.wrapped = sys.modules[ __name__ ]
self.flag = 0
- def connect(self, **connectargs):
- '''
+ def connect( self, **connectargs ):
+ """
Create ssh handle for Linc-OE cli
- '''
+ """
import time
for key in connectargs:
- vars(self)[key] = connectargs[key]
-
- self.name = self.options['name']
+ vars( self )[ key ] = connectargs[ key ]
+
+ self.name = self.options[ 'name' ]
self.handle = \
- super(LincOEDriver, self).connect(\
- user_name = self.user_name,
- ip_address = self.ip_address,
- port = None,
- pwd = self.pwd)
-
+ super( LincOEDriver, self ).connect(
+ user_name=self.user_name,
+ ip_address=self.ip_address,
+ port=None,
+ pwd=self.pwd )
+
self.ssh_handle = self.handle
-
- if self.handle :
- main.log.info("Handle successfully created")
+
+ if self.handle:
+ main.log.info( "Handle successfully created" )
self.home = "~/linc-oe"
-
- self.handle.sendline("cd "+self.home)
- self.handle.expect("oe$")
-
- #self.handle.sendline("pgrep -g linc")
- #self.handle.expect("\$")
- print "handle = ", self.handle.before
-
- return main.TRUE
- '''
- main.log.info("Building Linc-OE")
- self.handle.sendline("make rel")
- i = self.handle.expect(["ERROR","linc-oe\$"],timeout=60)
+
+ self.handle.sendline( "cd " + self.home )
+ self.handle.expect( "oe$" )
+
+ #self.handle.sendline( "pgrep -g linc" )
+ # self.handle.expect( "\$" )
+ print "handle = ", self.handle.before
+
+ return main.TRUE
+ """
+ main.log.info( "Building Linc-OE" )
+ self.handle.sendline( "make rel" )
+ i = self.handle.expect( [ "ERROR","linc-oe\$" ],timeout=60 )
if i == 0:
- self.handle.sendline("sudo pkill -9 epmd")
- self.handle.expect("\$")
- self.handle.sendline("make rel")
- x = self.handle.expect(["\$",pexpect.EOF,pexpect.TIMEOUT])
- main.log.info("make rel returned: "+ str(x))
- else:
-
- main.log.info(self.name+": Starting Linc-OE CLI.. This may take a while")
- time.sleep(30)
- self.handle.sendline("sudo ./rel/linc/bin/linc console")
- j = self.handle.expect(["linc@",pexpect.EOF,pexpect.TIMEOUT])
+ self.handle.sendline( "sudo pkill -9 epmd" )
+ self.handle.expect( "\$" )
+ self.handle.sendline( "make rel" )
+ x = self.handle.expect( [ "\$",pexpect.EOF,pexpect.TIMEOUT ] )
+ main.log.info( "make rel returned: "+ str( x ) )
+ else:
+
+ main.log.info( self.name+": Starting Linc-OE CLI.. This may take a while" )
+ time.sleep( 30 )
+ self.handle.sendline( "sudo ./rel/linc/bin/linc console" )
+ j = self.handle.expect( [ "linc@",pexpect.EOF,pexpect.TIMEOUT ] )
if j == 0:
- main.log.info("Linc-OE CLI started")
+ main.log.info( "Linc-OE CLI started" )
return main.TRUE
- '''
+ """
else:
- main.log.error(self.name+
- ": Connection failed to the host "+
- self.user_name+"@"+self.ip_address)
- main.log.error(self.name+
- ": Failed to connect to Linc-OE")
+ main.log.error( self.name +
+ ": Connection failed to the host " +
+ self.user_name + "@" + self.ip_address )
+ main.log.error( self.name +
+ ": Failed to connect to Linc-OE" )
return main.FALSE
-
- def start_console(self):
+ def start_console( self ):
import time
- main.log.info(self.name+": Starting Linc-OE CLI.. This may take a while")
- time.sleep(30)
- self.handle.sendline("sudo ./rel/linc/bin/linc console")
- j = self.handle.expect(["linc@",pexpect.EOF,pexpect.TIMEOUT])
+ main.log.info(
+ self.name +
+ ": Starting Linc-OE CLI.. This may take a while" )
+ time.sleep( 30 )
+ self.handle.sendline( "sudo ./rel/linc/bin/linc console" )
+ j = self.handle.expect( [ "linc@", pexpect.EOF, pexpect.TIMEOUT ] )
start_result = self.handle.before
if j == 0:
- main.log.info("Linc-OE CLI started")
+ main.log.info( "Linc-OE CLI started" )
return main.TRUE
else:
- main.log.error(self.name+
- ": Connection failed to the host "+self.user_name+"@"+self.ip_address)
- main.log.error(self.name+
- ": Failed to connect to Linc-OE")
+ main.log.error(
+ self.name +
+ ": Connection failed to the host " +
+ self.user_name +
+ "@" +
+ self.ip_address )
+ main.log.error( self.name +
+ ": Failed to connect to Linc-OE" )
return main.FALSE
-
-
- def build(self):
- '''
+ def build( self ):
+ """
Build Linc-OE with the specified settings
- '''
+ """
try:
- self.handle.sendline("make rel")
- i = self.handle.expect([
+ self.handle.sendline( "make rel" )
+ i = self.handle.expect( [
"ERROR",
- "\$"])
+ "\$" ] )
if i == 0:
- #If error, try to resolve the most common error
- #(epmd running and cannot compile)
- self.handle.sendline("sudo pkill -9 epmd")
- self.handle.sendline("make rel")
- self.handle.expect("\$")
-
+ # If error, try to resolve the most common error
+ #( epmd running and cannot compile )
+ self.handle.sendline( "sudo pkill -9 epmd" )
+ self.handle.sendline( "make rel" )
+ self.handle.expect( "\$" )
+
handle = self.handle.before
return handle
@@ -143,226 +147,225 @@
return main.TRUE
except pexpect.EOF:
- main.log.error(self.name+ ": EOF exception")
- main.log.error(self.name+ ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" :::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" :::::::")
+ main.log.info( self.name + " :::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " :::::::" )
main.cleanup()
main.exit()
- def set_interface_up(self, intfs):
- '''
+ def set_interface_up( self, intfs ):
+ """
Specify interface to bring up.
When Linc-OE is started, tap interfaces should
be created. They must be brought up manually
- '''
+ """
try:
- self.handle.sendline("ifconfig "+str(intfs)+" up")
- self.handle.expect("linc@")
-
+ self.handle.sendline( "ifconfig " + str( intfs ) + " up" )
+ self.handle.expect( "linc@" )
+
handle = self.handle.before
return handle
except pexpect.EOF:
- main.log.error(self.name+ ": EOF exception")
- main.log.error(self.name+ ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" :::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" :::::::")
+ main.log.info( self.name + " :::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " :::::::" )
main.cleanup()
main.exit()
- def start_switch(self, sw_id):
- '''
+ def start_switch( self, sw_id ):
+ """
Start a logical switch using switch id
- '''
+ """
try:
- self.handle.sendline("linc:start_switch("+str(sw_id)+").")
- self.handle.expect("linc@")
+ self.handle.sendline( "linc:start_switch(" + str( sw_id ) + ")." )
+ self.handle.expect( "linc@" )
handle = self.handle.before
except pexpect.EOF:
- main.log.error(self.name+ ": EOF exception")
- main.log.error(self.name+ ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" :::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" :::::::")
+ main.log.info( self.name + " :::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " :::::::" )
main.cleanup()
main.exit()
- def stop_switch(self, sw_id):
- '''
+ def stop_switch( self, sw_id ):
+ """
Stop a logical switch using switch id
- '''
+ """
try:
- self.handle.sendline("linc:stop_switch("+str(sw_id)+").")
- self.handle.expect("linc@")
+ self.handle.sendline( "linc:stop_switch(" + str( sw_id ) + ")." )
+ self.handle.expect( "linc@" )
handle = self.handle.before
except pexpect.EOF:
- main.log.error(self.name+ ": EOF exception")
- main.log.error(self.name+ ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" :::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" :::::::")
+ main.log.info( self.name + " :::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " :::::::" )
main.cleanup()
main.exit()
-
- def get_datapath_id(self, sw_id):
- '''
+
+ def get_datapath_id( self, sw_id ):
+ """
Get datapath id of a specific switch by switch id
- '''
+ """
try:
- self.handle.sendline("linc_logic:get_datapath_id("+
- str(sw_id)+").")
- self.handle.expect("linc@")
+ self.handle.sendline( "linc_logic:get_datapath_id(" +
+ str( sw_id ) + ")." )
+ self.handle.expect( "linc@" )
handle = self.handle.before
-
+
except pexpect.EOF:
- main.log.error(self.name+ ": EOF exception")
- main.log.error(self.name+ ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" :::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" :::::::")
+ main.log.info( self.name + " :::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " :::::::" )
main.cleanup()
main.exit()
- def list_ports(self, sw_id):
- '''
+ def list_ports( self, sw_id ):
+ """
List all ports of a switch by switch id
- '''
+ """
try:
- self.handle.sendline("linc:ports("+str(sw_id)+").")
- self.handle.expect("linc@")
+ self.handle.sendline( "linc:ports(" + str( sw_id ) + ")." )
+ self.handle.expect( "linc@" )
handle = self.handle.before
except pexpect.EOF:
- main.log.error(self.name+ ": EOF exception")
- main.log.error(self.name+ ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" :::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" :::::::")
+ main.log.info( self.name + " :::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " :::::::" )
main.cleanup()
main.exit()
- def port_up(self, sw_id, pt_id):
- '''
+ def port_up( self, sw_id, pt_id ):
+ """
Bring port up using switch id and port id
- '''
+ """
try:
- self.handle.sendline("linc:port_up("+
- str(sw_id)+", "+str(pt_id)+").")
- self.handle.expect("linc@")
+ self.handle.sendline( "linc:port_up(" +
+ str( sw_id ) + ", " + str( pt_id ) + ")." )
+ self.handle.expect( "linc@" )
handle = self.handle.before
except pexpect.EOF:
- main.log.error(self.name+ ": EOF exception")
- main.log.error(self.name+ ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" :::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" :::::::")
+ main.log.info( self.name + " :::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " :::::::" )
main.cleanup()
main.exit()
-
- def port_down(self, sw_id, pt_id):
- '''
+
+ def port_down( self, sw_id, pt_id ):
+ """
Bring port down using switch id and port id
- '''
+ """
try:
- self.handle.sendline("linc:port_down("+
- str(sw_id)+", "+str(pt_id)+").")
- self.handle.expect("linc@")
+ self.handle.sendline( "linc:port_down(" +
+ str( sw_id ) + ", " + str( pt_id ) + ")." )
+ self.handle.expect( "linc@" )
handle = self.handle.before
except pexpect.EOF:
- main.log.error(self.name+ ": EOF exception")
- main.log.error(self.name+ ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" :::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" :::::::")
+ main.log.info( self.name + " :::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " :::::::" )
main.cleanup()
main.exit()
-
- def stopLincOEConsole(self):
- '''
+
+ def stopLincOEConsole( self ):
+ """
This function is only used for packet optical testing
Send disconnect prompt to Linc-OE CLI
- (CTRL+C) and kill the linc process
- '''
+ ( CTRL+C ) and kill the linc process
+ """
try:
cmd = "pgrep -f linc"
- self.handle.sendline("pgrep -f linc")
- self.handle.expect("linc")
+ self.handle.sendline( "pgrep -f linc" )
+ self.handle.expect( "linc" )
print "stophandle = ", self.handle.before
except pexpect.EOF:
- main.log.error(self.name+ ": EOF exception")
- main.log.error(self.name+ ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception" )
+ main.log.error( self.name + ": " + self.handle.before )
- def disconnect(self):
- '''
+ def disconnect( self ):
+ """
Send disconnect prompt to Linc-OE CLI
- (CTRL+C) and kill the linc process
- '''
+ ( CTRL+C ) and kill the linc process
+ """
try:
- #Send CTRL+C twice to exit CLI
- self.handle.send("\x03")
- self.handle.send("\x03")
- self.handle.expect("\$")
+ # Send CTRL+C twice to exit CLI
+ self.handle.send( "\x03" )
+ self.handle.send( "\x03" )
+ self.handle.expect( "\$" )
handle1 = self.handle.before
cmd = "pgrep -f linc"
- self.handle.sendline(cmd)
- self.handle.expect("\$")
+ self.handle.sendline( cmd )
+ self.handle.expect( "\$" )
handle2 = self.handle.before
- main.log.info("pid's = "+handle2)
+ main.log.info( "pid's = " + handle2 )
cmd = "sudo kill -9 `pgrep -f linc`"
- self.handle.sendline(cmd)
- self.handle.expect("\$")
-
+ self.handle.sendline( cmd )
+ self.handle.expect( "\$" )
+
except pexpect.EOF:
- main.log.error(self.name+ ": EOF exception")
- main.log.error(self.name+ ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" :::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" :::::::")
+ main.log.info( self.name + " :::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " :::::::" )
main.cleanup()
main.exit()
if __name__ != "__main__":
import sys
- sys.modules[__name__] = LincOEDriver()
-
+ sys.modules[ __name__ ] = LincOEDriver()
diff --git a/TestON/drivers/common/cli/emulator/mininetclidriver.py b/TestON/drivers/common/cli/emulator/mininetclidriver.py
index 10e46a7..d82a58e 100644
--- a/TestON/drivers/common/cli/emulator/mininetclidriver.py
+++ b/TestON/drivers/common/cli/emulator/mininetclidriver.py
@@ -103,10 +103,10 @@
main.log.info( self.name + ": building fresh mininet" )
# for reactive/PARP enabled tests
cmdString = "sudo mn " + self.options[ 'arg1' ] +\
- " " + self.options[ 'arg2' ] +\
- " --mac --controller " +\
- self.options[ 'controller' ] + " " +\
- self.options[ 'arg3' ]
+ " " + self.options[ 'arg2' ] +\
+ " --mac --controller " +\
+ self.options[ 'controller' ] + " " +\
+ self.options[ 'arg3' ]
argList = self.options[ 'arg1' ].split( "," )
global topoArgList
@@ -185,7 +185,7 @@
total_num_hosts = num_switches * num_hosts_per_sw
num_links = total_num_hosts + ( num_switches - 1 )
print "num_switches for %s(%d,%d) = %d and links=%d" %\
- ( topoType, depth, fanout, num_switches, num_links )
+ ( topoType, depth, fanout, num_switches, num_links )
topoDict = {}
topoDict = {
"num_switches": int( num_switches ),
@@ -227,7 +227,7 @@
# NOTE: mininet's pingall rounds, so we will check the number of
# passed and number of failed
pattern = "Results\:\s0\%\sdropped\s\(" +\
- "(?P<passed>[\d]+)/(?P=passed)"
+ "(?P<passed>[\d]+)/(?P=passed)"
if re.search( pattern, response ):
main.log.info( self.name + ": All hosts are reachable" )
return main.TRUE
@@ -323,11 +323,11 @@
main.exit()
pattern = "inet\s(addr|Mask):([0-1]{1}[0-9]{1,2}|" +\
- "2[0-4][0-9]|25[0-5]|[0-9]{1,2}).([0-1]{1}" +\
- "[0-9]{1,2}|2[0-4][0-9]|25[0-5]|[0-9]{1,2})." +\
- "([0-1]{1}[0-9]{1,2}|2[0-4][0-9]|25[0-5]|" +\
- "[0-9]{1,2}).([0-1]{1}[0-9]{1,2}|2[0-4]" +\
- "[0-9]|25[0-5]|[0-9]{1,2})"
+ "2[0-4][0-9]|25[0-5]|[0-9]{1,2}).([0-1]{1}" +\
+ "[0-9]{1,2}|2[0-4][0-9]|25[0-5]|[0-9]{1,2})." +\
+ "([0-1]{1}[0-9]{1,2}|2[0-4][0-9]|25[0-5]|" +\
+ "[0-9]{1,2}).([0-1]{1}[0-9]{1,2}|2[0-4]" +\
+ "[0-9]|25[0-5]|[0-9]{1,2})"
# pattern = "inet addr:10.0.0.6"
if re.search( pattern, response ):
main.log.info( self.name + ": Host Ip configured properly" )
@@ -588,7 +588,7 @@
return information dict about interfaces connected to the node"""
if self.handle:
cmd = 'py "\\n".join(["name=%s,mac=%s,ip=%s,enabled=%s"' +\
- ' % (i.name, i.MAC(), i.IP(), i.isUp())'
+ ' % (i.name, i.MAC(), i.IP(), i.isUp())'
cmd += ' for i in %s.intfs.values()])' % node
try:
response = self.execute(
@@ -851,7 +851,7 @@
sw = args[ "SW" ] if args[ "SW" ] is not None else ""
ptcpA = int( args[ "PORT1" ] ) + \
- int( sw ) if args[ "PORT1" ] is not None else ""
+ int( sw ) if args[ "PORT1" ] is not None else ""
ptcpB = "ptcp:" + str( ptcpA ) if ptcpA != "" else ""
command = "sh ovs-vsctl set-controller s" + \
@@ -871,7 +871,7 @@
"PORT" +
str( i ) ] is not None else ""
tcp = "tcp:" + str( ip ) + ":" + str( port ) + \
- " " if ip != "" else ""
+ " " if ip != "" else ""
command = command + tcp
try:
self.execute( cmd=command, prompt="mininet>", timeout=5 )
@@ -883,7 +883,7 @@
except:
main.log.info( self.name + ":" * 50 )
main.log.error( traceback.print_exc() )
- main.log.info(":" * 50 )
+ main.log.info( ":" * 50 )
main.cleanup()
main.exit()
@@ -1251,7 +1251,7 @@
except:
main.log.info( self.name + ":" * 50 )
main.log.error( traceback.print_exc() )
- main.log.info(":" * 50 )
+ main.log.info( ":" * 50 )
main.cleanup()
main.exit()
@@ -1270,7 +1270,7 @@
except:
main.log.info( self.name + ":" * 50 )
main.log.error( traceback.print_exc() )
- main.log.info(":" * 50 )
+ main.log.info( ":" * 50 )
main.cleanup()
main.exit()
@@ -1290,7 +1290,7 @@
for port in switch.ports.values():
ports.append( { 'of_port': port.port_no,
'mac': str( port.hw_addr ).replace( '\'',
- ''),
+ '' ),
'name': port.name } )
output[ 'switches' ].append( {
"name": switch.name,
@@ -1344,7 +1344,7 @@
main.log.report( str( list1 ) )
main.log.report( "Switches in ONOS but not in MN:" )
list2 = [ switch for switch in onosDPIDs if switch not in mnDPIDs ]
- main.log.report(str( list2 ) )
+ main.log.report( str( list2 ) )
else: # list of dpid's match in onos and mn
switch_results = main.TRUE
return switch_results
@@ -1476,7 +1476,7 @@
# print port.hw_addr.toStr( separator='' )
ports.append( { 'of_port': port.port_no,
'mac': str( port.hw_addr ).replace( '\'',
- ''),
+ '' ),
'name': port.name } )
output[ 'switches' ].append( {
"name": switch.name,
@@ -1568,7 +1568,7 @@
elif ( str( onos_node1 ) == str( node2 ) and
str( onos_node2 ) == str( node1 ) ):
if ( int( onos_port1 ) == int( port2 )
- and int( onos_port2 ) == int( port1 ) ):
+ and int( onos_port2 ) == int( port1 ) ):
second_dir = main.TRUE
else:
main.log.warn(
diff --git a/TestON/drivers/common/cli/emulator/poxclidriver.py b/TestON/drivers/common/cli/emulator/poxclidriver.py
index a562274..291e916 100644
--- a/TestON/drivers/common/cli/emulator/poxclidriver.py
+++ b/TestON/drivers/common/cli/emulator/poxclidriver.py
@@ -1,14 +1,14 @@
#!/usr/bin/env python
-'''
+"""
Created on 26-Oct-2012
-
-@author: Raghav Kashyap(raghavkashyap@paxterrasolutions.com)
+
+author:: Raghav Kashyap( raghavkashyap@paxterrasolutions.com )
TestON is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
+ ( at your option ) any later version.
TestON is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -16,112 +16,141 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with TestON. If not, see <http://www.gnu.org/licenses/>.
+ along with TestON. If not, see <http://www.gnu.org/licenses/>.
pox driver provides the basic functions of POX controller
-'''
+"""
import pexpect
-import struct, fcntl, os, sys, signal
+import struct
+import fcntl
+import os
+import sys
+import signal
import sys
from drivers.common.cli.emulatordriver import Emulator
-class PoxCliDriver(Emulator):
- '''
- PoxCliDriver driver provides the basic functions of POX controller
- '''
- def __init__(self):
- super(Emulator, self).__init__()
- self.handle = self
- self.wrapped = sys.modules[__name__]
- def connect(self, **connectargs):
- #,user_name, ip_address, pwd,options):
- '''
- this subroutine is to launch pox controller . It must have arguments as :
+class PoxCliDriver( Emulator ):
+
+ """
+ PoxCliDriver driver provides the basic functions of POX controller
+ """
+ def __init__( self ):
+ super( Emulator, self ).__init__()
+ self.handle = self
+ self.wrapped = sys.modules[ __name__ ]
+
+ def connect( self, **connectargs ):
+ #,user_name, ip_address, pwd,options ):
+ """
+ this subroutine is to launch pox controller . It must have arguments as :
user_name = host name ,
ip_address = ip address of the host ,
pwd = password of host ,
options = it is a topology hash which will consists the component's details for the test run
*** host is here a virtual mahine or system where pox framework hierarchy exists
- '''
-
+ """
for key in connectargs:
- vars(self)[key] = connectargs[key]
-
- self.name = self.options['name']
-
+ vars( self )[ key ] = connectargs[ key ]
+
+ self.name = self.options[ 'name' ]
+
poxLibPath = 'default'
- copy = super(PoxCliDriver, self).secureCopy(self.user_name, self.ip_address,'/home/openflow/pox/pox/core.py', self.pwd,path+'/lib/pox/')
- self.handle = super(PoxCliDriver, self).connect(user_name = self.user_name, ip_address = self.ip_address,port = None, pwd = self.pwd)
-
+ copy = super(
+ PoxCliDriver,
+ self ).secureCopy(
+ self.user_name,
+ self.ip_address,
+ '/home/openflow/pox/pox/core.py',
+ self.pwd,
+ path +
+ '/lib/pox/' )
+ self.handle = super(
+ PoxCliDriver,
+ self ).connect(
+ user_name=self.user_name,
+ ip_address=self.ip_address,
+ port=None,
+ pwd=self.pwd )
+
if self.handle:
- self.handle.expect("openflow")
- command = self.getcmd(self.options)
- #print command
- main.log.info("Entering into POX hierarchy")
- if self.options['pox_lib_location'] != 'default':
- self.execute(cmd="cd "+self.options['pox_lib_location'],prompt="/pox\$",timeout=120)
- else:
- self.execute(cmd="cd ~/TestON/lib/pox/",prompt="/pox\$",timeout=120)
- ### launching pox with components
- main.log.info("launching POX controller with given components")
- self.execute(cmd=command,prompt="DEBUG:",timeout=120)
+ self.handle.expect( "openflow" )
+ command = self.getcmd( self.options )
+ # print command
+ main.log.info( "Entering into POX hierarchy" )
+ if self.options[ 'pox_lib_location' ] != 'default':
+ self.execute(
+ cmd="cd " +
+ self.options[ 'pox_lib_location' ],
+ prompt="/pox\$",
+ timeout=120 )
+ else:
+ self.execute(
+ cmd="cd ~/TestON/lib/pox/",
+ prompt="/pox\$",
+ timeout=120 )
+ # launching pox with components
+ main.log.info( "launching POX controller with given components" )
+ self.execute( cmd=command, prompt="DEBUG:", timeout=120 )
return main.TRUE
- else :
- main.log.error("Connection failed to the host "+self.user_name+"@"+self.ip_address)
- main.log.error("Failed to connect to the POX controller")
+ else:
+ main.log.error(
+ "Connection failed to the host " +
+ self.user_name +
+ "@" +
+ self.ip_address )
+ main.log.error( "Failed to connect to the POX controller" )
return main.FALSE
-
-
- def disconnect(self,handle):
+
+ def disconnect( self, handle ):
if self.handle:
- self.execute(cmd="exit()",prompt="/pox\$",timeout=120)
- else :
- main.log.error("Connection failed to the host")
+ self.execute( cmd="exit()", prompt="/pox\$", timeout=120 )
+ else:
+ main.log.error( "Connection failed to the host" )
-
- def get_version(self):
- file_input = path+'/lib/pox/core.py'
- version = super(PoxCliDriver, self).get_version()
+ def get_version( self ):
+ file_input = path + '/lib/pox/core.py'
+ version = super( PoxCliDriver, self ).get_version()
pattern = '\s*self\.version(.*)'
import re
- for line in open(file_input,'r').readlines():
- result = re.match(pattern, line)
+ for line in open( file_input, 'r' ).readlines():
+ result = re.match( pattern, line )
if result:
- version = result.group(0)
- version = re.sub("\s*self\.version\s*=\s*|\(|\)",'',version)
- version = re.sub(",",'.',version)
- version = "POX "+version
-
-
- return version
-
+ version = result.group( 0 )
+ version = re.sub(
+ "\s*self\.version\s*=\s*|\(|\)",
+ '',
+ version )
+ version = re.sub( ",", '.', version )
+ version = "POX " + version
- def getcmd(self,options):
- command = "./pox.py "
+ return version
+
+ def getcmd( self, options ):
+ command = "./pox.py "
for item in options.keys():
- if isinstance(options[item],dict):
+ if isinstance( options[ item ], dict ):
command = command + item
- for items in options[item].keys():
- if options[item][items] == "None":
+ for items in options[ item ].keys():
+ if options[ item ][ items ] == "None":
command = command + " --" + items + " "
- else :
- command = command + " --" + items + "=" + options[item][items] + " "
+ else:
+ command = command + " --" + items + \
+ "=" + options[ item ][ items ] + " "
else:
if item == 'pox_lib_location':
- poxLibPath = options[item]
+ poxLibPath = options[ item ]
elif item == 'type' or item == 'name':
pass
- else :
+ else:
command = command + item
+ return command
- return command
-
if __name__ != "__main__":
import sys
- sys.modules[__name__] = PoxCliDriver()
+ sys.modules[ __name__ ] = PoxCliDriver()
diff --git a/TestON/drivers/common/cli/emulator/remotemininetdriver.py b/TestON/drivers/common/cli/emulator/remotemininetdriver.py
index 48d3389..a8aedea 100644
--- a/TestON/drivers/common/cli/emulator/remotemininetdriver.py
+++ b/TestON/drivers/common/cli/emulator/remotemininetdriver.py
@@ -1,14 +1,14 @@
#!/usr/bin/env python
-'''
+"""
Created on 26-Oct-2012
-@author: Anil Kumar (anilkumar.s@paxterrasolutions.com)
+author:: Anil Kumar ( anilkumar.s@paxterrasolutions.com )
TestON is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
+ ( at your option ) any later version.
TestON is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -20,449 +20,536 @@
MininetCliDriver is the basic driver which will handle the Mininet functions
-'''
+"""
import traceback
import pexpect
import re
import sys
-sys.path.append("../")
+sys.path.append( "../" )
from drivers.common.cli.emulatordriver import Emulator
-class RemoteMininetDriver(Emulator):
- '''
+
+class RemoteMininetDriver( Emulator ):
+
+ """
RemoteMininetCliDriver is the basic driver which will handle the Mininet functions
The main different between this and the MininetCliDriver is that this one does not build the mininet.
It assumes that there is already a mininet running on the target.
- '''
- def __init__(self):
- super(Emulator, self).__init__()
+ """
+ def __init__( self ):
+ super( Emulator, self ).__init__()
self.handle = self
- self.wrapped = sys.modules[__name__]
+ self.wrapped = sys.modules[ __name__ ]
self.flag = 0
- def connect(self, **connectargs):
- #,user_name, ip_address, pwd,options):
- # Here the main is the TestON instance after creating all the log handles.
+ def connect( self, **connectargs ):
+ #,user_name, ip_address, pwd,options ):
+ # Here the main is the TestON instance after creating all the log
+ # handles.
for key in connectargs:
- vars(self)[key] = connectargs[key]
+ vars( self )[ key ] = connectargs[ key ]
- self.name = self.options['name']
- self.handle = super(RemoteMininetDriver, self).connect(user_name = self.user_name, ip_address = self.ip_address,port = None, pwd = self.pwd)
+ self.name = self.options[ 'name' ]
+ self.handle = super(
+ RemoteMininetDriver,
+ self ).connect(
+ user_name=self.user_name,
+ ip_address=self.ip_address,
+ port=None,
+ pwd=self.pwd )
self.ssh_handle = self.handle
# Copying the readme file to process the
- if self.handle :
+ if self.handle:
return main.TRUE
- else :
- main.log.error("Connection failed to the host "+self.user_name+"@"+self.ip_address)
- main.log.error("Failed to connect to the Mininet")
+ else:
+ main.log.error(
+ "Connection failed to the host " +
+ self.user_name +
+ "@" +
+ self.ip_address )
+ main.log.error( "Failed to connect to the Mininet" )
return main.FALSE
-#*********************************************************************************************
-#*********************************************************************************************
+#*************************************************************************
+#*************************************************************************
# checkForLoss will determine if any of the pings had any packets lost during the course of
# the pingLong.
-#*********************************************************************************************
-#*********************************************************************************************
+#*************************************************************************
+#*************************************************************************
- def checkForLoss(self, pingList):
- '''
+ def checkForLoss( self, pingList ):
+ """
Returns main.FALSE for 0% packet loss and
Returns main.ERROR if "found multiple mininet" is found and
Returns main.TRUE else
- '''
- #TODO: maybe we want to return the % loss instead? This way we can set an acceptible loss %.
- #EX: 393 packets transmitted, 380 received, 3% packet loss, time 78519ms
+ """
+ # TODO: maybe we want to return the % loss instead? This way we can set an acceptible loss %.
+ # EX: 393 packets transmitted, 380 received, 3% packet loss, time 78519ms
# we may need to return a float to get around rounding errors
- self.handle.sendline("")
- self.handle.expect("\$")
- #Clear any output waiting in the bg from killing pings
- self.handle.sendline("")
- self.handle.expect("\$")
- self.handle.sendline("cat " + pingList)
- self.handle.expect(pingList)
- self.handle.expect("\$")
+ self.handle.sendline( "" )
+ self.handle.expect( "\$" )
+ # Clear any output waiting in the bg from killing pings
+ self.handle.sendline( "" )
+ self.handle.expect( "\$" )
+ self.handle.sendline( "cat " + pingList )
+ self.handle.expect( pingList )
+ self.handle.expect( "\$" )
outputs = self.handle.before + self.handle.after
- if re.search(" 0% packet loss",outputs):
+ if re.search( " 0% packet loss", outputs ):
return main.FALSE
- elif re.search("found multiple mininet",outputs):
+ elif re.search( "found multiple mininet", outputs ):
return main.ERROR
else:
- main.log.error("Error, unexpected output in the ping file")
+ main.log.error( "Error, unexpected output in the ping file" )
main.log.warn( outputs )
return main.TRUE
-
-
- def pingLong(self,**pingParams):
- '''
+ def pingLong( self, **pingParams ):
+ """
Starts a continuous ping on the mininet host outputing to a file in the /tmp dir.
- '''
- self.handle.sendline("")
- self.handle.expect("\$")
- args = utilities.parse_args(["SRC","TARGET","PINGTIME"],**pingParams)
- precmd = "sudo rm /tmp/ping." + args["SRC"]
- self.execute(cmd=precmd,prompt="(.*)",timeout=10)
- command = "sudo mininet/util/m " + args["SRC"] + " ping "+args ["TARGET"]+" -i .2 -w " + str(args['PINGTIME']) + " -D > /tmp/ping." + args["SRC"] + " &"
+ """
+ self.handle.sendline( "" )
+ self.handle.expect( "\$" )
+ args = utilities.parse_args(
+ [ "SRC", "TARGET", "PINGTIME" ], **pingParams )
+ precmd = "sudo rm /tmp/ping." + args[ "SRC" ]
+ self.execute( cmd=precmd, prompt="(.*)", timeout=10 )
+ command = "sudo mininet/util/m " + args[ "SRC" ] + " ping " + args[
+ "TARGET" ] + " -i .2 -w " + str( args[ 'PINGTIME' ] ) + " -D > /tmp/ping." + args[ "SRC" ] + " &"
main.log.info( command )
- self.execute(cmd=command,prompt="(.*)",timeout=10)
- self.handle.sendline("")
- self.handle.expect("\$")
+ self.execute( cmd=command, prompt="(.*)", timeout=10 )
+ self.handle.sendline( "" )
+ self.handle.expect( "\$" )
return main.TRUE
- def pingstatus(self,**pingParams):
- '''
+ def pingstatus( self, **pingParams ):
+ """
Tails the respective ping output file and check that there is a moving "64 bytes"
- '''
- self.handle.sendline("")
- self.handle.expect("\$")
- args = utilities.parse_args(["SRC"],**pingParams)
- self.handle.sendline("tail /tmp/ping." + args["SRC"])
- self.handle.expect("tail")
- self.handle.expect("\$")
+ """
+ self.handle.sendline( "" )
+ self.handle.expect( "\$" )
+ args = utilities.parse_args( [ "SRC" ], **pingParams )
+ self.handle.sendline( "tail /tmp/ping." + args[ "SRC" ] )
+ self.handle.expect( "tail" )
+ self.handle.expect( "\$" )
result = self.handle.before + self.handle.after
- self.handle.sendline("")
- self.handle.expect("\$")
- if re.search('Unreachable', result ):
- main.log.info("Unreachable found in ping logs...")
+ self.handle.sendline( "" )
+ self.handle.expect( "\$" )
+ if re.search( 'Unreachable', result ):
+ main.log.info( "Unreachable found in ping logs..." )
return main.FALSE
- elif re.search('64\sbytes', result):
- main.log.info("Pings look good")
+ elif re.search( '64\sbytes', result ):
+ main.log.info( "Pings look good" )
return main.TRUE
else:
- main.log.info("No, or faulty ping data...")
+ main.log.info( "No, or faulty ping data..." )
return main.FALSE
- def pingKill(self, testONUser, testONIP):
- '''
+ def pingKill( self, testONUser, testONIP ):
+ """
Kills all continuous ping processes.
Then copies all the ping files to the TestStation.
- '''
- self.handle.sendline("")
- self.handle.expect("\$")
+ """
+ self.handle.sendline( "" )
+ self.handle.expect( "\$" )
command = "sudo kill -SIGINT `pgrep ping`"
main.log.info( command )
- self.execute(cmd=command,prompt="(.*)",timeout=10)
+ self.execute( cmd=command, prompt="(.*)", timeout=10 )
main.log.info( "Transferring ping files to TestStation" )
- command = "scp /tmp/ping.* "+ str(testONUser) + "@" + str(testONIP) + ":/tmp/"
- self.execute(cmd=command,prompt="100%",timeout=20)
- #Make sure the output is cleared
- self.handle.sendline("")
- self.handle.expect("\$")
- self.handle.sendline("")
- self.handle.expect("\$")
- self.handle.sendline("")
- i=self.handle.expect(["password","\$"])
+ command = "scp /tmp/ping.* " + \
+ str( testONUser ) + "@" + str( testONIP ) + ":/tmp/"
+ self.execute( cmd=command, prompt="100%", timeout=20 )
+ # Make sure the output is cleared
+ self.handle.sendline( "" )
+ self.handle.expect( "\$" )
+ self.handle.sendline( "" )
+ self.handle.expect( "\$" )
+ self.handle.sendline( "" )
+ i = self.handle.expect( [ "password", "\$" ] )
if i == 0:
- main.log.error("Error, sudo asking for password")
- main.log.error(self.handle.before)
+ main.log.error( "Error, sudo asking for password" )
+ main.log.error( self.handle.before )
return main.FALSE
else:
return main.TRUE
- def pingLongKill(self):
- self.handle.sendline("")
- self.handle.expect("\$")
+ def pingLongKill( self ):
+ self.handle.sendline( "" )
+ self.handle.expect( "\$" )
command = "sudo kill -SIGING `pgrep ping`"
- main.log.info(command)
- self.execute(cmd=command,prompt="(.*)",timeout=10)
- self.handle.sendline("")
- self.handle.expect("\$")
+ main.log.info( command )
+ self.execute( cmd=command, prompt="(.*)", timeout=10 )
+ self.handle.sendline( "" )
+ self.handle.expect( "\$" )
return main.TRUE
- def pingHostOptical(self,**pingParams):
- '''
+ def pingHostOptical( self, **pingParams ):
+ """
This function is only for Packey Optical related ping
- Use the next pingHost() function for all normal scenarios)
+ Use the next pingHost() function for all normal scenarios )
Ping from one mininet host to another
Currently the only supported Params: SRC and TARGET
- '''
- args = utilities.parse_args(["SRC","TARGET"],**pingParams)
- #command = args["SRC"] + " ping -" + args["CONTROLLER"] + " " +args ["TARGET"]
- command = args["SRC"] + " ping "+args ["TARGET"]+" -c 1 -i 1 -W 8"
+ """
+ args = utilities.parse_args( [ "SRC", "TARGET" ], **pingParams )
+ #command = args[ "SRC" ] + " ping -" + args[ "CONTROLLER" ] + " " +args [ "TARGET" ]
+ command = args[ "SRC" ] + " ping " + \
+ args[ "TARGET" ] + " -c 1 -i 1 -W 8"
try:
- main.log.warn("Sending: " + command)
- #response = self.execute(cmd=command,prompt="mininet",timeout=10 )
- self.handle.sendline(command)
- i = self.handle.expect([command,pexpect.TIMEOUT])
+ main.log.warn( "Sending: " + command )
+ #response = self.execute( cmd=command,prompt="mininet",timeout=10 )
+ self.handle.sendline( command )
+ i = self.handle.expect( [ command, pexpect.TIMEOUT ] )
if i == 1:
- main.log.error(self.name + ": timeout when waiting for response from mininet")
- main.log.error("response: " + str(self.handle.before))
- i = self.handle.expect(["mininet>",pexpect.TIMEOUT])
+ main.log.error(
+ self.name +
+ ": timeout when waiting for response from mininet" )
+ main.log.error( "response: " + str( self.handle.before ) )
+ i = self.handle.expect( [ "mininet>", pexpect.TIMEOUT ] )
if i == 1:
- main.log.error(self.name + ": timeout when waiting for response from mininet")
- main.log.error("response: " + str(self.handle.before))
+ main.log.error(
+ self.name +
+ ": timeout when waiting for response from mininet" )
+ main.log.error( "response: " + str( self.handle.before ) )
response = self.handle.before
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- main.log.info(self.name+": Ping Response: "+ response )
- #if utilities.assert_matches(expect=',\s0\%\spacket\sloss',actual=response,onpass="No Packet loss",onfail="Host is not reachable"):
- if re.search(',\s0\%\spacket\sloss',response):
- main.log.info(self.name+": no packets lost, host is reachable")
+ main.log.info( self.name + ": Ping Response: " + response )
+ # if utilities.assert_matches(
+ # expect=',\s0\%\spacket\sloss',actual=response,onpass="No Packet
+ # loss",onfail="Host is not reachable" ):
+ if re.search( ',\s0\%\spacket\sloss', response ):
+ main.log.info( self.name + ": no packets lost, host is reachable" )
main.last_result = main.TRUE
return main.TRUE
- else :
- main.log.error(self.name+": PACKET LOST, HOST IS NOT REACHABLE")
+ else:
+ main.log.error(
+ self.name +
+ ": PACKET LOST, HOST IS NOT REACHABLE" )
main.last_result = main.FALSE
return main.FALSE
- def pingHost(self,**pingParams):
- '''
+ def pingHost( self, **pingParams ):
+ """
Pings between two hosts on remote mininet
- '''
- self.handle.sendline("")
- self.handle.expect("\$")
- args = utilities.parse_args(["SRC","TARGET"],**pingParams)
- #command = "mininet/util/m " + args["SRC"] + " ping "+args ["TARGET"]+" -c 4 -W 1 -i .2"
- command = "mininet/util/m " + args["SRC"] + " ping "+args ["TARGET"]+" -c 4 -W 1 -i .2"
- main.log.info ( command )
- response = self.execute(cmd=command,prompt="rtt",timeout=10 )
- #self.handle.sendline("")
- #self.handle.expect("\$")
- if utilities.assert_matches(expect=',\s0\%\spacket\sloss',actual=response,onpass="No Packet loss",onfail="Host is not reachable"):
- main.log.info("NO PACKET LOSS, HOST IS REACHABLE")
+ """
+ self.handle.sendline( "" )
+ self.handle.expect( "\$" )
+ args = utilities.parse_args( [ "SRC", "TARGET" ], **pingParams )
+ #command = "mininet/util/m " + args[ "SRC" ] + " ping "+args [ "TARGET" ]+" -c 4 -W 1 -i .2"
+ command = "mininet/util/m " + \
+ args[ "SRC" ] + " ping " + args[ "TARGET" ] + " -c 4 -W 1 -i .2"
+ main.log.info( command )
+ response = self.execute( cmd=command, prompt="rtt", timeout=10 )
+ # self.handle.sendline( "" )
+ # self.handle.expect( "\$" )
+ if utilities.assert_matches(
+ expect=',\s0\%\spacket\sloss',
+ actual=response,
+ onpass="No Packet loss",
+ onfail="Host is not reachable" ):
+ main.log.info( "NO PACKET LOSS, HOST IS REACHABLE" )
main.last_result = main.TRUE
return main.TRUE
- else :
- main.log.error("PACKET LOST, HOST IS NOT REACHABLE")
+ else:
+ main.log.error( "PACKET LOST, HOST IS NOT REACHABLE" )
main.last_result = main.FALSE
return main.FALSE
-
- def checknum(self,num):
- '''
+ def checknum( self, num ):
+ """
Verifies the correct number of switches are running
- '''
- if self.handle :
- self.handle.sendline("")
- self.handle.expect("\$")
- self.handle.sendline('ifconfig -a | grep "sw.. " | wc -l')
- self.handle.expect("wc")
- self.handle.expect("\$")
+ """
+ if self.handle:
+ self.handle.sendline( "" )
+ self.handle.expect( "\$" )
+ self.handle.sendline( 'ifconfig -a | grep "sw.. " | wc -l' )
+ self.handle.expect( "wc" )
+ self.handle.expect( "\$" )
response = self.handle.before
- self.handle.sendline('ps -ef | grep "bash -ms mininet:sw" | grep -v color | wc -l')
- self.handle.expect("color")
- self.handle.expect("\$")
+ self.handle.sendline(
+ 'ps -ef | grep "bash -ms mininet:sw" | grep -v color | wc -l' )
+ self.handle.expect( "color" )
+ self.handle.expect( "\$" )
response2 = self.handle.before
- if re.search(num, response):
- if re.search(num, response2):
+ if re.search( num, response ):
+ if re.search( num, response2 ):
return main.TRUE
else:
return main.FALSE
else:
return main.FALSE
- else :
- main.log.error("Connection failed to the host")
+ else:
+ main.log.error( "Connection failed to the host" )
- def start_tcpdump(self, filename, intf = "eth0", port = "port 6633", user="admin"):
- '''
+ def start_tcpdump(
+ self,
+ filename,
+ intf="eth0",
+ port="port 6633",
+ user="admin" ):
+ """
Runs tpdump on an intferface and saves the file
intf can be specified, or the default eth0 is used
- '''
+ """
try:
- self.handle.sendline("")
- self.handle.sendline("sudo tcpdump -n -i "+ intf + " " + port + " -w " + filename.strip() + " -Z " + user + " &")
- self.handle.sendline("")
- self.handle.sendline("")
- i=self.handle.expect(['No\ssuch\device','listening\son',pexpect.TIMEOUT,"\$"],timeout=10)
- main.log.warn(self.handle.before + self.handle.after)
+ self.handle.sendline( "" )
+ self.handle.sendline(
+ "sudo tcpdump -n -i " +
+ intf +
+ " " +
+ port +
+ " -w " +
+ filename.strip() +
+ " -Z " +
+ user +
+ " &" )
+ self.handle.sendline( "" )
+ self.handle.sendline( "" )
+ i = self.handle.expect(
+ [ 'No\ssuch\device', 'listening\son', pexpect.TIMEOUT, "\$" ], timeout=10 )
+ main.log.warn( self.handle.before + self.handle.after )
if i == 0:
- main.log.error(self.name + ": tcpdump - No such device exists. tcpdump attempted on: " + intf)
+ main.log.error(
+ self.name +
+ ": tcpdump - No such device exists. tcpdump attempted on: " +
+ intf )
return main.FALSE
elif i == 1:
- main.log.info(self.name + ": tcpdump started on " + intf)
+ main.log.info( self.name + ": tcpdump started on " + intf )
return main.TRUE
elif i == 2:
- main.log.error(self.name + ": tcpdump command timed out! Check interface name, given interface was: " + intf)
+ main.log.error(
+ self.name +
+ ": tcpdump command timed out! Check interface name, given interface was: " +
+ intf )
return main.FALSE
- elif i ==3:
- main.log.info(self.name +": " + self.handle.before)
+ elif i == 3:
+ main.log.info( self.name + ": " + self.handle.before )
return main.TRUE
else:
- main.log.error(self.name + ": tcpdump - unexpected response")
+ main.log.error( self.name + ": tcpdump - unexpected response" )
return main.FALSE
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name + ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::")
+ main.log.info(
+ self.name +
+ ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" )
main.log.error( traceback.print_exc() )
- main.log.info(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::")
+ main.log.info(
+ ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" )
main.cleanup()
main.exit()
- def stop_tcpdump(self):
+ def stop_tcpdump( self ):
"pkills tcpdump"
try:
- self.handle.sendline("sudo pkill tcpdump")
- self.handle.sendline("")
- self.handle.sendline("")
- self.handle.expect("\$")
+ self.handle.sendline( "sudo pkill tcpdump" )
+ self.handle.sendline( "" )
+ self.handle.sendline( "" )
+ self.handle.expect( "\$" )
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name + ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::")
+ main.log.info(
+ self.name +
+ ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" )
main.log.error( traceback.print_exc() )
- main.log.info(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::")
+ main.log.info(
+ ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" )
main.cleanup()
main.exit()
- def run_optical_mn_script(self):
- '''
+ def run_optical_mn_script( self ):
+ """
This function is only meant for Packet Optical.
- It runs the python script "optical.py" to create the packet layer(mn)
+ It runs the python script "optical.py" to create the packet layer( mn )
topology
- '''
+ """
try:
- self.handle.sendline("")
- self.handle.expect("\$")
- self.handle.sendline("cd ~")
- self.handle.expect("\$")
- self.handle.sendline("sudo python optical.py")
- self.handle.expect(">")
+ self.handle.sendline( "" )
+ self.handle.expect( "\$" )
+ self.handle.sendline( "cd ~" )
+ self.handle.expect( "\$" )
+ self.handle.sendline( "sudo python optical.py" )
+ self.handle.expect( ">" )
return main.TRUE
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
return main.FALSE
- def disconnect(self):
- '''
+ def disconnect( self ):
+ """
Called at the end of the test to disconnect the handle.
- '''
+ """
response = ''
- #print "Disconnecting Mininet"
+ # print "Disconnecting Mininet"
if self.handle:
- self.handle.sendline("exit")
- self.handle.expect("exit")
- self.handle.expect("(.*)")
+ self.handle.sendline( "exit" )
+ self.handle.expect( "exit" )
+ self.handle.expect( "(.*)" )
response = self.handle.before
- else :
- main.log.error("Connection failed to the host")
+ else:
+ main.log.error( "Connection failed to the host" )
response = main.FALSE
return response
- def get_flowTable(self, protoVersion, sw):
- #TODO document usage
- #TODO add option to look at cookies. ignoreing them for now
- self.handle.sendline("cd")
- self.handle.expect(["\$",pexpect.EOF,pexpect.TIMEOUT])
- #print "get_flowTable(" + str(protoVersion) +" " + str(sw) +")"
- #NOTE: Use format to force consistent flow table output across versions
- if protoVersion==1.0:
- command = "sudo ovs-ofctl dump-flows " + sw + " -F OpenFlow10-table_id | awk '{OFS=\",\" ; print $1 $3 $6 $7 $8}' | cut -d ',' -f 2- | sort -n -k1 -r"
- self.handle.sendline(command)
- self.handle.expect(["k1 -r",pexpect.EOF,pexpect.TIMEOUT])
- self.handle.expect(["OFPST_FLOW",pexpect.EOF,pexpect.TIMEOUT])
+ def get_flowTable( self, protoVersion, sw ):
+ # TODO document usage
+ # TODO add option to look at cookies. ignoreing them for now
+ self.handle.sendline( "cd" )
+ self.handle.expect( [ "\$", pexpect.EOF, pexpect.TIMEOUT ] )
+ # print "get_flowTable(" + str( protoVersion ) +" " + str( sw ) +")"
+ # NOTE: Use format to force consistent flow table output across
+ # versions
+ if protoVersion == 1.0:
+ command = "sudo ovs-ofctl dump-flows " + sw + \
+ " -F OpenFlow10-table_id | awk '{OFS=\",\" ; print $1 $3 $6 $7 $8}' | cut -d ',' -f 2- | sort -n -k1 -r"
+ self.handle.sendline( command )
+ self.handle.expect( [ "k1 -r", pexpect.EOF, pexpect.TIMEOUT ] )
+ self.handle.expect(
+ [ "OFPST_FLOW", pexpect.EOF, pexpect.TIMEOUT ] )
response = self.handle.before
- #print "response=", response
+ # print "response=", response
return response
- elif protoVersion==1.3:
- command = "sudo ovs-ofctl dump-flows " + sw + " -O OpenFlow13 | awk '{OFS=\",\" ; print $1 $3 $6 $7}' | cut -d ',' -f 2- | sort -n -k1 -r"
- self.handle.sendline(command)
- self.handle.expect(["k1 -r",pexpect.EOF,pexpect.TIMEOUT])
- self.handle.expect(["OFPST_FLOW",pexpect.EOF,pexpect.TIMEOUT])
+ elif protoVersion == 1.3:
+ command = "sudo ovs-ofctl dump-flows " + sw + \
+ " -O OpenFlow13 | awk '{OFS=\",\" ; print $1 $3 $6 $7}' | cut -d ',' -f 2- | sort -n -k1 -r"
+ self.handle.sendline( command )
+ self.handle.expect( [ "k1 -r", pexpect.EOF, pexpect.TIMEOUT ] )
+ self.handle.expect(
+ [ "OFPST_FLOW", pexpect.EOF, pexpect.TIMEOUT ] )
response = self.handle.before
- #print "response=", response
+ # print "response=", response
return response
else:
- main.log.error("Unknown protoVersion in get_flowTable(). given: ("+str(type(protoVersion))+") '"+str(protoVersion)+"'")
+ main.log.error(
+ "Unknown protoVersion in get_flowTable(). given: (" +
+ str(
+ type( protoVersion ) ) +
+ ") '" +
+ str(protoVersion) +
+ "'" )
-
- def flow_comp(self,flow1,flow2):
- if flow1==flow2:
+ def flow_comp( self, flow1, flow2 ):
+ if flow1 == flow2:
return main.TRUE
else:
- main.log.info("Flow tables do not match, printing tables:")
- main.log.info("Flow Table 1:")
- main.log.info(flow1)
- main.log.info("Flow Table 2:")
- main.log.info(flow2)
+ main.log.info( "Flow tables do not match, printing tables:" )
+ main.log.info( "Flow Table 1:" )
+ main.log.info( flow1 )
+ main.log.info( "Flow Table 2:" )
+ main.log.info( flow2 )
return main.FALSE
- def setIpTablesOUTPUT(self, dst_ip, dst_port, action='add', packet_type='tcp',rule='DROP'):
- '''
+ def setIpTablesOUTPUT(
+ self,
+ dst_ip,
+ dst_port,
+ action='add',
+ packet_type='tcp',
+ rule='DROP' ):
+ """
Description:
- add or remove iptables rule to DROP (default) packets from specific IP and PORT
+ add or remove iptables rule to DROP ( default ) packets from specific IP and PORT
Usage:
- * specify action ('add' or 'remove')
+ * specify action ( 'add' or 'remove' )
when removing, pass in the same argument as you would add. It will
delete that specific rule.
* specify the destination ip to block with dst_ip
* specify destination port to block to dst_port
- * optional packet type to block (default tcp)
- * optional iptables rule (default DROP)
+ * optional packet type to block ( default tcp )
+ * optional iptables rule ( default DROP )
WARNING:
* This function uses root privilege iptables command which may result in
unwanted network errors. USE WITH CAUTION
- '''
+ """
import re
import time
- #NOTE*********
+ # NOTE*********
# The strict checking methods of this driver function is intentional
# to discourage any misuse or error of iptables, which can cause
# severe network errors
#*************
- #NOTE: Sleep needed to give some time for rule to be added and registered
+ # NOTE: Sleep needed to give some time for rule to be added and registered
# to the instance
- time.sleep(5)
+ time.sleep( 5 )
action_type = action.lower()
- if action_type != 'add' and action_type !='remove':
- main.log.error("Invalid action type. 'add' or 'remove' table rule")
+ if action_type != 'add' and action_type != 'remove':
+ main.log.error(
+ "Invalid action type. 'add' or 'remove' table rule" )
if rule != 'DROP' and rule != 'ACCEPT' and rule != 'LOG':
- #NOTE: Currently only supports rules DROP, ACCEPT, and LOG
- main.log.error("Invalid rule. 'DROP' or 'ACCEPT' or 'LOG' only.")
+ # NOTE: Currently only supports rules DROP, ACCEPT, and LOG
+ main.log.error(
+ "Invalid rule. 'DROP' or 'ACCEPT' or 'LOG' only." )
return
return
else:
- #If there is no existing rule in the iptables, we will see an
+ # If there is no existing rule in the iptables, we will see an
#'iptables:'... message. We expect to see this message.
- #Otherwise, if there IS an existing rule, we will get the prompt
+ # Otherwise, if there IS an existing rule, we will get the prompt
# back, hence why we expect $ for remove type. We want to remove
# an already existing rule
if action_type == 'add':
- #NOTE: "iptables:" expect is a result of return from the command
+ # NOTE: "iptables:" expect is a result of return from the command
# iptables -C ...
# Any changes by the iptables command return string
- # will result in failure of the function. (deemed unlikely
- # at the time of writing this function)
- #Check for existing rules on current input
- self.handle.sendline("")
- self.handle.expect("\$")
- self.handle.sendline("sudo iptables -C OUTPUT -p "+str(packet_type)+
- " -d "+ str(dst_ip)+" --dport "+str(dst_port)+" -j "+str(rule))
- i = self.handle.expect(["iptables:", "\$"])
+ # will result in failure of the function. ( deemed unlikely
+ # at the time of writing this function )
+ # Check for existing rules on current input
+ self.handle.sendline( "" )
+ self.handle.expect( "\$" )
+ self.handle.sendline(
+ "sudo iptables -C OUTPUT -p " +
+ str( packet_type ) +
+ " -d " +
+ str( dst_ip ) +
+ " --dport " +
+ str( dst_port ) +
+ " -j " +
+ str( rule ) )
+ i = self.handle.expect( [ "iptables:", "\$" ] )
print i
print self.handle.before
print "after: "
print self.handle.after
elif action_type == 'remove':
- #Check for existing rules on current input
- self.handle.sendline("")
- self.handle.expect("\$")
- self.handle.sendline("sudo iptables -C OUTPUT -p "+str(packet_type)+
- " -d "+ str(dst_ip)+" --dport "+str(dst_port)+" -j "+str(rule))
- self.handle.expect("\$")
+ # Check for existing rules on current input
+ self.handle.sendline( "" )
+ self.handle.expect( "\$" )
+ self.handle.sendline(
+ "sudo iptables -C OUTPUT -p " +
+ str( packet_type ) +
+ " -d " +
+ str( dst_ip ) +
+ " --dport " +
+ str( dst_port ) +
+ " -j " +
+ str( rule ) )
+ self.handle.expect( "\$" )
print "before: "
print self.handle.before
actual_string = self.handle.after
@@ -470,73 +557,104 @@
print "Actual String:"
print actual_string
- if re.search(expect_string, actual_string):
+ if re.search( expect_string, actual_string ):
match_result = main.TRUE
else:
match_result = main.FALSE
- #If match_result is main.TRUE, it means there is no matching rule.
+ # If match_result is main.TRUE, it means there is no matching rule.
- #If tables does not exist and expected prompt is returned, go ahead and
- #add iptables rule
+ # If tables does not exist and expected prompt is returned, go ahead and
+ # add iptables rule
if match_result == main.TRUE:
- #Ensure action type is add
+ # Ensure action type is add
if action_type == 'add':
#-A is the 'append' action of iptables
action_add = '-A'
try:
- self.handle.sendline("")
- self.handle.sendline("sudo iptables "+action_add+" OUTPUT -p "+str(packet_type)+
- " -d "+ str(dst_ip)+" --dport "+str(dst_port)+" -j "+str(rule))
+ self.handle.sendline( "" )
+ self.handle.sendline(
+ "sudo iptables " +
+ action_add +
+ " OUTPUT -p " +
+ str( packet_type ) +
+ " -d " +
+ str( dst_ip ) +
+ " --dport " +
+ str( dst_port ) +
+ " -j " +
+ str( rule ) )
- info_string = "Rules added to "+str(self.name)
- info_string += "iptable rule added to block IP: "+str(dst_ip)
- info_string += "Port: "+str(dst_port)+" Rule: "+str(rule)
+ info_string = "Rules added to " + str( self.name )
+ info_string += "iptable rule added to block IP: " + \
+ str( dst_ip )
+ info_string += "Port: " + \
+ str( dst_port ) + " Rule: " + str( rule )
- main.log.info(info_string)
+ main.log.info( info_string )
- self.handle.expect(["\$",pexpect.EOF,pexpect.TIMEOUT])
+ self.handle.expect(
+ [ "\$", pexpect.EOF, pexpect.TIMEOUT ] )
except pexpect.TIMEOUT:
- main.log.error(self.name + ": Timeout exception in setIpTables function")
+ main.log.error(
+ self.name +
+ ": Timeout exception in setIpTables function" )
except:
- main.log.error( traceback.print_exc())
+ main.log.error( traceback.print_exc() )
main.cleanup()
main.exit()
else:
- main.log.error("Given rule already exists, but attempted to add it")
- #If match_result is 0, it means there IS a matching rule provided
+ main.log.error(
+ "Given rule already exists, but attempted to add it" )
+ # If match_result is 0, it means there IS a matching rule provided
elif match_result == main.FALSE:
- #Ensure action type is remove
+ # Ensure action type is remove
if action_type == 'remove':
#-D is the 'delete' rule of iptables
action_remove = '-D'
try:
- self.handle.sendline("")
- #Delete a specific rule specified into the function
- self.handle.sendline("sudo iptables "+action_remove+" OUTPUT -p "+str(packet_type)+
- " -d "+ str(dst_ip)+" --dport "+str(dst_port)+" -j "+str(rule))
+ self.handle.sendline( "" )
+ # Delete a specific rule specified into the function
+ self.handle.sendline(
+ "sudo iptables " +
+ action_remove +
+ " OUTPUT -p " +
+ str( packet_type ) +
+ " -d " +
+ str( dst_ip ) +
+ " --dport " +
+ str( dst_port ) +
+ " -j " +
+ str( rule ) )
- info_string = "Rules removed from "+str(self.name)
- info_string += " iptables rule removed from blocking IP: "+str(dst_ip)
- info_string += " Port: "+str(dst_port)+" Rule: "+str(rule)
+ info_string = "Rules removed from " + str( self.name )
+ info_string += " iptables rule removed from blocking IP: " + \
+ str( dst_ip )
+ info_string += " Port: " + \
+ str( dst_port ) + " Rule: " + str( rule )
- main.log.info(info_string)
+ main.log.info( info_string )
- self.handle.expect(["\$",pexpect.EOF,pexpect.TIMEOUT])
+ self.handle.expect(
+ [ "\$", pexpect.EOF, pexpect.TIMEOUT ] )
except pexpect.TIMEOUT:
- main.log.error(self.name + ": Timeout exception in setIpTables function")
+ main.log.error(
+ self.name +
+ ": Timeout exception in setIpTables function" )
except:
- main.log.error( traceback.print_exc())
+ main.log.error( traceback.print_exc() )
main.cleanup()
main.exit()
else:
- main.log.error("Given rule does not exist, but attempted to remove it")
+ main.log.error(
+ "Given rule does not exist, but attempted to remove it" )
else:
- #NOTE: If a bad usage of this function occurs, exit the entire test
- main.log.error("Bad rule given for iptables. Exiting...")
+ # NOTE: If a bad usage of this function occurs, exit the entire
+ # test
+ main.log.error( "Bad rule given for iptables. Exiting..." )
main.cleanup()
main.exit()
if __name__ != "__main__":
import sys
- sys.modules[__name__] = RemoteMininetDriver()
+ sys.modules[ __name__ ] = RemoteMininetDriver()
diff --git a/TestON/drivers/common/cli/emulatordriver.py b/TestON/drivers/common/cli/emulatordriver.py
index b561e9c..bb8da7c 100644
--- a/TestON/drivers/common/cli/emulatordriver.py
+++ b/TestON/drivers/common/cli/emulatordriver.py
@@ -1,13 +1,13 @@
#!/usr/bin/env python
-'''
-Created on 26-Oct-2012
+"""
+Created on 26-Oct-2012
-@author: Anil Kumar (anilkumar.s@paxterrasolutions.com)
+author:: Anil Kumar ( anilkumar.s@paxterrasolutions.com )
TestON is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
+ ( at your option ) any later version.
TestON is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -15,18 +15,24 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with TestON. If not, see <http://www.gnu.org/licenses/>.
+ along with TestON. If not, see <http://www.gnu.org/licenses/>.
-'''
+"""
import pexpect
-import struct, fcntl, os, sys, signal
+import struct
+import fcntl
+import os
import sys
-sys.path.append("../")
+import signal
+import sys
+sys.path.append( "../" )
from drivers.common.clidriver import CLI
-class Emulator(CLI):
+
+class Emulator( CLI ):
# The common functions for emulator included in emulatordriver
- def __init__(self):
- super(CLI, self).__init__()
-
+
+ def __init__( self ):
+ super( CLI, self ).__init__()
+
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index 838e6f4..b8a2bd5 100644
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -1,9 +1,9 @@
#!/usr/bin/env python
-'''
+"""
This driver enters the onos> prompt to issue commands.
-Please follow the coding style demonstrated by existing
+Please follow the coding style demonstrated by existing
functions and document properly.
If you are a contributor to the driver, please
@@ -15,1131 +15,1055 @@
OCT 13 2014
-'''
-
+"""
import sys
import pexpect
import re
import traceback
#import os.path
-sys.path.append("../")
+sys.path.append( "../" )
from drivers.common.clidriver import CLI
-class OnosCliDriver(CLI):
- def __init__(self):
- '''
- Initialize client
- '''
- super(CLI, self).__init__()
+class OnosCliDriver( CLI ):
- def connect(self,**connectargs):
- '''
+ def __init__( self ):
+ """
+ Initialize client
+ """
+ super( CLI, self ).__init__()
+
+ def connect( self, **connectargs ):
+ """
Creates ssh handle for ONOS cli.
- '''
+ """
try:
for key in connectargs:
- vars(self)[key] = connectargs[key]
+ vars( self )[ key ] = connectargs[ key ]
self.home = "~/ONOS"
for key in self.options:
if key == "home":
- self.home = self.options['home']
+ self.home = self.options[ 'home' ]
break
+ self.name = self.options[ 'name' ]
+ self.handle = super( OnosCliDriver, self ).connect(
+ user_name=self.user_name,
+ ip_address=self.ip_address,
+ port=self.port,
+ pwd=self.pwd,
+ home=self.home )
- self.name = self.options['name']
- self.handle = super(OnosCliDriver,self).connect(
- user_name = self.user_name,
- ip_address = self.ip_address,
- port = self.port,
- pwd = self.pwd,
- home = self.home)
-
- self.handle.sendline("cd "+ self.home)
- self.handle.expect("\$")
+ self.handle.sendline( "cd " + self.home )
+ self.handle.expect( "\$" )
if self.handle:
return self.handle
- else :
- main.log.info("NO ONOS HANDLE")
+ else:
+ main.log.info( "NO ONOS HANDLE" )
return main.FALSE
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name + ":::::::::::::::::::::::")
+ main.log.info( self.name + ":::::::::::::::::::::::" )
main.log.error( traceback.print_exc() )
- main.log.info(":::::::::::::::::::::::")
+ main.log.info( ":::::::::::::::::::::::" )
main.cleanup()
main.exit()
- def disconnect(self):
- '''
+ def disconnect( self ):
+ """
Called when Test is complete to disconnect the ONOS handle.
- '''
+ """
response = ''
try:
- self.handle.sendline("")
- i = self.handle.expect(["onos>","\$"])
+ self.handle.sendline( "" )
+ i = self.handle.expect( [ "onos>", "\$" ] )
if i == 0:
- self.handle.sendline("system:shutdown")
- self.handle.expect("Confirm")
- self.handle.sendline("yes")
- self.handle.expect("\$")
- self.handle.sendline("")
- self.handle.expect("\$")
- self.handle.sendline("exit")
- self.handle.expect("closed")
+ self.handle.sendline( "system:shutdown" )
+ self.handle.expect( "Confirm" )
+ self.handle.sendline( "yes" )
+ self.handle.expect( "\$" )
+ self.handle.sendline( "" )
+ self.handle.expect( "\$" )
+ self.handle.sendline( "exit" )
+ self.handle.expect( "closed" )
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
except:
- main.log.error(self.name + ": Connection failed to the host")
+ main.log.error( self.name + ": Connection failed to the host" )
response = main.FALSE
return response
- def logout(self):
- '''
+ def logout( self ):
+ """
Sends 'logout' command to ONOS cli
- '''
+ """
try:
- self.handle.sendline("")
- i = self.handle.expect([
+ self.handle.sendline( "" )
+ i = self.handle.expect( [
"onos>",
- "\$"], timeout=10)
+ "\$" ], timeout=10 )
if i == 0:
- self.handle.sendline("logout")
- self.handle.expect("\$")
+ self.handle.sendline( "logout" )
+ self.handle.expect( "\$" )
elif i == 1:
return main.TRUE
-
+
except pexpect.EOF:
- main.log.error(self.name + ": eof exception found")
- main.log.error(self.name + ": " +
- self.handle.before)
+ main.log.error( self.name + ": eof exception found" )
+ main.log.error( self.name + ": " +
+ self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
- def set_cell(self, cellname):
- '''
+ def set_cell( self, cellname ):
+ """
Calls 'cell <name>' to set the environment variables on ONOSbench
-
+
Before issuing any cli commands, set the environment variable first.
- '''
+ """
try:
if not cellname:
- main.log.error("Must define cellname")
+ main.log.error( "Must define cellname" )
main.cleanup()
main.exit()
else:
- self.handle.sendline("cell "+str(cellname))
- #Expect the cellname in the ONOS_CELL variable.
- #Note that this variable name is subject to change
+ self.handle.sendline( "cell " + str( cellname ) )
+ # Expect the cellname in the ONOS_CELL variable.
+ # Note that this variable name is subject to change
# and that this driver will have to change accordingly
- self.handle.expect("ONOS_CELL="+str(cellname))
+ self.handle.expect( "ONOS_CELL=" + str( cellname ) )
handle_before = self.handle.before
handle_after = self.handle.after
- #Get the rest of the handle
- self.handle.sendline("")
- self.handle.expect("\$")
+ # Get the rest of the handle
+ self.handle.sendline( "" )
+ self.handle.expect( "\$" )
handle_more = self.handle.before
- main.log.info("Cell call returned: "+handle_before+
- handle_after + handle_more)
+ main.log.info( "Cell call returned: " + handle_before +
+ handle_after + handle_more )
return main.TRUE
except pexpect.EOF:
- main.log.error(self.name + ": eof exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": eof exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
-
- def start_onos_cli(self, ONOS_ip, karafTimeout=""):
- '''
- karafTimeout is an optional arugument. karafTimeout value passed by user would be used to set the
+
+ def start_onos_cli( self, ONOS_ip, karafTimeout="" ):
+ """
+ karafTimeout is an optional arugument. karafTimeout value passed by user would be used to set the
current karaf shell idle timeout. Note that when ever this property is modified the shell will exit and
the subsequent login would reflect new idle timeout.
- Below is an example to start a session with 60 seconds idle timeout (input value is in milliseconds):
-
+ Below is an example to start a session with 60 seconds idle timeout ( input value is in milliseconds ):
+
tValue = "60000"
- main.ONOScli1.start_onos_cli(ONOS_ip, karafTimeout=tValue)
-
+ main.ONOScli1.start_onos_cli( ONOS_ip, karafTimeout=tValue )
+
Note: karafTimeout is left as str so that this could be read and passed to start_onos_cli from PARAMS file as str.
- '''
+ """
try:
- self.handle.sendline("")
- x = self.handle.expect([
- "\$", "onos>"], timeout=10)
+ self.handle.sendline( "" )
+ x = self.handle.expect( [
+ "\$", "onos>" ], timeout=10 )
if x == 1:
- main.log.info("ONOS cli is already running")
+ main.log.info( "ONOS cli is already running" )
return main.TRUE
- #Wait for onos start (-w) and enter onos cli
- self.handle.sendline("onos -w "+str(ONOS_ip))
- i = self.handle.expect([
- "onos>",
- pexpect.TIMEOUT],timeout=60)
+ # Wait for onos start ( -w ) and enter onos cli
+ self.handle.sendline( "onos -w " + str( ONOS_ip ) )
+ i = self.handle.expect( [
+ "onos>",
+ pexpect.TIMEOUT ], timeout=60 )
if i == 0:
- main.log.info(str(ONOS_ip)+" CLI Started successfully")
+ main.log.info( str( ONOS_ip ) + " CLI Started successfully" )
if karafTimeout:
- self.handle.sendline("config:property-set -p org.apache.karaf.shell sshIdleTimeout "+karafTimeout)
- self.handle.expect("\$")
- self.handle.sendline("onos -w "+str(ONOS_ip))
- self.handle.expect("onos>")
+ self.handle.sendline(
+ "config:property-set -p org.apache.karaf.shell sshIdleTimeout " +
+ karafTimeout )
+ self.handle.expect( "\$" )
+ self.handle.sendline( "onos -w " + str( ONOS_ip ) )
+ self.handle.expect( "onos>" )
return main.TRUE
else:
- #If failed, send ctrl+c to process and try again
- main.log.info("Starting CLI failed. Retrying...")
- self.handle.send("\x03")
- self.handle.sendline("onos -w "+str(ONOS_ip))
- i = self.handle.expect(["onos>",pexpect.TIMEOUT],
- timeout=30)
+ # If failed, send ctrl+c to process and try again
+ main.log.info( "Starting CLI failed. Retrying..." )
+ self.handle.send( "\x03" )
+ self.handle.sendline( "onos -w " + str( ONOS_ip ) )
+ i = self.handle.expect( [ "onos>", pexpect.TIMEOUT ],
+ timeout=30 )
if i == 0:
- main.log.info(str(ONOS_ip)+" CLI Started "+
- "successfully after retry attempt")
+ main.log.info( str( ONOS_ip ) + " CLI Started " +
+ "successfully after retry attempt" )
if karafTimeout:
- self.handle.sendline("config:property-set -p org.apache.karaf.shell sshIdleTimeout "+karafTimeout)
- self.handle.expect("\$")
- self.handle.sendline("onos -w "+str(ONOS_ip))
- self.handle.expect("onos>")
+ self.handle.sendline(
+ "config:property-set -p org.apache.karaf.shell sshIdleTimeout " +
+ karafTimeout )
+ self.handle.expect( "\$" )
+ self.handle.sendline( "onos -w " + str( ONOS_ip ) )
+ self.handle.expect( "onos>" )
return main.TRUE
else:
- main.log.error("Connection to CLI "+\
- str(ONOS_ip)+" timeout")
+ main.log.error( "Connection to CLI " +
+ str( ONOS_ip ) + " timeout" )
return main.FALSE
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
- def sendline(self, cmd_str):
- '''
- Send a completely user specified string to
- the onos> prompt. Use this function if you have
+ def sendline( self, cmd_str ):
+ """
+ Send a completely user specified string to
+ the onos> prompt. Use this function if you have
a very specific command to send.
-
+
Warning: There are no sanity checking to commands
sent using this method.
- '''
+ """
try:
- self.handle.sendline("")
- self.handle.expect("onos>")
+ self.handle.sendline( "" )
+ self.handle.expect( "onos>" )
- self.handle.sendline(cmd_str)
- self.handle.expect("onos>")
+ self.handle.sendline( "log:log \"Sending CLI command: '"
+ + cmd_str + "'\"" )
+ self.handle.expect( "onos>" )
+ self.handle.sendline( cmd_str )
+ self.handle.expect( cmd_str )
+ self.handle.expect( "onos>" )
handle = self.handle.before
-
- self.handle.sendline("")
- self.handle.expect("onos>")
-
- handle += self.handle.before
- handle += self.handle.after
- main.log.info("Command sent.")
- ansi_escape = re.compile(r'\x1b[^m]*m')
- handle = ansi_escape.sub('', handle)
+ self.handle.sendline( "" )
+ self.handle.expect( "onos>" )
+
+ #handle += self.handle.before
+ #handle += self.handle.after
+
+ main.log.info( "Command '" + str(cmd_str) + "' sent to "
+ + self.name + "." )
+ ansi_escape = re.compile( r'\x1b[^m]*m' )
+ handle = ansi_escape.sub( '', handle )
return handle
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
- #IMPORTANT NOTE:
- #For all cli commands, naming convention should match
- #the cli command replacing ':' with '_'.
- #Ex) onos:topology > onos_topology
+ # IMPORTANT NOTE:
+ # For all cli commands, naming convention should match
+ # the cli command replacing ':' with '_'.
+ # Ex ) onos:topology > onos_topology
# onos:links > onos_links
# feature:list > feature_list
-
- def add_node(self, node_id, ONOS_ip, tcp_port=""):
- '''
+
+ def add_node( self, node_id, ONOS_ip, tcp_port="" ):
+ """
Adds a new cluster node by ID and address information.
Required:
* node_id
* ONOS_ip
Optional:
* tcp_port
- '''
+ """
try:
- self.handle.sendline("")
- self.handle.expect("onos>")
-
- self.handle.sendline("add-node "+
- str(node_id)+" "+
- str(ONOS_ip)+" "+
- str(tcp_port))
-
- i = self.handle.expect([
- "Error",
- "onos>" ])
-
- #Clear handle to get previous output
- self.handle.sendline("")
- self.handle.expect("onos>")
-
- handle = self.handle.before
-
- if i == 0:
- main.log.error("Error in adding node")
- main.log.error(handle)
- return main.FALSE
+ cmd_str = "add-node " + str( node_id ) + " " +\
+ str( ONOS_ip ) + " " + str( tcp_port )
+ handle = self.sendline( cmd_str )
+ if re.search( "Error", handle ):
+ main.log.error( "Error in adding node" )
+ main.log.error( handle )
+ return main.FALSE
else:
- main.log.info("Node "+str(ONOS_ip)+" added")
+ main.log.info( "Node " + str( ONOS_ip ) + " added" )
return main.TRUE
-
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
- def remove_node(self, node_id):
- '''
+ def remove_node( self, node_id ):
+ """
Removes a cluster by ID
Issues command: 'remove-node [<node-id>]'
Required:
* node_id
- '''
+ """
try:
- self.handle.sendline("")
- self.handle.expect("onos>")
- self.handle.sendline("remove-node "+str(node_id))
- self.handle.expect("onos>")
+ cmd_str = "remove-node " + str( node_id )
+ self.sendline( cmd_str )
+ # TODO: add error checking. Does ONOS give any errors?
return main.TRUE
-
+
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
- def nodes(self):
- '''
+ def nodes( self ):
+ """
List the nodes currently visible
Issues command: 'nodes'
Returns: entire handle of list of nodes
- '''
+ """
try:
- self.handle.sendline("")
- self.handle.expect("onos>")
-
- self.handle.sendline("nodes")
- self.handle.expect("onos>")
-
- self.handle.sendline("")
- self.handle.expect("onos>")
-
- handle = self.handle.before
-
+ cmd_str = "nodes"
+ handle = self.sendline( cmd_str )
return handle
-
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
- def topology(self):
- '''
+ def topology( self ):
+ """
Shows the current state of the topology
by issusing command: 'onos> onos:topology'
- '''
+ """
try:
- self.handle.sendline("")
- self.handle.expect("onos>")
- #either onos:topology or 'topology' will work in CLI
- self.handle.sendline("onos:topology")
- self.handle.expect("onos>")
-
- handle = self.handle.before
-
- main.log.info("onos:topology returned: " +
- str(handle))
-
+ # either onos:topology or 'topology' will work in CLI
+ cmd_str = "onos:topology"
+ handle = self.sendline( cmd_str )
+ main.log.info( "onos:topology returned: " + str( handle ) )
return handle
-
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
-
- def feature_install(self, feature_str):
- '''
- Installs a specified feature
+
+ def feature_install( self, feature_str ):
+ """
+ Installs a specified feature
by issuing command: 'onos> feature:install <feature_str>'
- '''
+ """
try:
- self.handle.sendline("")
- self.handle.expect("onos>")
-
- self.handle.sendline("feature:install "+str(feature_str))
- self.handle.expect("onos>")
-
+ cmd_str = "feature:install " + str( feature_str )
+ self.sendline( cmd_str )
+ # TODO: Check for possible error responses from karaf
return main.TRUE
-
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
- main.log.report("Failed to install feature")
- main.log.report("Exiting test")
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
+ main.log.report( "Failed to install feature" )
+ main.log.report( "Exiting test" )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.report("Failed to install feature")
- main.log.report("Exiting test")
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.report( "Failed to install feature" )
+ main.log.report( "Exiting test" )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
-
- def feature_uninstall(self, feature_str):
- '''
+
+ def feature_uninstall( self, feature_str ):
+ """
Uninstalls a specified feature
by issuing command: 'onos> feature:uninstall <feature_str>'
- '''
+ """
try:
- self.handle.sendline("")
- self.handle.expect("onos>")
-
- self.handle.sendline("feature:uninstall "+str(feature_str))
- self.handle.expect("onos>")
-
+ cmd_str = "feature:uninstall " + str( feature_str )
+ self.sendline( cmd_str )
+ # TODO: Check for possible error responses from karaf
return main.TRUE
-
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
- def devices(self, json_format=True):
- '''
+ def devices( self, json_format=True ):
+ """
Lists all infrastructure devices or switches
Optional argument:
* json_format - boolean indicating if you want output in json
- '''
+ """
try:
- self.handle.sendline("")
- self.handle.expect("onos>")
-
if json_format:
- self.handle.sendline("devices -j")
- self.handle.expect("devices -j")
- self.handle.expect("onos>")
- handle = self.handle.before
- '''
- handle variable here contains some ANSI escape color code sequences at the end which are invisible in the print command output
- To make that escape sequence visible, use repr() function. The repr(handle) output when printed shows the ANSI escape sequences.
- In json.loads(somestring), this somestring variable is actually repr(somestring) and json.loads would fail with the escape sequence.
- So we take off that escape sequence using
- ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
- handle1 = ansi_escape.sub('', handle)
- '''
- #print "repr(handle) =", repr(handle)
- ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
- handle1 = ansi_escape.sub('', handle)
- #print "repr(handle1) = ", repr(handle1)
+ cmd_str = "devices -j"
+ handle = self.sendline( cmd_str )
+ """
+ handle variable here contains some ANSI escape color code
+ sequences at the end which are invisible in the print command
+ output. To make that escape sequence visible, use repr()
+ function. The repr( handle ) output when printed shows the
+ ANSI escape sequences. In json.loads( somestring ), this
+ somestring variable is actually repr( somestring ) and
+ json.loads would fail with the escape sequence. So we take off
+ that escape sequence using:
+
+ ansi_escape = re.compile( r'\r\r\n\x1b[^m]*m' )
+ handle1 = ansi_escape.sub( '', handle )
+ """
+ ansi_escape = re.compile( r'\r\r\n\x1b[^m]*m' )
+ handle1 = ansi_escape.sub( '', handle )
return handle1
else:
- self.handle.sendline("devices")
- self.handle.expect("onos>")
- handle = self.handle.before
- #print "handle =",handle
+ cmd_str = "devices"
+ handle = self.sendline( cmd_str )
return handle
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
-
- def balance_masters(self):
- '''
+ def balance_masters( self ):
+ """
This balances the devices across all controllers
by issuing command: 'onos> onos:balance-masters'
If required this could be extended to return devices balanced output.
- '''
+ """
try:
- self.handle.sendline("")
- self.handle.expect("onos>")
-
- self.handle.sendline("onos:balance-masters")
- self.handle.expect("onos>")
+ cmd_str = "onos:balance-masters"
+ self.sendline( cmd_str )
+ # TODO: Check for error responses from ONOS
return main.TRUE
-
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
- def links(self, json_format=True):
- '''
+ def links( self, json_format=True ):
+ """
Lists all core links
Optional argument:
* json_format - boolean indicating if you want output in json
- '''
+ """
try:
- self.handle.sendline("")
- self.handle.expect("onos>")
-
if json_format:
- self.handle.sendline("links -j")
- self.handle.expect("links -j")
- self.handle.expect("onos>")
- handle = self.handle.before
- '''
- handle variable here contains some ANSI escape color code sequences at the end which are invisible in the print command output
- To make that escape sequence visible, use repr() function. The repr(handle) output when printed shows the ANSI escape sequences.
- In json.loads(somestring), this somestring variable is actually repr(somestring) and json.loads would fail with the escape sequence.
- So we take off that escape sequence using
- ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
- handle1 = ansi_escape.sub('', handle)
- '''
- #print "repr(handle) =", repr(handle)
- ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
- handle1 = ansi_escape.sub('', handle)
- #print "repr(handle1) = ", repr(handle1)
+ cmd_str = "links -j"
+ handle = self.sendline( cmd_str )
+ """
+ handle variable here contains some ANSI escape color code
+ sequences at the end which are invisible in the print command
+ output. To make that escape sequence visible, use repr()
+ function. The repr( handle ) output when printed shows the ANSI
+ escape sequences. In json.loads( somestring ), this somestring
+ variable is actually repr( somestring ) and json.loads would
+ fail with the escape sequence. So we take off that escape
+ sequence using:
+
+ ansi_escape = re.compile( r'\r\r\n\x1b[^m]*m' )
+ handle1 = ansi_escape.sub( '', handle )
+ """
+ ansi_escape = re.compile( r'\r\r\n\x1b[^m]*m' )
+ handle1 = ansi_escape.sub( '', handle )
return handle1
else:
- self.handle.sendline("links")
- self.handle.expect("onos>")
- handle = self.handle.before
- #print "handle =",handle
+ cmd_str = "links"
+ handle = self.sendline( cmd_str )
return handle
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
-
- def ports(self, json_format=True):
- '''
+ def ports( self, json_format=True ):
+ """
Lists all ports
Optional argument:
* json_format - boolean indicating if you want output in json
- '''
+ """
try:
- self.handle.sendline("")
- self.handle.expect("onos>")
-
if json_format:
- self.handle.sendline("ports -j")
- self.handle.expect("ports -j")
- self.handle.expect("onos>")
- handle = self.handle.before
- '''
- handle variable here contains some ANSI escape color code sequences at the end which are invisible in the print command output
- To make that escape sequence visible, use repr() function. The repr(handle) output when printed shows the ANSI escape sequences.
- In json.loads(somestring), this somestring variable is actually repr(somestring) and json.loads would fail with the escape sequence.
- So we take off that escape sequence using the following commads:
- ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
- handle1 = ansi_escape.sub('', handle)
- '''
- #print "repr(handle) =", repr(handle)
- ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
- handle1 = ansi_escape.sub('', handle)
- #print "repr(handle1) = ", repr(handle1)
+ cmd_str = "ports -j"
+ handle = self.sendline( cmd_str )
+ """
+ handle variable here contains some ANSI escape color code
+ sequences at the end which are invisible in the print command
+ output. To make that escape sequence visible, use repr()
+ function. The repr( handle ) output when printed shows the ANSI
+ escape sequences. In json.loads( somestring ), this somestring
+ variable is actually repr( somestring ) and json.loads would
+ fail with the escape sequence. So we take off that escape
+ sequence using the following commads:
+
+ ansi_escape = re.compile( r'\r\r\n\x1b[^m]*m' )
+ handle1 = ansi_escape.sub( '', handle )
+ """
+ ansi_escape = re.compile( r'\r\r\n\x1b[^m]*m' )
+ handle1 = ansi_escape.sub( '', handle )
return handle1
else:
- self.handle.sendline("ports")
- self.handle.expect("onos>")
- self.handle.sendline("")
- self.handle.expect("onos>")
- handle = self.handle.before
- #print "handle =",handle
+ cmd_str = "ports"
+ handle = self.sendline( cmd_str )
return handle
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
-
- def roles(self, json_format=True):
- '''
+ def roles( self, json_format=True ):
+ """
Lists all devices and the controllers with roles assigned to them
Optional argument:
* json_format - boolean indicating if you want output in json
- '''
+ """
try:
- self.handle.sendline("")
- self.handle.expect("onos>")
-
if json_format:
- self.handle.sendline("roles -j")
- self.handle.expect("roles -j")
- self.handle.expect("onos>")
- handle = self.handle.before
- '''
- handle variable here contains some ANSI escape color code sequences at the
- end which are invisible in the print command output. To make that escape
- sequence visible, use repr() function. The repr(handle) output when printed
- shows the ANSI escape sequences. In json.loads(somestring), this somestring
- variable is actually repr(somestring) and json.loads would fail with the escape
- sequence.
+ cmd_str = "roles -j"
+ handle = self.sendline( cmd_str )
+ """
+ handle variable here contains some ANSI escape color code
+ sequences at the end which are invisible in the print command
+ output. To make that escape sequence visible, use repr()
+ function. The repr( handle ) output when printed shows the ANSI
+ escape sequences. In json.loads( somestring ), this somestring
+ variable is actually repr( somestring ) and json.loads would
+ fail with the escape sequence.
- So we take off that escape sequence using the following commads:
- ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
- handle1 = ansi_escape.sub('', handle)
- '''
- #print "repr(handle) =", repr(handle)
- ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
- handle1 = ansi_escape.sub('', handle)
- #print "repr(handle1) = ", repr(handle1)
+ So we take off that escape sequence using the following
+ commads:
+
+ ansi_escape = re.compile( r'\r\r\n\x1b[^m]*m' )
+ handle1 = ansi_escape.sub( '', handle )
+ """
+ ansi_escape = re.compile( r'\r\r\n\x1b[^m]*m' )
+ handle1 = ansi_escape.sub( '', handle )
return handle1
else:
- self.handle.sendline("roles")
- self.handle.expect("onos>")
- self.handle.sendline("")
- self.handle.expect("onos>")
- handle = self.handle.before
- #print "handle =",handle
+ cmd_str = "roles"
+ handle = self.sendline( cmd_str )
return handle
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
- def get_role(self, device_id):
- '''
- Given the a string containing the json representation of the "roles" cli command and a
- partial or whole device id, returns a json object containing the
- roles output for the first device whose id contains "device_id"
+ def get_role( self, device_id ):
+ """
+ Given the a string containing the json representation of the "roles"
+ cli command and a partial or whole device id, returns a json object
+ containing the roles output for the first device whose id contains
+ "device_id"
Returns:
- Dict of the role assignments for the given device or
- None if not match
- '''
+ A dict of the role assignments for the given device or
+ None if no match
+ """
try:
import json
- if device_id == None:
+ if device_id is None:
return None
else:
raw_roles = self.roles()
- roles_json = json.loads(raw_roles)
- #search json for the device with id then return the device
+ roles_json = json.loads( raw_roles )
+ # search json for the device with id then return the device
for device in roles_json:
- #print device
- if str(device_id) in device['id']:
+ # print device
+ if str( device_id ) in device[ 'id' ]:
return device
return None
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
- def roles_not_null(self):
- '''
+ def roles_not_null( self ):
+ """
Iterates through each device and checks if there is a master assigned
Returns: main.TRUE if each device has a master
main.FALSE any device has no master
- '''
+ """
try:
import json
raw_roles = self.roles()
- roles_json = json.loads(raw_roles)
- #search json for the device with id then return the device
+ roles_json = json.loads( raw_roles )
+ # search json for the device with id then return the device
for device in roles_json:
- #print device
- if device['master'] == "none":
- main.log.warn("Device has no master: " + str(device) )
+ # print device
+ if device[ 'master' ] == "none":
+ main.log.warn( "Device has no master: " + str( device ) )
return main.FALSE
return main.TRUE
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
-
- def paths(self, src_id, dst_id):
- '''
+ def paths( self, src_id, dst_id ):
+ """
Returns string of paths, and the cost.
Issues command: onos:paths <src> <dst>
- '''
+ """
try:
- self.handle.sendline("")
- self.handle.expect("onos>")
-
- self.handle.sendline("onos:paths "+
- str(src_id) + " " + str(dst_id))
- i = self.handle.expect([
- "Error",
- "onos>"])
-
- self.handle.sendline("")
- self.handle.expect("onos>")
-
- handle = self.handle.before
-
- if i == 0:
- main.log.error("Error in getting paths")
- return (handle, "Error")
+ cmd_str = "onos:paths " + str( src_id ) + " " + str( dst_id )
+ handle = self.sendline( cmd_str )
+ if re.search( "Error", handle ):
+ main.log.error( "Error in getting paths" )
+ return ( handle, "Error" )
else:
- path = handle.split(";")[0]
- cost = handle.split(";")[1]
- return (path, cost)
-
+ path = handle.split( ";" )[ 0 ]
+ cost = handle.split( ";" )[ 1 ]
+ return ( path, cost )
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
- def hosts(self, json_format=True):
- '''
+ def hosts( self, json_format=True ):
+ """
Lists all discovered hosts
Optional argument:
* json_format - boolean indicating if you want output in json
- '''
+ """
try:
- self.handle.sendline("")
- self.handle.expect("onos>")
-
if json_format:
- self.handle.sendline("hosts -j")
- self.handle.expect("hosts -j")
- self.handle.expect("onos>")
- handle = self.handle.before
- '''
- handle variable here contains some ANSI escape color code sequences at the end which are invisible in the print command output
- To make that escape sequence visible, use repr() function. The repr(handle) output when printed shows the ANSI escape sequences.
- In json.loads(somestring), this somestring variable is actually repr(somestring) and json.loads would fail with the escape sequence.
- So we take off that escape sequence using
- ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
- handle1 = ansi_escape.sub('', handle)
- '''
- #print "repr(handle) =", repr(handle)
- ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
- handle1 = ansi_escape.sub('', handle)
- #print "repr(handle1) = ", repr(handle1)
+ cmd_str = "hosts -j"
+ handle = self.sendline( cmd_str )
+ """
+ handle variable here contains some ANSI escape color code
+ sequences at the end which are invisible in the print command
+ output. To make that escape sequence visible, use repr()
+ function. The repr( handle ) output when printed shows the ANSI
+ escape sequences. In json.loads( somestring ), this somestring
+ variable is actually repr( somestring ) and json.loads would
+ fail with the escape sequence. So we take off that escape
+ sequence using:
+
+ ansi_escape = re.compile( r'\r\r\n\x1b[^m]*m' )
+ handle1 = ansi_escape.sub( '', handle )
+ """
+ ansi_escape = re.compile( r'\r\r\n\x1b[^m]*m' )
+ handle1 = ansi_escape.sub( '', handle )
return handle1
else:
- self.handle.sendline("hosts")
- self.handle.expect("onos>")
- handle = self.handle.before
- #print "handle =",handle
+ cmd_str = "hosts"
+ handle = self.sendline( cmd_str )
return handle
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
- def get_host(self, mac):
- '''
+ def get_host( self, mac ):
+ """
Return the first host from the hosts api whose 'id' contains 'mac'
- Note: mac must be a colon seperated mac address, but could be a partial mac address
+
+ Note: mac must be a colon seperated mac address, but could be a
+ partial mac address
+
Return None if there is no match
- '''
+ """
import json
try:
- if mac == None:
+ if mac is None:
return None
else:
mac = mac
raw_hosts = self.hosts()
- hosts_json = json.loads(raw_hosts)
- #search json for the host with mac then return the device
+ hosts_json = json.loads( raw_hosts )
+ # search json for the host with mac then return the device
for host in hosts_json:
- #print "%s in %s?" % (mac, host['id'])
- if mac in host['id']:
+ # print "%s in %s?" % ( mac, host[ 'id' ] )
+ if mac in host[ 'id' ]:
return host
return None
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
-
- def get_hosts_id(self, host_list):
- '''
- Obtain list of hosts
+ def get_hosts_id( self, host_list ):
+ """
+ Obtain list of hosts
Issues command: 'onos> hosts'
-
+
Required:
* host_list: List of hosts obtained by Mininet
IMPORTANT:
This function assumes that you started your
- topology with the option '--mac'.
+ topology with the option '--mac'.
Furthermore, it assumes that value of VLAN is '-1'
Description:
- Converts mininet hosts (h1, h2, h3...) into
- ONOS format (00:00:00:00:00:01/-1 , ...)
- '''
-
+ Converts mininet hosts ( h1, h2, h3... ) into
+ ONOS format ( 00:00:00:00:00:01/-1 , ... )
+ """
try:
onos_host_list = []
for host in host_list:
- host = host.replace("h", "")
- host_hex = hex(int(host)).zfill(12)
- host_hex = str(host_hex).replace('x','0')
- i = iter(str(host_hex))
- host_hex = ":".join(a+b for a,b in zip(i,i))
+ host = host.replace( "h", "" )
+ host_hex = hex( int( host ) ).zfill( 12 )
+ host_hex = str( host_hex ).replace( 'x', '0' )
+ i = iter( str( host_hex ) )
+ host_hex = ":".join( a + b for a, b in zip( i, i ) )
host_hex = host_hex + "/-1"
- onos_host_list.append(host_hex)
+ onos_host_list.append( host_hex )
- return onos_host_list
+ return onos_host_list
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
- def add_host_intent(self, host_id_one, host_id_two):
- '''
+ def add_host_intent( self, host_id_one, host_id_two ):
+ """
Required:
* host_id_one: ONOS host id for host1
* host_id_two: ONOS host id for host2
Description:
- Adds a host-to-host intent (bidrectional) by
+ Adds a host-to-host intent ( bidrectional ) by
specifying the two hosts.
- '''
+ """
try:
- self.handle.sendline("")
- self.handle.expect("onos>")
-
- self.handle.sendline("add-host-intent "+
- str(host_id_one) + " " + str(host_id_two))
- self.handle.expect("onos>")
-
- handle = self.handle.before
- #print "handle =", handle
-
- main.log.info("Host intent installed between "+
- str(host_id_one) + " and " + str(host_id_two))
-
+ cmd_str = "add-host-intent " + str( host_id_one ) +\
+ " " + str( host_id_two )
+ handle = self.sendline( cmd_str )
+ main.log.info( "Host intent installed between " +
+ str( host_id_one ) + " and " + str( host_id_two ) )
return handle
-
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
- def add_optical_intent(self, ingress_device, egress_device):
- '''
+ def add_optical_intent( self, ingress_device, egress_device ):
+ """
Required:
* ingress_device: device id of ingress device
* egress_device: device id of egress device
Optional:
TODO: Still needs to be implemented via dev side
- '''
+ """
try:
- self.handle.sendline("add-optical-intent "+
- str(ingress_device) + " " + str(egress_device))
- self.handle.expect("add-optical-intent")
- i = self.handle.expect([
- "Error",
- "onos>"])
-
- handle = self.handle.before
-
- #If error, return error message
- if i == 0:
+ cmd_str = "add-optical-intent " + str( ingress_device ) +\
+ " " + str( egress_device )
+ handle = self.sendline( cmd_str )
+ # If error, return error message
+ if re.search( "Error", handle ):
return handle
else:
return main.TRUE
-
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
- def add_point_intent(self, ingress_device, egress_device,
- port_ingress="", port_egress="", ethType="", ethSrc="",
- ethDst="", bandwidth="", lambda_alloc=False,
- ipProto="", ipSrc="", ipDst="", tcpSrc="", tcpDst=""):
- '''
+ def add_point_intent(
+ self,
+ ingress_device,
+ egress_device,
+ port_ingress="",
+ port_egress="",
+ ethType="",
+ ethSrc="",
+ ethDst="",
+ bandwidth="",
+ lambda_alloc=False,
+ ipProto="",
+ ipSrc="",
+ ipDst="",
+ tcpSrc="",
+ tcpDst="" ):
+ """
Required:
* ingress_device: device id of ingress device
* egress_device: device id of egress device
Optional:
* ethType: specify ethType
- * ethSrc: specify ethSrc (i.e. src mac addr)
- * ethDst: specify ethDst (i.e. dst mac addr)
+ * ethSrc: specify ethSrc ( i.e. src mac addr )
+ * ethDst: specify ethDst ( i.e. dst mac addr )
* bandwidth: specify bandwidth capacity of link
- * lambda_alloc: if True, intent will allocate lambda
+ * lambda_alloc: if True, intent will allocate lambda
for the specified intent
- * ipProto: specify ip protocol
+ * ipProto: specify ip protocol
* ipSrc: specify ip source address
* ipDst: specify ip destination address
* tcpSrc: specify tcp source port
* tcpDst: specify tcp destination port
Description:
- Adds a point-to-point intent (uni-directional) by
+ Adds a point-to-point intent ( uni-directional ) by
specifying device id's and optional fields
- NOTE: This function may change depending on the
+ NOTE: This function may change depending on the
options developers provide for point-to-point
intent via cli
- '''
+ """
try:
cmd = ""
- #If there are no optional arguments
+ # If there are no optional arguments
if not ethType and not ethSrc and not ethDst\
and not bandwidth and not lambda_alloc \
and not ipProto and not ipSrc and not ipDst \
and not tcpSrc and not tcpDst:
cmd = "add-point-intent"
-
else:
cmd = "add-point-intent"
-
+
if ethType:
- cmd += " --ethType " + str(ethType)
+ cmd += " --ethType " + str( ethType )
if ethSrc:
- cmd += " --ethSrc " + str(ethSrc)
- if ethDst:
- cmd += " --ethDst " + str(ethDst)
+ cmd += " --ethSrc " + str( ethSrc )
+ if ethDst:
+ cmd += " --ethDst " + str( ethDst )
if bandwidth:
- cmd += " --bandwidth " + str(bandwidth)
+ cmd += " --bandwidth " + str( bandwidth )
if lambda_alloc:
cmd += " --lambda "
if ipProto:
- cmd += " --ipProto " + str(ipProto)
+ cmd += " --ipProto " + str( ipProto )
if ipSrc:
- cmd += " --ipSrc " + str(ipSrc)
+ cmd += " --ipSrc " + str( ipSrc )
if ipDst:
- cmd += " --ipDst " + str(ipDst)
+ cmd += " --ipDst " + str( ipDst )
if tcpSrc:
- cmd += " --tcpSrc " + str(tcpSrc)
+ cmd += " --tcpSrc " + str( tcpSrc )
if tcpDst:
- cmd += " --tcpDst " + str(tcpDst)
+ cmd += " --tcpDst " + str( tcpDst )
- #Check whether the user appended the port
- #or provided it as an input
+ # Check whether the user appended the port
+ # or provided it as an input
if "/" in ingress_device:
- cmd += " "+str(ingress_device)
+ cmd += " " + str( ingress_device )
else:
if not port_ingress:
- main.log.error("You must specify "+
- "the ingress port")
- #TODO: perhaps more meaningful return
+ main.log.error( "You must specify " +
+ "the ingress port" )
+ # TODO: perhaps more meaningful return
return main.FALSE
- cmd += " "+ \
- str(ingress_device) + "/" +\
- str(port_ingress) + " "
+ cmd += " " + \
+ str( ingress_device ) + "/" +\
+ str( port_ingress ) + " "
if "/" in egress_device:
- cmd += " "+str(egress_device)
+ cmd += " " + str( egress_device )
else:
if not port_egress:
- main.log.error("You must specify "+
- "the egress port")
+ main.log.error( "You must specify " +
+ "the egress port" )
return main.FALSE
-
- cmd += " "+\
- str(egress_device) + "/" +\
- str(port_egress)
- self.handle.sendline(cmd)
-
- main.log.info(cmd + " sent")
- i = self.handle.expect([
- "Error",
- "onos>"])
+ cmd += " " +\
+ str( egress_device ) + "/" +\
+ str( port_egress )
- if i == 0:
- main.log.error("Error in adding point-to-point intent")
+ handle = self.sendline( cmd )
+ if re.search( "Error", handle ):
+ main.log.error( "Error in adding point-to-point intent" )
return main.FALSE
else:
return main.TRUE
-
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
-
- def add_multipoint_to_singlepoint_intent(self, ingress_device1, ingress_device2,egress_device,
- port_ingress="", port_egress="", ethType="", ethSrc="",
- ethDst="", bandwidth="", lambda_alloc=False,
- ipProto="", ipSrc="", ipDst="", tcpSrc="", tcpDst="", setEthSrc="", setEthDst=""):
- '''
+ def add_multipoint_to_singlepoint_intent(
+ self,
+ ingress_device1,
+ ingress_device2,
+ egress_device,
+ port_ingress="",
+ port_egress="",
+ ethType="",
+ ethSrc="",
+ ethDst="",
+ bandwidth="",
+ lambda_alloc=False,
+ ipProto="",
+ ipSrc="",
+ ipDst="",
+ tcpSrc="",
+ tcpDst="",
+ setEthSrc="",
+ setEthDst="" ):
+ """
Note:
- This function assumes that there would be 2 ingress devices and one egress device
- For more number of ingress devices, this function needs to be modified
+ This function assumes that there would be 2 ingress devices and
+ one egress device. For more number of ingress devices, this
+ function needs to be modified
Required:
* ingress_device1: device id of ingress device1
* ingress_device2: device id of ingress device2
* egress_device: device id of egress device
Optional:
* ethType: specify ethType
- * ethSrc: specify ethSrc (i.e. src mac addr)
- * ethDst: specify ethDst (i.e. dst mac addr)
+ * ethSrc: specify ethSrc ( i.e. src mac addr )
+ * ethDst: specify ethDst ( i.e. dst mac addr )
* bandwidth: specify bandwidth capacity of link
- * lambda_alloc: if True, intent will allocate lambda
+ * lambda_alloc: if True, intent will allocate lambda
for the specified intent
- * ipProto: specify ip protocol
+ * ipProto: specify ip protocol
* ipSrc: specify ip source address
* ipDst: specify ip destination address
* tcpSrc: specify tcp source port
@@ -1147,273 +1071,236 @@
* setEthSrc: action to Rewrite Source MAC Address
* setEthDst: action to Rewrite Destination MAC Address
Description:
- Adds a multipoint-to-singlepoint intent (uni-directional) by
+ Adds a multipoint-to-singlepoint intent ( uni-directional ) by
specifying device id's and optional fields
- NOTE: This function may change depending on the
+ NOTE: This function may change depending on the
options developers provide for multipointpoint-to-singlepoint
intent via cli
- '''
+ """
try:
cmd = ""
- #If there are no optional arguments
+ # If there are no optional arguments
if not ethType and not ethSrc and not ethDst\
- and not bandwidth and not lambda_alloc \
- and not ipProto and not ipSrc and not ipDst \
- and not tcpSrc and not tcpDst and not setEthSrc and not setEthDst:
+ and not bandwidth and not lambda_alloc\
+ and not ipProto and not ipSrc and not ipDst\
+ and not tcpSrc and not tcpDst and not setEthSrc\
+ and not setEthDst:
cmd = "add-multi-to-single-intent"
-
else:
cmd = "add-multi-to-single-intent"
-
+
if ethType:
- cmd += " --ethType " + str(ethType)
+ cmd += " --ethType " + str( ethType )
if ethSrc:
- cmd += " --ethSrc " + str(ethSrc)
- if ethDst:
- cmd += " --ethDst " + str(ethDst)
+ cmd += " --ethSrc " + str( ethSrc )
+ if ethDst:
+ cmd += " --ethDst " + str( ethDst )
if bandwidth:
- cmd += " --bandwidth " + str(bandwidth)
+ cmd += " --bandwidth " + str( bandwidth )
if lambda_alloc:
cmd += " --lambda "
if ipProto:
- cmd += " --ipProto " + str(ipProto)
+ cmd += " --ipProto " + str( ipProto )
if ipSrc:
- cmd += " --ipSrc " + str(ipSrc)
+ cmd += " --ipSrc " + str( ipSrc )
if ipDst:
- cmd += " --ipDst " + str(ipDst)
+ cmd += " --ipDst " + str( ipDst )
if tcpSrc:
- cmd += " --tcpSrc " + str(tcpSrc)
+ cmd += " --tcpSrc " + str( tcpSrc )
if tcpDst:
- cmd += " --tcpDst " + str(tcpDst)
+ cmd += " --tcpDst " + str( tcpDst )
if setEthSrc:
- cmd += " --setEthSrc "+ str(setEthSrc)
+ cmd += " --setEthSrc " + str( setEthSrc )
if setEthDst:
- cmd += " --setEthDst "+ str(setEthDst)
+ cmd += " --setEthDst " + str( setEthDst )
- #Check whether the user appended the port
- #or provided it as an input
+ # Check whether the user appended the port
+ # or provided it as an input
if "/" in ingress_device1:
- cmd += " "+str(ingress_device1)
+ cmd += " " + str( ingress_device1 )
else:
if not port_ingress1:
- main.log.error("You must specify "+
- "the ingress port1")
- #TODO: perhaps more meaningful return
+ main.log.error( "You must specify " +
+ "the ingress port1" )
+ # TODO: perhaps more meaningful return
return main.FALSE
- cmd += " "+ \
- str(ingress_device1) + "/" +\
- str(port_ingress1) + " "
+ cmd += " " + \
+ str( ingress_device1 ) + "/" +\
+ str( port_ingress1 ) + " "
if "/" in ingress_device2:
- cmd += " "+str(ingress_device2)
+ cmd += " " + str( ingress_device2 )
else:
if not port_ingress2:
- main.log.error("You must specify "+
- "the ingress port2")
- #TODO: perhaps more meaningful return
+ main.log.error( "You must specify " +
+ "the ingress port2" )
+ # TODO: perhaps more meaningful return
return main.FALSE
- cmd += " "+ \
- str(ingress_device2) + "/" +\
- str(port_ingress2) + " "
+ cmd += " " + \
+ str( ingress_device2 ) + "/" +\
+ str( port_ingress2 ) + " "
if "/" in egress_device:
- cmd += " "+str(egress_device)
+ cmd += " " + str( egress_device )
else:
if not port_egress:
- main.log.error("You must specify "+
- "the egress port")
+ main.log.error( "You must specify " +
+ "the egress port" )
return main.FALSE
-
- cmd += " "+\
- str(egress_device) + "/" +\
- str(port_egress)
- print "cmd= ",cmd
- self.handle.sendline(cmd)
-
- main.log.info(cmd + " sent")
- i = self.handle.expect([
- "Error",
- "onos>"])
- if i == 0:
- main.log.error("Error in adding point-to-point intent")
+ cmd += " " +\
+ str( egress_device ) + "/" +\
+ str( port_egress )
+ print "cmd= ", cmd
+ handle = self.sendline( cmd )
+ if re.search( "Error", handle ):
+ main.log.error( "Error in adding point-to-point intent" )
return self.handle
else:
return main.TRUE
-
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
-
- def remove_intent(self, intent_id):
- '''
+ def remove_intent( self, intent_id ):
+ """
Remove intent for specified intent id
- '''
+
+ Returns:
+ main.False on error and
+ cli output otherwise
+ """
try:
- self.handle.sendline("")
- self.handle.expect("onos>")
-
- self.handle.sendline("remove-intent "+str(intent_id))
- i = self.handle.expect([
- "Error",
- "onos>"])
-
- handle = self.handle.before
-
- if i == 0:
- main.log.error("Error in removing intent")
- return handle
+ cmd_str = "remove-intent " + str( intent_id )
+ handle = self.sendline( cmd_str )
+ if re.search( "Error", handle ):
+ main.log.error( "Error in removing intent" )
+ return main.FALSE
else:
- return handle
-
+ # TODO: Should this be main.TRUE
+ return handle
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
- # This method should be used after installing application: onos-app-sdnip
- def routes(self, json_format=False):
- '''
+ def routes( self, json_format=False ):
+ """
+ NOTE: This method should be used after installing application:
+ onos-app-sdnip
Optional:
* json_format: enable output formatting in json
Description:
Obtain all routes in the system
- '''
+ """
try:
if json_format:
- self.handle.sendline("routes -j")
- self.handle.expect("routes -j")
- self.handle.expect("onos>")
- handle_tmp = self.handle.before
-
- ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
- handle = ansi_escape.sub('', handle_tmp)
-
+ cmd_str = "routes -j"
+ handle_tmp = self.sendline( cmd_str )
+ ansi_escape = re.compile( r'\r\r\n\x1b[^m]*m' )
+ handle = ansi_escape.sub( '', handle_tmp )
else:
- self.handle.sendline("")
- self.handle.expect("onos>")
-
- self.handle.sendline("routes")
- self.handle.expect("onos>")
- handle = self.handle.before
-
+ cmd_str = "routes"
+ handle = self.sendline( cmd_str )
return handle
-
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name + " ::::::")
- main.log.error(traceback.print_exc())
- main.log.info(self.name + " ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
- def intents(self, json_format = True):
- '''
+ def intents( self, json_format=True ):
+ """
Optional:
* json_format: enable output formatting in json
Description:
- Obtain intents currently installed
- '''
+ Obtain intents currently installed
+ """
try:
if json_format:
- self.handle.sendline("intents -j")
- self.handle.expect("intents -j")
- self.handle.expect("onos>")
- handle = self.handle.before
-
- ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
- handle = ansi_escape.sub('', handle)
+ cmd_str = "intents -j"
+ handle = self.sendline( cmd_str )
+ ansi_escape = re.compile( r'\r\r\n\x1b[^m]*m' )
+ handle = ansi_escape.sub( '', handle )
else:
- self.handle.sendline("")
- self.handle.expect("onos>")
-
- self.handle.sendline("intents")
- self.handle.expect("onos>")
- handle = self.handle.before
-
+ cmd_str = "intents"
+ handle = self.sendline( cmd_str )
return handle
-
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
- def flows(self, json_format = True):
- '''
+ def flows( self, json_format=True ):
+ """
Optional:
* json_format: enable output formatting in json
Description:
- Obtain flows currently installed
- '''
+ Obtain flows currently installed
+ """
try:
if json_format:
- self.handle.sendline("flows -j")
- self.handle.expect("flows -j")
- self.handle.expect("onos>")
- handle = self.handle.before
- ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
- handle = ansi_escape.sub('', handle)
-
+ cmd_str = "flows -j"
+ handle = self.sendline( cmd_str )
+ ansi_escape = re.compile( r'\r\r\n\x1b[^m]*m' )
+ handle = ansi_escape.sub( '', handle )
else:
- self.handle.sendline("")
- self.handle.expect("onos>")
- self.handle.sendline("flows")
- self.handle.expect("onos>")
- handle = self.handle.before
- if re.search("Error\sexecuting\scommand:", handle):
- main.log.error(self.name + ".flows() response: " + str(handle))
-
+ cmd_str = "flows"
+ handle = self.sendline( cmd_str )
+ if re.search( "Error\sexecuting\scommand:", handle ):
+ main.log.error( self.name + ".flows() response: " +
+ str( handle ) )
return handle
-
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
- def push_test_intents(self, dpid_src, dpid_dst, num_intents,
- num_mult="", app_id="", report=True):
- '''
+ def push_test_intents( self, dpid_src, dpid_dst, num_intents,
+ num_mult="", app_id="", report=True ):
+ """
Description:
- Push a number of intents in a batch format to
+ Push a number of intents in a batch format to
a specific point-to-point intent definition
Required:
* dpid_src: specify source dpid
@@ -1425,310 +1312,280 @@
* app_id: specify the application id init to further
modularize the intents
* report: default True, returns latency information
- '''
+ """
try:
- cmd = "push-test-intents "+\
- str(dpid_src)+" "+str(dpid_dst)+" "+\
- str(num_intents)
-
+ cmd = "push-test-intents " +\
+ str( dpid_src ) + " " + str( dpid_dst ) + " " +\
+ str( num_intents )
if num_mult:
- cmd += " " + str(num_mult)
- #If app id is specified, then num_mult
- #must exist because of the way this command
+ cmd += " " + str( num_mult )
+ # If app id is specified, then num_mult
+ # must exist because of the way this command
#takes in arguments
if app_id:
- cmd += " " + str(app_id)
-
- self.handle.sendline(cmd)
- self.handle.expect(cmd)
- self.handle.expect("onos>")
-
- handle = self.handle.before
-
- #Some color thing that we want to escape
- ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
- handle = ansi_escape.sub('', handle)
-
+ cmd += " " + str( app_id )
+ handle = self.sendline( cmd )
+ # Some color thing that we want to escape
+ ansi_escape = re.compile( r'\r\r\n\x1b[^m]*m' )
+ handle = ansi_escape.sub( '', handle )
if report:
lat_result = []
- main.log.info(handle)
- #Split result by newline
- newline = handle.split("\r\r\n")
- #Ignore the first object of list, which is empty
- newline = newline[1:]
- #Some sloppy parsing method to get the latency
+ main.log.info( handle )
+ # Split result by newline
+ newline = handle.split( "\r\r\n" )
+ # Ignore the first object of list, which is empty
+ newline = newline[ 1: ]
+ # Some sloppy parsing method to get the latency
for result in newline:
- result = result.split(": ")
- #Append the first result of second parse
- lat_result.append(result[1].split(" ")[0])
-
- main.log.info(lat_result)
- return lat_result
+ result = result.split( ": " )
+ # Append the first result of second parse
+ lat_result.append( result[ 1 ].split( " " )[ 0 ] )
+ main.log.info( lat_result )
+ return lat_result
else:
return main.TRUE
-
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
- def intents_events_metrics(self, json_format=True):
- '''
- Description:Returns topology metrics
+ def intents_events_metrics( self, json_format=True ):
+ """
+ Description:Returns topology metrics
Optional:
* json_format: enable json formatting of output
- '''
+ """
try:
if json_format:
- self.handle.sendline("intents-events-metrics -j")
- self.handle.expect("intents-events-metrics -j")
- self.handle.expect("onos>")
-
- handle = self.handle.before
-
- #Some color thing that we want to escape
- ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
- handle = ansi_escape.sub('', handle)
-
+ cmd_str = "intents-events-metrics -j"
+ handle = self.sendline( cmd_str )
+ # Some color thing that we want to escape
+ ansi_escape = re.compile( r'\r\r\n\x1b[^m]*m' )
+ handle = ansi_escape.sub( '', handle )
else:
- self.handle.sendline("intents-events-metrics")
- self.handle.expect("intents-events-metrics")
- self.handle.expect("onos>")
-
- handle = self.handle.before
-
+ cmd_str = "intents-events-metrics"
+ handle = self.sendline( cmd_str )
return handle
-
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
- def topology_events_metrics(self, json_format=True):
- '''
- Description:Returns topology metrics
+ def topology_events_metrics( self, json_format=True ):
+ """
+ Description:Returns topology metrics
Optional:
* json_format: enable json formatting of output
- '''
+ """
try:
if json_format:
- self.handle.sendline("topology-events-metrics -j")
- self.handle.expect("topology-events-metrics -j")
- self.handle.expect("onos>")
-
- handle = self.handle.before
-
- #Some color thing that we want to escape
- ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
- handle = ansi_escape.sub('', handle)
-
+ cmd_str = "topology-events-metrics -j"
+ handle = self.sendline( cmd_str )
+ # Some color thing that we want to escape
+ ansi_escape = re.compile( r'\r\r\n\x1b[^m]*m' )
+ handle = ansi_escape.sub( '', handle )
else:
- self.handle.sendline("topology-events-metrics")
- self.handle.expect("topology-events-metrics")
- self.handle.expect("onos>")
-
- handle = self.handle.before
-
+ cmd_str = "topology-events-metrics"
+ handle = self.sendline( cmd_str )
return handle
-
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
- #Wrapper functions ****************
- #Wrapper functions use existing driver
- #functions and extends their use case.
- #For example, we may use the output of
- #a normal driver function, and parse it
- #using a wrapper function
+ # Wrapper functions ****************
+ # Wrapper functions use existing driver
+ # functions and extends their use case.
+ # For example, we may use the output of
+ # a normal driver function, and parse it
+ # using a wrapper function
- def get_all_intents_id(self):
- '''
+ def get_all_intents_id( self ):
+ """
Description:
Obtain all intent id's in a list
- '''
+ """
try:
- #Obtain output of intents function
+ # Obtain output of intents function
intents_str = self.intents()
all_intent_list = []
intent_id_list = []
- #Parse the intents output for ID's
- intents_list = [s.strip() for s in intents_str.splitlines()]
+ # Parse the intents output for ID's
+ intents_list = [ s.strip() for s in intents_str.splitlines() ]
for intents in intents_list:
if "onos>" in intents:
continue
elif "intents" in intents:
continue
else:
- line_list = intents.split(" ")
- all_intent_list.append(line_list[0])
-
- all_intent_list = all_intent_list[1:-2]
+ line_list = intents.split( " " )
+ all_intent_list.append( line_list[ 0 ] )
+
+ all_intent_list = all_intent_list[ 1:-2 ]
for intents in all_intent_list:
if not intents:
continue
else:
- intent_id_list.append(intents)
+ intent_id_list.append( intents )
return intent_id_list
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
- def get_all_devices_id(self):
- '''
+ def get_all_devices_id( self ):
+ """
Use 'devices' function to obtain list of all devices
and parse the result to obtain a list of all device
id's. Returns this list. Returns empty list if no
devices exist
- List is ordered sequentially
-
+ List is ordered sequentially
+
This function may be useful if you are not sure of the
- device id, and wish to execute other commands using
+ device id, and wish to execute other commands using
the ids. By obtaining the list of device ids on the fly,
you can iterate through the list to get mastership, etc.
- '''
+ """
try:
- #Call devices and store result string
- devices_str = self.devices(json_format=False)
+ # Call devices and store result string
+ devices_str = self.devices( json_format=False )
id_list = []
-
+
if not devices_str:
- main.log.info("There are no devices to get id from")
+ main.log.info( "There are no devices to get id from" )
return id_list
-
- #Split the string into list by comma
- device_list = devices_str.split(",")
- #Get temporary list of all arguments with string 'id='
- temp_list = [dev for dev in device_list if "id=" in dev]
- #Split list further into arguments before and after string
- # 'id='. Get the latter portion (the actual device id) and
+
+ # Split the string into list by comma
+ device_list = devices_str.split( "," )
+ # Get temporary list of all arguments with string 'id='
+ temp_list = [ dev for dev in device_list if "id=" in dev ]
+ # Split list further into arguments before and after string
+ # 'id='. Get the latter portion ( the actual device id ) and
# append to id_list
for arg in temp_list:
- id_list.append(arg.split("id=")[1])
+ id_list.append( arg.split( "id=" )[ 1 ] )
return id_list
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
- def get_all_nodes_id(self):
- '''
+ def get_all_nodes_id( self ):
+ """
Uses 'nodes' function to obtain list of all nodes
and parse the result of nodes to obtain just the
- node id's.
+ node id's.
Returns:
list of node id's
- '''
+ """
try:
nodes_str = self.nodes()
id_list = []
if not nodes_str:
- main.log.info("There are no nodes to get id from")
+ main.log.info( "There are no nodes to get id from" )
return id_list
- #Sample nodes_str output
- #id=local, address=127.0.0.1:9876, state=ACTIVE *
+ # Sample nodes_str output
+ # id=local, address=127.0.0.1:9876, state=ACTIVE *
- #Split the string into list by comma
- nodes_list = nodes_str.split(",")
- temp_list = [node for node in nodes_list if "id=" in node]
+ # Split the string into list by comma
+ nodes_list = nodes_str.split( "," )
+ temp_list = [ node for node in nodes_list if "id=" in node ]
for arg in temp_list:
- id_list.append(arg.split("id=")[1])
+ id_list.append( arg.split( "id=" )[ 1 ] )
return id_list
-
+
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
- def get_device(self, dpid=None):
- '''
+ def get_device( self, dpid=None ):
+ """
Return the first device from the devices api whose 'id' contains 'dpid'
Return None if there is no match
- '''
+ """
import json
try:
- if dpid == None:
+ if dpid is None:
return None
else:
- dpid = dpid.replace(':', '')
+ dpid = dpid.replace( ':', '' )
raw_devices = self.devices()
- devices_json = json.loads(raw_devices)
- #search json for the device with dpid then return the device
+ devices_json = json.loads( raw_devices )
+ # search json for the device with dpid then return the device
for device in devices_json:
- #print "%s in %s?" % (dpid, device['id'])
- if dpid in device['id']:
+ # print "%s in %s?" % ( dpid, device[ 'id' ] )
+ if dpid in device[ 'id' ]:
return device
return None
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
- def check_status(self, ip, numoswitch, numolink, log_level="info"):
- '''
- Checks the number of swithes & links that ONOS sees against the
- supplied values. By default this will report to main.log, but the
+ def check_status( self, ip, numoswitch, numolink, log_level="info" ):
+ """
+ Checks the number of swithes & links that ONOS sees against the
+ supplied values. By default this will report to main.log, but the
log level can be specifid.
-
+
Params: ip = ip used for the onos cli
numoswitch = expected number of switches
numlink = expected number of links
@@ -1737,380 +1594,339 @@
log_level can
- Returns: main.TRUE if the number of switchs and links are correct,
+ Returns: main.TRUE if the number of switchs and links are correct,
main.FALSE if the numer of switches and links is incorrect,
and main.ERROR otherwise
- '''
-
+ """
try:
- topology = self.get_topology(ip)
+ topology = self.get_topology( ip )
if topology == {}:
return main.ERROR
output = ""
- #Is the number of switches is what we expected
- devices = topology.get('devices',False)
- links = topology.get('links',False)
+ # Is the number of switches is what we expected
+ devices = topology.get( 'devices', False )
+ links = topology.get( 'links', False )
if devices == False or links == False:
return main.ERROR
- switch_check = ( int(devices) == int(numoswitch) )
- #Is the number of links is what we expected
- link_check = ( int(links) == int(numolink) )
- if (switch_check and link_check):
- #We expected the correct numbers
+ switch_check = ( int( devices ) == int( numoswitch ) )
+ # Is the number of links is what we expected
+ link_check = ( int( links ) == int( numolink ) )
+ if ( switch_check and link_check ):
+ # We expected the correct numbers
output = output + "The number of links and switches match "\
- + "what was expected"
+ + "what was expected"
result = main.TRUE
else:
output = output + \
- "The number of links and switches does not match what was expected"
+ "The number of links and switches does not match what was expected"
result = main.FALSE
- output = output + "\n ONOS sees %i devices (%i expected) and %i links (%i expected)"\
- % ( int(devices), int(numoswitch), int(links), int(numolink) )
+ output = output + "\n ONOS sees %i devices (%i expected) and %i links (%i expected)" % (
+ int( devices ), int( numoswitch ), int( links ), int( numolink ) )
if log_level == "report":
- main.log.report(output)
+ main.log.report( output )
elif log_level == "warn":
- main.log.warn(output)
+ main.log.warn( output )
else:
- main.log.info(output)
- return result
+ main.log.info( output )
+ return result
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
- def device_role(self, device_id, onos_node, role="master"):
- '''
+ def device_role( self, device_id, onos_node, role="master" ):
+ """
Calls the device-role cli command.
device_id must be the id of a device as seen in the onos devices command
onos_node is the ip of one of the onos nodes in the cluster
role must be either master, standby, or none
- Returns main.TRUE or main.FALSE based on argument verification.
- When device-role supports errors this should be extended to
- support that output
- '''
+ Returns:
+ main.TRUE or main.FALSE based on argument verification and
+ main.ERROR if command returns and error
+ """
try:
- #print "beginning device_role... \n\tdevice_id:" + device_id
- #print "\tonos_node: " + onos_node
- #print "\trole: "+ role
- if role.lower() == "master" or \
- role.lower() == "standby" or \
+ if role.lower() == "master" or role.lower() == "standby" or\
role.lower() == "none":
- self.handle.sendline("")
- self.handle.expect("onos>")
- self.handle.sendline("device-role " +
- str(device_id) + " " +
- str(onos_node) + " " +
- str(role))
- i= self.handle.expect(["Error","onos>"])
- if i == 0:
- output = str(self.handle.before)
- self.handle.expect("onos>")
- output = output + str(self.handle.before)
- main.log.error(self.name + ": " +
- output + '\033[0m')#end color output to escape any colours from the cli
- return main.ERROR
- self.handle.sendline("")
- self.handle.expect("onos>")
- return main.TRUE
+ cmd_str = "device-role " +\
+ str( device_id ) + " " +\
+ str( onos_node ) + " " +\
+ str( role )
+ handle = self.sendline( cmd_str )
+ if re.search( "Error", handle ):
+ # end color output to escape any colours
+ # from the cli
+ main.log.error( self.name + ": " +
+ handle + '\033[0m' )
+ return main.ERROR
+ return main.TRUE
else:
+ main.log.error( "Invalid 'role' given to device_role(). " +
+ "Value was '" + str(role) + "'." )
return main.FALSE
-
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
- def clusters(self, json_format=True):
- '''
+ def clusters( self, json_format=True ):
+ """
Lists all clusters
Optional argument:
* json_format - boolean indicating if you want output in json
- '''
+ """
try:
- self.handle.sendline("")
- self.handle.expect("onos>")
-
if json_format:
- self.handle.sendline("clusters -j")
- self.handle.expect("clusters -j")
- self.handle.expect("onos>")
- handle = self.handle.before
- '''
+ cmd_str = "clusters -j"
+ handle = self.sendline( cmd_str )
+ """
handle variable here contains some ANSI escape color code
sequences at the end which are invisible in the print command
- output. To make that escape sequence visible, use repr() function.
- The repr(handle) output when printed shows the ANSI escape sequences.
- In json.loads(somestring), this somestring variable is actually
- repr(somestring) and json.loads would fail with the escape sequence.
- So we take off that escape sequence using
- ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
- handle1 = ansi_escape.sub('', handle)
- '''
- #print "repr(handle) =", repr(handle)
- ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
- handle1 = ansi_escape.sub('', handle)
- #print "repr(handle1) = ", repr(handle1)
+ output. To make that escape sequence visible, use repr()
+ function. The repr( handle ) output when printed shows the ANSI
+ escape sequences. In json.loads( somestring ), this somestring
+ variable is actually repr( somestring ) and json.loads would fail
+ with the escape sequence. So we take off that escape sequence
+ using:
+
+ ansi_escape = re.compile( r'\r\r\n\x1b[^m]*m' )
+ handle1 = ansi_escape.sub( '', handle )
+ """
+ ansi_escape = re.compile( r'\r\r\n\x1b[^m]*m' )
+ handle1 = ansi_escape.sub( '', handle )
return handle1
else:
- self.handle.sendline("clusters")
- self.handle.expect("onos>")
- handle = self.handle.before
- #print "handle =",handle
+ cmd_str = "clusters"
+ handle = self.sendline( cmd_str )
return handle
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
- def election_test_leader(self):
- '''
- * CLI command to get the current leader for the Election test application.
- #NOTE: Requires installation of the onos-app-election feature
- Returns: Node IP of the leader if one exists
- None if none exists
- Main.FALSE on error
- '''
+ def election_test_leader( self ):
+ """
+ CLI command to get the current leader for the Election test application
+ NOTE: Requires installation of the onos-app-election feature
+ Returns: Node IP of the leader if one exists
+ None if none exists
+ Main.FALSE on error
+ """
try:
- self.handle.sendline("election-test-leader")
- self.handle.expect("election-test-leader")
- self.handle.expect("onos>")
- response = self.handle.before
- #Leader
- node_search = re.search("The\scurrent\sleader\sfor\sthe\sElection\sapp\sis\s(?P<node>.+)\.", response)
+ cmd_str = "election-test-leader"
+ response = self.sendline( cmd_str )
+ # Leader
+ leaderPattern = "The\scurrent\sleader\sfor\sthe\sElection\s" +\
+ "app\sis\s(?P<node>.+)\."
+ node_search = re.search( leaderPattern, response )
if node_search:
- node = node_search.group('node')
- main.log.info("Election-test-leader on "+str(self.name)+" found " + node + " as the leader")
+ node = node_search.group( 'node' )
+ main.log.info( "Election-test-leader on " + str( self.name ) +
+ " found " + node + " as the leader" )
return node
- #no leader
- null_search = re.search("There\sis\scurrently\sno\sleader\selected\sfor\sthe\sElection\sapp", response)
+ # no leader
+ nullPattern = "There\sis\scurrently\sno\sleader\selected\sfor\s" +\
+ "the\sElection\sapp"
+ null_search = re.search( nullPattern, response )
if null_search:
- main.log.info("Election-test-leader found no leader on " + self.name )
+ main.log.info( "Election-test-leader found no leader on " +
+ self.name )
return None
- #error
- if re.search("Command\snot\sfound", response):
- main.log.error("Election app is not loaded on " + self.name)
+ # error
+ errorPattern = "Command\snot\sfound"
+ if re.search( errorPattern, response ):
+ main.log.error( "Election app is not loaded on " + self.name )
+ # TODO: Should this be main.ERROR?
return main.FALSE
else:
- main.log.error("Error in election_test_leader: unexpected response")
- main.log.error( repr(response) )
+ main.log.error( "Error in election_test_leader: " +
+ "unexpected response" )
+ main.log.error( repr( response ) )
return main.FALSE
-
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
- def election_test_run(self):
- '''
- * CLI command to run for leadership of the Election test application.
- #NOTE: Requires installation of the onos-app-election feature
- Returns: Main.TRUE on success
- Main.FALSE on error
- '''
+ def election_test_run( self ):
+ """
+ CLI command to run for leadership of the Election test application.
+ NOTE: Requires installation of the onos-app-election feature
+ Returns: Main.TRUE on success
+ Main.FALSE on error
+ """
try:
- self.handle.sendline("election-test-run")
- self.handle.expect("election-test-run")
- self.handle.expect("onos>")
- response = self.handle.before
- #success
- search = re.search("Entering\sleadership\selections\sfor\sthe\sElection\sapp.", response)
+ cmd_str = "election-test-run"
+ response = self.sendline( cmd_str )
+ # success
+ successPattern = "Entering\sleadership\selections\sfor\sthe\s" +\
+ "Election\sapp."
+ search = re.search( successPattern, response )
if search:
- main.log.info(self.name + " entering leadership elections for the Election app.")
+ main.log.info( self.name + " entering leadership elections " +
+ "for the Election app." )
return main.TRUE
- #error
- if re.search("Command\snot\sfound", response):
- main.log.error("Election app is not loaded on " + self.name)
+ # error
+ errorPattern = "Command\snot\sfound"
+ if re.search( errorPattern, response ):
+ main.log.error( "Election app is not loaded on " + self.name )
return main.FALSE
else:
- main.log.error("Error in election_test_run: unexpected response")
- main.log.error( repr(response) )
+ main.log.error( "Error in election_test_run: " +
+ "unexpected response" )
+ main.log.error( repr( response ) )
return main.FALSE
-
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
- def election_test_withdraw(self):
- '''
+ def election_test_withdraw( self ):
+ """
* CLI command to withdraw the local node from leadership election for
* the Election test application.
#NOTE: Requires installation of the onos-app-election feature
Returns: Main.TRUE on success
Main.FALSE on error
- '''
+ """
try:
- self.handle.sendline("election-test-withdraw")
- self.handle.expect("election-test-withdraw")
- self.handle.expect("onos>")
- response = self.handle.before
- #success
- search = re.search("Withdrawing\sfrom\sleadership\selections\sfor\sthe\sElection\sapp.", response)
- if search:
- main.log.info(self.name + " withdrawing from leadership elections for the Election app.")
+ cmd_str = "election-test-withdraw"
+ response = self.sendline( cmd_str )
+ # success
+ successPattern = "Withdrawing\sfrom\sleadership\selections\sfor" +\
+ "\sthe\sElection\sapp."
+ if re.search( successPattern, response ):
+ main.log.info( self.name + " withdrawing from leadership " +
+ "elections for the Election app." )
return main.TRUE
- #error
- if re.search("Command\snot\sfound", response):
- main.log.error("Election app is not loaded on " + self.name)
+ # error
+ errorPattern = "Command\snot\sfound"
+ if re.search( errorPattern, response ):
+ main.log.error( "Election app is not loaded on " + self.name )
return main.FALSE
else:
- main.log.error("Error in election_test_withdraw: unexpected response")
- main.log.error( repr(response) )
+ main.log.error( "Error in election_test_withdraw: " +
+ "unexpected response" )
+ main.log.error( repr( response ) )
return main.FALSE
-
-
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
#***********************************
- def getDevicePortsEnabledCount(self,dpid):
- '''
+ def getDevicePortsEnabledCount( self, dpid ):
+ """
Get the count of all enabled ports on a particular device/switch
- '''
+ """
try:
- dpid = str(dpid)
- self.handle.sendline("")
- self.handle.expect("onos>")
-
- self.handle.sendline("onos:ports -e "+dpid+" | wc -l")
- i = self.handle.expect([
- "No such device",
- "onos>"])
-
- #self.handle.sendline("")
- #self.handle.expect("onos>")
-
- output = self.handle.before
-
- if i == 0:
- main.log.error("Error in getting ports")
- return (output, "Error")
+ dpid = str( dpid )
+ cmd_str = "onos:ports -e " + dpid + " | wc -l"
+ output = self.sendline( cmd_str )
+ if re.search( "No such device", output ):
+ main.log.error( "Error in getting ports" )
+ return ( output, "Error" )
else:
- result = output
- return result
-
+ return output
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
- def getDeviceLinksActiveCount(self,dpid):
- '''
+ def getDeviceLinksActiveCount( self, dpid ):
+ """
Get the count of all enabled ports on a particular device/switch
- '''
+ """
try:
- dpid = str(dpid)
- self.handle.sendline("")
- self.handle.expect("onos>")
-
- self.handle.sendline("onos:links "+dpid+" | grep ACTIVE | wc -l")
- i = self.handle.expect([
- "No such device",
- "onos>"])
-
- output = self.handle.before
-
- if i == 0:
- main.log.error("Error in getting ports")
- return (output, "Error")
+ dpid = str( dpid )
+ cmd_str = "onos:links " + dpid + " | grep ACTIVE | wc -l"
+ output = self.sendline( cmd_str )
+ if re.search( "No such device", output ):
+ main.log.error( "Error in getting ports " )
+ return ( output, "Error " )
else:
- result = output
- return result
-
+ return output
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
- def getAllIntentIds(self):
- '''
+ def getAllIntentIds( self ):
+ """
Return a list of all Intent IDs
- '''
+ """
try:
- self.handle.sendline("")
- self.handle.expect("onos>")
-
- self.handle.sendline("onos:intents | grep id=")
- i = self.handle.expect([
- "Error",
- "onos>"])
-
- output = self.handle.before
-
- if i == 0:
- main.log.error("Error in getting ports")
- return (output, "Error")
+ cmd_str = "onos:intents | grep id="
+ output = self.sendline( cmd_str )
+ if re.search( "Error", output ):
+ main.log.error( "Error in getting ports" )
+ return ( output, "Error" )
else:
- result = output
- return result
-
+ return output
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
diff --git a/TestON/drivers/common/cli/onosdriver.py b/TestON/drivers/common/cli/onosdriver.py
index c8713e5..d671f48 100644
--- a/TestON/drivers/common/cli/onosdriver.py
+++ b/TestON/drivers/common/cli/onosdriver.py
@@ -1,10 +1,10 @@
#!/usr/bin/env python
-'''
-This driver interacts with ONOS bench, the OSGi platform
-that configures the ONOS nodes. (aka ONOS-next)
+"""
+This driver interacts with ONOS bench, the OSGi platform
+that configures the ONOS nodes. ( aka ONOS-next )
-Please follow the coding style demonstrated by existing
+Please follow the coding style demonstrated by existing
functions and document properly.
If you are a contributor to the driver, please
@@ -15,125 +15,126 @@
OCT 9 2014
-'''
-
+"""
import sys
import time
import pexpect
import traceback
import os.path
-sys.path.append("../")
+sys.path.append( "../" )
from drivers.common.clidriver import CLI
-class OnosDriver(CLI):
- def __init__(self):
- '''
- Initialize client
- '''
- super(CLI, self).__init__()
+class OnosDriver( CLI ):
- def connect(self,**connectargs):
- '''
+ def __init__( self ):
+ """
+ Initialize client
+ """
+ super( CLI, self ).__init__()
+
+ def connect( self, **connectargs ):
+ """
Creates ssh handle for ONOS "bench".
- '''
+ """
try:
for key in connectargs:
- vars(self)[key] = connectargs[key]
+ vars( self )[ key ] = connectargs[ key ]
self.home = "~/ONOS"
for key in self.options:
if key == "home":
- self.home = self.options['home']
+ self.home = self.options[ 'home' ]
break
+ self.name = self.options[ 'name' ]
+ self.handle = super( OnosDriver, self ).connect(
+ user_name=self.user_name,
+ ip_address=self.ip_address,
+ port=self.port,
+ pwd=self.pwd,
+ home=self.home )
- self.name = self.options['name']
- self.handle = super(OnosDriver,self).connect(
- user_name = self.user_name,
- ip_address = self.ip_address,
- port = self.port,
- pwd = self.pwd,
- home = self.home)
-
- self.handle.sendline("cd "+ self.home)
- self.handle.expect("\$")
+ self.handle.sendline( "cd " + self.home )
+ self.handle.expect( "\$" )
if self.handle:
return self.handle
- else :
- main.log.info("NO ONOS HANDLE")
+ else:
+ main.log.info( "NO ONOS HANDLE" )
return main.FALSE
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name + ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::")
+ main.log.info(
+ self.name +
+ ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" )
main.log.error( traceback.print_exc() )
- main.log.info(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::")
+ main.log.info(
+ ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" )
main.cleanup()
main.exit()
- def disconnect(self):
- '''
+ def disconnect( self ):
+ """
Called when Test is complete to disconnect the ONOS handle.
- '''
+ """
response = ''
try:
- self.handle.sendline("")
- self.handle.expect("\$")
- self.handle.sendline("exit")
- self.handle.expect("closed")
+ self.handle.sendline( "" )
+ self.handle.expect( "\$" )
+ self.handle.sendline( "exit" )
+ self.handle.expect( "closed" )
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
except:
- main.log.error(self.name + ": Connection failed to the host")
+ main.log.error( self.name + ": Connection failed to the host" )
response = main.FALSE
return response
- def onos_package(self):
- '''
+ def onos_package( self ):
+ """
Produce a self-contained tar.gz file that can be deployed
- and executed on any platform with Java 7 JRE.
- '''
-
+ and executed on any platform with Java 7 JRE.
+ """
try:
- self.handle.sendline("onos-package")
- self.handle.expect("onos-package")
- self.handle.expect("tar.gz",timeout=30)
- handle = str(self.handle.before)
- main.log.info("onos-package command returned: "+
- handle)
- #As long as the sendline does not time out,
- #return true. However, be careful to interpret
- #the results of the onos-package command return
+ self.handle.sendline( "onos-package" )
+ self.handle.expect( "onos-package" )
+ self.handle.expect( "tar.gz", timeout=30 )
+ handle = str( self.handle.before )
+ main.log.info( "onos-package command returned: " +
+ handle )
+ # As long as the sendline does not time out,
+ # return true. However, be careful to interpret
+ # the results of the onos-package command return
return main.TRUE
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
except:
- main.log.error("Failed to package ONOS")
+ main.log.error( "Failed to package ONOS" )
main.cleanup()
main.exit()
- def onos_build(self):
- '''
+ def onos_build( self ):
+ """
Use the pre defined script to build onos via mvn
- '''
-
+ """
try:
- self.handle.sendline("onos-build")
- self.handle.expect("onos-build")
- i = self.handle.expect([
- "BUILD SUCCESS",
- "ERROR",
- "BUILD FAILED"], timeout=120)
- handle = str(self.handle.before)
+ self.handle.sendline( "onos-build" )
+ self.handle.expect( "onos-build" )
+ i = self.handle.expect( [
+ "BUILD SUCCESS",
+ "ERROR",
+ "BUILD FAILED" ],
+ timeout=120 )
+ handle = str( self.handle.before )
- main.log.info("onos-build command returned: "+
- handle)
+ main.log.info( "onos-build command returned: " +
+ handle )
if i == 0:
return main.TRUE
@@ -141,862 +142,920 @@
return handle
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
except:
- main.log.error("Failed to build ONOS")
+ main.log.error( "Failed to build ONOS" )
main.cleanup()
main.exit()
- def clean_install(self):
- '''
- Runs mvn clean install in the root of the ONOS directory.
- This will clean all ONOS artifacts then compile each module
+ def clean_install( self ):
+ """
+ Runs mvn clean install in the root of the ONOS directory.
+ This will clean all ONOS artifacts then compile each module
- Returns: main.TRUE on success
+ Returns: main.TRUE on success
On Failure, exits the test
- '''
+ """
try:
- main.log.info("Running 'mvn clean install' on " + str(self.name) +
- ". This may take some time.")
- self.handle.sendline("cd "+ self.home)
- self.handle.expect("\$")
+ main.log.info( "Running 'mvn clean install' on " + str( self.name ) +
+ ". This may take some time." )
+ self.handle.sendline( "cd " + self.home )
+ self.handle.expect( "\$" )
- self.handle.sendline("")
- self.handle.expect("\$")
- self.handle.sendline("mvn clean install")
- self.handle.expect("mvn clean install")
- while 1:
- i=self.handle.expect([
+ self.handle.sendline( "" )
+ self.handle.expect( "\$" )
+ self.handle.sendline( "mvn clean install" )
+ self.handle.expect( "mvn clean install" )
+ while True:
+ i = self.handle.expect( [
'There\sis\sinsufficient\smemory\sfor\sthe\sJava\s\
Runtime\sEnvironment\sto\scontinue',
'BUILD\sFAILURE',
'BUILD\sSUCCESS',
'ONOS\$',
- pexpect.TIMEOUT],timeout=600)
+ pexpect.TIMEOUT ], timeout=600 )
if i == 0:
- main.log.error(self.name + ":There is insufficient memory \
- for the Java Runtime Environment to continue.")
- #return main.FALSE
+ main.log.error( self.name + ":There is insufficient memory \
+ for the Java Runtime Environment to continue." )
+ # return main.FALSE
main.cleanup()
main.exit()
if i == 1:
- main.log.error(self.name + ": Build failure!")
- #return main.FALSE
+ main.log.error( self.name + ": Build failure!" )
+ # return main.FALSE
main.cleanup()
main.exit()
elif i == 2:
- main.log.info(self.name + ": Build success!")
+ main.log.info( self.name + ": Build success!" )
elif i == 3:
- main.log.info(self.name + ": Build complete")
- #Print the build time
+ main.log.info( self.name + ": Build complete" )
+ # Print the build time
for line in self.handle.before.splitlines():
if "Total time:" in line:
- main.log.info(line)
- self.handle.sendline("")
- self.handle.expect("\$", timeout=60)
+ main.log.info( line )
+ self.handle.sendline( "" )
+ self.handle.expect( "\$", timeout=60 )
return main.TRUE
elif i == 4:
- main.log.error(self.name + ": mvn clean install TIMEOUT!")
- #return main.FALSE
+ main.log.error(
+ self.name +
+ ": mvn clean install TIMEOUT!" )
+ # return main.FALSE
main.cleanup()
main.exit()
else:
- main.log.error(self.name + ": unexpected response from \
- mvn clean install")
- #return main.FALSE
+ main.log.error( self.name + ": unexpected response from \
+ mvn clean install" )
+ # return main.FALSE
main.cleanup()
main.exit()
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name + ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::")
+ main.log.info(
+ self.name +
+ ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" )
main.log.error( traceback.print_exc() )
- main.log.info(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::")
+ main.log.info(
+ ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" )
main.cleanup()
main.exit()
- def git_pull(self, comp1=""):
- '''
+ def git_pull( self, comp1="" ):
+ """
Assumes that "git pull" works without login
This function will perform a git pull on the ONOS instance.
- If used as git_pull("NODE") it will do git pull + NODE. This is
+ If used as git_pull( "NODE" ) it will do git pull + NODE. This is
for the purpose of pulling from other nodes if necessary.
Otherwise, this function will perform a git pull in the
ONOS repository. If it has any problems, it will return main.ERROR
- If it successfully does a git_pull, it will return a 1 (main.TRUE)
+ If it successfully does a git_pull, it will return a 1 ( main.TRUE )
If it has no updates, it will return 3.
- '''
+ """
try:
- # main.log.info(self.name + ": Stopping ONOS")
- #self.stop()
- self.handle.sendline("cd " + self.home)
- self.handle.expect("ONOS\$")
- if comp1=="":
- self.handle.sendline("git pull")
+ # main.log.info( self.name + ": Stopping ONOS" )
+ # self.stop()
+ self.handle.sendline( "cd " + self.home )
+ self.handle.expect( "ONOS\$" )
+ if comp1 == "":
+ self.handle.sendline( "git pull" )
else:
- self.handle.sendline("git pull " + comp1)
+ self.handle.sendline( "git pull " + comp1 )
- i=self.handle.expect(['fatal',
- 'Username\sfor\s(.*):\s',
- '\sfile(s*) changed,\s',
- 'Already up-to-date',
- 'Aborting',
- 'You\sare\snot\scurrently\son\sa\sbranch',
- 'You\sasked\sme\sto\spull\swithout\stelling\sme\swhich\sbranch\syou',
- 'Pull\sis\snot\spossible\sbecause\syou\shave\sunmerged\sfiles',
- pexpect.TIMEOUT],
- timeout=300)
- #debug
- #main.log.report(self.name +": DEBUG: \n"+"git pull response: " + str(self.handle.before) + str(self.handle.after))
- if i==0:
- main.log.error(self.name + ": Git pull had some issue...")
+ i = self.handle.expect( [ 'fatal',
+ 'Username\sfor\s(.*):\s',
+ '\sfile(s*) changed,\s',
+ 'Already up-to-date',
+ 'Aborting',
+ 'You\sare\snot\scurrently\son\sa\sbranch',
+ 'You\sasked\sme\sto\spull\swithout\stelling\sme\swhich\sbranch\syou',
+ 'Pull\sis\snot\spossible\sbecause\syou\shave\sunmerged\sfiles',
+ pexpect.TIMEOUT ],
+ timeout=300 )
+ # debug
+ # main.log.report( self.name +": DEBUG: \n"+"git pull response: " +
+ # str( self.handle.before ) + str( self.handle.after ) )
+ if i == 0:
+ main.log.error( self.name + ": Git pull had some issue..." )
return main.ERROR
- elif i==1:
- main.log.error(self.name + ": Git Pull Asking for username. ")
+ elif i == 1:
+ main.log.error(
+ self.name +
+ ": Git Pull Asking for username. " )
return main.ERROR
- elif i==2:
- main.log.info(self.name + ": Git Pull - pulling repository now")
- self.handle.expect("ONOS\$", 120)
- return main.TRUE # So that only when git pull is done, we do mvn clean compile
- elif i==3:
- main.log.info(self.name + ": Git Pull - Already up to date")
+ elif i == 2:
+ main.log.info(
+ self.name +
+ ": Git Pull - pulling repository now" )
+ self.handle.expect( "ONOS\$", 120 )
+ return main.TRUE # So that only when git pull is done, we do mvn clean compile
+ elif i == 3:
+ main.log.info( self.name + ": Git Pull - Already up to date" )
return i
- elif i==4:
- main.log.info(self.name + ": Git Pull - Aborting... Are there conflicting git files?")
+ elif i == 4:
+ main.log.info(
+ self.name +
+ ": Git Pull - Aborting... Are there conflicting git files?" )
return main.ERROR
- elif i==5:
- main.log.info(self.name + ": Git Pull - You are not currently on a branch so git pull failed!")
+ elif i == 5:
+ main.log.info(
+ self.name +
+ ": Git Pull - You are not currently on a branch so git pull failed!" )
return main.ERROR
- elif i==6:
- main.log.info(self.name + ": Git Pull - You have not configured an upstream branch to pull from. Git pull failed!")
+ elif i == 6:
+ main.log.info(
+ self.name +
+ ": Git Pull - You have not configured an upstream branch to pull from. Git pull failed!" )
return main.ERROR
- elif i==7:
- main.log.info(self.name + ": Git Pull - Pull is not possible because you have unmerged files.")
+ elif i == 7:
+ main.log.info(
+ self.name +
+ ": Git Pull - Pull is not possible because you have unmerged files." )
return main.ERROR
- elif i==8:
- main.log.error(self.name + ": Git Pull - TIMEOUT")
- main.log.error(self.name + " Response was: " + str(self.handle.before))
+ elif i == 8:
+ main.log.error( self.name + ": Git Pull - TIMEOUT" )
+ main.log.error(
+ self.name + " Response was: " + str(
+ self.handle.before ) )
return main.ERROR
else:
- main.log.error(self.name + ": Git Pull - Unexpected response, check for pull errors")
+ main.log.error(
+ self.name +
+ ": Git Pull - Unexpected response, check for pull errors" )
return main.ERROR
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name + ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::")
+ main.log.info(
+ self.name +
+ ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" )
main.log.error( traceback.print_exc() )
- main.log.info(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::")
+ main.log.info(
+ ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" )
main.cleanup()
main.exit()
- def git_checkout(self, branch="master"):
- '''
+ def git_checkout( self, branch="master" ):
+ """
Assumes that "git pull" works without login
-
+
This function will perform a git git checkout on the ONOS instance.
- If used as git_checkout("branch") it will do git checkout of the "branch".
+ If used as git_checkout( "branch" ) it will do git checkout of the "branch".
Otherwise, this function will perform a git checkout of the master
- branch of the ONOS repository. If it has any problems, it will return
- main.ERROR.
- If the branch was already the specified branch, or the git checkout was
+ branch of the ONOS repository. If it has any problems, it will return
+ main.ERROR.
+ If the branch was already the specified branch, or the git checkout was
successful then the function will return main.TRUE.
- '''
+ """
try:
- self.handle.sendline("cd " + self.home)
- self.handle.expect("ONOS\$")
- main.log.info(self.name + ": Checking out git branch: " + branch + "...")
- cmd = "git checkout "+branch
- self.handle.sendline(cmd)
- self.handle.expect(cmd)
- i=self.handle.expect(['fatal',
- 'Username\sfor\s(.*):\s',
- 'Already\son\s\'',
- 'Switched\sto\sbranch\s\'' + str(branch),
- pexpect.TIMEOUT,
- 'error: Your local changes to the following files would be overwritten by checkout:',
- 'error: you need to resolve your current index first'],timeout=60)
+ self.handle.sendline( "cd " + self.home )
+ self.handle.expect( "ONOS\$" )
+ main.log.info(
+ self.name +
+ ": Checking out git branch: " +
+ branch +
+ "..." )
+ cmd = "git checkout " + branch
+ self.handle.sendline( cmd )
+ self.handle.expect( cmd )
+ i = self.handle.expect( [ 'fatal',
+ 'Username\sfor\s(.*):\s',
+ 'Already\son\s\'',
+ 'Switched\sto\sbranch\s\'' +
+ str( branch ),
+ pexpect.TIMEOUT,
+ 'error: Your local changes to the following files would be overwritten by checkout:',
+ 'error: you need to resolve your current index first' ], timeout=60 )
- if i==0:
- main.log.error(self.name + ": Git checkout had some issue...")
- main.log.error(self.name + ": " + self.handle.before)
+ if i == 0:
+ main.log.error(
+ self.name +
+ ": Git checkout had some issue..." )
+ main.log.error( self.name + ": " + self.handle.before )
return main.ERROR
- elif i==1:
- main.log.error(self.name + ": Git checkout asking for username."\
- +" Please configure your local git repository to be able "\
- +"to access your remote repository passwordlessly")
+ elif i == 1:
+ main.log.error( self.name + ": Git checkout asking for username."
+ + " Please configure your local git repository to be able "
+ + "to access your remote repository passwordlessly" )
return main.ERROR
- elif i==2:
- main.log.info(self.name + ": Git Checkout %s : Already on this branch" %branch)
- self.handle.expect("ONOS\$")
- #main.log.info("DEBUG: after checkout cmd = "+ self.handle.before)
+ elif i == 2:
+ main.log.info(
+ self.name +
+ ": Git Checkout %s : Already on this branch" %
+ branch )
+ self.handle.expect( "ONOS\$" )
+ # main.log.info( "DEBUG: after checkout cmd = "+
+ # self.handle.before )
return main.TRUE
- elif i==3:
- main.log.info(self.name + ": Git checkout %s - Switched to this branch" %branch)
- self.handle.expect("ONOS\$")
- #main.log.info("DEBUG: after checkout cmd = "+ self.handle.before)
+ elif i == 3:
+ main.log.info(
+ self.name +
+ ": Git checkout %s - Switched to this branch" %
+ branch )
+ self.handle.expect( "ONOS\$" )
+ # main.log.info( "DEBUG: after checkout cmd = "+
+ # self.handle.before )
return main.TRUE
- elif i==4:
- main.log.error(self.name + ": Git Checkout- TIMEOUT")
- main.log.error(self.name + " Response was: " + str(self.handle.before))
+ elif i == 4:
+ main.log.error( self.name + ": Git Checkout- TIMEOUT" )
+ main.log.error(
+ self.name + " Response was: " + str(
+ self.handle.before ) )
return main.ERROR
- elif i==5:
- self.handle.expect("Aborting")
- main.log.error(self.name + ": Git checkout error: \n" + \
- "Your local changes to the following files would be overwritten by checkout:" + \
- str(self.handle.before))
- self.handle.expect("ONOS\$")
+ elif i == 5:
+ self.handle.expect( "Aborting" )
+ main.log.error( self.name + ": Git checkout error: \n" +
+ "Your local changes to the following files would be overwritten by checkout:" +
+ str( self.handle.before ) )
+ self.handle.expect( "ONOS\$" )
return main.ERROR
- elif i==6:
- main.log.error(self.name + ": Git checkout error: \n" + \
- "You need to resolve your current index first:" + \
- str(self.handle.before))
- self.handle.expect("ONOS\$")
+ elif i == 6:
+ main.log.error( self.name + ": Git checkout error: \n" +
+ "You need to resolve your current index first:" +
+ str( self.handle.before ) )
+ self.handle.expect( "ONOS\$" )
return main.ERROR
else:
- main.log.error(self.name + ": Git Checkout - Unexpected response, check for pull errors")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error(
+ self.name +
+ ": Git Checkout - Unexpected response, check for pull errors" )
+ main.log.error( self.name + ": " + self.handle.before )
return main.ERROR
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name + ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::")
+ main.log.info(
+ self.name +
+ ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" )
main.log.error( traceback.print_exc() )
- main.log.info(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::")
+ main.log.info(
+ ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" )
main.cleanup()
main.exit()
- def get_version(self, report=False):
- '''
+ def get_version( self, report=False ):
+ """
Writes the COMMIT number to the report to be parsed by Jenkins data collecter.
- '''
+ """
try:
- self.handle.sendline("export TERM=xterm-256color")
- self.handle.expect("xterm-256color")
- self.handle.expect("\$")
- self.handle.sendline("")
- self.handle.expect("\$")
- self.handle.sendline("cd " + self.home + "; git log -1 --pretty=fuller --decorate=short | grep -A 6 \"commit\" --color=never")
- #NOTE: for some reason there are backspaces inserted in this phrase when run from Jenkins on some tests
- self.handle.expect("never")
- self.handle.expect("\$")
- response=(self.name +": \n"+ str(self.handle.before + self.handle.after))
- self.handle.sendline("cd " + self.home)
- self.handle.expect("\$")
- lines=response.splitlines()
+ self.handle.sendline( "export TERM=xterm-256color" )
+ self.handle.expect( "xterm-256color" )
+ self.handle.expect( "\$" )
+ self.handle.sendline( "" )
+ self.handle.expect( "\$" )
+ self.handle.sendline(
+ "cd " +
+ self.home +
+ "; git log -1 --pretty=fuller --decorate=short | grep -A 6 \"commit\" --color=never" )
+ # NOTE: for some reason there are backspaces inserted in this
+ # phrase when run from Jenkins on some tests
+ self.handle.expect( "never" )
+ self.handle.expect( "\$" )
+ response = ( self.name + ": \n" + str(
+ self.handle.before + self.handle.after ) )
+ self.handle.sendline( "cd " + self.home )
+ self.handle.expect( "\$" )
+ lines = response.splitlines()
for line in lines:
print line
if report:
- for line in lines[2:-1]:
- #Bracket replacement is for Wiki-compliant
- #formatting. '<' or '>' are interpreted
- #as xml specific tags that cause errors
- line = line.replace("<","[")
- line = line.replace(">","]")
- main.log.report("\t" + line)
- return lines[2]
+ for line in lines[ 2:-1 ]:
+ # Bracket replacement is for Wiki-compliant
+ # formatting. '<' or '>' are interpreted
+ # as xml specific tags that cause errors
+ line = line.replace( "<", "[" )
+ line = line.replace( ">", "]" )
+ main.log.report( "\t" + line )
+ return lines[ 2 ]
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except pexpect.TIMEOUT:
- main.log.error(self.name + ": TIMEOUT exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": TIMEOUT exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name + ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::")
+ main.log.info(
+ self.name +
+ ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" )
main.log.error( traceback.print_exc() )
- main.log.info(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::")
+ main.log.info(
+ ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" )
main.cleanup()
main.exit()
- def create_cell_file(self, bench_ip, file_name, mn_ip_addrs,
- extra_feature_string, *onos_ip_addrs):
- '''
+ def create_cell_file( self, bench_ip, file_name, mn_ip_addrs,
+ extra_feature_string, *onos_ip_addrs ):
+ """
Creates a cell file based on arguments
Required:
- * Bench IP address (bench_ip)
+ * Bench IP address ( bench_ip )
- Needed to copy the cell file over
- * File name of the cell file (file_name)
- * Mininet IP address (mn_ip_addrs)
- - Note that only 1 ip address is
+ * File name of the cell file ( file_name )
+ * Mininet IP address ( mn_ip_addrs )
+ - Note that only 1 ip address is
supported currently
- * ONOS IP addresses (onos_ip_addrs)
+ * ONOS IP addresses ( onos_ip_addrs )
- Must be passed in as last arguments
-
+
NOTE: Assumes cells are located at:
~/<self.home>/tools/test/cells/
- '''
-
- #Variable initialization
+ """
+ # Variable initialization
cell_directory = self.home + "/tools/test/cells/"
- #We want to create the cell file in the dependencies directory
- #of TestON first, then copy over to ONOS bench
+ # We want to create the cell file in the dependencies directory
+ # of TestON first, then copy over to ONOS bench
temp_directory = "/tmp/"
- #Create the cell file in the directory for writing (w+)
- cell_file = open(temp_directory+file_name , 'w+')
-
- #Feature string is hardcoded environment variables
- #That you may wish to use by default on startup.
- #Note that you may not want certain features listed
- #on here.
- core_feature_string = "export ONOS_FEATURES=webconsole,onos-api,"+\
- "onos-cli,onos-openflow,"+extra_feature_string
+ # Create the cell file in the directory for writing ( w+ )
+ cell_file = open( temp_directory + file_name, 'w+' )
+
+ # Feature string is hardcoded environment variables
+ # That you may wish to use by default on startup.
+ # Note that you may not want certain features listed
+ # on here.
+ core_feature_string = "export ONOS_FEATURES=webconsole,onos-api," +\
+ "onos-cli,onos-openflow," + extra_feature_string
mn_string = "export OCN="
onos_string = "export OC"
temp_count = 1
-
- #Create ONOS_NIC ip address prefix
- temp_onos_ip = onos_ip_addrs[0]
+
+ # Create ONOS_NIC ip address prefix
+ temp_onos_ip = onos_ip_addrs[ 0 ]
temp_list = []
- temp_list = temp_onos_ip.split(".")
- #Omit last element of list to format for NIC
- temp_list = temp_list[:-1]
- #Structure the nic string ip
- nic_addr = ".".join(temp_list) + ".*"
- onos_nic_string = "export ONOS_NIC="+nic_addr
+ temp_list = temp_onos_ip.split( "." )
+ # Omit last element of list to format for NIC
+ temp_list = temp_list[ :-1 ]
+ # Structure the nic string ip
+ nic_addr = ".".join( temp_list ) + ".*"
+ onos_nic_string = "export ONOS_NIC=" + nic_addr
try:
- #Start writing to file
- cell_file.write(onos_nic_string + "\n")
+ # Start writing to file
+ cell_file.write( onos_nic_string + "\n" )
for arg in onos_ip_addrs:
- #For each argument in onos_ip_addrs, write to file
- #Output should look like the following:
+ # For each argument in onos_ip_addrs, write to file
+ # Output should look like the following:
# export OC1="10.128.20.11"
# export OC2="10.128.20.12"
- cell_file.write(onos_string + str(temp_count) +
- "=" + "\"" + arg + "\"" + "\n" )
+ cell_file.write( onos_string + str( temp_count ) +
+ "=" + "\"" + arg + "\"" + "\n" )
temp_count = temp_count + 1
-
- cell_file.write(mn_string +"\""+ mn_ip_addrs +"\""+ "\n")
- cell_file.write(core_feature_string + "\n")
+
+ cell_file.write( mn_string + "\"" + mn_ip_addrs + "\"" + "\n" )
+ cell_file.write( core_feature_string + "\n" )
cell_file.close()
- #We use os.system to send the command to TestON cluster
- #to account for the case in which TestON is not located
- #on the same cluster as the ONOS bench
- #Note that even if TestON is located on the same cluster
- #as ONOS bench, you must setup passwordless ssh
- #between TestON and ONOS bench in order to automate the test.
- os.system("scp "+temp_directory+file_name+
- " admin@"+bench_ip+":"+cell_directory)
+ # We use os.system to send the command to TestON cluster
+ # to account for the case in which TestON is not located
+ # on the same cluster as the ONOS bench
+ # Note that even if TestON is located on the same cluster
+ # as ONOS bench, you must setup passwordless ssh
+ # between TestON and ONOS bench in order to automate the test.
+ os.system( "scp " + temp_directory + file_name +
+ " admin@" + bench_ip + ":" + cell_directory )
return main.TRUE
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name + ":::::::::")
+ main.log.info( self.name + ":::::::::" )
main.log.error( traceback.print_exc() )
- main.log.info(":::::::")
+ main.log.info( ":::::::" )
main.cleanup()
main.exit()
- def set_cell(self, cellname):
- '''
+ def set_cell( self, cellname ):
+ """
Calls 'cell <name>' to set the environment variables on ONOSbench
- '''
+ """
try:
if not cellname:
- main.log.error("Must define cellname")
+ main.log.error( "Must define cellname" )
main.cleanup()
main.exit()
else:
- self.handle.sendline("cell "+str(cellname))
- #Expect the cellname in the ONOS_CELL variable.
- #Note that this variable name is subject to change
+ self.handle.sendline( "cell " + str( cellname ) )
+ # Expect the cellname in the ONOS_CELL variable.
+ # Note that this variable name is subject to change
# and that this driver will have to change accordingly
- self.handle.expect("ONOS_CELL="+str(cellname))
+ self.handle.expect( "ONOS_CELL=" + str( cellname ) )
handle_before = self.handle.before
handle_after = self.handle.after
- #Get the rest of the handle
- self.handle.sendline("")
- self.handle.expect("\$")
+ # Get the rest of the handle
+ self.handle.sendline( "" )
+ self.handle.expect( "\$" )
handle_more = self.handle.before
- main.log.info("Cell call returned: "+handle_before+
- handle_after + handle_more)
+ main.log.info( "Cell call returned: " + handle_before +
+ handle_after + handle_more )
return main.TRUE
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
- def verify_cell(self):
- '''
+ def verify_cell( self ):
+ """
Calls 'onos-verify-cell' to check for cell installation
- '''
- #TODO: Add meaningful expect value
+ """
+ # TODO: Add meaningful expect value
try:
- #Clean handle by sending empty and expecting $
- self.handle.sendline("")
- self.handle.expect("\$")
- self.handle.sendline("onos-verify-cell")
- self.handle.expect("\$")
+ # Clean handle by sending empty and expecting $
+ self.handle.sendline( "" )
+ self.handle.expect( "\$" )
+ self.handle.sendline( "onos-verify-cell" )
+ self.handle.expect( "\$" )
handle_before = self.handle.before
handle_after = self.handle.after
- #Get the rest of the handle
- self.handle.sendline("")
- self.handle.expect("\$")
+ # Get the rest of the handle
+ self.handle.sendline( "" )
+ self.handle.expect( "\$" )
handle_more = self.handle.before
- main.log.info("Verify cell returned: "+handle_before+
- handle_after + handle_more)
+ main.log.info( "Verify cell returned: " + handle_before +
+ handle_after + handle_more )
return main.TRUE
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
- def onos_cli(self, ONOS_ip, cmdstr):
- '''
+ def onos_cli( self, ONOS_ip, cmdstr ):
+ """
Uses 'onos' command to send various ONOS CLI arguments.
Required:
* ONOS_ip: specify the ip of the cell machine
* cmdstr: specify the command string to send
-
- This function is intended to expose the entire karaf
+
+ This function is intended to expose the entire karaf
CLI commands for ONOS. Try to use this function first
before attempting to write a ONOS CLI specific driver
- function.
- You can see a list of available 'cmdstr' arguments
+ function.
+ You can see a list of available 'cmdstr' arguments
by starting onos, and typing in 'onos' to enter the
onos> CLI. Then, type 'help' to see the list of
- available commands.
- '''
+ available commands.
+ """
try:
if not ONOS_ip:
- main.log.error("You must specify the IP address")
+ main.log.error( "You must specify the IP address" )
return main.FALSE
if not cmdstr:
- main.log.error("You must specify the command string")
+ main.log.error( "You must specify the command string" )
return main.FALSE
- cmdstr = str(cmdstr)
- self.handle.sendline("")
- self.handle.expect("\$")
+ cmdstr = str( cmdstr )
+ self.handle.sendline( "" )
+ self.handle.expect( "\$" )
- self.handle.sendline("onos -w " + ONOS_ip + " " + cmdstr)
- self.handle.expect("\$")
+ self.handle.sendline( "onos -w " + ONOS_ip + " " + cmdstr )
+ self.handle.expect( "\$" )
handle_before = self.handle.before
print "handle_before = ", self.handle.before
- #handle_after = str(self.handle.after)
+ # handle_after = str( self.handle.after )
- #self.handle.sendline("")
- #self.handle.expect("\$")
- #handle_more = str(self.handle.before)
+ # self.handle.sendline( "" )
+ # self.handle.expect( "\$" )
+ # handle_more = str( self.handle.before )
- main.log.info("Command sent successfully")
+ main.log.info( "Command sent successfully" )
- #Obtain return handle that consists of result from
- #the onos command. The string may need to be
- #configured further.
- #return_string = handle_before + handle_after
+ # Obtain return handle that consists of result from
+ # the onos command. The string may need to be
+ # configured further.
+ # return_string = handle_before + handle_after
return_string = handle_before
print "return_string = ", return_string
return return_string
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
- def onos_install(self, options="-f", node = ""):
- '''
+ def onos_install( self, options="-f", node="" ):
+ """
Installs ONOS bits on the designated cell machine.
- If -f option is provided, it also forces an uninstall.
- Presently, install also includes onos-push-bits and
+ If -f option is provided, it also forces an uninstall.
+ Presently, install also includes onos-push-bits and
onos-config within.
- The node option allows you to selectively only push the jar
+ The node option allows you to selectively only push the jar
files to certain onos nodes
Returns: main.TRUE on success and main.FALSE on failure
- '''
+ """
try:
if options:
- self.handle.sendline("onos-install " + options + " " + node)
+ self.handle.sendline( "onos-install " + options + " " + node )
else:
- self.handle.sendline("onos-install "+node)
- self.handle.expect("onos-install ")
- #NOTE: this timeout may need to change depending on the network and size of ONOS
- i=self.handle.expect(["Network\sis\sunreachable",
- "onos\sstart/running,\sprocess",
- "ONOS\sis\salready\sinstalled",
- pexpect.TIMEOUT],timeout=60)
+ self.handle.sendline( "onos-install " + node )
+ self.handle.expect( "onos-install " )
+ # NOTE: this timeout may need to change depending on the network
+ # and size of ONOS
+ i = self.handle.expect( [ "Network\sis\sunreachable",
+ "onos\sstart/running,\sprocess",
+ "ONOS\sis\salready\sinstalled",
+ pexpect.TIMEOUT ], timeout=60 )
if i == 0:
- main.log.warn("Network is unreachable")
+ main.log.warn( "Network is unreachable" )
return main.FALSE
elif i == 1:
- main.log.info("ONOS was installed on " + node + " and started")
+ main.log.info(
+ "ONOS was installed on " +
+ node +
+ " and started" )
return main.TRUE
elif i == 2:
- main.log.info("ONOS is already installed on "+node)
+ main.log.info( "ONOS is already installed on " + node )
return main.TRUE
- elif i == 3:
- main.log.info("Installation of ONOS on " + node + " timed out")
+ elif i == 3:
+ main.log.info(
+ "Installation of ONOS on " +
+ node +
+ " timed out" )
return main.FALSE
-
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
- def onos_start(self, node_ip):
- '''
+ def onos_start( self, node_ip ):
+ """
Calls onos command: 'onos-service [<node-ip>] start'
This command is a remote management of the ONOS upstart daemon
- '''
-
+ """
try:
- self.handle.sendline("")
- self.handle.expect("\$")
- self.handle.sendline("onos-service "+str(node_ip)+
- " start")
- i = self.handle.expect([
+ self.handle.sendline( "" )
+ self.handle.expect( "\$" )
+ self.handle.sendline( "onos-service " + str( node_ip ) +
+ " start" )
+ i = self.handle.expect( [
"Job\sis\salready\srunning",
"start/running",
"Unknown\sinstance",
- pexpect.TIMEOUT],timeout=120)
+ pexpect.TIMEOUT ], timeout=120 )
if i == 0:
- main.log.info("Service is already running")
+ main.log.info( "Service is already running" )
return main.TRUE
elif i == 1:
- main.log.info("ONOS service started")
+ main.log.info( "ONOS service started" )
return main.TRUE
else:
- main.log.error("ONOS service failed to start")
+ main.log.error( "ONOS service failed to start" )
main.cleanup()
main.exit()
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
- def onos_stop(self, node_ip):
- '''
+ def onos_stop( self, node_ip ):
+ """
Calls onos command: 'onos-service [<node-ip>] stop'
This command is a remote management of the ONOS upstart daemon
- '''
+ """
try:
- self.handle.sendline("")
- self.handle.expect("\$")
- self.handle.sendline("onos-service "+str(node_ip)+
- " stop")
- i = self.handle.expect([
+ self.handle.sendline( "" )
+ self.handle.expect( "\$" )
+ self.handle.sendline( "onos-service " + str( node_ip ) +
+ " stop" )
+ i = self.handle.expect( [
"stop/waiting",
"Unknown\sinstance",
- pexpect.TIMEOUT],timeout=60)
+ pexpect.TIMEOUT ], timeout=60 )
if i == 0:
- main.log.info("ONOS service stopped")
+ main.log.info( "ONOS service stopped" )
return main.TRUE
elif i == 1:
- main.log.info("Unknown ONOS instance specified: "+
- str(node_ip))
+ main.log.info( "Unknown ONOS instance specified: " +
+ str( node_ip ) )
return main.FALSE
else:
- main.log.error("ONOS service failed to stop")
+ main.log.error( "ONOS service failed to stop" )
return main.FALSE
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
-
- def onos_uninstall(self, node_ip=""):
- '''
+
+ def onos_uninstall( self, node_ip="" ):
+ """
Calls the command: 'onos-uninstall'
- Uninstalls ONOS from the designated cell machine, stopping
+ Uninstalls ONOS from the designated cell machine, stopping
if needed
- '''
+ """
try:
- self.handle.sendline("")
- self.handle.expect("\$")
- self.handle.sendline( "onos-uninstall "+str(node_ip) )
- self.handle.expect("\$")
+ self.handle.sendline( "" )
+ self.handle.expect( "\$" )
+ self.handle.sendline( "onos-uninstall " + str( node_ip ) )
+ self.handle.expect( "\$" )
- main.log.info("ONOS "+node_ip+" was uninstalled")
+ main.log.info( "ONOS " + node_ip + " was uninstalled" )
- #onos-uninstall command does not return any text
+ # onos-uninstall command does not return any text
return main.TRUE
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
- def onos_die(self, node_ip):
- '''
+ def onos_die( self, node_ip ):
+ """
Issues the command 'onos-die <node-ip>'
This command calls onos-kill and also stops the node
- '''
+ """
try:
- self.handle.sendline("")
- self.handle.expect("\$")
- cmd_str = "onos-kill "+str(node_ip)
- self.handle.sendline(cmd_str)
- i = self.handle.expect([
+ self.handle.sendline( "" )
+ self.handle.expect( "\$" )
+ cmd_str = "onos-kill " + str( node_ip )
+ self.handle.sendline( cmd_str )
+ i = self.handle.expect( [
"Killing\sONOS",
"ONOS\sprocess\sis\snot\srunning",
- pexpect.TIMEOUT], timeout=20)
+ pexpect.TIMEOUT ], timeout=20 )
if i == 0:
- main.log.info("ONOS instance "+str(node_ip)+
- " was killed and stopped")
+ main.log.info( "ONOS instance " + str( node_ip ) +
+ " was killed and stopped" )
return main.TRUE
elif i == 1:
- main.log.info("ONOS process was not running")
+ main.log.info( "ONOS process was not running" )
return main.FALSE
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
-
- def onos_kill(self, node_ip):
- '''
+ def onos_kill( self, node_ip ):
+ """
Calls the command: 'onos-kill [<node-ip>]'
"Remotely, and unceremoniously kills the ONOS instance running on
the specified cell machine" - Tom V
- '''
-
+ """
try:
- self.handle.sendline("")
- self.handle.expect("\$")
- self.handle.sendline("onos-kill " + str(node_ip))
- i = self.handle.expect([
+ self.handle.sendline( "" )
+ self.handle.expect( "\$" )
+ self.handle.sendline( "onos-kill " + str( node_ip ) )
+ i = self.handle.expect( [
"\$",
"No\sroute\sto\shost",
"password:",
- pexpect.TIMEOUT], timeout=20)
-
+ pexpect.TIMEOUT ], timeout=20 )
+
if i == 0:
- main.log.info("ONOS instance "+str(node_ip)+" was killed")
+ main.log.info(
+ "ONOS instance " + str(
+ node_ip ) + " was killed" )
return main.TRUE
elif i == 1:
- main.log.info("No route to host")
+ main.log.info( "No route to host" )
return main.FALSE
elif i == 2:
- main.log.info("Passwordless login for host: "+str(node_ip)+
- " not configured")
+ main.log.info( "Passwordless login for host: " + str( node_ip ) +
+ " not configured" )
return main.FALSE
else:
- main.log.info("ONOS instasnce was not killed")
+ main.log.info( "ONOS instasnce was not killed" )
return main.FALSE
-
+
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
- def onos_remove_raft_logs(self):
- '''
+ def onos_remove_raft_logs( self ):
+ """
Removes Raft / Copy cat files from ONOS to ensure
a cleaner environment.
Description:
Stops all ONOS defined in the cell,
wipes the raft / copycat log files
- '''
+ """
try:
- self.handle.sendline("")
- self.handle.expect("\$")
- self.handle.sendline("onos-remove-raft-logs")
- #Sometimes this command hangs
- i = self.handle.expect(["\$", pexpect.TIMEOUT],
- timeout=120)
+ self.handle.sendline( "" )
+ self.handle.expect( "\$" )
+ self.handle.sendline( "onos-remove-raft-logs" )
+ # Sometimes this command hangs
+ i = self.handle.expect( [ "\$", pexpect.TIMEOUT ],
+ timeout=120 )
if i == 1:
- i = self.handle.expect(["\$", pexpect.TIMEOUT],
- timeout=120)
+ i = self.handle.expect( [ "\$", pexpect.TIMEOUT ],
+ timeout=120 )
if i == 1:
return main.FALSE
- self.handle.sendline("")
- self.handle.expect("\$")
+ self.handle.sendline( "" )
+ self.handle.expect( "\$" )
return main.TRUE
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
- def onos_start_network(self, mntopo):
- '''
- Calls the command 'onos-start-network [<mininet-topo>]
- "remotely starts the specified topology on the cell's
+ def onos_start_network( self, mntopo ):
+ """
+ Calls the command 'onos-start-network [ <mininet-topo> ]
+ "remotely starts the specified topology on the cell's
mininet machine against all controllers configured in the
- cell."
+ cell."
* Specify mininet topology file name for mntopo
* Topo files should be placed at:
~/<your-onos-directory>/tools/test/topos
-
+
NOTE: This function will take you to the mininet prompt
- '''
+ """
try:
if not mntopo:
- main.log.error("You must specify a topo file to execute")
+ main.log.error( "You must specify a topo file to execute" )
return main.FALSE
-
- mntopo = str(mntopo)
- self.handle.sendline("")
- self.handle.expect("\$")
- self.handle.sendline("onos-start-network " + mntopo)
- self.handle.expect("mininet>")
- main.log.info("Network started, entered mininet prompt")
+ mntopo = str( mntopo )
+ self.handle.sendline( "" )
+ self.handle.expect( "\$" )
- #TODO: Think about whether return is necessary or not
+ self.handle.sendline( "onos-start-network " + mntopo )
+ self.handle.expect( "mininet>" )
+ main.log.info( "Network started, entered mininet prompt" )
+
+ # TODO: Think about whether return is necessary or not
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
-
- def isup(self, node = ""):
- '''
- Run's onos-wait-for-start which only returns once ONOS is at run
- level 100(ready for use)
+ def isup( self, node="" ):
+ """
+ Run's onos-wait-for-start which only returns once ONOS is at run
+ level 100( ready for use )
Returns: main.TRUE if ONOS is running and main.FALSE on timeout
- '''
+ """
try:
- self.handle.sendline("onos-wait-for-start " + node )
- self.handle.expect("onos-wait-for-start")
- #NOTE: this timeout is arbitrary"
- i = self.handle.expect(["\$", pexpect.TIMEOUT], timeout = 120)
+ self.handle.sendline( "onos-wait-for-start " + node )
+ self.handle.expect( "onos-wait-for-start" )
+ # NOTE: this timeout is arbitrary"
+ i = self.handle.expect( [ "\$", pexpect.TIMEOUT ], timeout=120 )
if i == 0:
- main.log.info(self.name + ": " + node + " is up")
+ main.log.info( self.name + ": " + node + " is up" )
return main.TRUE
elif i == 1:
- #NOTE: since this function won't return until ONOS is ready,
+ # NOTE: since this function won't return until ONOS is ready,
# we will kill it on timeout
- main.log.error("ONOS has not started yet")
- self.handle.send("\x03") #Control-C
- self.handle.expect("\$")
+ main.log.error( "ONOS has not started yet" )
+ self.handle.send( "\x03" ) # Control-C
+ self.handle.expect( "\$" )
return main.FALSE
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
- def push_test_intents_shell(self, dpid_src, dpid_dst, num_intents,
- dir_file, onos_ip, num_mult="", app_id="", report=True,
- options=""):
- '''
+ def push_test_intents_shell( self, dpid_src, dpid_dst, num_intents,
+ dir_file, onos_ip, num_mult="", app_id="", report=True,
+ options="" ):
+ """
Description:
- Use the linux prompt to push test intents to
+ Use the linux prompt to push test intents to
better parallelize the results than the CLI
Required:
* dpid_src: specify source dpid
@@ -1005,105 +1064,107 @@
* dir_file: specify directory and file name to save
results
* onos_ip: specify the IP of ONOS to install on
- NOTE:
+ NOTE:
You must invoke this command at linux shell prompt
- '''
- try:
- #Create the string to sendline
+ """
+ try:
+ # Create the string to sendline
if options:
- base_cmd = "onos "+str(onos_ip)+" push-test-intents "+\
- options+" "
+ base_cmd = "onos " + str( onos_ip ) + " push-test-intents " +\
+ options + " "
else:
- base_cmd = "onos "+str(onos_ip)+" push-test-intents "
-
- add_dpid = base_cmd + str(dpid_src) + " " + str(dpid_dst)
+ base_cmd = "onos " + str( onos_ip ) + " push-test-intents "
+
+ add_dpid = base_cmd + str( dpid_src ) + " " + str( dpid_dst )
if not num_mult:
- add_intents = add_dpid + " " + str(num_intents)
+ add_intents = add_dpid + " " + str( num_intents )
elif num_mult:
- add_intents = add_dpid + " " + str(num_intents) + " " +\
- str(num_mult)
+ add_intents = add_dpid + " " + str( num_intents ) + " " +\
+ str( num_mult )
if app_id:
- add_app = add_intents + " " + str(app_id)
+ add_app = add_intents + " " + str( app_id )
else:
add_app = add_intents
if report:
- send_cmd = add_app + " > " + str(dir_file) + " &"
+ send_cmd = add_app + " > " + str( dir_file ) + " &"
else:
send_cmd = add_app + " &"
- main.log.info("Send cmd: "+send_cmd)
+ main.log.info( "Send cmd: " + send_cmd )
- self.handle.sendline(send_cmd)
+ self.handle.sendline( send_cmd )
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
- main.exit()
+ main.exit()
- def get_topology(self,topology_output):
- '''
+ def get_topology( self, topology_output ):
+ """
parses the onos:topology output
- Returns: a topology dict populated by the key values found in
+ Returns: a topology dict populated by the key values found in
the cli command.
- '''
-
+ """
try:
- #call the cli to get the topology summary
- #cmdstr = "onos:topology"
- #cli_result = self.onos_cli(ip, cmdstr)
- #print "cli_result = ", cli_result
+ # call the cli to get the topology summary
+ # cmdstr = "onos:topology"
+ # cli_result = self.onos_cli( ip, cmdstr )
+ # print "cli_result = ", cli_result
- #Parse the output
+ # Parse the output
topology = {}
- #for line in cli_result.split("\n"):
+ # for line in cli_result.split( "\n" ):
for line in topology_output.splitlines():
- if not line.startswith("time="):
+ if not line.startswith( "time=" ):
continue
- #else
- #print line
- for var in line.split(","):
- #print "'"+var+"'"
- #print "'"+var.strip()+"'"
- key, value = var.strip().split("=")
- topology[key] = value
- #print "topology = ", topology
- #devices = topology.get('devices', False)
- #print "devices = ", devices
- #links = topology.get('links', False)
- #print "links = ", links
- #SCCs = topology.get('SCC(s)', False)
- #print "SCCs = ", SCCs
- #paths = topology.get('paths', False)
- #print "paths = ", paths
+ # else
+ # print line
+ for var in line.split( "," ):
+ # print "'"+var+"'"
+ # print "'"+var.strip()+"'"
+ key, value = var.strip().split( "=" )
+ topology[ key ] = value
+ # print "topology = ", topology
+ # devices = topology.get( 'devices', False )
+ # print "devices = ", devices
+ # links = topology.get( 'links', False )
+ # print "links = ", links
+ # SCCs = topology.get( 'SCC(s)', False )
+ # print "SCCs = ", SCCs
+ # paths = topology.get( 'paths', False )
+ # print "paths = ", paths
return topology
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
-
-
- def check_status(self, topology_result, numoswitch, numolink, log_level="info"):
- '''
- Checks the number of swithes & links that ONOS sees against the
- supplied values. By default this will report to main.log, but the
+ def check_status(
+ self,
+ topology_result,
+ numoswitch,
+ numolink,
+ log_level="info" ):
+ """
+ Checks the number of swithes & links that ONOS sees against the
+ supplied values. By default this will report to main.log, but the
log level can be specifid.
-
+
Params: ip = ip used for the onos cli
numoswitch = expected number of switches
numlink = expected number of links
@@ -1112,283 +1173,280 @@
log_level can
- Returns: main.TRUE if the number of switchs and links are correct,
+ Returns: main.TRUE if the number of switchs and links are correct,
main.FALSE if the numer of switches and links is incorrect,
and main.ERROR otherwise
- '''
-
+ """
try:
- topology = self.get_topology(topology_result)
+ topology = self.get_topology( topology_result )
if topology == {}:
return main.ERROR
output = ""
- #Is the number of switches is what we expected
- devices = topology.get('devices',False)
- links = topology.get('links',False)
+ # Is the number of switches is what we expected
+ devices = topology.get( 'devices', False )
+ links = topology.get( 'links', False )
if devices == False or links == False:
return main.ERROR
- switch_check = ( int(devices) == int(numoswitch) )
- #Is the number of links is what we expected
- link_check = ( int(links) == int(numolink) )
- if (switch_check and link_check):
- #We expected the correct numbers
+ switch_check = ( int( devices ) == int( numoswitch ) )
+ # Is the number of links is what we expected
+ link_check = ( int( links ) == int( numolink ) )
+ if ( switch_check and link_check ):
+ # We expected the correct numbers
output = output + "The number of links and switches match "\
- + "what was expected"
+ + "what was expected"
result = main.TRUE
else:
output = output + \
- "The number of links and switches does not match what was expected"
+ "The number of links and switches does not match what was expected"
result = main.FALSE
output = output + "\n ONOS sees %i devices (%i expected) and %i links (%i expected)"\
- % ( int(devices), int(numoswitch), int(links), int(numolink) )
+ % ( int( devices ), int( numoswitch ), int( links ), int( numolink ) )
if log_level == "report":
- main.log.report(output)
+ main.log.report( output )
elif log_level == "warn":
- main.log.warn(output)
+ main.log.warn( output )
else:
- main.log.info(output)
- return result
+ main.log.info( output )
+ return result
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
- def tshark_pcap(self, interface, dir_file):
- '''
+ def tshark_pcap( self, interface, dir_file ):
+ """
Capture all packet activity and store in specified
directory/file
Required:
* interface: interface to capture
* dir: directory/filename to store pcap
- '''
- self.handle.sendline("")
- self.handle.expect("\$")
+ """
+ self.handle.sendline( "" )
+ self.handle.expect( "\$" )
- self.handle.sendline("tshark -i "+str(interface)+
- " -t e -w "+str(dir_file)+ " &")
- self.handle.sendline("\r")
- self.handle.expect("Capturing on")
- self.handle.sendline("\r")
- self.handle.expect("\$")
+ self.handle.sendline( "tshark -i " + str( interface ) +
+ " -t e -w " + str( dir_file ) + " &" )
+ self.handle.sendline( "\r" )
+ self.handle.expect( "Capturing on" )
+ self.handle.sendline( "\r" )
+ self.handle.expect( "\$" )
- main.log.info("Tshark started capturing files on "+
- str(interface)+ " and saving to directory: "+
- str(dir_file))
+ main.log.info( "Tshark started capturing files on " +
+ str( interface ) + " and saving to directory: " +
+ str( dir_file ) )
-
- def run_onos_topo_cfg(self, instance_name, json_file):
- '''
+ def run_onos_topo_cfg( self, instance_name, json_file ):
+ """
On ONOS bench, run this command: ./~/ONOS/tools/test/bin/onos-topo-cfg $OC1 filename
which starts the rest and copies the json file to the onos instance
- '''
+ """
try:
- self.handle.sendline("")
- self.handle.expect("\$")
- self.handle.sendline("cd ~/ONOS/tools/test/bin")
- self.handle.expect("/bin$")
- cmd = "./onos-topo-cfg " +instance_name +" " +json_file
+ self.handle.sendline( "" )
+ self.handle.expect( "\$" )
+ self.handle.sendline( "cd ~/ONOS/tools/test/bin" )
+ self.handle.expect( "/bin$" )
+ cmd = "./onos-topo-cfg " + instance_name + " " + json_file
print "cmd = ", cmd
- self.handle.sendline(cmd)
- self.handle.expect("\$")
- self.handle.sendline("cd ~")
- self.handle.expect("\$")
+ self.handle.sendline( cmd )
+ self.handle.expect( "\$" )
+ self.handle.sendline( "cd ~" )
+ self.handle.expect( "\$" )
return main.TRUE
except:
return main.FALSE
-
- def tshark_grep(self, grep, directory, interface='eth0'):
- '''
+
+ def tshark_grep( self, grep, directory, interface='eth0' ):
+ """
Required:
- * grep string
+ * grep string
* directory to store results
Optional:
* interface - default: eth0
Description:
Uses tshark command to grep specific group of packets
and stores the results to specified directory.
- The timestamp is hardcoded to be in epoch
- '''
- self.handle.sendline("")
- self.handle.expect("\$")
- self.handle.sendline("")
- self.handle.sendline("tshark -i "+str(interface)+
- " -t e | grep --line-buffered \""+str(grep)+"\" >"+directory+" &")
- self.handle.sendline("\r")
- self.handle.expect("Capturing on")
- self.handle.sendline("\r")
- self.handle.expect("\$")
+ The timestamp is hardcoded to be in epoch
+ """
+ self.handle.sendline( "" )
+ self.handle.expect( "\$" )
+ self.handle.sendline( "" )
+ self.handle.sendline( "tshark -i " + str( interface ) +
+ " -t e | grep --line-buffered \"" + str(grep) + "\" >" + directory + " &" )
+ self.handle.sendline( "\r" )
+ self.handle.expect( "Capturing on" )
+ self.handle.sendline( "\r" )
+ self.handle.expect( "\$" )
- def tshark_stop(self):
- '''
+ def tshark_stop( self ):
+ """
Removes wireshark files from /tmp and kills all tshark processes
- '''
- #Remove all pcap from previous captures
- self.execute(cmd="sudo rm /tmp/wireshark*")
- self.handle.sendline("")
- self.handle.sendline("sudo kill -9 `ps -ef | grep \"tshark -i\" |"+
- " grep -v grep | awk '{print $2}'`")
- self.handle.sendline("")
- main.log.info("Tshark stopped")
+ """
+ # Remove all pcap from previous captures
+ self.execute( cmd="sudo rm /tmp/wireshark*" )
+ self.handle.sendline( "" )
+ self.handle.sendline( "sudo kill -9 `ps -ef | grep \"tshark -i\" |" +
+ " grep -v grep | awk '{print $2}'`" )
+ self.handle.sendline( "" )
+ main.log.info( "Tshark stopped" )
- def ptpd(self, args):
- '''
+ def ptpd( self, args ):
+ """
Initiate ptp with user-specified args.
Required:
* args: specify string of args after command
'sudo ptpd'
- '''
+ """
try:
- self.handle.sendline("sudo ptpd "+str(args))
- i = self.handle.expect([
+ self.handle.sendline( "sudo ptpd " + str( args ) )
+ i = self.handle.expect( [
"Multiple",
"Error",
- "\$"])
- self.handle.expect("\$")
+ "\$" ] )
+ self.handle.expect( "\$" )
if i == 0:
handle = self.handle.before
- main.log.info("ptpd returned an error: "+
- str(handle))
+ main.log.info( "ptpd returned an error: " +
+ str( handle ) )
return handle
elif i == 1:
handle = self.handle.before
- main.log.error("ptpd returned an error: "+
- str(handle))
+ main.log.error( "ptpd returned an error: " +
+ str( handle ) )
return handle
else:
return main.TRUE
-
+
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
- def cp_logs_to_dir(self, log_to_copy,
- dest_dir, copy_file_name=""):
- '''
- Copies logs to a desired directory.
+ def cp_logs_to_dir( self, log_to_copy,
+ dest_dir, copy_file_name="" ):
+ """
+ Copies logs to a desired directory.
Current implementation of ONOS deletes its karaf
logs on every iteration. For debugging purposes,
- you may want to use this function to capture
- certain karaf logs. (or any other logs if needed)
+ you may want to use this function to capture
+ certain karaf logs. ( or any other logs if needed )
Localtime will be attached to the filename
Required:
* log_to_copy: specify directory and log name to
copy.
- ex) /opt/onos/log/karaf.log.1
+ ex ) /opt/onos/log/karaf.log.1
For copying multiple files, leave copy_file_name
- empty and only specify dest_dir -
- ex) /opt/onos/log/karaf*
+ empty and only specify dest_dir -
+ ex ) /opt/onos/log/karaf*
* dest_dir: specify directory to copy to.
- ex) /tmp/
- Optional:
+ ex ) /tmp/
+ Optional:
* copy_file_name: If you want to rename the log
file, specify copy_file_name. This will not work
with multiple file copying
- '''
+ """
try:
- localtime = time.strftime('%x %X')
- localtime = localtime.replace("/","")
- localtime = localtime.replace(" ","_")
- localtime = localtime.replace(":","")
- if dest_dir[-1:] != "/":
+ localtime = time.strftime( '%x %X' )
+ localtime = localtime.replace( "/", "" )
+ localtime = localtime.replace( " ", "_" )
+ localtime = localtime.replace( ":", "" )
+ if dest_dir[ -1: ] != "/":
dest_dir += "/"
if copy_file_name:
- self.handle.sendline("cp "+str(log_to_copy)+
- " "+str(dest_dir)+str(copy_file_name)+
- localtime)
- self.handle.expect("cp")
- self.handle.expect("\$")
+ self.handle.sendline( "cp " + str( log_to_copy ) +
+ " " + str( dest_dir ) + str( copy_file_name ) +
+ localtime )
+ self.handle.expect( "cp" )
+ self.handle.expect( "\$" )
else:
- self.handle.sendline("cp "+str(log_to_copy)+
- " "+str(dest_dir))
- self.handle.expect("cp")
- self.handle.expect("\$")
-
- return self.handle.before
-
- except pexpect.EOF:
- main.log.error("Copying files failed")
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
- except:
- main.log.error("Copying files failed")
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ self.handle.sendline( "cp " + str( log_to_copy ) +
+ " " + str( dest_dir ) )
+ self.handle.expect( "cp" )
+ self.handle.expect( "\$" )
- def check_logs(self, onos_ip):
- '''
+ return self.handle.before
+
+ except pexpect.EOF:
+ main.log.error( "Copying files failed" )
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
+ except:
+ main.log.error( "Copying files failed" )
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
+
+ def check_logs( self, onos_ip ):
+ """
runs onos-check-logs on the given onos node
returns the response
- '''
+ """
try:
- cmd = "onos-check-logs " + str(onos_ip)
- self.handle.sendline(cmd)
- self.handle.expect(cmd)
- self.handle.expect("\$")
+ cmd = "onos-check-logs " + str( onos_ip )
+ self.handle.sendline( cmd )
+ self.handle.expect( cmd )
+ self.handle.expect( "\$" )
response = self.handle.before
return response
except pexpect.EOF:
- main.log.error("Lost ssh connection")
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( "Lost ssh connection" )
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
except:
- main.log.error("Some error in check_logs:")
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.error( "Some error in check_logs:" )
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
- def onos_status(self, node=""):
- '''
+ def onos_status( self, node="" ):
+ """
Calls onos command: 'onos-service [<node-ip>] status'
- '''
-
+ """
try:
- self.handle.sendline("")
- self.handle.expect("\$")
- self.handle.sendline("onos-service "+str(node)+
- " status")
- i = self.handle.expect([
+ self.handle.sendline( "" )
+ self.handle.expect( "\$" )
+ self.handle.sendline( "onos-service " + str( node ) +
+ " status" )
+ i = self.handle.expect( [
"start/running",
"stop/waiting",
- pexpect.TIMEOUT],timeout=120)
+ pexpect.TIMEOUT ], timeout=120 )
if i == 0:
- main.log.info("ONOS is running")
+ main.log.info( "ONOS is running" )
return main.TRUE
elif i == 1:
- main.log.info("ONOS is stopped")
+ main.log.info( "ONOS is stopped" )
return main.FALSE
else:
- main.log.error("ONOS service failed to check the status")
+ main.log.error( "ONOS service failed to check the status" )
main.cleanup()
main.exit()
except pexpect.EOF:
- main.log.error(self.name + ": EOF exception found")
- main.log.error(self.name + ": " + self.handle.before)
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
except:
- main.log.info(self.name+" ::::::")
- main.log.error( traceback.print_exc())
- main.log.info(self.name+" ::::::")
+ main.log.info( self.name + " ::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
diff --git a/TestON/drivers/common/cli/quaggaclidriver.py b/TestON/drivers/common/cli/quaggaclidriver.py
index 8314941..28f95af 100644
--- a/TestON/drivers/common/cli/quaggaclidriver.py
+++ b/TestON/drivers/common/cli/quaggaclidriver.py
@@ -2,93 +2,111 @@
import time
import pexpect
-import struct, fcntl, os, sys, signal
+import struct
+import fcntl
+import os
+import sys
+import signal
import sys
import re
import json
-sys.path.append("../")
+sys.path.append( "../" )
from drivers.common.clidriver import CLI
-class QuaggaCliDriver(CLI):
- def __init__(self):
- super(CLI, self).__init__()
+class QuaggaCliDriver( CLI ):
+
+ def __init__( self ):
+ super( CLI, self ).__init__()
# TODO: simplify this method
- def connect(self, **connectargs):
+ def connect( self, **connectargs ):
for key in connectargs:
- vars(self)[key] = connectargs[key]
+ vars( self )[ key ] = connectargs[ key ]
- self.name = self.options['name']
- # self.handle = super(QuaggaCliDriver,self).connect(user_name = self.user_name, ip_address = self.ip_address,port = self.port, pwd = self.pwd)
- self.handle = super(QuaggaCliDriver, self).connect(user_name=self.user_name, ip_address="1.1.1.1", port=self.port, pwd=self.pwd)
- main.log.info("connect parameters:" + str(self.user_name) + ";" + str(self.ip_address) + ";" + str(self.port) + ";" + str(self.pwd))
+ self.name = self.options[ 'name' ]
+ # self.handle = super( QuaggaCliDriver,self ).connect(
+ # user_name=self.user_name, ip_address=self.ip_address,port=self.port,
+ # pwd=self.pwd )
+ self.handle = super(
+ QuaggaCliDriver,
+ self ).connect(
+ user_name=self.user_name,
+ ip_address="1.1.1.1",
+ port=self.port,
+ pwd=self.pwd )
+ main.log.info(
+ "connect parameters:" + str(
+ self.user_name ) + ";" + str(
+ self.ip_address ) + ";" + str(
+ self.port ) + ";" + str(
+ self.pwd ) )
if self.handle:
- #self.handle.expect("",timeout=10)
- #self.handle.expect("\$",timeout=10)
- self.handle.sendline("telnet localhost 2605")
- #self.handle.expect("Password:", timeout=5)
- self.handle.expect("Password:")
- self.handle.sendline("hello")
- #self.handle.expect("bgpd", timeout=5)
- self.handle.expect("bgpd")
- self.handle.sendline("enable")
- #self.handle.expect("bgpd#", timeout=5)
- self.handle.expect("bgpd#")
+ # self.handle.expect( "",timeout=10 )
+ # self.handle.expect( "\$",timeout=10 )
+ self.handle.sendline( "telnet localhost 2605" )
+ # self.handle.expect( "Password:", timeout=5 )
+ self.handle.expect( "Password:" )
+ self.handle.sendline( "hello" )
+ # self.handle.expect( "bgpd", timeout=5 )
+ self.handle.expect( "bgpd" )
+ self.handle.sendline( "enable" )
+ # self.handle.expect( "bgpd#", timeout=5 )
+ self.handle.expect( "bgpd#" )
return self.handle
- else :
- main.log.info("NO HANDLE")
+ else:
+ main.log.info( "NO HANDLE" )
return main.FALSE
- def loginQuagga(self, ip_address):
- self.name = self.options['name']
- self.handle = super(QuaggaCliDriver, self).connect(
+ def loginQuagga( self, ip_address ):
+ self.name = self.options[ 'name' ]
+ self.handle = super( QuaggaCliDriver, self ).connect(
user_name=self.user_name, ip_address=ip_address,
- port=self.port, pwd=self.pwd)
- main.log.info("connect parameters:" + str(self.user_name) + ";"
- + str(self.ip_address) + ";" + str(self.port) + ";" + str(self.pwd))
+ port=self.port, pwd=self.pwd )
+ main.log.info( "connect parameters:" + str( self.user_name ) + ";"
+ + str( self.ip_address ) + ";" + str( self.port ) + ";" + str( self.pwd ) )
if self.handle:
- #self.handle.expect("")
- #self.handle.expect("\$")
- self.handle.sendline("telnet localhost 2605")
- #self.handle.expect("Password:", timeout=5)
- self.handle.expect("Password:")
- self.handle.sendline("hello")
- #self.handle.expect("bgpd", timeout=5)
- self.handle.expect("bgpd")
- self.handle.sendline("enable")
- #self.handle.expect("bgpd#", timeout=5)
- self.handle.expect("bgpd#")
- main.log.info("I in quagga on host " + str(ip_address))
+ # self.handle.expect( "" )
+ # self.handle.expect( "\$" )
+ self.handle.sendline( "telnet localhost 2605" )
+ # self.handle.expect( "Password:", timeout=5 )
+ self.handle.expect( "Password:" )
+ self.handle.sendline( "hello" )
+ # self.handle.expect( "bgpd", timeout=5 )
+ self.handle.expect( "bgpd" )
+ self.handle.sendline( "enable" )
+ # self.handle.expect( "bgpd#", timeout=5 )
+ self.handle.expect( "bgpd#" )
+ main.log.info( "I in quagga on host " + str( ip_address ) )
return self.handle
else:
- main.log.info("NO HANDLE")
+ main.log.info( "NO HANDLE" )
return main.FALSE
- def enter_config(self, asn):
- main.log.info("I am in enter_config method!")
+ def enter_config( self, asn ):
+ main.log.info( "I am in enter_config method!" )
try:
- self.handle.sendline("")
- self.handle.expect("bgpd#")
+ self.handle.sendline( "" )
+ self.handle.expect( "bgpd#" )
except:
- main.log.warn("Probably not currently in enable mode!")
+ main.log.warn( "Probably not currently in enable mode!" )
self.disconnect()
return main.FALSE
- self.handle.sendline("configure terminal")
- self.handle.expect("config", timeout=5)
- routerAS = "router bgp " + str(asn)
+ self.handle.sendline( "configure terminal" )
+ self.handle.expect( "config", timeout=5 )
+ routerAS = "router bgp " + str( asn )
try:
- self.handle.sendline(routerAS)
- self.handle.expect("config-router", timeout=5)
+ self.handle.sendline( routerAS )
+ self.handle.expect( "config-router", timeout=5 )
return main.TRUE
except:
return main.FALSE
- def generate_prefixes(self, net, numRoutes):
- main.log.info("I am in generate_prefixes method!")
+ def generate_prefixes( self, net, numRoutes ):
+ main.log.info( "I am in generate_prefixes method!" )
# each IP prefix will be composed by "net" + "." + m + "." + n + "." + x
# the length of each IP prefix is 24
@@ -97,248 +115,298 @@
m = numRoutes / 256
n = numRoutes % 256
- for i in range(0, m):
- for j in range(0, 256):
- network = str(net) + "." + str(i) + "." + str(j) + ".0/24"
- routes.append(network)
+ for i in range( 0, m ):
+ for j in range( 0, 256 ):
+ network = str(
+ net ) + "." + str(
+ i ) + "." + str(
+ j ) + ".0/24"
+ routes.append( network )
routes_gen = routes_gen + 1
- for j in range(0, n):
- network = str(net) + "." + str(m) + "." + str(j) + ".0/24"
- routes.append(network)
+ for j in range( 0, n ):
+ network = str( net ) + "." + str( m ) + "." + str( j ) + ".0/24"
+ routes.append( network )
routes_gen = routes_gen + 1
if routes_gen == numRoutes:
- main.log.info("Successfully generated " + str(numRoutes)
- + " prefixes!")
+ main.log.info( "Successfully generated " + str( numRoutes )
+ + " prefixes!" )
return routes
return main.FALSE
- # This method generates a multiple to single point intent(MultiPointToSinglePointIntent) for a given route
- def generate_expected_singleRouteIntent(self, prefix, nextHop, nextHopMac, sdnip_data):
+ # This method generates a multiple to single point intent(
+ # MultiPointToSinglePointIntent ) for a given route
+ def generate_expected_singleRouteIntent( self, prefix, nextHop, nextHopMac, sdnip_data ):
ingress = []
egress = ""
- for peer in sdnip_data['bgpPeers']:
- if peer['ipAddress'] == nextHop:
- egress = "of:" + str(peer['attachmentDpid']).replace(":", "") + ":" + str(peer['attachmentPort'])
+ for peer in sdnip_data[ 'bgpPeers' ]:
+ if peer[ 'ipAddress' ] == nextHop:
+ egress = "of:" + str( peer[ 'attachmentDpid' ] ).replace( ":", "" ) + ":" + str( peer[ 'attachmentPort' ] )
else:
- ingress.append("of:" + str(peer['attachmentDpid']).replace(":", "") + ":" + str(peer['attachmentPort']))
+ ingress.append( "of:" + \
+ str( peer[ 'attachmentDpid' ] ).replace( ":",
+ "" ) + ":" + str( peer[ 'attachmentPort' ] ) )
selector = "ETH_TYPE{ethType=800},IPV4_DST{ip=" + prefix + "}"
- treatment = "[ETH_DST{mac=" + str(nextHopMac) + "}]"
+ treatment = "[ETH_DST{mac=" + str( nextHopMac ) + "}]"
- intent = egress + "/" + str(sorted(ingress)) + "/" + selector + "/" + treatment
+ intent = egress + "/" + \
+ str( sorted( ingress ) ) + "/" + selector + "/" + treatment
return intent
- def generate_expected_onePeerRouteIntents(self, prefixes, nextHop, nextHopMac, sdnip_json_file_path):
+ def generate_expected_onePeerRouteIntents( self, prefixes, nextHop, nextHopMac, sdnip_json_file_path ):
intents = []
- sdnip_json_file = open(sdnip_json_file_path).read()
+ sdnip_json_file = open( sdnip_json_file_path ).read()
- sdnip_data = json.loads(sdnip_json_file)
+ sdnip_data = json.loads( sdnip_json_file )
for prefix in prefixes:
- intents.append(self.generate_expected_singleRouteIntent(prefix, nextHop, nextHopMac, sdnip_data))
- return sorted(intents)
+ intents.append(
+ self.generate_expected_singleRouteIntent(
+ prefix,
+ nextHop,
+ nextHopMac,
+ sdnip_data ) )
+ return sorted( intents )
# TODO
# This method generates all expected route intents for all BGP peers
- def generate_expected_routeIntents(self):
+ def generate_expected_routeIntents( self ):
intents = []
return intents
# This method extracts all actual routes from ONOS CLI
- def extract_actual_routes(self, get_routes_result):
- routes_json_obj = json.loads(get_routes_result)
+ def extract_actual_routes( self, get_routes_result ):
+ routes_json_obj = json.loads( get_routes_result )
allRoutes_actual = []
for route in routes_json_obj:
- if route['prefix'] == '172.16.10.0/24':
+ if route[ 'prefix' ] == '172.16.10.0/24':
continue
- allRoutes_actual.append(route['prefix'] + "/" + route['nextHop'])
+ allRoutes_actual.append(
+ route[ 'prefix' ] + "/" + route[ 'nextHop' ] )
- return sorted(allRoutes_actual)
+ return sorted( allRoutes_actual )
# This method extracts all actual route intents from ONOS CLI
- def extract_actual_routeIntents(self, get_intents_result):
+ def extract_actual_routeIntents( self, get_intents_result ):
intents = []
# TODO: delete the line below when change to Mininet demo script
- # get_intents_result=open("../tests/SdnIpTest/intents.json").read()
- intents_json_obj = json.loads(get_intents_result)
+ # get_intents_result=open( "../tests/SdnIpTest/intents.json" ).read()
+ intents_json_obj = json.loads( get_intents_result )
for intent in intents_json_obj:
- if intent['appId'] != "org.onosproject.sdnip" :
+ if intent[ 'appId' ] != "org.onosproject.sdnip":
continue
- if intent['type'] == "MultiPointToSinglePointIntent" and intent['state'] == 'INSTALLED':
- egress = str(intent['egress']['device']) + ":" + str(intent['egress']['port'])
+ if intent[ 'type' ] == "MultiPointToSinglePointIntent" and intent[ 'state' ] == 'INSTALLED':
+ egress = str( intent[ 'egress' ][ 'device' ] ) + ":" + str(
+ intent[ 'egress' ][ 'port' ] )
ingress = []
- for attachmentPoint in intent['ingress']:
- ingress.append(str(attachmentPoint['device']) + ":" + str(attachmentPoint['port']))
+ for attachmentPoint in intent[ 'ingress' ]:
+ ingress.append(
+ str( attachmentPoint[ 'device' ] ) + ":" + str( attachmentPoint[ 'port' ] ) )
- selector = intent['selector'].replace("[" , "").replace("]" , "").replace(" ", "")
- if str(selector).startswith("IPV4"):
- str1, str2 = str(selector).split(",")
+ selector = intent[ 'selector' ].replace(
+ "[", "" ).replace( "]", "" ).replace( " ", "" )
+ if str( selector ).startswith( "IPV4" ):
+ str1, str2 = str( selector ).split( "," )
selector = str2 + "," + str1
- intent = egress + "/" + str(sorted(ingress)) + "/" + selector + "/" + intent['treatment']
- intents.append(intent)
- return sorted(intents)
+ intent = egress + "/" + \
+ str( sorted( ingress ) ) + "/" + \
+ selector + "/" + intent[ 'treatment' ]
+ intents.append( intent )
+ return sorted( intents )
# This method extracts all actual BGP intents from ONOS CLI
- def extract_actual_bgpIntents(self, get_intents_result):
+ def extract_actual_bgpIntents( self, get_intents_result ):
intents = []
# TODO: delete the line below when change to Mininet demo script
- # get_intents_result=open("../tests/SdnIpTest/intents.json").read()
- intents_json_obj = json.loads(get_intents_result)
+ # get_intents_result=open( "../tests/SdnIpTest/intents.json" ).read()
+ intents_json_obj = json.loads( get_intents_result )
for intent in intents_json_obj:
- if intent['appId'] != "org.onosproject.sdnip":
+ if intent[ 'appId' ] != "org.onosproject.sdnip":
continue
- if intent['type'] == "PointToPointIntent" and "protocol=6" in str(intent['selector']):
- ingress = str(intent['ingress']['device']) + ":" + str(intent['ingress']['port'])
- egress = str(intent['egress']['device']) + ":" + str(intent['egress']['port'])
- selector = str(intent['selector']).replace(" ", "").replace("[", "").replace("]", "").split(",")
- intent = ingress + "/" + egress + "/" + str(sorted(selector))
- intents.append(intent)
+ if intent[ 'type' ] == "PointToPointIntent" and "protocol=6" in str( intent[ 'selector' ] ):
+ ingress = str( intent[ 'ingress' ][ 'device' ] ) + ":" + str(
+ intent[ 'ingress' ][ 'port' ] )
+ egress = str( intent[ 'egress' ][ 'device' ] ) + ":" + str(
+ intent[ 'egress' ][ 'port' ] )
+ selector = str(
+ intent[ 'selector' ] ).replace( " ", "" ).replace( "[", "" ).replace( "]", "" ).split( "," )
+ intent = ingress + "/" + egress + \
+ "/" + str( sorted( selector ) )
+ intents.append( intent )
- return sorted(intents)
+ return sorted( intents )
- # This method generates a single point to single point intent(PointToPointIntent) for BGP path
- def generate_expected_bgpIntents(self, sdnip_json_file_path):
+ # This method generates a single point to single point intent(
+ # PointToPointIntent ) for BGP path
+ def generate_expected_bgpIntents( self, sdnip_json_file_path ):
from operator import eq
- sdnip_json_file = open(sdnip_json_file_path).read()
- sdnip_data = json.loads(sdnip_json_file)
+ sdnip_json_file = open( sdnip_json_file_path ).read()
+ sdnip_data = json.loads( sdnip_json_file )
intents = []
bgpPeerAttachmentPoint = ""
- bgpSpeakerAttachmentPoint = "of:" + str(sdnip_data['bgpSpeakers'][0]['attachmentDpid']).replace(":", "") + ":" + str(sdnip_data['bgpSpeakers'][0]['attachmentPort'])
- for peer in sdnip_data['bgpPeers']:
- bgpPeerAttachmentPoint = "of:" + str(peer['attachmentDpid']).replace(":", "") + ":" + str(peer['attachmentPort'])
+ bgpSpeakerAttachmentPoint = "of:" + str(
+ sdnip_data[ 'bgpSpeakers' ][ 0 ][ 'attachmentDpid' ] ).replace( ":",
+ "" ) + ":" + str( sdnip_data[ 'bgpSpeakers' ][ 0 ][ 'attachmentPort' ] )
+ for peer in sdnip_data[ 'bgpPeers' ]:
+ bgpPeerAttachmentPoint = "of:" + str(
+ peer[ 'attachmentDpid' ] ).replace( ":", "" ) + ":" + str( peer[ 'attachmentPort' ] )
# find out the BGP speaker IP address for this BGP peer
bgpSpeakerIpAddress = ""
- for interfaceAddress in sdnip_data['bgpSpeakers'][0]['interfaceAddresses']:
- # if eq(interfaceAddress['interfaceDpid'],sdnip_data['bgpSpeakers'][0]['attachmentDpid']) and eq(interfaceAddress['interfacePort'], sdnip_data['bgpSpeakers'][0]['attachmentPort']):
- if eq(interfaceAddress['interfaceDpid'], peer['attachmentDpid']) and eq(interfaceAddress['interfacePort'], peer['attachmentPort']):
- bgpSpeakerIpAddress = interfaceAddress['ipAddress']
+ for interfaceAddress in sdnip_data[ 'bgpSpeakers' ][ 0 ][ 'interfaceAddresses' ]:
+ # if eq( interfaceAddress[ 'interfaceDpid' ],sdnip_data[
+ # 'bgpSpeakers' ][ 0 ][ 'attachmentDpid' ] ) and eq(
+ # interfaceAddress[ 'interfacePort' ], sdnip_data[
+ # 'bgpSpeakers' ][ 0 ][ 'attachmentPort' ] ):
+ if eq( interfaceAddress[ 'interfaceDpid' ], peer[ 'attachmentDpid' ] ) and eq( interfaceAddress[ 'interfacePort' ], peer[ 'attachmentPort' ] ):
+ bgpSpeakerIpAddress = interfaceAddress[ 'ipAddress' ]
break
else:
continue
- # from bgpSpeakerAttachmentPoint to bgpPeerAttachmentPoint direction
- selector_str = "IPV4_SRC{ip=" + bgpSpeakerIpAddress + "/32}," + "IPV4_DST{ip=" + peer['ipAddress'] + "/32}," + "IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, TCP_DST{tcpPort=179}"
- selector = selector_str.replace(" ", "").replace("[", "").replace("]", "").split(",")
- intent = bgpSpeakerAttachmentPoint + "/" + bgpPeerAttachmentPoint + "/" + str(sorted(selector))
- intents.append(intent)
+ # from bgpSpeakerAttachmentPoint to bgpPeerAttachmentPoint
+ # direction
+ selector_str = "IPV4_SRC{ip=" + bgpSpeakerIpAddress + "/32}," + "IPV4_DST{ip=" + peer[
+ 'ipAddress' ] + "/32}," + "IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, TCP_DST{tcpPort=179}"
+ selector = selector_str.replace( " ", "" ).replace(
+ "[", "" ).replace( "]", "" ).split( "," )
+ intent = bgpSpeakerAttachmentPoint + "/" + \
+ bgpPeerAttachmentPoint + "/" + str( sorted( selector ) )
+ intents.append( intent )
- selector_str = "IPV4_SRC{ip=" + bgpSpeakerIpAddress + "/32}," + "IPV4_DST{ip=" + peer['ipAddress'] + "/32}," + "IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, TCP_SRC{tcpPort=179}"
- selector = selector_str.replace(" ", "").replace("[", "").replace("]", "").split(",")
- intent = bgpSpeakerAttachmentPoint + "/" + bgpPeerAttachmentPoint + "/" + str(sorted(selector))
- intents.append(intent)
+ selector_str = "IPV4_SRC{ip=" + bgpSpeakerIpAddress + "/32}," + "IPV4_DST{ip=" + peer[
+ 'ipAddress' ] + "/32}," + "IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, TCP_SRC{tcpPort=179}"
+ selector = selector_str.replace( " ", "" ).replace(
+ "[", "" ).replace( "]", "" ).split( "," )
+ intent = bgpSpeakerAttachmentPoint + "/" + \
+ bgpPeerAttachmentPoint + "/" + str( sorted( selector ) )
+ intents.append( intent )
- # from bgpPeerAttachmentPoint to bgpSpeakerAttachmentPoint direction
- selector_str = "IPV4_SRC{ip=" + peer['ipAddress'] + "/32}," + "IPV4_DST{ip=" + bgpSpeakerIpAddress + "/32}," + "IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, TCP_DST{tcpPort=179}"
- selector = selector_str.replace(" ", "").replace("[", "").replace("]", "").split(",")
- intent = bgpPeerAttachmentPoint + "/" + bgpSpeakerAttachmentPoint + "/" + str(sorted(selector))
- intents.append(intent)
+ # from bgpPeerAttachmentPoint to bgpSpeakerAttachmentPoint
+ # direction
+ selector_str = "IPV4_SRC{ip=" + peer[ 'ipAddress' ] + "/32}," + "IPV4_DST{ip=" + bgpSpeakerIpAddress + "/32}," + \
+ "IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, TCP_DST{tcpPort=179}"
+ selector = selector_str.replace( " ", "" ).replace(
+ "[", "" ).replace( "]", "" ).split( "," )
+ intent = bgpPeerAttachmentPoint + "/" + \
+ bgpSpeakerAttachmentPoint + "/" + str( sorted( selector ) )
+ intents.append( intent )
- selector_str = "IPV4_SRC{ip=" + peer['ipAddress'] + "/32}," + "IPV4_DST{ip=" + bgpSpeakerIpAddress + "/32}," + "IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, TCP_SRC{tcpPort=179}"
- selector = selector_str.replace(" ", "").replace("[", "").replace("]", "").split(",")
- intent = bgpPeerAttachmentPoint + "/" + bgpSpeakerAttachmentPoint + "/" + str(sorted(selector))
- intents.append(intent)
+ selector_str = "IPV4_SRC{ip=" + peer[ 'ipAddress' ] + "/32}," + "IPV4_DST{ip=" + bgpSpeakerIpAddress + "/32}," + \
+ "IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, TCP_SRC{tcpPort=179}"
+ selector = selector_str.replace( " ", "" ).replace(
+ "[", "" ).replace( "]", "" ).split( "," )
+ intent = bgpPeerAttachmentPoint + "/" + \
+ bgpSpeakerAttachmentPoint + "/" + str( sorted( selector ) )
+ intents.append( intent )
- return sorted(intents)
+ return sorted( intents )
- def add_routes(self, routes, routeRate):
- main.log.info("I am in add_routes method!")
+ def add_routes( self, routes, routeRate ):
+ main.log.info( "I am in add_routes method!" )
routes_added = 0
try:
- self.handle.sendline("")
- # self.handle.expect("config-router")
- self.handle.expect("config-router", timeout=5)
+ self.handle.sendline( "" )
+ # self.handle.expect( "config-router" )
+ self.handle.expect( "config-router", timeout=5 )
except:
- main.log.warn("Probably not in config-router mode!")
+ main.log.warn( "Probably not in config-router mode!" )
self.disconnect()
- main.log.info("Start to add routes")
+ main.log.info( "Start to add routes" )
- for i in range(0, len(routes)):
- routeCmd = "network " + routes[i]
+ for i in range( 0, len( routes ) ):
+ routeCmd = "network " + routes[ i ]
try:
- self.handle.sendline(routeCmd)
- self.handle.expect("bgpd", timeout=5)
+ self.handle.sendline( routeCmd )
+ self.handle.expect( "bgpd", timeout=5 )
except:
- main.log.warn("Failed to add route")
+ main.log.warn( "Failed to add route" )
self.disconnect()
waitTimer = 1.00 / routeRate
- time.sleep(waitTimer)
- if routes_added == len(routes):
- main.log.info("Finished adding routes")
+ time.sleep( waitTimer )
+ if routes_added == len( routes ):
+ main.log.info( "Finished adding routes" )
return main.TRUE
return main.FALSE
- def delete_routes(self, routes, routeRate):
- main.log.info("I am in delete_routes method!")
+ def delete_routes( self, routes, routeRate ):
+ main.log.info( "I am in delete_routes method!" )
routes_added = 0
try:
- self.handle.sendline("")
- # self.handle.expect("config-router")
- self.handle.expect("config-router", timeout=5)
+ self.handle.sendline( "" )
+ # self.handle.expect( "config-router" )
+ self.handle.expect( "config-router", timeout=5 )
except:
- main.log.warn("Probably not in config-router mode!")
+ main.log.warn( "Probably not in config-router mode!" )
self.disconnect()
- main.log.info("Start to delete routes")
+ main.log.info( "Start to delete routes" )
- for i in range(0, len(routes)):
- routeCmd = "no network " + routes[i]
+ for i in range( 0, len( routes ) ):
+ routeCmd = "no network " + routes[ i ]
try:
- self.handle.sendline(routeCmd)
- self.handle.expect("bgpd", timeout=5)
+ self.handle.sendline( routeCmd )
+ self.handle.expect( "bgpd", timeout=5 )
except:
- main.log.warn("Failed to add route")
+ main.log.warn( "Failed to add route" )
self.disconnect()
waitTimer = 1.00 / routeRate
- time.sleep(waitTimer)
- if routes_added == len(routes):
- main.log.info("Finished deleting routes")
+ time.sleep( waitTimer )
+ if routes_added == len( routes ):
+ main.log.info( "Finished deleting routes" )
return main.TRUE
return main.FALSE
- def ping_test(self, ip_address, ping_test_file, ping_test_result_file):
- main.log.info("Start the ping test on host:" + str(ip_address))
+ def ping_test( self, ip_address, ping_test_file, ping_test_result_file ):
+ main.log.info( "Start the ping test on host:" + str( ip_address ) )
- self.name = self.options['name']
- self.handle = super(QuaggaCliDriver, self).connect(
+ self.name = self.options[ 'name' ]
+ self.handle = super( QuaggaCliDriver, self ).connect(
user_name=self.user_name, ip_address=ip_address,
- port=self.port, pwd=self.pwd)
- main.log.info("connect parameters:" + str(self.user_name) + ";"
- + str(self.ip_address) + ";" + str(self.port) + ";" + str(self.pwd))
+ port=self.port, pwd=self.pwd )
+ main.log.info( "connect parameters:" + str( self.user_name ) + ";"
+ + str( self.ip_address ) + ";" + str( self.port ) + ";" + str( self.pwd ) )
if self.handle:
- #self.handle.expect("")
- #self.handle.expect("\$")
- main.log.info("I in host " + str(ip_address))
- main.log.info(ping_test_file + " > " + ping_test_result_file + " &")
- self.handle.sendline(ping_test_file + " > " + ping_test_result_file + " &")
- self.handle.expect("\$", timeout=60)
+ # self.handle.expect( "" )
+ # self.handle.expect( "\$" )
+ main.log.info( "I in host " + str( ip_address ) )
+ main.log.info(
+ ping_test_file +
+ " > " +
+ ping_test_result_file +
+ " &" )
+ self.handle.sendline(
+ ping_test_file +
+ " > " +
+ ping_test_result_file +
+ " &" )
+ self.handle.expect( "\$", timeout=60 )
handle = self.handle.before
return handle
else:
- main.log.info("NO HANDLE")
+ main.log.info( "NO HANDLE" )
return main.FALSE
-
# Please use the generate_routes plus add_routes instead of this one
- def add_route(self, net, numRoutes, routeRate):
+ def add_route( self, net, numRoutes, routeRate ):
try:
- self.handle.sendline("")
- self.handle.expect("config-router")
+ self.handle.sendline( "" )
+ self.handle.expect( "config-router" )
except:
- main.log.warn("Probably not in config-router mode!")
+ main.log.warn( "Probably not in config-router mode!" )
self.disconnect()
- main.log.info("Adding Routes")
+ main.log.info( "Adding Routes" )
j = 0
k = 0
while numRoutes > 255:
@@ -348,44 +416,47 @@
routes_added = 0
if numRoutes > 255:
numRoutes = 255
- for m in range(1, j + 1):
- for n in range(1, numRoutes + 1):
- network = str(net) + "." + str(m) + "." + str(n) + ".0/24"
+ for m in range( 1, j + 1 ):
+ for n in range( 1, numRoutes + 1 ):
+ network = str( net ) + "." + str( m ) + "." + str( n ) + ".0/24"
routeCmd = "network " + network
try:
- self.handle.sendline(routeCmd)
- self.handle.expect("bgpd")
+ self.handle.sendline( routeCmd )
+ self.handle.expect( "bgpd" )
except:
- main.log.warn("failed to add route")
+ main.log.warn( "failed to add route" )
self.disconnect()
waitTimer = 1.00 / routeRate
- time.sleep(waitTimer)
+ time.sleep( waitTimer )
routes_added = routes_added + 1
- for d in range(j + 1, j + 2):
- for e in range(1, k + 1):
- network = str(net) + "." + str(d) + "." + str(e) + ".0/24"
+ for d in range( j + 1, j + 2 ):
+ for e in range( 1, k + 1 ):
+ network = str(
+ net ) + "." + str(
+ d ) + "." + str(
+ e ) + ".0/24"
routeCmd = "network " + network
try:
- self.handle.sendline(routeCmd)
- self.handle.expect("bgpd")
+ self.handle.sendline( routeCmd )
+ self.handle.expect( "bgpd" )
except:
- main.log.warn("failed to add route")
+ main.log.warn( "failed to add route" )
self.disconnect
waitTimer = 1.00 / routeRate
- time.sleep(waitTimer)
+ time.sleep( waitTimer )
routes_added = routes_added + 1
if routes_added == numRoutes:
return main.TRUE
return main.FALSE
- def del_route(self, net, numRoutes, routeRate):
+ def del_route( self, net, numRoutes, routeRate ):
try:
- self.handle.sendline("")
- self.handle.expect("config-router")
+ self.handle.sendline( "" )
+ self.handle.expect( "config-router" )
except:
- main.log.warn("Probably not in config-router mode!")
+ main.log.warn( "Probably not in config-router mode!" )
self.disconnect()
- main.log.info("Deleting Routes")
+ main.log.info( "Deleting Routes" )
j = 0
k = 0
while numRoutes > 255:
@@ -395,100 +466,106 @@
routes_deleted = 0
if numRoutes > 255:
numRoutes = 255
- for m in range(1, j + 1):
- for n in range(1, numRoutes + 1):
- network = str(net) + "." + str(m) + "." + str(n) + ".0/24"
+ for m in range( 1, j + 1 ):
+ for n in range( 1, numRoutes + 1 ):
+ network = str( net ) + "." + str( m ) + "." + str( n ) + ".0/24"
routeCmd = "no network " + network
try:
- self.handle.sendline(routeCmd)
- self.handle.expect("bgpd")
+ self.handle.sendline( routeCmd )
+ self.handle.expect( "bgpd" )
except:
- main.log.warn("Failed to delete route")
+ main.log.warn( "Failed to delete route" )
self.disconnect()
waitTimer = 1.00 / routeRate
- time.sleep(waitTimer)
+ time.sleep( waitTimer )
routes_deleted = routes_deleted + 1
- for d in range(j + 1, j + 2):
- for e in range(1, k + 1):
- network = str(net) + "." + str(d) + "." + str(e) + ".0/24"
+ for d in range( j + 1, j + 2 ):
+ for e in range( 1, k + 1 ):
+ network = str( net ) + "." + str( d ) + "." + str( e ) + ".0/24"
routeCmd = "no network " + network
try:
- self.handle.sendline(routeCmd)
- self.handle.expect("bgpd")
+ self.handle.sendline( routeCmd )
+ self.handle.expect( "bgpd" )
except:
- main.log.warn("Failed to delete route")
+ main.log.warn( "Failed to delete route" )
self.disconnect()
waitTimer = 1.00 / routeRate
- time.sleep(waitTimer)
+ time.sleep( waitTimer )
routes_deleted = routes_deleted + 1
if routes_deleted == numRoutes:
return main.TRUE
return main.FALSE
- def check_routes(self, brand, ip, user, pw):
- def pronto(ip, user, passwd):
+ def check_routes( self, brand, ip, user, pw ):
+ def pronto( ip, user, passwd ):
print "Connecting to Pronto switch"
- child = pexpect.spawn("telnet " + ip)
- i = child.expect(["login:", "CLI#", pexpect.TIMEOUT])
+ child = pexpect.spawn( "telnet " + ip )
+ i = child.expect( [ "login:", "CLI#", pexpect.TIMEOUT ] )
if i == 0:
print "Username and password required. Passing login info."
- child.sendline(user)
- child.expect("Password:")
- child.sendline(passwd)
- child.expect("CLI#")
+ child.sendline( user )
+ child.expect( "Password:" )
+ child.sendline( passwd )
+ child.expect( "CLI#" )
print "Logged in, getting flowtable."
- child.sendline("flowtable brief")
- for t in range (9):
+ child.sendline( "flowtable brief" )
+ for t in range( 9 ):
t2 = 9 - t
- print "\r" + str(t2)
- sys.stdout.write("\033[F")
- time.sleep(1)
+ print "\r" + str( t2 )
+ sys.stdout.write( "\033[F" )
+ time.sleep( 1 )
print "Scanning flowtable"
- child.expect("Flow table show")
+ child.expect( "Flow table show" )
count = 0
- while 1:
- i = child.expect(['17\d\.\d{1,3}\.\d{1,3}\.\d{1,3}', 'CLI#', pexpect.TIMEOUT])
+ while True:
+ i = child.expect(
+ [ '17\d\.\d{1,3}\.\d{1,3}\.\d{1,3}',
+ 'CLI#',
+ pexpect.TIMEOUT ] )
if i == 0:
count = count + 1
elif i == 1:
- print "Pronto flows: " + str(count) + "\nDone\n"
+ print "Pronto flows: " + str( count ) + "\nDone\n"
break
else:
break
- def cisco(ip, user, passwd):
+
+ def cisco( ip, user, passwd ):
print "Establishing Cisco switch connection"
- child = pexpect.spawn("ssh " + user + "@" + ip)
- i = child.expect(["Password:", "CLI#", pexpect.TIMEOUT])
+ child = pexpect.spawn( "ssh " + user + "@" + ip )
+ i = child.expect( [ "Password:", "CLI#", pexpect.TIMEOUT ] )
if i == 0:
print "Password required. Passing now."
- child.sendline(passwd)
- child.expect("#")
+ child.sendline( passwd )
+ child.expect( "#" )
print "Logged in. Retrieving flow table then counting flows."
- child.sendline("show openflow switch all flows all")
- child.expect("Logical Openflow Switch")
+ child.sendline( "show openflow switch all flows all" )
+ child.expect( "Logical Openflow Switch" )
print "Flow table retrieved. Counting flows"
count = 0
- while 1:
- i = child.expect(["nw_src=17", "#", pexpect.TIMEOUT])
+ while True:
+ i = child.expect( [ "nw_src=17", "#", pexpect.TIMEOUT ] )
if i == 0:
count = count + 1
elif i == 1:
- print "Cisco flows: " + str(count) + "\nDone\n"
+ print "Cisco flows: " + str( count ) + "\nDone\n"
break
else:
break
if brand == "pronto" or brand == "PRONTO":
- pronto(ip, user, passwd)
+ pronto( ip, user, passwd )
# elif brand == "cisco" or brand == "CISCO":
- # cisco(ip,user,passwd)
- def disconnect(self):
- '''
- Called when Test is complete to disconnect the Quagga handle.
- '''
+ # cisco( ip,user,passwd )
+
+ def disconnect( self ):
+ """
+ Called when Test is complete to disconnect the Quagga handle.
+ """
response = ''
try:
self.handle.close()
except:
- main.log.error("Connection failed to the host")
+ main.log.error( "Connection failed to the host" )
response = main.FALSE
return response
+
diff --git a/TestON/drivers/common/cli/quaggaclidriver.py.fixed b/TestON/drivers/common/cli/quaggaclidriver.py.fixed
new file mode 100644
index 0000000..09b7614
--- /dev/null
+++ b/TestON/drivers/common/cli/quaggaclidriver.py.fixed
@@ -0,0 +1,596 @@
+#!/usr/bin/env python
+
+import time
+import pexpect
+import struct
+import fcntl
+import os
+import sys
+import signal
+import sys
+import re
+import json
+sys.path.append( "../" )
+from drivers.common.clidriver import CLI
+
+
+class QuaggaCliDriver( CLI ):
+
+ def __init__( self ):
+ super( CLI, self ).__init__()
+
+ # TODO: simplify this method
+ def connect( self, **connectargs ):
+ for key in connectargs:
+ vars( self )[ key ] = connectargs[ key ]
+
+ self.name = self.options[ 'name' ]
+ # self.handle = super( QuaggaCliDriver,self ).connect(
+ # user_name=self.user_name, ip_address=self.ip_address,port=self.port,
+ # pwd=self.pwd )
+ self.handle = super(
+ QuaggaCliDriver,
+ self ).connect(
+ user_name=self.user_name,
+ ip_address="1.1.1.1",
+ port=self.port,
+ pwd=self.pwd )
+ main.log.info(
+ "connect parameters:" + str(
+ self.user_name ) + ";" + str(
+ self.ip_address ) + ";" + str(
+ self.port ) + ";" + str(
+ self.pwd ) )
+
+ if self.handle:
+ # self.handle.expect( "",timeout=10 )
+ # self.handle.expect( "\$",timeout=10 )
+ self.handle.sendline( "telnet localhost 2605" )
+ # self.handle.expect( "Password:", timeout=5 )
+ self.handle.expect( "Password:" )
+ self.handle.sendline( "hello" )
+ # self.handle.expect( "bgpd", timeout=5 )
+ self.handle.expect( "bgpd" )
+ self.handle.sendline( "enable" )
+ # self.handle.expect( "bgpd#", timeout=5 )
+ self.handle.expect( "bgpd#" )
+ return self.handle
+ else:
+ main.log.info( "NO HANDLE" )
+ return main.FALSE
+
+ def loginQuagga( self, ip_address ):
+ self.name = self.options[ 'name' ]
+ self.handle = super( QuaggaCliDriver, self ).connect(
+ user_name=self.user_name, ip_address=ip_address,
+ port=self.port, pwd=self.pwd )
+ main.log.info( "connect parameters:" + str( self.user_name ) + ";"
+ + str( self.ip_address ) + ";" + str( self.port ) + ";" + str( self.pwd ) )
+
+ if self.handle:
+ # self.handle.expect( "" )
+ # self.handle.expect( "\$" )
+ self.handle.sendline( "telnet localhost 2605" )
+ # self.handle.expect( "Password:", timeout=5 )
+ self.handle.expect( "Password:" )
+ self.handle.sendline( "hello" )
+ # self.handle.expect( "bgpd", timeout=5 )
+ self.handle.expect( "bgpd" )
+ self.handle.sendline( "enable" )
+ # self.handle.expect( "bgpd#", timeout=5 )
+ self.handle.expect( "bgpd#" )
+ main.log.info( "I in quagga on host " + str( ip_address ) )
+
+ return self.handle
+ else:
+ main.log.info( "NO HANDLE" )
+ return main.FALSE
+
+ def enter_config( self, asn ):
+ main.log.info( "I am in enter_config method!" )
+ try:
+ self.handle.sendline( "" )
+ self.handle.expect( "bgpd#" )
+ except:
+ main.log.warn( "Probably not currently in enable mode!" )
+ self.disconnect()
+ return main.FALSE
+ self.handle.sendline( "configure terminal" )
+ self.handle.expect( "config", timeout=5 )
+ routerAS = "router bgp " + str( asn )
+ try:
+ self.handle.sendline( routerAS )
+ self.handle.expect( "config-router", timeout=5 )
+ return main.TRUE
+ except:
+ return main.FALSE
+
+ def generate_prefixes( self, net, numRoutes ):
+ main.log.info( "I am in generate_prefixes method!" )
+
+ # each IP prefix will be composed by "net" + "." + m + "." + n + "." + x
+ # the length of each IP prefix is 24
+ routes = []
+ routes_gen = 0
+ m = numRoutes / 256
+ n = numRoutes % 256
+
+ for i in range( 0, m ):
+ for j in range( 0, 256 ):
+ network = str(
+ net ) + "." + str(
+ i ) + "." + str(
+ j ) + ".0/24"
+ routes.append( network )
+ routes_gen = routes_gen + 1
+
+ for j in range( 0, n ):
+ network = str( net ) + "." + str( m ) + "." + str( j ) + ".0/24"
+ routes.append( network )
+ routes_gen = routes_gen + 1
+
+ if routes_gen == numRoutes:
+ main.log.info( "Successfully generated " + str( numRoutes )
+ + " prefixes!" )
+ return routes
+ return main.FALSE
+
+ # This method generates a multiple to single point intent(
+ # MultiPointToSinglePointIntent ) for a given route
+ def generate_expected_singleRouteIntent(
+ self,
+ prefix,
+ nextHop,
+ nextHopMac,
+ sdnip_data ):
+
+ ingress = []
+ egress = ""
+ for peer in sdnip_data[ 'bgpPeers' ]:
+ if peer[ 'ipAddress' ] == nextHop:
+ egress = "of:" + str(
+ peer[ 'attachmentDpid' ] ).replace( ":",
+ "" ) + ":" + str( peer[ 'attachmentPort' ] )
+ else:
+ ingress.append(
+ "of:" + str( peer[ 'attachmentDpid' ] ).replace( ":",
+ "" ) + ":" + str( peer[ 'attachmentPort' ] ) )
+
+ selector = "ETH_TYPE{ethType=800},IPV4_DST{ip=" + prefix + "}"
+ treatment = "[ETH_DST{mac=" + str( nextHopMac ) + "}]"
+
+ intent = egress + "/" + \
+ str( sorted( ingress ) ) + "/" + selector + "/" + treatment
+ return intent
+
+ def generate_expected_onePeerRouteIntents(
+ self,
+ prefixes,
+ nextHop,
+ nextHopMac,
+ sdnip_json_file_path ):
+ intents = []
+ sdnip_json_file = open( sdnip_json_file_path ).read()
+
+ sdnip_data = json.loads( sdnip_json_file )
+
+ for prefix in prefixes:
+ intents.append(
+ self.generate_expected_singleRouteIntent(
+ prefix,
+ nextHop,
+ nextHopMac,
+ sdnip_data ) )
+ return sorted( intents )
+
+ # TODO
+ # This method generates all expected route intents for all BGP peers
+ def generate_expected_routeIntents( self ):
+ intents = []
+ return intents
+
+ # This method extracts all actual routes from ONOS CLI
+ def extract_actual_routes( self, get_routes_result ):
+ routes_json_obj = json.loads( get_routes_result )
+
+ allRoutes_actual = []
+ for route in routes_json_obj:
+ if route[ 'prefix' ] == '172.16.10.0/24':
+ continue
+ allRoutes_actual.append(
+ route[ 'prefix' ] + "/" + route[ 'nextHop' ] )
+
+ return sorted( allRoutes_actual )
+
+ # This method extracts all actual route intents from ONOS CLI
+ def extract_actual_routeIntents( self, get_intents_result ):
+ intents = []
+ # TODO: delete the line below when change to Mininet demo script
+ # get_intents_result=open( "../tests/SdnIpTest/intents.json" ).read()
+ intents_json_obj = json.loads( get_intents_result )
+
+ for intent in intents_json_obj:
+ if intent[ 'appId' ] != "org.onosproject.sdnip":
+ continue
+ if intent[ 'type' ] == "MultiPointToSinglePointIntent" and intent[ 'state' ] == 'INSTALLED':
+ egress = str( intent[ 'egress' ][ 'device' ] ) + ":" + str(
+ intent[ 'egress' ][ 'port' ] )
+ ingress = []
+ for attachmentPoint in intent[ 'ingress' ]:
+ ingress.append(
+ str( attachmentPoint[ 'device' ] ) + ":" + str( attachmentPoint[ 'port' ] ) )
+
+ selector = intent[ 'selector' ].replace(
+ "[", "" ).replace( "]", "" ).replace( " ", "" )
+ if str( selector ).startswith( "IPV4" ):
+ str1, str2 = str( selector ).split( "," )
+ selector = str2 + "," + str1
+
+ intent = egress + "/" + \
+ str( sorted( ingress ) ) + "/" + \
+ selector + "/" + intent[ 'treatment' ]
+ intents.append( intent )
+ return sorted( intents )
+
+ # This method extracts all actual BGP intents from ONOS CLI
+ def extract_actual_bgpIntents( self, get_intents_result ):
+ intents = []
+ # TODO: delete the line below when change to Mininet demo script
+ # get_intents_result=open( "../tests/SdnIpTest/intents.json" ).read()
+ intents_json_obj = json.loads( get_intents_result )
+
+ for intent in intents_json_obj:
+ if intent[ 'appId' ] != "org.onosproject.sdnip":
+ continue
+ if intent[ 'type' ] == "PointToPointIntent" and "protocol=6" in str( intent[ 'selector' ] ):
+ ingress = str( intent[ 'ingress' ][ 'device' ] ) + ":" + str(
+ intent[ 'ingress' ][ 'port' ] )
+ egress = str( intent[ 'egress' ][ 'device' ] ) + ":" + str(
+ intent[ 'egress' ][ 'port' ] )
+ selector = str(
+ intent[ 'selector' ] ).replace( " ",
+ "" ).replace( "[",
+ "" ).replace( "]",
+ "" ).split( "," )
+ intent = ingress + "/" + egress + \
+ "/" + str( sorted( selector ) )
+ intents.append( intent )
+
+ return sorted( intents )
+
+ # This method generates a single point to single point intent(
+ # PointToPointIntent ) for BGP path
+ def generate_expected_bgpIntents( self, sdnip_json_file_path ):
+ from operator import eq
+
+ sdnip_json_file = open( sdnip_json_file_path ).read()
+ sdnip_data = json.loads( sdnip_json_file )
+
+ intents = []
+ bgpPeerAttachmentPoint = ""
+ bgpSpeakerAttachmentPoint = "of:" + str(
+ sdnip_data[ 'bgpSpeakers' ][ 0 ][ 'attachmentDpid' ] ).replace( ":",
+ "" ) + ":" + str( sdnip_data[ 'bgpSpeakers' ][ 0 ][ 'attachmentPort' ] )
+ for peer in sdnip_data[ 'bgpPeers' ]:
+ bgpPeerAttachmentPoint = "of:" + str(
+ peer[ 'attachmentDpid' ] ).replace( ":",
+ "" ) + ":" + str( peer[ 'attachmentPort' ] )
+ # find out the BGP speaker IP address for this BGP peer
+ bgpSpeakerIpAddress = ""
+ for interfaceAddress in sdnip_data[ 'bgpSpeakers' ][ 0 ][ 'interfaceAddresses' ]:
+ # if eq( interfaceAddress[ 'interfaceDpid' ],sdnip_data[
+ # 'bgpSpeakers' ][ 0 ][ 'attachmentDpid' ] ) and eq(
+ # interfaceAddress[ 'interfacePort' ], sdnip_data[
+ # 'bgpSpeakers' ][ 0 ][ 'attachmentPort' ] ):
+ if eq( interfaceAddress[ 'interfaceDpid' ], peer[ 'attachmentDpid' ] ) and eq( interfaceAddress[ 'interfacePort' ], peer[ 'attachmentPort' ] ):
+ bgpSpeakerIpAddress = interfaceAddress[ 'ipAddress' ]
+ break
+ else:
+ continue
+
+ # from bgpSpeakerAttachmentPoint to bgpPeerAttachmentPoint
+ # direction
+ selector_str = "IPV4_SRC{ip=" + bgpSpeakerIpAddress + "/32}," + "IPV4_DST{ip=" + peer[
+ 'ipAddress' ] + "/32}," + "IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, TCP_DST{tcpPort=179}"
+ selector = selector_str.replace( " ", "" ).replace(
+ "[", "" ).replace( "]", "" ).split( "," )
+ intent = bgpSpeakerAttachmentPoint + "/" + \
+ bgpPeerAttachmentPoint + "/" + str( sorted( selector ) )
+ intents.append( intent )
+
+ selector_str = "IPV4_SRC{ip=" + bgpSpeakerIpAddress + "/32}," + "IPV4_DST{ip=" + peer[
+ 'ipAddress' ] + "/32}," + "IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, TCP_SRC{tcpPort=179}"
+ selector = selector_str.replace( " ", "" ).replace(
+ "[", "" ).replace( "]", "" ).split( "," )
+ intent = bgpSpeakerAttachmentPoint + "/" + \
+ bgpPeerAttachmentPoint + "/" + str( sorted( selector ) )
+ intents.append( intent )
+
+ # from bgpPeerAttachmentPoint to bgpSpeakerAttachmentPoint
+ # direction
+ selector_str = "IPV4_SRC{ip=" + peer[ 'ipAddress' ] + "/32}," + "IPV4_DST{ip=" + bgpSpeakerIpAddress + "/32}," + \
+ "IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, TCP_DST{tcpPort=179}"
+ selector = selector_str.replace( " ", "" ).replace(
+ "[", "" ).replace( "]", "" ).split( "," )
+ intent = bgpPeerAttachmentPoint + "/" + \
+ bgpSpeakerAttachmentPoint + "/" + str( sorted( selector ) )
+ intents.append( intent )
+
+ selector_str = "IPV4_SRC{ip=" + peer[ 'ipAddress' ] + "/32}," + "IPV4_DST{ip=" + bgpSpeakerIpAddress + "/32}," + \
+ "IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, TCP_SRC{tcpPort=179}"
+ selector = selector_str.replace( " ", "" ).replace(
+ "[", "" ).replace( "]", "" ).split( "," )
+ intent = bgpPeerAttachmentPoint + "/" + \
+ bgpSpeakerAttachmentPoint + "/" + str( sorted( selector ) )
+ intents.append( intent )
+
+ return sorted( intents )
+
+ def add_routes( self, routes, routeRate ):
+ main.log.info( "I am in add_routes method!" )
+
+ routes_added = 0
+ try:
+ self.handle.sendline( "" )
+ # self.handle.expect( "config-router" )
+ self.handle.expect( "config-router", timeout=5 )
+ except:
+ main.log.warn( "Probably not in config-router mode!" )
+ self.disconnect()
+ main.log.info( "Start to add routes" )
+
+ for i in range( 0, len( routes ) ):
+ routeCmd = "network " + routes[ i ]
+ try:
+ self.handle.sendline( routeCmd )
+ self.handle.expect( "bgpd", timeout=5 )
+ except:
+ main.log.warn( "Failed to add route" )
+ self.disconnect()
+ waitTimer = 1.00 / routeRate
+ time.sleep( waitTimer )
+ if routes_added == len( routes ):
+ main.log.info( "Finished adding routes" )
+ return main.TRUE
+ return main.FALSE
+
+ def delete_routes( self, routes, routeRate ):
+ main.log.info( "I am in delete_routes method!" )
+
+ routes_added = 0
+ try:
+ self.handle.sendline( "" )
+ # self.handle.expect( "config-router" )
+ self.handle.expect( "config-router", timeout=5 )
+ except:
+ main.log.warn( "Probably not in config-router mode!" )
+ self.disconnect()
+ main.log.info( "Start to delete routes" )
+
+ for i in range( 0, len( routes ) ):
+ routeCmd = "no network " + routes[ i ]
+ try:
+ self.handle.sendline( routeCmd )
+ self.handle.expect( "bgpd", timeout=5 )
+ except:
+ main.log.warn( "Failed to add route" )
+ self.disconnect()
+ waitTimer = 1.00 / routeRate
+ time.sleep( waitTimer )
+ if routes_added == len( routes ):
+ main.log.info( "Finished deleting routes" )
+ return main.TRUE
+ return main.FALSE
+
+ def ping_test( self, ip_address, ping_test_file, ping_test_result_file ):
+ main.log.info( "Start the ping test on host:" + str( ip_address ) )
+
+ self.name = self.options[ 'name' ]
+ self.handle = super( QuaggaCliDriver, self ).connect(
+ user_name=self.user_name, ip_address=ip_address,
+ port=self.port, pwd=self.pwd )
+ main.log.info( "connect parameters:" + str( self.user_name ) + ";"
+ + str( self.ip_address ) + ";" + str( self.port ) + ";" + str( self.pwd ) )
+
+ if self.handle:
+ # self.handle.expect( "" )
+ # self.handle.expect( "\$" )
+ main.log.info( "I in host " + str( ip_address ) )
+ main.log.info(
+ ping_test_file +
+ " > " +
+ ping_test_result_file +
+ " &" )
+ self.handle.sendline(
+ ping_test_file +
+ " > " +
+ ping_test_result_file +
+ " &" )
+ self.handle.expect( "\$", timeout=60 )
+ handle = self.handle.before
+
+ return handle
+ else:
+ main.log.info( "NO HANDLE" )
+ return main.FALSE
+
+ # Please use the generate_routes plus add_routes instead of this one
+ def add_route( self, net, numRoutes, routeRate ):
+ try:
+ self.handle.sendline( "" )
+ self.handle.expect( "config-router" )
+ except:
+ main.log.warn( "Probably not in config-router mode!" )
+ self.disconnect()
+ main.log.info( "Adding Routes" )
+ j = 0
+ k = 0
+ while numRoutes > 255:
+ numRoutes = numRoutes - 255
+ j = j + 1
+ k = numRoutes % 254
+ routes_added = 0
+ if numRoutes > 255:
+ numRoutes = 255
+ for m in range( 1, j + 1 ):
+ for n in range( 1, numRoutes + 1 ):
+ network = str(
+ net ) + "." + str(
+ m ) + "." + str(
+ n ) + ".0/24"
+ routeCmd = "network " + network
+ try:
+ self.handle.sendline( routeCmd )
+ self.handle.expect( "bgpd" )
+ except:
+ main.log.warn( "failed to add route" )
+ self.disconnect()
+ waitTimer = 1.00 / routeRate
+ time.sleep( waitTimer )
+ routes_added = routes_added + 1
+ for d in range( j + 1, j + 2 ):
+ for e in range( 1, k + 1 ):
+ network = str(
+ net ) + "." + str(
+ d ) + "." + str(
+ e ) + ".0/24"
+ routeCmd = "network " + network
+ try:
+ self.handle.sendline( routeCmd )
+ self.handle.expect( "bgpd" )
+ except:
+ main.log.warn( "failed to add route" )
+ self.disconnect
+ waitTimer = 1.00 / routeRate
+ time.sleep( waitTimer )
+ routes_added = routes_added + 1
+ if routes_added == numRoutes:
+ return main.TRUE
+ return main.FALSE
+
+ def del_route( self, net, numRoutes, routeRate ):
+ try:
+ self.handle.sendline( "" )
+ self.handle.expect( "config-router" )
+ except:
+ main.log.warn( "Probably not in config-router mode!" )
+ self.disconnect()
+ main.log.info( "Deleting Routes" )
+ j = 0
+ k = 0
+ while numRoutes > 255:
+ numRoutes = numRoutes - 255
+ j = j + 1
+ k = numRoutes % 254
+ routes_deleted = 0
+ if numRoutes > 255:
+ numRoutes = 255
+ for m in range( 1, j + 1 ):
+ for n in range( 1, numRoutes + 1 ):
+ network = str(
+ net ) + "." + str(
+ m ) + "." + str(
+ n ) + ".0/24"
+ routeCmd = "no network " + network
+ try:
+ self.handle.sendline( routeCmd )
+ self.handle.expect( "bgpd" )
+ except:
+ main.log.warn( "Failed to delete route" )
+ self.disconnect()
+ waitTimer = 1.00 / routeRate
+ time.sleep( waitTimer )
+ routes_deleted = routes_deleted + 1
+ for d in range( j + 1, j + 2 ):
+ for e in range( 1, k + 1 ):
+ network = str(
+ net ) + "." + str(
+ d ) + "." + str(
+ e ) + ".0/24"
+ routeCmd = "no network " + network
+ try:
+ self.handle.sendline( routeCmd )
+ self.handle.expect( "bgpd" )
+ except:
+ main.log.warn( "Failed to delete route" )
+ self.disconnect()
+ waitTimer = 1.00 / routeRate
+ time.sleep( waitTimer )
+ routes_deleted = routes_deleted + 1
+ if routes_deleted == numRoutes:
+ return main.TRUE
+ return main.FALSE
+
+ def check_routes( self, brand, ip, user, pw ):
+ def pronto( ip, user, passwd ):
+ print "Connecting to Pronto switch"
+ child = pexpect.spawn( "telnet " + ip )
+ i = child.expect( [ "login:", "CLI#", pexpect.TIMEOUT ] )
+ if i == 0:
+ print "Username and password required. Passing login info."
+ child.sendline( user )
+ child.expect( "Password:" )
+ child.sendline( passwd )
+ child.expect( "CLI#" )
+ print "Logged in, getting flowtable."
+ child.sendline( "flowtable brief" )
+ for t in range( 9 ):
+ t2 = 9 - t
+ print "\r" + str( t2 )
+ sys.stdout.write( "\033[F" )
+ time.sleep( 1 )
+ print "Scanning flowtable"
+ child.expect( "Flow table show" )
+ count = 0
+ while True:
+ i = child.expect(
+ [ '17\d\.\d{1,3}\.\d{1,3}\.\d{1,3}',
+ 'CLI#',
+ pexpect.TIMEOUT ] )
+ if i == 0:
+ count = count + 1
+ elif i == 1:
+ print "Pronto flows: " + str( count ) + "\nDone\n"
+ break
+ else:
+ break
+
+ def cisco( ip, user, passwd ):
+ print "Establishing Cisco switch connection"
+ child = pexpect.spawn( "ssh " + user + "@" + ip )
+ i = child.expect( [ "Password:", "CLI#", pexpect.TIMEOUT ] )
+ if i == 0:
+ print "Password required. Passing now."
+ child.sendline( passwd )
+ child.expect( "#" )
+ print "Logged in. Retrieving flow table then counting flows."
+ child.sendline( "show openflow switch all flows all" )
+ child.expect( "Logical Openflow Switch" )
+ print "Flow table retrieved. Counting flows"
+ count = 0
+ while True:
+ i = child.expect( [ "nw_src=17", "#", pexpect.TIMEOUT ] )
+ if i == 0:
+ count = count + 1
+ elif i == 1:
+ print "Cisco flows: " + str( count ) + "\nDone\n"
+ break
+ else:
+ break
+ if brand == "pronto" or brand == "PRONTO":
+ pronto( ip, user, passwd )
+ # elif brand == "cisco" or brand == "CISCO":
+ # cisco( ip,user,passwd )
+
+ def disconnect( self ):
+ """
+ Called when Test is complete to disconnect the Quagga handle.
+ """
+ response = ''
+ try:
+ self.handle.close()
+ except:
+ main.log.error( "Connection failed to the host" )
+ response = main.FALSE
+ return response
+
diff --git a/TestON/drivers/common/cli/remotesysdriver.py b/TestON/drivers/common/cli/remotesysdriver.py
index 374e502..a536e02 100644
--- a/TestON/drivers/common/cli/remotesysdriver.py
+++ b/TestON/drivers/common/cli/remotesysdriver.py
@@ -1,13 +1,13 @@
#!/usr/bin/env python
-'''
-Created on 26-Oct-2012
+"""
+Created on 26-Oct-2012
-@author: Anil Kumar (anilkumar.s@paxterrasolutions.com)
+author:: Anil Kumar ( anilkumar.s@paxterrasolutions.com )
TestON is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
+ ( at your option ) any later version.
TestON is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -15,41 +15,52 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with TestON. If not, see <http://www.gnu.org/licenses/>.
+ along with TestON. If not, see <http://www.gnu.org/licenses/>.
-'''
+"""
import time
import pexpect
-import struct, fcntl, os, sys, signal
+import struct
+import fcntl
+import os
import sys
-sys.path.append("../")
+import signal
+import sys
+sys.path.append( "../" )
from drivers.common.clidriver import CLI
-class RemoteSysDriver(CLI):
+
+class RemoteSysDriver( CLI ):
# The common functions for emulator included in emulatordriver
- def __init__(self):
- super(CLI, self).__init__()
-
- def connect(self,**connectargs):
+
+ def __init__( self ):
+ super( CLI, self ).__init__()
+
+ def connect( self, **connectargs ):
for key in connectargs:
- vars(self)[key] = connectargs[key]
-
- self.name = self.options['name']
+ vars( self )[ key ] = connectargs[ key ]
- self.handle = super(RemoteSysDriver,self).connect(user_name = self.user_name, ip_address = self.ip_address,port = self.port, pwd = self.pwd)
- '''
+ self.name = self.options[ 'name' ]
+
+ self.handle = super(
+ RemoteSysDriver,
+ self ).connect(
+ user_name=self.user_name,
+ ip_address=self.ip_address,
+ port=self.port,
+ pwd=self.pwd )
+ """
if self.handle:
- self.execute(cmd= "\n",prompt= "\$|>|#",timeout= 10)
- self.execute(cmd= "ssh -l paxterra 10.128.4.1",prompt= "paxterra@10.128.4.1's password:",timeout= 10)
- self.execute(cmd= "\n",prompt= "paxterra@10.128.4.1's password:",timeout= 10)
- self.execute(cmd = "0nLab_gu3st",prompt = "\$",timeout = 10)
- self.execute(cmd = "cd TestON/bin/",prompt = "\$",timeout = 10)
- self.execute(cmd = "./cli.py run Assert example 1",prompt = "\$",timeout = 10)
- self.execute(cmd= "\n",prompt= "$",timeout= 10)
- #self.execute(cmd = "help",prompt = ">",timeout = 10)
-
- #self.execute(cmd = "~.",prompt= ".*",timeout= 10)
- return main.TRUE
- '''
+ self.execute( cmd= "\n",prompt= "\$|>|#",timeout= 10 )
+ self.execute( cmd= "ssh -l paxterra 10.128.4.1",prompt= "paxterra@10.128.4.1's password:",timeout= 10 )
+ self.execute( cmd= "\n",prompt= "paxterra@10.128.4.1's password:",timeout= 10 )
+ self.execute( cmd="0nLab_gu3st",prompt="\$",timeout=10 )
+ self.execute( cmd="cd TestON/bin/",prompt="\$",timeout=10 )
+ self.execute( cmd="./cli.py run Assert example 1",prompt="\$",timeout=10 )
+ self.execute( cmd= "\n",prompt= "$",timeout= 10 )
+ #self.execute( cmd="help",prompt=">",timeout=10 )
+ #self.execute( cmd="~.",prompt= ".*",timeout= 10 )
+ return main.TRUE
+ """
diff --git a/TestON/drivers/common/cli/remotetestbed/floodlightclidriver.py b/TestON/drivers/common/cli/remotetestbed/floodlightclidriver.py
index 8b25b2f..10e7a85 100644
--- a/TestON/drivers/common/cli/remotetestbed/floodlightclidriver.py
+++ b/TestON/drivers/common/cli/remotetestbed/floodlightclidriver.py
@@ -1,14 +1,14 @@
#!/usr/bin/env python
-'''
+"""
Created on 12-Feb-2013
-@author: Anil Kumar (anilkumar.s@paxterrasolutions.com)
+author:: Anil Kumar ( anilkumar.s@paxterrasolutions.com )
TestON is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
+ ( at your option ) any later version.
TestON is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -16,12 +16,11 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with TestON. If not, see <http://www.gnu.org/licenses/>.
+ along with TestON. If not, see <http://www.gnu.org/licenses/>.
FloodLightCliDriver is the basic driver which will handle the Mininet functions
-'''
-
+"""
import pexpect
import struct
import fcntl
@@ -31,30 +30,44 @@
import sys
import time
-sys.path.append("../")
+sys.path.append( "../" )
from drivers.common.cli.remotetestbeddriver import RemoteTestBedDriver
-class FloodLightCliDriver(RemoteTestBedDriver):
- '''
- FloodLightCliDriver is the basic driver which will handle the Mininet functions
- '''
- def __init__(self):
- super(RemoteTestBedDriver, self).__init__()
-
- def connect(self,**connectargs):
- for key in connectargs:
- vars(self)[key] = connectargs[key]
-
- self.name = self.options['name']
- self.handle = super(FloodLightCliDriver,self).connect(user_name = self.user_name, ip_address = self.ip_address,port = self.port, pwd = self.pwd)
- if self.handle :
- main.log.info("Connected "+self.name)
- self.execute(cmd="\r",prompt="\$",timeout=10)
- self.execute(cmd="cd /home/openflow/floodlight/",prompt="floodlight\$",timeout=3)
- self.execute(cmd="java -jar target/floodlight.jar &",prompt="\$",timeout=3)
- self.execute(cmd="\r",prompt="\$",timeout=10)
+class FloodLightCliDriver( RemoteTestBedDriver ):
+
+ """
+ FloodLightCliDriver is the basic driver which will handle the Mininet functions
+ """
+ def __init__( self ):
+ super( RemoteTestBedDriver, self ).__init__()
+
+ def connect( self, **connectargs ):
+ for key in connectargs:
+ vars( self )[ key ] = connectargs[ key ]
+
+ self.name = self.options[ 'name' ]
+
+ self.handle = super(
+ FloodLightCliDriver,
+ self ).connect(
+ user_name=self.user_name,
+ ip_address=self.ip_address,
+ port=self.port,
+ pwd=self.pwd )
+ if self.handle:
+ main.log.info( "Connected " + self.name )
+ self.execute( cmd="\r", prompt="\$", timeout=10 )
+ self.execute(
+ cmd="cd /home/openflow/floodlight/",
+ prompt="floodlight\$",
+ timeout=3 )
+ self.execute(
+ cmd="java -jar target/floodlight.jar &",
+ prompt="\$",
+ timeout=3 )
+ self.execute( cmd="\r", prompt="\$", timeout=10 )
return self.handle
- else :
+ else:
return main.FALSE
diff --git a/TestON/drivers/common/cli/remotetestbed/necswitchdriver.py b/TestON/drivers/common/cli/remotetestbed/necswitchdriver.py
index f5e652a..07fb668 100644
--- a/TestON/drivers/common/cli/remotetestbed/necswitchdriver.py
+++ b/TestON/drivers/common/cli/remotetestbed/necswitchdriver.py
@@ -1,545 +1,757 @@
class NEC:
+
def __init__( self ):
self.prompt = '(.*)'
- self.timeout = 60
+ self.timeout = 60
- def show(self, *options, **def_args ):
- '''Possible Options :[' access-filter ', ' accounting ', ' acknowledgments ', ' auto-config ', ' axrp ', ' cfm ', ' channel-group ', ' clock ', ' config-lock-status ', ' cpu ', ' dhcp ', ' dot1x ', ' dumpfile ', ' efmoam ', ' environment ', ' file ', ' flash ', ' gsrp ', ' history ', ' igmp-snooping ', ' interfaces ', ' ip ', ' ip-dual ', ' ipv6-dhcp ', ' license ', ' lldp ', ' logging ', ' loop-detection ', ' mac-address-table ', ' mc ', ' memory ', ' mld-snooping ', ' netconf ', ' netstat ', ' ntp ', ' oadp ', ' openflow ', ' port ', ' power ', ' processes ', ' qos ', ' qos-flow ', ' sessions ', ' sflow ', ' spanning-tree ', ' ssh ', ' system ', ' tcpdump ', ' tech-support ', ' track ', ' version ', ' vlan ', ' vrrpstatus ', ' whoami ']'''
- arguments= ''
+ def show( self, *options, **def_args ):
+ "Possible Options :[' access-filter ', ' accounting ', ' acknowledgments ', ' auto-config ', ' axrp ', ' cfm ', ' channel-group ', ' clock ', ' config-lock-status ', ' cpu ', ' dhcp ', ' dot1x ', ' dumpfile ', ' efmoam ', ' environment ', ' file ', ' flash ', ' gsrp ', ' history ', ' igmp-snooping ', ' interfaces ', ' ip ', ' ip-dual ', ' ipv6-dhcp ', ' license ', ' lldp ', ' logging ', ' loop-detection ', ' mac-address-table ', ' mc ', ' memory ', ' mld-snooping ', ' netconf ', ' netstat ', ' ntp ', ' oadp ', ' openflow ', ' port ', ' power ', ' processes ', ' qos ', ' qos-flow ', ' sessions ', ' sflow ', ' spanning-tree ', ' ssh ', ' system ', ' tcpdump ', ' tech-support ', ' track ', ' version ', ' vlan ', ' vrrpstatus ', ' whoami ']"
+ arguments = ''
for option in options:
- arguments = arguments + option +' '
- prompt = def_args.setdefault('prompt',self.prompt)
- timeout = def_args.setdefault('timeout',self.timeout)
- self.execute( cmd= "show "+ arguments, prompt = prompt, timeout = timeout )
+ arguments = arguments + option + ' '
+ prompt = def_args.setdefault( 'prompt', self.prompt )
+ timeout = def_args.setdefault( 'timeout', self.timeout )
+ self.execute( cmd="show " + arguments, prompt=prompt, timeout=timeout )
return main.TRUE
- def show_ip(self, *options, **def_args ):
- '''Possible Options :[]'''
- arguments= ''
+ def show_ip( self, *options, **def_args ):
+ "Possible Options :[]"
+ arguments = ''
for option in options:
- arguments = arguments + option +' '
- prompt = def_args.setdefault('prompt',self.prompt)
- timeout = def_args.setdefault('timeout',self.timeout)
- self.execute( cmd= "show ip "+ arguments, prompt = prompt, timeout = timeout )
+ arguments = arguments + option + ' '
+ prompt = def_args.setdefault( 'prompt', self.prompt )
+ timeout = def_args.setdefault( 'timeout', self.timeout )
+ self.execute(
+ cmd="show ip " +
+ arguments,
+ prompt=prompt,
+ timeout=timeout )
return main.TRUE
- def show_mc(self, *options, **def_args ):
- '''Possible Options :[]'''
- arguments= ''
+ def show_mc( self, *options, **def_args ):
+ "Possible Options :[]"
+ arguments = ''
for option in options:
- arguments = arguments + option +' '
- prompt = def_args.setdefault('prompt',self.prompt)
- timeout = def_args.setdefault('timeout',self.timeout)
- self.execute( cmd= "show mc "+ arguments, prompt = prompt, timeout = timeout )
+ arguments = arguments + option + ' '
+ prompt = def_args.setdefault( 'prompt', self.prompt )
+ timeout = def_args.setdefault( 'timeout', self.timeout )
+ self.execute(
+ cmd="show mc " +
+ arguments,
+ prompt=prompt,
+ timeout=timeout )
return main.TRUE
- def show_cfm(self, *options, **def_args ):
- '''Possible Options :[]'''
- arguments= ''
+ def show_cfm( self, *options, **def_args ):
+ "Possible Options :[]"
+ arguments = ''
for option in options:
- arguments = arguments + option +' '
- prompt = def_args.setdefault('prompt',self.prompt)
- timeout = def_args.setdefault('timeout',self.timeout)
- self.execute( cmd= "show cfm "+ arguments, prompt = prompt, timeout = timeout )
+ arguments = arguments + option + ' '
+ prompt = def_args.setdefault( 'prompt', self.prompt )
+ timeout = def_args.setdefault( 'timeout', self.timeout )
+ self.execute(
+ cmd="show cfm " +
+ arguments,
+ prompt=prompt,
+ timeout=timeout )
return main.TRUE
- def show_ntp(self, *options, **def_args ):
- '''Possible Options :[]'''
- arguments= ''
+ def show_ntp( self, *options, **def_args ):
+ "Possible Options :[]"
+ arguments = ''
for option in options:
- arguments = arguments + option +' '
- prompt = def_args.setdefault('prompt',self.prompt)
- timeout = def_args.setdefault('timeout',self.timeout)
- self.execute( cmd= "show ntp "+ arguments, prompt = prompt, timeout = timeout )
+ arguments = arguments + option + ' '
+ prompt = def_args.setdefault( 'prompt', self.prompt )
+ timeout = def_args.setdefault( 'timeout', self.timeout )
+ self.execute(
+ cmd="show ntp " +
+ arguments,
+ prompt=prompt,
+ timeout=timeout )
return main.TRUE
- def show_ssh(self, *options, **def_args ):
- '''Possible Options :[]'''
- arguments= ''
+ def show_ssh( self, *options, **def_args ):
+ "Possible Options :[]"
+ arguments = ''
for option in options:
- arguments = arguments + option +' '
- prompt = def_args.setdefault('prompt',self.prompt)
- timeout = def_args.setdefault('timeout',self.timeout)
- self.execute( cmd= "show ssh "+ arguments, prompt = prompt, timeout = timeout )
+ arguments = arguments + option + ' '
+ prompt = def_args.setdefault( 'prompt', self.prompt )
+ timeout = def_args.setdefault( 'timeout', self.timeout )
+ self.execute(
+ cmd="show ssh " +
+ arguments,
+ prompt=prompt,
+ timeout=timeout )
return main.TRUE
- def show_qos(self, *options, **def_args ):
- '''Possible Options :[]'''
- arguments= ''
+ def show_qos( self, *options, **def_args ):
+ "Possible Options :[]"
+ arguments = ''
for option in options:
- arguments = arguments + option +' '
- prompt = def_args.setdefault('prompt',self.prompt)
- timeout = def_args.setdefault('timeout',self.timeout)
- self.execute( cmd= "show qos "+ arguments, prompt = prompt, timeout = timeout )
+ arguments = arguments + option + ' '
+ prompt = def_args.setdefault( 'prompt', self.prompt )
+ timeout = def_args.setdefault( 'timeout', self.timeout )
+ self.execute(
+ cmd="show qos " +
+ arguments,
+ prompt=prompt,
+ timeout=timeout )
return main.TRUE
- def show_cpu(self, *options, **def_args ):
- '''Possible Options :[]'''
- arguments= ''
+ def show_cpu( self, *options, **def_args ):
+ "Possible Options :[]"
+ arguments = ''
for option in options:
- arguments = arguments + option +' '
- prompt = def_args.setdefault('prompt',self.prompt)
- timeout = def_args.setdefault('timeout',self.timeout)
- self.execute( cmd= "show cpu "+ arguments, prompt = prompt, timeout = timeout )
+ arguments = arguments + option + ' '
+ prompt = def_args.setdefault( 'prompt', self.prompt )
+ timeout = def_args.setdefault( 'timeout', self.timeout )
+ self.execute(
+ cmd="show cpu " +
+ arguments,
+ prompt=prompt,
+ timeout=timeout )
return main.TRUE
- def show_vlan(self, *options, **def_args ):
- '''Possible Options :[]'''
- arguments= ''
+ def show_vlan( self, *options, **def_args ):
+ "Possible Options :[]"
+ arguments = ''
for option in options:
- arguments = arguments + option +' '
- prompt = def_args.setdefault('prompt',self.prompt)
- timeout = def_args.setdefault('timeout',self.timeout)
- self.execute( cmd= "show vlan "+ arguments, prompt = prompt, timeout = timeout )
+ arguments = arguments + option + ' '
+ prompt = def_args.setdefault( 'prompt', self.prompt )
+ timeout = def_args.setdefault( 'timeout', self.timeout )
+ self.execute(
+ cmd="show vlan " +
+ arguments,
+ prompt=prompt,
+ timeout=timeout )
return main.TRUE
- def show_lldp(self, *options, **def_args ):
- '''Possible Options :[]'''
- arguments= ''
+ def show_lldp( self, *options, **def_args ):
+ "Possible Options :[]"
+ arguments = ''
for option in options:
- arguments = arguments + option +' '
- prompt = def_args.setdefault('prompt',self.prompt)
- timeout = def_args.setdefault('timeout',self.timeout)
- self.execute( cmd= "show lldp "+ arguments, prompt = prompt, timeout = timeout )
+ arguments = arguments + option + ' '
+ prompt = def_args.setdefault( 'prompt', self.prompt )
+ timeout = def_args.setdefault( 'timeout', self.timeout )
+ self.execute(
+ cmd="show lldp " +
+ arguments,
+ prompt=prompt,
+ timeout=timeout )
return main.TRUE
- def show_dhcp(self, *options, **def_args ):
- '''Possible Options :[]'''
- arguments= ''
+ def show_dhcp( self, *options, **def_args ):
+ "Possible Options :[]"
+ arguments = ''
for option in options:
- arguments = arguments + option +' '
- prompt = def_args.setdefault('prompt',self.prompt)
- timeout = def_args.setdefault('timeout',self.timeout)
- self.execute( cmd= "show dhcp "+ arguments, prompt = prompt, timeout = timeout )
+ arguments = arguments + option + ' '
+ prompt = def_args.setdefault( 'prompt', self.prompt )
+ timeout = def_args.setdefault( 'timeout', self.timeout )
+ self.execute(
+ cmd="show dhcp " +
+ arguments,
+ prompt=prompt,
+ timeout=timeout )
return main.TRUE
- def show_axrp(self, *options, **def_args ):
- '''Possible Options :[]'''
- arguments= ''
+ def show_axrp( self, *options, **def_args ):
+ "Possible Options :[]"
+ arguments = ''
for option in options:
- arguments = arguments + option +' '
- prompt = def_args.setdefault('prompt',self.prompt)
- timeout = def_args.setdefault('timeout',self.timeout)
- self.execute( cmd= "show axrp "+ arguments, prompt = prompt, timeout = timeout )
+ arguments = arguments + option + ' '
+ prompt = def_args.setdefault( 'prompt', self.prompt )
+ timeout = def_args.setdefault( 'timeout', self.timeout )
+ self.execute(
+ cmd="show axrp " +
+ arguments,
+ prompt=prompt,
+ timeout=timeout )
return main.TRUE
- def show_oadp(self, *options, **def_args ):
- '''Possible Options :[]'''
- arguments= ''
+ def show_oadp( self, *options, **def_args ):
+ "Possible Options :[]"
+ arguments = ''
for option in options:
- arguments = arguments + option +' '
- prompt = def_args.setdefault('prompt',self.prompt)
- timeout = def_args.setdefault('timeout',self.timeout)
- self.execute( cmd= "show oadp "+ arguments, prompt = prompt, timeout = timeout )
+ arguments = arguments + option + ' '
+ prompt = def_args.setdefault( 'prompt', self.prompt )
+ timeout = def_args.setdefault( 'timeout', self.timeout )
+ self.execute(
+ cmd="show oadp " +
+ arguments,
+ prompt=prompt,
+ timeout=timeout )
return main.TRUE
- def show_gsrp(self, *options, **def_args ):
- '''Possible Options :[]'''
- arguments= ''
+ def show_gsrp( self, *options, **def_args ):
+ "Possible Options :[]"
+ arguments = ''
for option in options:
- arguments = arguments + option +' '
- prompt = def_args.setdefault('prompt',self.prompt)
- timeout = def_args.setdefault('timeout',self.timeout)
- self.execute( cmd= "show gsrp "+ arguments, prompt = prompt, timeout = timeout )
+ arguments = arguments + option + ' '
+ prompt = def_args.setdefault( 'prompt', self.prompt )
+ timeout = def_args.setdefault( 'timeout', self.timeout )
+ self.execute(
+ cmd="show gsrp " +
+ arguments,
+ prompt=prompt,
+ timeout=timeout )
return main.TRUE
- def show_port(self, *options, **def_args ):
- '''Possible Options :[]'''
- arguments= ''
+ def show_port( self, *options, **def_args ):
+ "Possible Options :[]"
+ arguments = ''
for option in options:
- arguments = arguments + option +' '
- prompt = def_args.setdefault('prompt',self.prompt)
- timeout = def_args.setdefault('timeout',self.timeout)
- self.execute( cmd= "show port "+ arguments, prompt = prompt, timeout = timeout )
+ arguments = arguments + option + ' '
+ prompt = def_args.setdefault( 'prompt', self.prompt )
+ timeout = def_args.setdefault( 'timeout', self.timeout )
+ self.execute(
+ cmd="show port " +
+ arguments,
+ prompt=prompt,
+ timeout=timeout )
return main.TRUE
- def show_file(self, *options, **def_args ):
- '''Possible Options :[]'''
- arguments= ''
+ def show_file( self, *options, **def_args ):
+ "Possible Options :[]"
+ arguments = ''
for option in options:
- arguments = arguments + option +' '
- prompt = def_args.setdefault('prompt',self.prompt)
- timeout = def_args.setdefault('timeout',self.timeout)
- self.execute( cmd= "show file "+ arguments, prompt = prompt, timeout = timeout )
+ arguments = arguments + option + ' '
+ prompt = def_args.setdefault( 'prompt', self.prompt )
+ timeout = def_args.setdefault( 'timeout', self.timeout )
+ self.execute(
+ cmd="show file " +
+ arguments,
+ prompt=prompt,
+ timeout=timeout )
return main.TRUE
- def show_power(self, *options, **def_args ):
- '''Possible Options :[]'''
- arguments= ''
+ def show_power( self, *options, **def_args ):
+ "Possible Options :[]"
+ arguments = ''
for option in options:
- arguments = arguments + option +' '
- prompt = def_args.setdefault('prompt',self.prompt)
- timeout = def_args.setdefault('timeout',self.timeout)
- self.execute( cmd= "show power "+ arguments, prompt = prompt, timeout = timeout )
+ arguments = arguments + option + ' '
+ prompt = def_args.setdefault( 'prompt', self.prompt )
+ timeout = def_args.setdefault( 'timeout', self.timeout )
+ self.execute(
+ cmd="show power " +
+ arguments,
+ prompt=prompt,
+ timeout=timeout )
return main.TRUE
- def show_clock(self, *options, **def_args ):
- '''Possible Options :[]'''
- arguments= ''
+ def show_clock( self, *options, **def_args ):
+ "Possible Options :[]"
+ arguments = ''
for option in options:
- arguments = arguments + option +' '
- prompt = def_args.setdefault('prompt',self.prompt)
- timeout = def_args.setdefault('timeout',self.timeout)
- self.execute( cmd= "show clock "+ arguments, prompt = prompt, timeout = timeout )
+ arguments = arguments + option + ' '
+ prompt = def_args.setdefault( 'prompt', self.prompt )
+ timeout = def_args.setdefault( 'timeout', self.timeout )
+ self.execute(
+ cmd="show clock " +
+ arguments,
+ prompt=prompt,
+ timeout=timeout )
return main.TRUE
- def show_dot1x(self, *options, **def_args ):
- '''Possible Options :[]'''
- arguments= ''
+ def show_dot1x( self, *options, **def_args ):
+ "Possible Options :[]"
+ arguments = ''
for option in options:
- arguments = arguments + option +' '
- prompt = def_args.setdefault('prompt',self.prompt)
- timeout = def_args.setdefault('timeout',self.timeout)
- self.execute( cmd= "show dot1x "+ arguments, prompt = prompt, timeout = timeout )
+ arguments = arguments + option + ' '
+ prompt = def_args.setdefault( 'prompt', self.prompt )
+ timeout = def_args.setdefault( 'timeout', self.timeout )
+ self.execute(
+ cmd="show dot1x " +
+ arguments,
+ prompt=prompt,
+ timeout=timeout )
return main.TRUE
- def show_sflow(self, *options, **def_args ):
- '''Possible Options :[]'''
- arguments= ''
+ def show_sflow( self, *options, **def_args ):
+ "Possible Options :[]"
+ arguments = ''
for option in options:
- arguments = arguments + option +' '
- prompt = def_args.setdefault('prompt',self.prompt)
- timeout = def_args.setdefault('timeout',self.timeout)
- self.execute( cmd= "show sflow "+ arguments, prompt = prompt, timeout = timeout )
+ arguments = arguments + option + ' '
+ prompt = def_args.setdefault( 'prompt', self.prompt )
+ timeout = def_args.setdefault( 'timeout', self.timeout )
+ self.execute(
+ cmd="show sflow " +
+ arguments,
+ prompt=prompt,
+ timeout=timeout )
return main.TRUE
- def show_track(self, *options, **def_args ):
- '''Possible Options :[]'''
- arguments= ''
+ def show_track( self, *options, **def_args ):
+ "Possible Options :[]"
+ arguments = ''
for option in options:
- arguments = arguments + option +' '
- prompt = def_args.setdefault('prompt',self.prompt)
- timeout = def_args.setdefault('timeout',self.timeout)
- self.execute( cmd= "show track "+ arguments, prompt = prompt, timeout = timeout )
+ arguments = arguments + option + ' '
+ prompt = def_args.setdefault( 'prompt', self.prompt )
+ timeout = def_args.setdefault( 'timeout', self.timeout )
+ self.execute(
+ cmd="show track " +
+ arguments,
+ prompt=prompt,
+ timeout=timeout )
return main.TRUE
- def show_flash(self, *options, **def_args ):
- '''Possible Options :[]'''
- arguments= ''
+ def show_flash( self, *options, **def_args ):
+ "Possible Options :[]"
+ arguments = ''
for option in options:
- arguments = arguments + option +' '
- prompt = def_args.setdefault('prompt',self.prompt)
- timeout = def_args.setdefault('timeout',self.timeout)
- self.execute( cmd= "show flash "+ arguments, prompt = prompt, timeout = timeout )
+ arguments = arguments + option + ' '
+ prompt = def_args.setdefault( 'prompt', self.prompt )
+ timeout = def_args.setdefault( 'timeout', self.timeout )
+ self.execute(
+ cmd="show flash " +
+ arguments,
+ prompt=prompt,
+ timeout=timeout )
return main.TRUE
- def show_system(self, *options, **def_args ):
- '''Possible Options :[]'''
- arguments= ''
+ def show_system( self, *options, **def_args ):
+ "Possible Options :[]"
+ arguments = ''
for option in options:
- arguments = arguments + option +' '
- prompt = def_args.setdefault('prompt',self.prompt)
- timeout = def_args.setdefault('timeout',self.timeout)
- self.execute( cmd= "show system "+ arguments, prompt = prompt, timeout = timeout )
+ arguments = arguments + option + ' '
+ prompt = def_args.setdefault( 'prompt', self.prompt )
+ timeout = def_args.setdefault( 'timeout', self.timeout )
+ self.execute(
+ cmd="show system " +
+ arguments,
+ prompt=prompt,
+ timeout=timeout )
return main.TRUE
- def show_whoami(self, *options, **def_args ):
- '''Possible Options :[]'''
- arguments= ''
+ def show_whoami( self, *options, **def_args ):
+ "Possible Options :[]"
+ arguments = ''
for option in options:
- arguments = arguments + option +' '
- prompt = def_args.setdefault('prompt',self.prompt)
- timeout = def_args.setdefault('timeout',self.timeout)
- self.execute( cmd= "show whoami "+ arguments, prompt = prompt, timeout = timeout )
+ arguments = arguments + option + ' '
+ prompt = def_args.setdefault( 'prompt', self.prompt )
+ timeout = def_args.setdefault( 'timeout', self.timeout )
+ self.execute(
+ cmd="show whoami " +
+ arguments,
+ prompt=prompt,
+ timeout=timeout )
return main.TRUE
- def show_efmoam(self, *options, **def_args ):
- '''Possible Options :[]'''
- arguments= ''
+ def show_efmoam( self, *options, **def_args ):
+ "Possible Options :[]"
+ arguments = ''
for option in options:
- arguments = arguments + option +' '
- prompt = def_args.setdefault('prompt',self.prompt)
- timeout = def_args.setdefault('timeout',self.timeout)
- self.execute( cmd= "show efmoam "+ arguments, prompt = prompt, timeout = timeout )
+ arguments = arguments + option + ' '
+ prompt = def_args.setdefault( 'prompt', self.prompt )
+ timeout = def_args.setdefault( 'timeout', self.timeout )
+ self.execute(
+ cmd="show efmoam " +
+ arguments,
+ prompt=prompt,
+ timeout=timeout )
return main.TRUE
- def show_memory(self, *options, **def_args ):
- '''Possible Options :[]'''
- arguments= ''
+ def show_memory( self, *options, **def_args ):
+ "Possible Options :[]"
+ arguments = ''
for option in options:
- arguments = arguments + option +' '
- prompt = def_args.setdefault('prompt',self.prompt)
- timeout = def_args.setdefault('timeout',self.timeout)
- self.execute( cmd= "show memory "+ arguments, prompt = prompt, timeout = timeout )
+ arguments = arguments + option + ' '
+ prompt = def_args.setdefault( 'prompt', self.prompt )
+ timeout = def_args.setdefault( 'timeout', self.timeout )
+ self.execute(
+ cmd="show memory " +
+ arguments,
+ prompt=prompt,
+ timeout=timeout )
return main.TRUE
- def show_tcpdump(self, *options, **def_args ):
- '''Possible Options :[]'''
- arguments= ''
+ def show_tcpdump( self, *options, **def_args ):
+ "Possible Options :[]"
+ arguments = ''
for option in options:
- arguments = arguments + option +' '
- prompt = def_args.setdefault('prompt',self.prompt)
- timeout = def_args.setdefault('timeout',self.timeout)
- self.execute( cmd= "show tcpdump "+ arguments, prompt = prompt, timeout = timeout )
+ arguments = arguments + option + ' '
+ prompt = def_args.setdefault( 'prompt', self.prompt )
+ timeout = def_args.setdefault( 'timeout', self.timeout )
+ self.execute(
+ cmd="show tcpdump " +
+ arguments,
+ prompt=prompt,
+ timeout=timeout )
return main.TRUE
- def show_history(self, *options, **def_args ):
- '''Possible Options :[]'''
- arguments= ''
+ def show_history( self, *options, **def_args ):
+ "Possible Options :[]"
+ arguments = ''
for option in options:
- arguments = arguments + option +' '
- prompt = def_args.setdefault('prompt',self.prompt)
- timeout = def_args.setdefault('timeout',self.timeout)
- self.execute( cmd= "show history "+ arguments, prompt = prompt, timeout = timeout )
+ arguments = arguments + option + ' '
+ prompt = def_args.setdefault( 'prompt', self.prompt )
+ timeout = def_args.setdefault( 'timeout', self.timeout )
+ self.execute(
+ cmd="show history " +
+ arguments,
+ prompt=prompt,
+ timeout=timeout )
return main.TRUE
- def show_logging(self, *options, **def_args ):
- '''Possible Options :[]'''
- arguments= ''
+ def show_logging( self, *options, **def_args ):
+ "Possible Options :[]"
+ arguments = ''
for option in options:
- arguments = arguments + option +' '
- prompt = def_args.setdefault('prompt',self.prompt)
- timeout = def_args.setdefault('timeout',self.timeout)
- self.execute( cmd= "show logging "+ arguments, prompt = prompt, timeout = timeout )
+ arguments = arguments + option + ' '
+ prompt = def_args.setdefault( 'prompt', self.prompt )
+ timeout = def_args.setdefault( 'timeout', self.timeout )
+ self.execute(
+ cmd="show logging " +
+ arguments,
+ prompt=prompt,
+ timeout=timeout )
return main.TRUE
- def show_license(self, *options, **def_args ):
- '''Possible Options :[]'''
- arguments= ''
+ def show_license( self, *options, **def_args ):
+ "Possible Options :[]"
+ arguments = ''
for option in options:
- arguments = arguments + option +' '
- prompt = def_args.setdefault('prompt',self.prompt)
- timeout = def_args.setdefault('timeout',self.timeout)
- self.execute( cmd= "show license "+ arguments, prompt = prompt, timeout = timeout )
+ arguments = arguments + option + ' '
+ prompt = def_args.setdefault( 'prompt', self.prompt )
+ timeout = def_args.setdefault( 'timeout', self.timeout )
+ self.execute(
+ cmd="show license " +
+ arguments,
+ prompt=prompt,
+ timeout=timeout )
return main.TRUE
- def show_netstat(self, *options, **def_args ):
- '''Possible Options :[]'''
- arguments= ''
+ def show_netstat( self, *options, **def_args ):
+ "Possible Options :[]"
+ arguments = ''
for option in options:
- arguments = arguments + option +' '
- prompt = def_args.setdefault('prompt',self.prompt)
- timeout = def_args.setdefault('timeout',self.timeout)
- self.execute( cmd= "show netstat "+ arguments, prompt = prompt, timeout = timeout )
+ arguments = arguments + option + ' '
+ prompt = def_args.setdefault( 'prompt', self.prompt )
+ timeout = def_args.setdefault( 'timeout', self.timeout )
+ self.execute(
+ cmd="show netstat " +
+ arguments,
+ prompt=prompt,
+ timeout=timeout )
return main.TRUE
- def show_version(self, *options, **def_args ):
- '''Possible Options :[]'''
- arguments= ''
+ def show_version( self, *options, **def_args ):
+ "Possible Options :[]"
+ arguments = ''
for option in options:
- arguments = arguments + option +' '
- prompt = def_args.setdefault('prompt',self.prompt)
- timeout = def_args.setdefault('timeout',self.timeout)
- self.execute( cmd= "show version "+ arguments, prompt = prompt, timeout = timeout )
+ arguments = arguments + option + ' '
+ prompt = def_args.setdefault( 'prompt', self.prompt )
+ timeout = def_args.setdefault( 'timeout', self.timeout )
+ self.execute(
+ cmd="show version " +
+ arguments,
+ prompt=prompt,
+ timeout=timeout )
return main.TRUE
- def show_netconf(self, *options, **def_args ):
- '''Possible Options :[]'''
- arguments= ''
+ def show_netconf( self, *options, **def_args ):
+ "Possible Options :[]"
+ arguments = ''
for option in options:
- arguments = arguments + option +' '
- prompt = def_args.setdefault('prompt',self.prompt)
- timeout = def_args.setdefault('timeout',self.timeout)
- self.execute( cmd= "show netconf "+ arguments, prompt = prompt, timeout = timeout )
+ arguments = arguments + option + ' '
+ prompt = def_args.setdefault( 'prompt', self.prompt )
+ timeout = def_args.setdefault( 'timeout', self.timeout )
+ self.execute(
+ cmd="show netconf " +
+ arguments,
+ prompt=prompt,
+ timeout=timeout )
return main.TRUE
- def show_ipdual(self, *options, **def_args ):
- '''Possible Options :[]'''
- arguments= ''
+ def show_ipdual( self, *options, **def_args ):
+ "Possible Options :[]"
+ arguments = ''
for option in options:
- arguments = arguments + option +' '
- prompt = def_args.setdefault('prompt',self.prompt)
- timeout = def_args.setdefault('timeout',self.timeout)
- self.execute( cmd= "show ip-dual "+ arguments, prompt = prompt, timeout = timeout )
+ arguments = arguments + option + ' '
+ prompt = def_args.setdefault( 'prompt', self.prompt )
+ timeout = def_args.setdefault( 'timeout', self.timeout )
+ self.execute(
+ cmd="show ip-dual " +
+ arguments,
+ prompt=prompt,
+ timeout=timeout )
return main.TRUE
- def show_sessions(self, *options, **def_args ):
- '''Possible Options :[]'''
- arguments= ''
+ def show_sessions( self, *options, **def_args ):
+ "Possible Options :[]"
+ arguments = ''
for option in options:
- arguments = arguments + option +' '
- prompt = def_args.setdefault('prompt',self.prompt)
- timeout = def_args.setdefault('timeout',self.timeout)
- self.execute( cmd= "show sessions "+ arguments, prompt = prompt, timeout = timeout )
+ arguments = arguments + option + ' '
+ prompt = def_args.setdefault( 'prompt', self.prompt )
+ timeout = def_args.setdefault( 'timeout', self.timeout )
+ self.execute(
+ cmd="show sessions " +
+ arguments,
+ prompt=prompt,
+ timeout=timeout )
return main.TRUE
- def show_qosflow(self, *options, **def_args ):
- '''Possible Options :[]'''
- arguments= ''
+ def show_qosflow( self, *options, **def_args ):
+ "Possible Options :[]"
+ arguments = ''
for option in options:
- arguments = arguments + option +' '
- prompt = def_args.setdefault('prompt',self.prompt)
- timeout = def_args.setdefault('timeout',self.timeout)
- self.execute( cmd= "show qos-flow "+ arguments, prompt = prompt, timeout = timeout )
+ arguments = arguments + option + ' '
+ prompt = def_args.setdefault( 'prompt', self.prompt )
+ timeout = def_args.setdefault( 'timeout', self.timeout )
+ self.execute(
+ cmd="show qos-flow " +
+ arguments,
+ prompt=prompt,
+ timeout=timeout )
return main.TRUE
- def show_openflow(self, *options, **def_args ):
- '''Possible Options :[]'''
- arguments= ''
+ def show_openflow( self, *options, **def_args ):
+ "Possible Options :[]"
+ arguments = ''
for option in options:
- arguments = arguments + option +' '
- prompt = def_args.setdefault('prompt',self.prompt)
- timeout = def_args.setdefault('timeout',self.timeout)
- self.execute( cmd= "show openflow "+ arguments, prompt = prompt, timeout = timeout )
+ arguments = arguments + option + ' '
+ prompt = def_args.setdefault( 'prompt', self.prompt )
+ timeout = def_args.setdefault( 'timeout', self.timeout )
+ self.execute(
+ cmd="show openflow " +
+ arguments,
+ prompt=prompt,
+ timeout=timeout )
return main.TRUE
- def show_dumpfile(self, *options, **def_args ):
- '''Possible Options :[]'''
- arguments= ''
+ def show_dumpfile( self, *options, **def_args ):
+ "Possible Options :[]"
+ arguments = ''
for option in options:
- arguments = arguments + option +' '
- prompt = def_args.setdefault('prompt',self.prompt)
- timeout = def_args.setdefault('timeout',self.timeout)
- self.execute( cmd= "show dumpfile "+ arguments, prompt = prompt, timeout = timeout )
+ arguments = arguments + option + ' '
+ prompt = def_args.setdefault( 'prompt', self.prompt )
+ timeout = def_args.setdefault( 'timeout', self.timeout )
+ self.execute(
+ cmd="show dumpfile " +
+ arguments,
+ prompt=prompt,
+ timeout=timeout )
return main.TRUE
- def show_ipv6dhcp(self, *options, **def_args ):
- '''Possible Options :[]'''
- arguments= ''
+ def show_ipv6dhcp( self, *options, **def_args ):
+ "Possible Options :[]"
+ arguments = ''
for option in options:
- arguments = arguments + option +' '
- prompt = def_args.setdefault('prompt',self.prompt)
- timeout = def_args.setdefault('timeout',self.timeout)
- self.execute( cmd= "show ipv6-dhcp "+ arguments, prompt = prompt, timeout = timeout )
+ arguments = arguments + option + ' '
+ prompt = def_args.setdefault( 'prompt', self.prompt )
+ timeout = def_args.setdefault( 'timeout', self.timeout )
+ self.execute(
+ cmd="show ipv6-dhcp " +
+ arguments,
+ prompt=prompt,
+ timeout=timeout )
return main.TRUE
- def show_processes(self, *options, **def_args ):
- '''Possible Options :[]'''
- arguments= ''
+ def show_processes( self, *options, **def_args ):
+ "Possible Options :[]"
+ arguments = ''
for option in options:
- arguments = arguments + option +' '
- prompt = def_args.setdefault('prompt',self.prompt)
- timeout = def_args.setdefault('timeout',self.timeout)
- self.execute( cmd= "show processes "+ arguments, prompt = prompt, timeout = timeout )
+ arguments = arguments + option + ' '
+ prompt = def_args.setdefault( 'prompt', self.prompt )
+ timeout = def_args.setdefault( 'timeout', self.timeout )
+ self.execute(
+ cmd="show processes " +
+ arguments,
+ prompt=prompt,
+ timeout=timeout )
return main.TRUE
- def show_vrrpstatus(self, *options, **def_args ):
- '''Possible Options :[]'''
- arguments= ''
+ def show_vrrpstatus( self, *options, **def_args ):
+ "Possible Options :[]"
+ arguments = ''
for option in options:
- arguments = arguments + option +' '
- prompt = def_args.setdefault('prompt',self.prompt)
- timeout = def_args.setdefault('timeout',self.timeout)
- self.execute( cmd= "show vrrpstatus "+ arguments, prompt = prompt, timeout = timeout )
+ arguments = arguments + option + ' '
+ prompt = def_args.setdefault( 'prompt', self.prompt )
+ timeout = def_args.setdefault( 'timeout', self.timeout )
+ self.execute(
+ cmd="show vrrpstatus " +
+ arguments,
+ prompt=prompt,
+ timeout=timeout )
return main.TRUE
- def show_interfaces(self, *options, **def_args ):
- '''Possible Options :[]'''
- arguments= ''
+ def show_interfaces( self, *options, **def_args ):
+ "Possible Options :[]"
+ arguments = ''
for option in options:
- arguments = arguments + option +' '
- prompt = def_args.setdefault('prompt',self.prompt)
- timeout = def_args.setdefault('timeout',self.timeout)
- self.execute( cmd= "show interfaces "+ arguments, prompt = prompt, timeout = timeout )
+ arguments = arguments + option + ' '
+ prompt = def_args.setdefault( 'prompt', self.prompt )
+ timeout = def_args.setdefault( 'timeout', self.timeout )
+ self.execute(
+ cmd="show interfaces " +
+ arguments,
+ prompt=prompt,
+ timeout=timeout )
return main.TRUE
- def show_environment(self, *options, **def_args ):
- '''Possible Options :[]'''
- arguments= ''
+ def show_environment( self, *options, **def_args ):
+ "Possible Options :[]"
+ arguments = ''
for option in options:
- arguments = arguments + option +' '
- prompt = def_args.setdefault('prompt',self.prompt)
- timeout = def_args.setdefault('timeout',self.timeout)
- self.execute( cmd= "show environment "+ arguments, prompt = prompt, timeout = timeout )
+ arguments = arguments + option + ' '
+ prompt = def_args.setdefault( 'prompt', self.prompt )
+ timeout = def_args.setdefault( 'timeout', self.timeout )
+ self.execute(
+ cmd="show environment " +
+ arguments,
+ prompt=prompt,
+ timeout=timeout )
return main.TRUE
- def show_autoconfig(self, *options, **def_args ):
- '''Possible Options :[]'''
- arguments= ''
+ def show_autoconfig( self, *options, **def_args ):
+ "Possible Options :[]"
+ arguments = ''
for option in options:
- arguments = arguments + option +' '
- prompt = def_args.setdefault('prompt',self.prompt)
- timeout = def_args.setdefault('timeout',self.timeout)
- self.execute( cmd= "show auto-config "+ arguments, prompt = prompt, timeout = timeout )
+ arguments = arguments + option + ' '
+ prompt = def_args.setdefault( 'prompt', self.prompt )
+ timeout = def_args.setdefault( 'timeout', self.timeout )
+ self.execute(
+ cmd="show auto-config " +
+ arguments,
+ prompt=prompt,
+ timeout=timeout )
return main.TRUE
- def show_techsupport(self, *options, **def_args ):
- '''Possible Options :[]'''
- arguments= ''
+ def show_techsupport( self, *options, **def_args ):
+ "Possible Options :[]"
+ arguments = ''
for option in options:
- arguments = arguments + option +' '
- prompt = def_args.setdefault('prompt',self.prompt)
- timeout = def_args.setdefault('timeout',self.timeout)
- self.execute( cmd= "show tech-support "+ arguments, prompt = prompt, timeout = timeout )
+ arguments = arguments + option + ' '
+ prompt = def_args.setdefault( 'prompt', self.prompt )
+ timeout = def_args.setdefault( 'timeout', self.timeout )
+ self.execute(
+ cmd="show tech-support " +
+ arguments,
+ prompt=prompt,
+ timeout=timeout )
return main.TRUE
- def show_mldsnooping(self, *options, **def_args ):
- '''Possible Options :[]'''
- arguments= ''
+ def show_mldsnooping( self, *options, **def_args ):
+ "Possible Options :[]"
+ arguments = ''
for option in options:
- arguments = arguments + option +' '
- prompt = def_args.setdefault('prompt',self.prompt)
- timeout = def_args.setdefault('timeout',self.timeout)
- self.execute( cmd= "show mld-snooping "+ arguments, prompt = prompt, timeout = timeout )
+ arguments = arguments + option + ' '
+ prompt = def_args.setdefault( 'prompt', self.prompt )
+ timeout = def_args.setdefault( 'timeout', self.timeout )
+ self.execute(
+ cmd="show mld-snooping " +
+ arguments,
+ prompt=prompt,
+ timeout=timeout )
return main.TRUE
- def show_igmpsnooping(self, *options, **def_args ):
- '''Possible Options :[]'''
- arguments= ''
+ def show_igmpsnooping( self, *options, **def_args ):
+ "Possible Options :[]"
+ arguments = ''
for option in options:
- arguments = arguments + option +' '
- prompt = def_args.setdefault('prompt',self.prompt)
- timeout = def_args.setdefault('timeout',self.timeout)
- self.execute( cmd= "show igmp-snooping "+ arguments, prompt = prompt, timeout = timeout )
+ arguments = arguments + option + ' '
+ prompt = def_args.setdefault( 'prompt', self.prompt )
+ timeout = def_args.setdefault( 'timeout', self.timeout )
+ self.execute(
+ cmd="show igmp-snooping " +
+ arguments,
+ prompt=prompt,
+ timeout=timeout )
return main.TRUE
- def show_channelgroup(self, *options, **def_args ):
- '''Possible Options :[]'''
- arguments= ''
+ def show_channelgroup( self, *options, **def_args ):
+ "Possible Options :[]"
+ arguments = ''
for option in options:
- arguments = arguments + option +' '
- prompt = def_args.setdefault('prompt',self.prompt)
- timeout = def_args.setdefault('timeout',self.timeout)
- self.execute( cmd= "show channel-group "+ arguments, prompt = prompt, timeout = timeout )
+ arguments = arguments + option + ' '
+ prompt = def_args.setdefault( 'prompt', self.prompt )
+ timeout = def_args.setdefault( 'timeout', self.timeout )
+ self.execute(
+ cmd="show channel-group " +
+ arguments,
+ prompt=prompt,
+ timeout=timeout )
return main.TRUE
- def show_spanningtree(self, *options, **def_args ):
- '''Possible Options :[]'''
- arguments= ''
+ def show_spanningtree( self, *options, **def_args ):
+ "Possible Options :[]"
+ arguments = ''
for option in options:
- arguments = arguments + option +' '
- prompt = def_args.setdefault('prompt',self.prompt)
- timeout = def_args.setdefault('timeout',self.timeout)
- self.execute( cmd= "show spanning-tree "+ arguments, prompt = prompt, timeout = timeout )
+ arguments = arguments + option + ' '
+ prompt = def_args.setdefault( 'prompt', self.prompt )
+ timeout = def_args.setdefault( 'timeout', self.timeout )
+ self.execute(
+ cmd="show spanning-tree " +
+ arguments,
+ prompt=prompt,
+ timeout=timeout )
return main.TRUE
- def show_loopdetection(self, *options, **def_args ):
- '''Possible Options :[]'''
- arguments= ''
+ def show_loopdetection( self, *options, **def_args ):
+ "Possible Options :[]"
+ arguments = ''
for option in options:
- arguments = arguments + option +' '
- prompt = def_args.setdefault('prompt',self.prompt)
- timeout = def_args.setdefault('timeout',self.timeout)
- self.execute( cmd= "show loop-detection "+ arguments, prompt = prompt, timeout = timeout )
+ arguments = arguments + option + ' '
+ prompt = def_args.setdefault( 'prompt', self.prompt )
+ timeout = def_args.setdefault( 'timeout', self.timeout )
+ self.execute(
+ cmd="show loop-detection " +
+ arguments,
+ prompt=prompt,
+ timeout=timeout )
return main.TRUE
- def show_acknowledgments(self, *options, **def_args ):
- '''Possible Options :[' interface ']'''
- arguments= ''
+ def show_acknowledgments( self, *options, **def_args ):
+ "Possible Options :[' interface ']"
+ arguments = ''
for option in options:
- arguments = arguments + option +' '
- prompt = def_args.setdefault('prompt',self.prompt)
- timeout = def_args.setdefault('timeout',self.timeout)
- self.execute( cmd= "show acknowledgments "+ arguments, prompt = prompt, timeout = timeout )
+ arguments = arguments + option + ' '
+ prompt = def_args.setdefault( 'prompt', self.prompt )
+ timeout = def_args.setdefault( 'timeout', self.timeout )
+ self.execute(
+ cmd="show acknowledgments " +
+ arguments,
+ prompt=prompt,
+ timeout=timeout )
return main.TRUE
- def show_macaddresstable(self, *options, **def_args ):
- '''Possible Options :[]'''
- arguments= ''
+ def show_macaddresstable( self, *options, **def_args ):
+ "Possible Options :[]"
+ arguments = ''
for option in options:
- arguments = arguments + option +' '
- prompt = def_args.setdefault('prompt',self.prompt)
- timeout = def_args.setdefault('timeout',self.timeout)
- self.execute( cmd= "show mac-address-table "+ arguments, prompt = prompt, timeout = timeout )
+ arguments = arguments + option + ' '
+ prompt = def_args.setdefault( 'prompt', self.prompt )
+ timeout = def_args.setdefault( 'timeout', self.timeout )
+ self.execute(
+ cmd="show mac-address-table " +
+ arguments,
+ prompt=prompt,
+ timeout=timeout )
return main.TRUE
- def show_configlockstatus(self, *options, **def_args ):
- '''Possible Options :[]'''
- arguments= ''
+ def show_configlockstatus( self, *options, **def_args ):
+ "Possible Options :[]"
+ arguments = ''
for option in options:
- arguments = arguments + option +' '
- prompt = def_args.setdefault('prompt',self.prompt)
- timeout = def_args.setdefault('timeout',self.timeout)
- self.execute( cmd= "show config-lock-status "+ arguments, prompt = prompt, timeout = timeout )
+ arguments = arguments + option + ' '
+ prompt = def_args.setdefault( 'prompt', self.prompt )
+ timeout = def_args.setdefault( 'timeout', self.timeout )
+ self.execute(
+ cmd="show config-lock-status " +
+ arguments,
+ prompt=prompt,
+ timeout=timeout )
return main.TRUE
- def show_acknowledgments_interface(self, *options, **def_args ):
- '''Possible Options :[]'''
- arguments= ''
+ def show_acknowledgments_interface( self, *options, **def_args ):
+ "Possible Options :[]"
+ arguments = ''
for option in options:
- arguments = arguments + option +' '
- prompt = def_args.setdefault('prompt',self.prompt)
- timeout = def_args.setdefault('timeout',self.timeout)
- self.execute( cmd= "show acknowledgments interface "+ arguments, prompt = prompt, timeout = timeout )
+ arguments = arguments + option + ' '
+ prompt = def_args.setdefault( 'prompt', self.prompt )
+ timeout = def_args.setdefault( 'timeout', self.timeout )
+ self.execute(
+ cmd="show acknowledgments interface " +
+ arguments,
+ prompt=prompt,
+ timeout=timeout )
return main.TRUE
-
diff --git a/TestON/drivers/common/cli/remotetestbed/remotepoxdriver.py b/TestON/drivers/common/cli/remotetestbed/remotepoxdriver.py
index f0d2a16..44951aa 100644
--- a/TestON/drivers/common/cli/remotetestbed/remotepoxdriver.py
+++ b/TestON/drivers/common/cli/remotetestbed/remotepoxdriver.py
@@ -1,14 +1,14 @@
#!/usr/bin/env python
-'''
+"""
Created on 12-Feb-2013
-@author: Anil Kumar (anilkumar.s@paxterrasolutions.com)
+author:: Anil Kumar ( anilkumar.s@paxterrasolutions.com )
TestON is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
+ ( at your option ) any later version.
TestON is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -16,12 +16,11 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with TestON. If not, see <http://www.gnu.org/licenses/>.
+ along with TestON. If not, see <http://www.gnu.org/licenses/>.
RemoteVMDriver is the basic driver which will handle the Mininet functions
-'''
-
+"""
import pexpect
import struct
import fcntl
@@ -31,34 +30,49 @@
import sys
import time
-sys.path.append("../")
+sys.path.append( "../" )
from drivers.common.cli.remotetestbeddriver import RemoteTestBedDriver
-class RemotePoxDriver(RemoteTestBedDriver):
- '''
- RemoteVMDriver is the basic driver which will handle the Mininet functions
- '''
- def __init__(self):
- super(RemoteTestBedDriver, self).__init__()
-
- def connect(self,**connectargs):
- for key in connectargs:
- vars(self)[key] = connectargs[key]
-
- self.name = self.options['name']
- self.handle = super(RemotePoxDriver,self).connect(user_name = self.user_name, ip_address = self.ip_address,port = self.port, pwd = self.pwd)
- if self.handle :
- main.log.info(self.name+" connected successfully ")
-
- self.execute(cmd="cd "+self.options['pox_lib_location'],prompt="/pox\$",timeout=120)
- self.execute(cmd='./pox.py samples.of_tutorial',prompt="DEBUG:",timeout=120)
+class RemotePoxDriver( RemoteTestBedDriver ):
+
+ """
+ RemoteVMDriver is the basic driver which will handle the Mininet functions
+ """
+ def __init__( self ):
+ super( RemoteTestBedDriver, self ).__init__()
+
+ def connect( self, **connectargs ):
+ for key in connectargs:
+ vars( self )[ key ] = connectargs[ key ]
+
+ self.name = self.options[ 'name' ]
+
+ self.handle = super(
+ RemotePoxDriver,
+ self ).connect(
+ user_name=self.user_name,
+ ip_address=self.ip_address,
+ port=self.port,
+ pwd=self.pwd )
+ if self.handle:
+ main.log.info( self.name + " connected successfully " )
+
+ self.execute(
+ cmd="cd " +
+ self.options[ 'pox_lib_location' ],
+ prompt="/pox\$",
+ timeout=120 )
+ self.execute(
+ cmd='./pox.py samples.of_tutorial',
+ prompt="DEBUG:",
+ timeout=120 )
return self.handle
return main.TRUE
-
- def disconnect(self,handle):
+
+ def disconnect( self, handle ):
if self.handle:
- self.execute(cmd="exit()",prompt="/pox\$",timeout=120)
- else :
- main.log.error("Connection failed to the host")
+ self.execute( cmd="exit()", prompt="/pox\$", timeout=120 )
+ else:
+ main.log.error( "Connection failed to the host" )
diff --git a/TestON/drivers/common/cli/remotetestbed/remotevmdriver.py b/TestON/drivers/common/cli/remotetestbed/remotevmdriver.py
index 4592e71..4f97854 100644
--- a/TestON/drivers/common/cli/remotetestbed/remotevmdriver.py
+++ b/TestON/drivers/common/cli/remotetestbed/remotevmdriver.py
@@ -1,14 +1,14 @@
#!/usr/bin/env python
-'''
+"""
Created on 12-Feb-2013
-@author: Anil Kumar (anilkumar.s@paxterrasolutions.com)
+author:: Anil Kumar ( anilkumar.s@paxterrasolutions.com )
TestON is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
+ ( at your option ) any later version.
TestON is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -16,12 +16,11 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with TestON. If not, see <http://www.gnu.org/licenses/>.
+ along with TestON. If not, see <http://www.gnu.org/licenses/>.
RemoteVMDriver is the basic driver which will handle the Mininet functions
-'''
-
+"""
import pexpect
import struct
import fcntl
@@ -31,68 +30,100 @@
import sys
import time
-sys.path.append("../")
+sys.path.append( "../" )
from drivers.common.cli.remotetestbeddriver import RemoteTestBedDriver
-class RemoteVMDriver(RemoteTestBedDriver):
- '''
- RemoteVMDriver is the basic driver which will handle the Mininet functions
- '''
- def __init__(self):
- super(RemoteTestBedDriver, self).__init__()
-
- def connect(self,**connectargs):
- for key in connectargs:
- vars(self)[key] = connectargs[key]
-
- self.name = self.options['name']
- self.handle = super(RemoteVMDriver,self).connect(user_name = self.user_name, ip_address = self.ip_address,port = self.port, pwd = self.pwd)
- if self.handle :
- main.log.info(self.name+" connected successfully ")
+class RemoteVMDriver( RemoteTestBedDriver ):
+
+ """
+ RemoteVMDriver is the basic driver which will handle the Mininet functions
+ """
+ def __init__( self ):
+ super( RemoteTestBedDriver, self ).__init__()
+
+ def connect( self, **connectargs ):
+ for key in connectargs:
+ vars( self )[ key ] = connectargs[ key ]
+
+ self.name = self.options[ 'name' ]
+
+ self.handle = super(
+ RemoteVMDriver,
+ self ).connect(
+ user_name=self.user_name,
+ ip_address=self.ip_address,
+ port=self.port,
+ pwd=self.pwd )
+ if self.handle:
+ main.log.info( self.name + " connected successfully " )
return self.handle
return main.TRUE
- def SSH(self,**connectargs):
+
+ def SSH( self, **connectargs ):
for key in connectargs:
- vars(self)[key] = connectargs[key]
-
- '''
+ vars( self )[ key ] = connectargs[ key ]
+
+ """
Connection will establish to the remote host using ssh.
It will take user_name ,ip_address and password as arguments<br>
- and will return the handle.
- '''
+ and will return the handle.
+ """
for key in connectargs:
- vars(self)[key] = connectargs[key]
-
+ vars( self )[ key ] = connectargs[ key ]
+
ssh_newkey = 'Are you sure you want to continue connecting'
- refused = "ssh: connect to host "+self.ip_address+" port 22: Connection refused"
+ refused = "ssh: connect to host " + \
+ self.ip_address + " port 22: Connection refused"
if self.port:
- self.handle.sendline('ssh -p '+self.port+' '+self.user_name+'@'+self.ip_address)
- else :
- self.handle.sendline('ssh '+self.user_name+'@'+self.ip_address)
- self.handle.sendline("\r")
-
- i=self.handle.expect([ssh_newkey,'password:',pexpect.EOF,pexpect.TIMEOUT,refused],120)
-
- if i==0:
- main.log.info("ssh key confirmation received, send yes")
- self.handle.sendline('yes')
- i=self.handle.expect([ssh_newkey,'password:',pexpect.EOF])
- if i==1:
- main.log.info("ssh connection asked for password, gave password")
- self.handle.sendline(self.pwd)
- self.handle.expect('>|#|$')
-
- elif i==2:
- main.log.error("Connection timeout")
+ self.handle.sendline(
+ 'ssh -p ' +
+ self.port +
+ ' ' +
+ self.user_name +
+ '@' +
+ self.ip_address )
+ else:
+ self.handle.sendline(
+ 'ssh ' +
+ self.user_name +
+ '@' +
+ self.ip_address )
+ self.handle.sendline( "\r" )
+
+ i = self.handle.expect( [ ssh_newkey,
+ 'password:',
+ pexpect.EOF,
+ pexpect.TIMEOUT,
+ refused ],
+ 120 )
+
+ if i == 0:
+ main.log.info( "ssh key confirmation received, send yes" )
+ self.handle.sendline( 'yes' )
+ i = self.handle.expect( [ ssh_newkey, 'password:', pexpect.EOF ] )
+ if i == 1:
+ main.log.info( "ssh connection asked for password, gave password" )
+ self.handle.sendline( self.pwd )
+ self.handle.expect( '>|#|$' )
+
+ elif i == 2:
+ main.log.error( "Connection timeout" )
return main.FALSE
- elif i==3: #timeout
- main.log.error("No route to the Host "+self.user_name+"@"+self.ip_address)
+ elif i == 3: # timeout
+ main.log.error(
+ "No route to the Host " +
+ self.user_name +
+ "@" +
+ self.ip_address )
return main.FALSE
- elif i==4:
- main.log.error("ssh: connect to host "+self.ip_address+" port 22: Connection refused")
+ elif i == 4:
+ main.log.error(
+ "ssh: connect to host " +
+ self.ip_address +
+ " port 22: Connection refused" )
return main.FALSE
- self.handle.sendline("\r")
+ self.handle.sendline( "\r" )
return main.TRUE
diff --git a/TestON/drivers/common/cli/remotetestbeddriver.py b/TestON/drivers/common/cli/remotetestbeddriver.py
index 79fbf1c..eaeacd9 100644
--- a/TestON/drivers/common/cli/remotetestbeddriver.py
+++ b/TestON/drivers/common/cli/remotetestbeddriver.py
@@ -1,13 +1,13 @@
#!/usr/bin/env python
-'''
-Created on 26-Oct-2012
+"""
+Created on 26-Oct-2012
-@author: Anil Kumar (anilkumar.s@paxterrasolutions.com)
+author:: Anil Kumar ( anilkumar.s@paxterrasolutions.com )
TestON is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
+ ( at your option ) any later version.
TestON is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -15,44 +15,66 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with TestON. If not, see <http://www.gnu.org/licenses/>.
+ along with TestON. If not, see <http://www.gnu.org/licenses/>.
-'''
+"""
import time
import pexpect
-import struct, fcntl, os, sys, signal
+import struct
+import fcntl
+import os
import sys
-sys.path.append("../")
+import signal
+import sys
+sys.path.append( "../" )
from drivers.common.clidriver import CLI
-class RemoteTestBedDriver(CLI):
- # The common functions for emulator included in RemoteTestBedDriver
- def __init__(self):
- super(CLI, self).__init__()
-
- def connect(self,**connectargs):
- for key in connectargs:
- vars(self)['vm_'+key] = connectargs[key]
- remote_user_name = main.componentDictionary[self.name]['remote_user_name']
- remote_ip_address = main.componentDictionary[self.name]['remote_ip_address']
- remote_port = main.componentDictionary[self.name]['remote_port']
- remote_pwd = main.componentDictionary[self.name]['remote_pwd']
-
- self.handle = super(RemoteTestBedDriver,self).connect(user_name = remote_user_name,
- ip_address = remote_ip_address,
- port = remote_port, pwd = remote_pwd)
-
+class RemoteTestBedDriver( CLI ):
+ # The common functions for emulator included in RemoteTestBedDriver
+
+ def __init__( self ):
+ super( CLI, self ).__init__()
+
+ def connect( self, **connectargs ):
+ for key in connectargs:
+ vars( self )[ 'vm_' + key ] = connectargs[ key ]
+
+ remote_user_name = main.componentDictionary[
+ self.name ][ 'remote_user_name' ]
+ remote_ip_address = main.componentDictionary[
+ self.name ][ 'remote_ip_address' ]
+ remote_port = main.componentDictionary[ self.name ][ 'remote_port' ]
+ remote_pwd = main.componentDictionary[ self.name ][ 'remote_pwd' ]
+
+ self.handle = super(
+ RemoteTestBedDriver,
+ self ).connect(
+ user_name=remote_user_name,
+ ip_address=remote_ip_address,
+ port=remote_port,
+ pwd=remote_pwd )
+
if self.handle:
- self.execute(cmd= "\n",prompt= "\$|>|#",timeout= 10)
- self.execute(cmd= "SET CYGWIN=notty",prompt= "\$|>|#",timeout= 10)
- self.execute(cmd= "\n",prompt= "\$|>|#",timeout= 10)
- main.log.info("ssh "+self.vm_user_name+'@'+self.vm_ip_address)
- self.execute(cmd= "ssh "+self.vm_user_name+'@'+self.vm_ip_address,prompt= "(.*)",timeout= 10)
- self.execute(cmd= "\n",prompt= "assword:",timeout= 10)
- self.execute(cmd = self.vm_pwd,prompt = "\$",timeout = 10)
-
+ self.execute( cmd="\n", prompt="\$|>|#", timeout=10 )
+ self.execute( cmd="SET CYGWIN=notty", prompt="\$|>|#", timeout=10 )
+ self.execute( cmd="\n", prompt="\$|>|#", timeout=10 )
+ main.log.info(
+ "ssh " +
+ self.vm_user_name +
+ '@' +
+ self.vm_ip_address )
+ self.execute(
+ cmd="ssh " +
+ self.vm_user_name +
+ '@' +
+ self.vm_ip_address,
+ prompt="(.*)",
+ timeout=10 )
+ self.execute( cmd="\n", prompt="assword:", timeout=10 )
+ self.execute( cmd=self.vm_pwd, prompt="\$", timeout=10 )
+
return self.handle
- else :
+ else:
return main.FALSE
diff --git a/TestON/drivers/common/cli/tool/dpctlclidriver.py b/TestON/drivers/common/cli/tool/dpctlclidriver.py
index 3ad5bba..252fb8c 100644
--- a/TestON/drivers/common/cli/tool/dpctlclidriver.py
+++ b/TestON/drivers/common/cli/tool/dpctlclidriver.py
@@ -1,14 +1,14 @@
#/usr/bin/env python
-'''
+"""
Created on 26-Nov-2012
-
-@author: Raghav Kashyap(raghavkashyap@paxterrasolutions.com)
+
+author:: Raghav Kashyap( raghavkashyap@paxterrasolutions.com )
TestON is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
+ ( at your option ) any later version.
TestON is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -16,14 +16,18 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with TestON. If not, see <http://www.gnu.org/licenses/>.
+ along with TestON. If not, see <http://www.gnu.org/licenses/>.
DPCTL driver class provides the basic functions of DPCTL controller
-'''
+"""
import pexpect
-import struct, fcntl, os, sys, signal
+import struct
+import fcntl
+import os
+import sys
+import signal
import sys
from drivers.common.cli.toolsdriver import Tools
import pydoc
@@ -32,214 +36,280 @@
import os
import sys
-class DpctlCliDriver(Tools):
- '''
+
+class DpctlCliDriver( Tools ):
+
+ """
DpctlCliDriver driver class provides the basic functions of DPCTL controller
- '''
- def __init__(self):
- super(DpctlCliDriver, self).__init__()
+ """
+ def __init__( self ):
+ super( DpctlCliDriver, self ).__init__()
self.handle = self
- self.wrapped = sys.modules[__name__]
-
- def connect(self,**connectargs):
-
+ self.wrapped = sys.modules[ __name__ ]
+
+ def connect( self, **connectargs ):
+
for key in connectargs:
- vars(self)[key] = connectargs[key]
-
- self.name = self.options['name']
-
- self.handle = super(DpctlCliDriver, self).connect(user_name = self.user_name, ip_address = self.ip_address,port = None, pwd = self.pwd)
- if self.handle :
- main.log.info("Connected to the host")
- return main.TRUE
- else :
- main.log.error("Connection failed to the host "+self.user_name+"@"+self.ip_address)
- return main.FALSE
+ vars( self )[ key ] = connectargs[ key ]
- def addFlow(self,**flowParameters):
- '''
+ self.name = self.options[ 'name' ]
+
+ self.handle = super(
+ DpctlCliDriver, self ).connect( user_name=self.user_name,
+ ip_address=self.ip_address,
+ port=None,
+ pwd=self.pwd )
+ if self.handle:
+ main.log.info( "Connected to the host" )
+ return main.TRUE
+ else:
+ main.log.error(
+ "Connection failed to the host " +
+ self.user_name +
+ "@" +
+ self.ip_address )
+ return main.FALSE
+
+ def addFlow( self, **flowParameters ):
+ """
addFlow create a new flow entry into flow table using "dpctl"
- '''
- args = utilities.parse_args(["TCPIP","TCPPORT","INPORT","ACTION","TIMEOUT"],**flowParameters)
+ """
+ args = utilities.parse_args( [
+ "TCPIP",
+ "TCPPORT",
+ "INPORT",
+ "ACTION",
+ "TIMEOUT" ],
+ **flowParameters )
+
cmd = "dpctl add-flow tcp:"
- tcpIP = args["TCPIP"] if args["TCPIP"] != None else "127.0.0.1"
- tcpPort = args["TCPPORT"] if args["TCPPORT"] != None else "6634"
- timeOut = args["TIMEOUT"] if args["TIMEOUT"] != None else 120
- cmd = cmd + tcpIP + ":" + tcpPort + " in_port=" + str(args["INPORT"]) + ",idle_timeout=" + str(args["TIMEOUT"]) +",actions=" + args["ACTION"]
- response = self.execute(cmd=cmd,prompt="\~\$",timeout=60 )
- if utilities.assert_matches(expect="openflow",actual=response,onpass="Flow Added Successfully",onfail="Adding Flow Failed!!!"):
+ tcpIP = args[ "TCPIP" ] if args[ "TCPIP" ] is not None else "127.0.0.1"
+ tcpPort = args[ "TCPPORT" ] if args[
+ "TCPPORT" ] is not None else "6634"
+ timeOut = args[ "TIMEOUT" ] if args[ "TIMEOUT" ] is not None else 120
+ cmd = cmd + tcpIP + ":" + tcpPort + " in_port=" + \
+ str( args[ "INPORT" ] ) + ",idle_timeout=" + str(
+ args[ "TIMEOUT" ] ) + ",actions=" + args[ "ACTION" ]
+ response = self.execute( cmd=cmd, prompt="\~\$", timeout=60 )
+ if utilities.assert_matches( expect="openflow", actual=response, onpass="Flow Added Successfully", onfail="Adding Flow Failed!!!" ):
return main.TRUE
- else :
+ else:
return main.FALSE
- def showFlow(self,**flowParameters):
- '''
+ def showFlow( self, **flowParameters ):
+ """
showFlow dumps the flow entries of flow table using "dpctl"
- '''
- args = utilities.parse_args(["TCPIP","TCPPORT"],**flowParameters)
- tcpIP = args["TCPIP"] if args["TCPIP"] != None else "127.0.0.1"
- tcpPort = args["TCPPORT"] if args["TCPPORT"] != None else "6634"
- command = "dpctl show tcp:" + str(tcpIP) + ":" + str(tcpPort)
- response = self.execute(cmd=command,prompt="get_config_reply",timeout=240)
- if utilities.assert_matches(expect='features_reply',actual=response,onpass="Show flow executed",onfail="Show flow execution Failed"):
+ """
+ args = utilities.parse_args( [ "TCPIP", "TCPPORT" ], **flowParameters )
+ tcpIP = args[ "TCPIP" ] if args[ "TCPIP" ] is not None else "127.0.0.1"
+ tcpPort = args[ "TCPPORT" ] if args[
+ "TCPPORT" ] is not None else "6634"
+ command = "dpctl show tcp:" + str( tcpIP ) + ":" + str( tcpPort )
+ response = self.execute(
+ cmd=command,
+ prompt="get_config_reply",
+ timeout=240 )
+ if utilities.assert_matches( expect='features_reply', actual=response, onpass="Show flow executed", onfail="Show flow execution Failed" ):
main.last_result = main.TRUE
return main.TRUE
- else :
+ else:
main.last_result = main.FALSE
return main.FALSE
- def dumpFlow(self,**flowParameters):
- '''
+ def dumpFlow( self, **flowParameters ):
+ """
dumpFlow gives installed flow information
- '''
- args = utilities.parse_args(["TCPIP","TCPPORT"],**flowParameters)
- tcpIP = args["TCPIP"] if args["TCPIP"] != None else "127.0.0.1"
- tcpPort = args["TCPPORT"] if args["TCPPORT"] != None else "6634"
- command = "dpctl dump-flows tcp:" + str(tcpIP) + ":" + str(tcpPort)
- response = self.execute(cmd=command,prompt="type=",timeout=240)
- if utilities.assert_matches(expect='stats_reply',actual=response,onpass="Dump flow executed",onfail="Dump flow execution Failed"):
+ """
+ args = utilities.parse_args( [ "TCPIP", "TCPPORT" ], **flowParameters )
+ tcpIP = args[ "TCPIP" ] if args[ "TCPIP" ] is not None else "127.0.0.1"
+ tcpPort = args[ "TCPPORT" ] if args[
+ "TCPPORT" ] is not None else "6634"
+ command = "dpctl dump-flows tcp:" + str( tcpIP ) + ":" + str( tcpPort )
+ response = self.execute( cmd=command, prompt="type=", timeout=240 )
+ if utilities.assert_matches( expect='stats_reply', actual=response, onpass="Dump flow executed", onfail="Dump flow execution Failed" ):
main.last_result = main.TRUE
return main.TRUE
- else :
+ else:
main.last_result = main.FALSE
return main.FALSE
-
- def dumpTables(self,**flowParameters):
- '''
+ def dumpTables( self, **flowParameters ):
+ """
dumpTables gives statistics for each of the flow tables used by datapath switch.
- '''
- args = utilities.parse_args(["TCPIP","TCPPORT"],**flowParameters)
- tcpIP = args["TCPIP"] if args["TCPIP"] != None else "127.0.0.1"
- tcpPort = args["TCPPORT"] if args["TCPPORT"] != None else "6634"
- command = "dpctl dump-tables tcp:" + str(tcpIP) + ":" + str(tcpPort)
- response = self.execute(cmd=command,prompt="matched",timeout=240)
- if utilities.assert_matches(expect='lookup=3',actual=response,onpass="Dump Tables executed",onfail="Dump Tables execution Failed"):
+ """
+ args = utilities.parse_args( [ "TCPIP", "TCPPORT" ], **flowParameters )
+ tcpIP = args[ "TCPIP" ] if args[ "TCPIP" ] is not None else "127.0.0.1"
+ tcpPort = args[ "TCPPORT" ] if args[
+ "TCPPORT" ] is not None else "6634"
+ command = "dpctl dump-tables tcp:" + \
+ str( tcpIP ) + ":" + str( tcpPort )
+ response = self.execute( cmd=command, prompt="matched", timeout=240 )
+ if utilities.assert_matches( expect='lookup=3', actual=response, onpass="Dump Tables executed", onfail="Dump Tables execution Failed" ):
main.last_result = main.TRUE
return main.TRUE
- else :
+ else:
main.last_result = main.FALSE
return main.FALSE
-
- def dumpPorts(self,**flowParameters):
- '''
+
+ def dumpPorts( self, **flowParameters ):
+ """
dumpPorts gives ports information
- '''
- args = utilities.parse_args(["TCPIP","TCPPORT"],**flowParameters)
- tcpIP = args["TCPIP"] if args["TCPIP"] != None else "127.0.0.1"
- tcpPort = args["TCPPORT"] if args["TCPPORT"] != None else "6634"
- command = "dpctl dump-ports tcp:" + str(tcpIP) + ":" + str(tcpPort)
- response = self.execute(cmd=command,prompt="rx pkts",timeout=240)
- if utilities.assert_matches(expect='ports',actual=response,onpass="Dump Ports executed",onfail="Dump Ports execution Failed"):
+ """
+ args = utilities.parse_args( [ "TCPIP", "TCPPORT" ], **flowParameters )
+ tcpIP = args[ "TCPIP" ] if args[ "TCPIP" ] is not None else "127.0.0.1"
+ tcpPort = args[ "TCPPORT" ] if args[
+ "TCPPORT" ] is not None else "6634"
+ command = "dpctl dump-ports tcp:" + str( tcpIP ) + ":" + str( tcpPort )
+ response = self.execute( cmd=command, prompt="rx pkts", timeout=240 )
+ if utilities.assert_matches( expect='ports', actual=response, onpass="Dump Ports executed", onfail="Dump Ports execution Failed" ):
main.last_result = main.TRUE
return main.TRUE
- else :
+ else:
main.last_result = main.FALSE
return main.FALSE
-
- def dumpAggregate(self,**flowParameters):
- '''
+ def dumpAggregate( self, **flowParameters ):
+ """
dumpAggregate gives installed flow information.ggregate statistics for flows in datapath WITCH's tables that match flows.
If flows is omitted, the statistics are aggregated across all flows in the datapath's flow tables
- '''
- args = utilities.parse_args(["TCPIP","TCPPORT","FLOW"],**flowParameters)
- tcpIP = args["TCPIP"] if args["TCPIP"] != None else "127.0.0.1"
- tcpPort = args["TCPPORT"] if args["TCPPORT"] != None else "6634"
- flow = args["FLOW"] if args["FLOW"] != None else ""
- command = "dpctl dump-aggregate tcp:" + str(tcpIP) + ":" + str(tcpPort) + " " + str (flow)
- response = self.execute(cmd=command,prompt="flow_count=",timeout=240)
- if utilities.assert_matches(expect='stats_reply',actual=response,onpass="Dump Aggregate executed",onfail="Dump Aggregate execution Failed"):
+ """
+ args = utilities.parse_args(
+ [ "TCPIP", "TCPPORT", "FLOW" ], **flowParameters )
+ tcpIP = args[ "TCPIP" ] if args[ "TCPIP" ] is not None else "127.0.0.1"
+ tcpPort = args[ "TCPPORT" ] if args[
+ "TCPPORT" ] is not None else "6634"
+ flow = args[ "FLOW" ] if args[ "FLOW" ] is not None else ""
+ command = "dpctl dump-aggregate tcp:" + \
+ str( tcpIP ) + ":" + str( tcpPort ) + " " + str( flow )
+ response = self.execute(
+ cmd=command,
+ prompt="flow_count=",
+ timeout=240 )
+ if utilities.assert_matches( expect='stats_reply', actual=response, onpass="Dump Aggregate executed", onfail="Dump Aggregate execution Failed" ):
main.last_result = main.TRUE
return main.TRUE
- else :
+ else:
main.last_result = main.FALSE
return main.FALSE
- def delFlow(self,**flowParameters):
- '''
+ def delFlow( self, **flowParameters ):
+ """
delFlow Deletes entries from the datapath switch's tables that match flow
- '''
- args = utilities.parse_args(["TCPIP","TCPPORT","FLOW"],**flowParameters)
- tcpIP = args["TCPIP"] if args["TCPIP"] != None else "127.0.0.1"
- tcpPort = args["TCPPORT"] if args["TCPPORT"] != None else "6634"
- flow = args["FLOW"] if args["FLOW"] != None else ""
- command = "dpctl del-flows tcp:" + str(tcpIP) + ":" + str(tcpPort) + " " +str(flow)
- response = self.execute(cmd=command,prompt="ETH-Tutorial",timeout=240)
- if utilities.assert_matches(expect='@',actual=response,onpass="Delete flow executed",onfail="Delete flow execution Failed"):
+ """
+ args = utilities.parse_args(
+ [ "TCPIP", "TCPPORT", "FLOW" ], **flowParameters )
+ tcpIP = args[ "TCPIP" ] if args[ "TCPIP" ] is not None else "127.0.0.1"
+ tcpPort = args[ "TCPPORT" ] if args[
+ "TCPPORT" ] is not None else "6634"
+ flow = args[ "FLOW" ] if args[ "FLOW" ] is not None else ""
+ command = "dpctl del-flows tcp:" + \
+ str( tcpIP ) + ":" + str( tcpPort ) + " " + str( flow )
+ response = self.execute(
+ cmd=command,
+ prompt="ETH-Tutorial",
+ timeout=240 )
+ if utilities.assert_matches( expect='@', actual=response, onpass="Delete flow executed", onfail="Delete flow execution Failed" ):
main.last_result = main.TRUE
return main.TRUE
- else :
+ else:
main.last_result = main.FALSE
return main.FALSE
- def show(self,**flowParameters):
- '''
+ def show( self, **flowParameters ):
+ """
show gives information on datapath switch including information on its flow tables and ports.
- '''
- args = utilities.parse_args(["TCPIP","TCPPORT"],**flowParameters)
- tcpIP = args["TCPIP"] if args["TCPIP"] != None else "127.0.0.1"
- tcpPort = args["TCPPORT"] if args["TCPPORT"] != None else "6634"
- command = "dpctl show tcp:" + str(tcpIP) + ":" + str(tcpPort)
- response = self.execute(cmd=command,prompt="miss_send_len=",timeout=240)
- if utilities.assert_matches(expect='get_config_reply',actual=response,onpass="show command executed",onfail="show command execution Failed"):
+ """
+ args = utilities.parse_args( [ "TCPIP", "TCPPORT" ], **flowParameters )
+ tcpIP = args[ "TCPIP" ] if args[ "TCPIP" ] is not None else "127.0.0.1"
+ tcpPort = args[ "TCPPORT" ] if args[
+ "TCPPORT" ] is not None else "6634"
+ command = "dpctl show tcp:" + str( tcpIP ) + ":" + str( tcpPort )
+ response = self.execute(
+ cmd=command,
+ prompt="miss_send_len=",
+ timeout=240 )
+ if utilities.assert_matches( expect='get_config_reply', actual=response, onpass="show command executed", onfail="show command execution Failed" ):
main.last_result = main.TRUE
return main.TRUE
- else :
+ else:
main.last_result = main.FALSE
return main.FALSE
- def showStatus(self,**flowParameters):
- '''
- showStatus gives a series of key-value pairs that report the status of switch.
- If key is specified, only the key-value pairs whose key names begin with key are printed.
- '''
- args = utilities.parse_args(["TCPIP","TCPPORT","KEY"],**flowParameters)
- tcpIP = args["TCPIP"] if args["TCPIP"] != None else "127.0.0.1"
- tcpPort = args["TCPPORT"] if args["TCPPORT"] != None else "6634"
- key = args["KEY"] if args["KEY"] != None else ""
- command = "dpctl status tcp:" + str(tcpIP) + ":" + str(tcpPort) + " " + key
- response = self.execute(cmd=command,prompt="(.*)",timeout=240)
- if utilities.assert_matches(expect='(.*)',actual=response,onpass="show command executed",onfail="show command execution Failed"):
+ def showStatus( self, **flowParameters ):
+ """
+ showStatus gives a series of key-value pairs that report the status of switch.
+ If key is specified, only the key-value pairs whose key names begin with key are printed.
+ """
+ args = utilities.parse_args(
+ [ "TCPIP", "TCPPORT", "KEY" ], **flowParameters )
+ tcpIP = args[ "TCPIP" ] if args[ "TCPIP" ] is not None else "127.0.0.1"
+ tcpPort = args[ "TCPPORT" ] if args[
+ "TCPPORT" ] is not None else "6634"
+ key = args[ "KEY" ] if args[ "KEY" ] is not None else ""
+ command = "dpctl status tcp:" + \
+ str( tcpIP ) + ":" + str( tcpPort ) + " " + key
+ response = self.execute( cmd=command, prompt="(.*)", timeout=240 )
+ if utilities.assert_matches( expect='(.*)', actual=response, onpass="show command executed", onfail="show command execution Failed" ):
main.last_result = main.TRUE
return main.TRUE
- else :
+ else:
main.last_result = main.FALSE
return main.FALSE
- def desc_set(self,**flowParameters):
- '''
- desc_set Sets the switch description (as returned in ofp_desc_stats) to string (max length is DESC_STR_LEN)
- '''
- args = utilities.parse_args(["TCPIP","TCPPORT","STRING"],**flowParameters)
- tcpIP = args["TCPIP"] if args["TCPIP"] != None else "127.0.0.1"
- tcpPort = args["TCPPORT"] if args["TCPPORT"] != None else "6634"
- string = " " + args["STRING"] if args["STRING"] != None else " DESC_STR_LEN"
- command = "dpctl desc tcp:" + str(tcpIP) + ":" + str(tcpPort) + str(string)
- response = self.execute(cmd=command,prompt="ETH-Tutorial",timeout=240)
- if utilities.assert_matches(expect='@',actual=response,onpass="desc command executed",onfail="desc command execution Failed"):
+ def desc_set( self, **flowParameters ):
+ """
+ desc_set Sets the switch description ( as returned in ofp_desc_stats ) to string ( max length is DESC_STR_LEN )
+ """
+ args = utilities.parse_args( [
+ "TCPIP",
+ "TCPPORT",
+ "STRING" ],
+ **flowParameters )
+
+ tcpIP = args[ "TCPIP" ] if args[ "TCPIP" ] is not None else "127.0.0.1"
+ tcpPort = args[ "TCPPORT" ] if args[
+ "TCPPORT" ] is not None else "6634"
+ string = " " + args[ "STRING" ] if args[
+ "STRING" ] is not None else " DESC_STR_LEN"
+ command = "dpctl desc tcp:" + \
+ str( tcpIP ) + ":" + str( tcpPort ) + str( string )
+ response = self.execute(
+ cmd=command,
+ prompt="ETH-Tutorial",
+ timeout=240 )
+ if utilities.assert_matches( expect='@', actual=response, onpass="desc command executed", onfail="desc command execution Failed" ):
main.last_result = main.TRUE
return main.TRUE
- else :
+ else:
main.last_result = main.FALSE
return main.FALSE
- def dumpDesc(self,**flowParameters):
- '''
- dumpDesc Sets the switch description (as returned in ofp_desc_stats) to string (max length is DESC_STR_LEN)
- '''
- args = utilities.parse_args(["TCPIP","TCPPORT","STRING"],**flowParameters)
- tcpIP = args["TCPIP"] if args["TCPIP"] != None else "127.0.0.1"
- tcpPort = args["TCPPORT"] if args["TCPPORT"] != None else "6634"
- command = "dpctl dump-desc tcp:" + str(tcpIP) + ":" + str(tcpPort)
- response = self.execute(cmd=command,prompt="Serial Num:",timeout=240)
- if utilities.assert_matches(expect='stats_reply',actual=response,onpass="desc command executed",onfail="desc command execution Failed"):
+ def dumpDesc( self, **flowParameters ):
+ """
+ dumpDesc Sets the switch description ( as returned in ofp_desc_stats ) to string ( max length is DESC_STR_LEN )
+ """
+ args = utilities.parse_args( [
+ "TCPIP",
+ "TCPPORT",
+ "STRING" ],
+ **flowParameters )
+
+ tcpIP = args[ "TCPIP" ] if args[ "TCPIP" ] is not None else "127.0.0.1"
+ tcpPort = args[ "TCPPORT" ] if args[
+ "TCPPORT" ] is not None else "6634"
+ command = "dpctl dump-desc tcp:" + str( tcpIP ) + ":" + str( tcpPort )
+ response = self.execute(
+ cmd=command,
+ prompt="Serial Num:",
+ timeout=240 )
+ if utilities.assert_matches( expect='stats_reply', actual=response, onpass="desc command executed", onfail="desc command execution Failed" ):
main.last_result = main.TRUE
return main.TRUE
- else :
+ else:
main.last_result = main.FALSE
return main.FALSE
if __name__ != "__main__":
import sys
- sys.modules[__name__] = DpctlCliDriver()
+ sys.modules[ __name__ ] = DpctlCliDriver()
+
diff --git a/TestON/drivers/common/cli/toolsdriver.py b/TestON/drivers/common/cli/toolsdriver.py
index 2c165f9..ec4585f 100644
--- a/TestON/drivers/common/cli/toolsdriver.py
+++ b/TestON/drivers/common/cli/toolsdriver.py
@@ -1,13 +1,13 @@
#!/usr/bin/env python
-'''
+"""
Created on 26-Nov-2012
-@author: Raghav Kashyap(raghavkashyap@paxterrasolutions.com)
+author:: Raghav Kashyap( raghavkashyap@paxterrasolutions.com )
TestON is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
+ ( at your option ) any later version.
TestON is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -15,18 +15,23 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with TestON. If not, see <http://www.gnu.org/licenses/>.
+ along with TestON. If not, see <http://www.gnu.org/licenses/>.
-'''
+"""
import pexpect
-import struct, fcntl, os, sys, signal
+import struct
+import fcntl
+import os
import sys
-sys.path.append("../")
+import signal
+import sys
+sys.path.append( "../" )
from drivers.common.clidriver import CLI
-class Tools(CLI):
+class Tools( CLI ):
# The common functions for Tools included in toolsdriver
- def __init__(self):
- super(CLI, self).__init__()
+
+ def __init__( self ):
+ super( CLI, self ).__init__()
diff --git a/TestON/drivers/common/clidriver.py b/TestON/drivers/common/clidriver.py
index 878839e..55ff522 100644
--- a/TestON/drivers/common/clidriver.py
+++ b/TestON/drivers/common/clidriver.py
@@ -1,15 +1,15 @@
#!/usr/bin/env python
-'''
+"""
Created on 24-Oct-2012
-
-@authors: Anil Kumar (anilkumar.s@paxterrasolutions.com),
- Raghav Kashyap(raghavkashyap@paxterrasolutions.com)
+
+author:s: Anil Kumar ( anilkumar.s@paxterrasolutions.com ),
+ Raghav Kashyap( raghavkashyap@paxterrasolutions.com )
TestON is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
+ ( at your option ) any later version.
TestON is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -17,78 +17,117 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with TestON. If not, see <http://www.gnu.org/licenses/>.
+ along with TestON. If not, see <http://www.gnu.org/licenses/>.
-
-'''
+
+"""
import pexpect
-import struct, fcntl, os, sys, signal
-import sys, re
-sys.path.append("../")
+import struct
+import fcntl
+import os
+import sys
+import signal
+import sys
+import re
+sys.path.append( "../" )
from drivers.component import Component
-class CLI(Component):
- '''
+
+
+class CLI( Component ):
+
+ """
This will define common functions for CLI included.
- '''
- def __init__(self):
- super(Component, self).__init__()
-
- def connect(self,**connectargs):
- '''
+ """
+ def __init__( self ):
+ super( Component, self ).__init__()
+
+ def connect( self, **connectargs ):
+ """
Connection will establish to the remote host using ssh.
It will take user_name ,ip_address and password as arguments<br>
- and will return the handle.
- '''
+ and will return the handle.
+ """
for key in connectargs:
- vars(self)[key] = connectargs[key]
+ vars( self )[ key ] = connectargs[ key ]
- connect_result = super(CLI, self).connect()
+ connect_result = super( CLI, self ).connect()
ssh_newkey = 'Are you sure you want to continue connecting'
- refused = "ssh: connect to host "+self.ip_address+" port 22: Connection refused"
+ refused = "ssh: connect to host " + \
+ self.ip_address + " port 22: Connection refused"
if self.port:
- self.handle =pexpect.spawn('ssh -p '+self.port+' '+self.user_name+'@'+self.ip_address, env = {"TERM": "vt100"} , maxread=50000)
- else :
- self.handle =pexpect.spawn('ssh -X '+self.user_name+'@'+self.ip_address,maxread=1000000,timeout=60)
+ self.handle = pexpect.spawn(
+ 'ssh -p ' +
+ self.port +
+ ' ' +
+ self.user_name +
+ '@' +
+ self.ip_address,
+ env={
+ "TERM": "vt100" },
+ maxread=50000 )
+ else:
+ self.handle = pexpect.spawn(
+ 'ssh -X ' +
+ self.user_name +
+ '@' +
+ self.ip_address,
+ maxread=1000000,
+ timeout=60 )
self.handle.logfile = self.logfile_handler
- i = 5
- while i == 5:
- i=self.handle.expect([ssh_newkey,'password:',pexpect.EOF,pexpect.TIMEOUT,refused,'teston>','>|#|\$'],120)
- if i==0:
- main.log.info("ssh key confirmation received, send yes")
- self.handle.sendline('yes')
- i=self.handle.expect([ssh_newkey,'password:',pexpect.EOF])
- if i==1:
- main.log.info("ssh connection asked for password, gave password")
- self.handle.sendline(self.pwd)
- self.handle.expect('>|#|\$')
- elif i==2:
- main.log.error("Connection timeout")
- return main.FALSE
- elif i==3: #timeout
- main.log.error("No route to the Host "+self.user_name+"@"+self.ip_address)
- return main.FALSE
- elif i==4:
- main.log.error("ssh: connect to host "+self.ip_address+" port 22: Connection refused")
- return main.FALSE
- elif i==6:
- main.log.info("Password not required logged in")
+ i = 5
+ while i == 5:
+ i = self.handle.expect( [
+ ssh_newkey,
+ 'password:',
+ pexpect.EOF,
+ pexpect.TIMEOUT,
+ refused,
+ 'teston>',
+ '>|#|\$' ],
+ 120 )
+ if i == 0:
+ main.log.info( "ssh key confirmation received, send yes" )
+ self.handle.sendline( 'yes' )
+ i = self.handle.expect(
+ [ ssh_newkey, 'password:', pexpect.EOF ] )
+ if i == 1:
+ main.log.info(
+ "ssh connection asked for password, gave password" )
+ self.handle.sendline( self.pwd )
+ self.handle.expect( '>|#|\$' )
+ elif i == 2:
+ main.log.error( "Connection timeout" )
+ return main.FALSE
+ elif i == 3: # timeout
+ main.log.error(
+ "No route to the Host " +
+ self.user_name +
+ "@" +
+ self.ip_address )
+ return main.FALSE
+ elif i == 4:
+ main.log.error(
+ "ssh: connect to host " +
+ self.ip_address +
+ " port 22: Connection refused" )
+ return main.FALSE
+ elif i == 6:
+ main.log.info( "Password not required logged in" )
- self.handle.sendline("")
- self.handle.expect('>|#|\$')
+ self.handle.sendline( "" )
+ self.handle.expect( '>|#|\$' )
return self.handle
-
- def disconnect(self):
- result = super(CLI, self).disconnect(self)
+ def disconnect( self ):
+ result = super( CLI, self ).disconnect( self )
result = main.TRUE
- #self.execute(cmd="exit",timeout=120,prompt="(.*)")
-
-
- def execute(self, **execparams):
- '''
+ # self.execute( cmd="exit",timeout=120,prompt="(.*)" )
+
+ def execute( self, **execparams ):
+ """
It facilitates the command line execution of a given command. It has arguments as :
cmd => represents command to be executed,
prompt => represents expect command prompt or output,
@@ -96,127 +135,171 @@
more => to provide a key press if it is on.
It will return output of command exection.
- '''
-
- result = super(CLI, self).execute(self)
+ """
+ result = super( CLI, self ).execute( self )
defaultPrompt = '.*[$>\#]'
- args = utilities.parse_args(["CMD", "TIMEOUT", "PROMPT", "MORE"], **execparams)
- expectPrompt = args["PROMPT"] if args["PROMPT"] else defaultPrompt
+ args = utilities.parse_args( [
+ "CMD",
+ "TIMEOUT",
+ "PROMPT",
+ "MORE" ],
+ **execparams )
+
+ expectPrompt = args[ "PROMPT" ] if args[ "PROMPT" ] else defaultPrompt
self.LASTRSP = ""
- timeoutVar = args["TIMEOUT"] if args["TIMEOUT"] else 10
+ timeoutVar = args[ "TIMEOUT" ] if args[ "TIMEOUT" ] else 10
cmd = ''
- if args["CMD"]:
- cmd = args["CMD"]
- else :
+ if args[ "CMD" ]:
+ cmd = args[ "CMD" ]
+ else:
return 0
- if args["MORE"] == None:
- args["MORE"] = " "
- self.handle.sendline(cmd)
+ if args[ "MORE" ] is None:
+ args[ "MORE" ] = " "
+ self.handle.sendline( cmd )
self.lastCommand = cmd
- index = self.handle.expect([expectPrompt, "--More--", 'Command not found.', pexpect.TIMEOUT,"^:$"], timeout = timeoutVar)
+ index = self.handle.expect( [
+ expectPrompt,
+ "--More--",
+ 'Command not found.',
+ pexpect.TIMEOUT,
+ "^:$" ],
+ timeout=timeoutVar )
if index == 0:
- self.LASTRSP = self.LASTRSP + self.handle.before + self.handle.after
- main.log.info("Executed :"+str(cmd)+" \t\t Expected Prompt '"+ str(expectPrompt)+"' Found")
+ self.LASTRSP = self.LASTRSP + \
+ self.handle.before + self.handle.after
+ main.log.info(
+ "Executed :" + str(
+ cmd ) + " \t\t Expected Prompt '" + str(
+ expectPrompt) + "' Found" )
elif index == 1:
self.LASTRSP = self.LASTRSP + self.handle.before
- self.handle.send(args["MORE"])
- main.log.info("Found More screen to go , Sending a key to proceed")
- indexMore = self.handle.expect(["--More--", expectPrompt], timeout = timeoutVar)
+ self.handle.send( args[ "MORE" ] )
+ main.log.info(
+ "Found More screen to go , Sending a key to proceed" )
+ indexMore = self.handle.expect(
+ [ "--More--", expectPrompt ], timeout=timeoutVar )
while indexMore == 0:
- main.log.info("Found anoother More screen to go , Sending a key to proceed")
- self.handle.send(args["MORE"])
- indexMore = self.handle.expect(["--More--", expectPrompt], timeout = timeoutVar)
+ main.log.info(
+ "Found anoother More screen to go , Sending a key to proceed" )
+ self.handle.send( args[ "MORE" ] )
+ indexMore = self.handle.expect(
+ [ "--More--", expectPrompt ], timeout=timeoutVar )
self.LASTRSP = self.LASTRSP + self.handle.before
- elif index ==2:
- main.log.error("Command not found")
+ elif index == 2:
+ main.log.error( "Command not found" )
self.LASTRSP = self.LASTRSP + self.handle.before
- elif index ==3:
- main.log.error("Expected Prompt not found , Time Out!!")
- main.log.error( expectPrompt )
+ elif index == 3:
+ main.log.error( "Expected Prompt not found , Time Out!!" )
+ main.log.error( expectPrompt )
return "Expected Prompt not found , Time Out!!"
-
+
elif index == 4:
self.LASTRSP = self.LASTRSP + self.handle.before
- #self.handle.send(args["MORE"])
- self.handle.sendcontrol("D")
- main.log.info("Found More screen to go , Sending a key to proceed")
- indexMore = self.handle.expect(["^:$", expectPrompt], timeout = timeoutVar)
+ # self.handle.send( args[ "MORE" ] )
+ self.handle.sendcontrol( "D" )
+ main.log.info(
+ "Found More screen to go , Sending a key to proceed" )
+ indexMore = self.handle.expect(
+ [ "^:$", expectPrompt ], timeout=timeoutVar )
while indexMore == 0:
- main.log.info("Found another More screen to go , Sending a key to proceed")
- self.handle.sendcontrol("D")
- indexMore = self.handle.expect(["^:$", expectPrompt], timeout = timeoutVar)
+ main.log.info(
+ "Found another More screen to go , Sending a key to proceed" )
+ self.handle.sendcontrol( "D" )
+ indexMore = self.handle.expect(
+ [ "^:$", expectPrompt ], timeout=timeoutVar )
self.LASTRSP = self.LASTRSP + self.handle.before
-
- main.last_response = self.remove_contol_chars(self.LASTRSP)
+
+ main.last_response = self.remove_contol_chars( self.LASTRSP )
return self.LASTRSP
-
- def remove_contol_chars(self,response):
- #RE_XML_ILLEGAL = '([\u0000-\u0008\u000b-\u000c\u000e-\u001f\ufffe-\uffff])|([%s-%s][^%s-%s])|([^%s-%s][%s-%s])|([%s-%s]$)|(^[%s-%s])'%(unichr(0xd800),unichr(0xdbff),unichr(0xdc00),unichr(0xdfff),unichr(0xd800),unichr(0xdbff),unichr(0xdc00),unichr(0xdfff),unichr(0xd800),unichr(0xdbff),unichr(0xdc00),unichr(0xdfff))
- #response = re.sub(RE_XML_ILLEGAL, "\n", response)
- response = re.sub(r"[\x01-\x1F\x7F]", "", response)
- #response = re.sub(r"\[\d+\;1H", "\n", response)
- response = re.sub(r"\[\d+\;\d+H", "", response)
+
+ def remove_contol_chars( self, response ):
+ # RE_XML_ILLEGAL = '([\u0000-\u0008\u000b-\u000c\u000e-\u001f\ufffe-\uffff])|([%s-%s][^%s-%s])|([^%s-%s][%s-%s])|([%s-%s]$)|(^[%s-%s])'%( unichr( 0xd800 ),unichr( 0xdbff ),unichr( 0xdc00 ),unichr( 0xdfff ),unichr( 0xd800 ),unichr( 0xdbff ),unichr( 0xdc00 ),unichr( 0xdfff ),unichr( 0xd800 ),unichr( 0xdbff ),unichr( 0xdc00 ),unichr( 0xdfff ) )
+ # response = re.sub( RE_XML_ILLEGAL, "\n", response )
+ response = re.sub( r"[\x01-\x1F\x7F]", "", response )
+ # response = re.sub( r"\[\d+\;1H", "\n", response )
+ response = re.sub( r"\[\d+\;\d+H", "", response )
return response
-
- def runAsSudoUser(self,handle,pwd,default):
-
- i = handle.expect([".ssword:*",default, pexpect.EOF])
- if i==0:
- handle.sendline(pwd)
- handle.sendline("\r")
- if i==1:
- handle.expect(default)
-
- if i==2:
- main.log.error("Unable to run as Sudo user")
-
+ def runAsSudoUser( self, handle, pwd, default ):
+
+ i = handle.expect( [ ".ssword:*", default, pexpect.EOF ] )
+ if i == 0:
+ handle.sendline( pwd )
+ handle.sendline( "\r" )
+
+ if i == 1:
+ handle.expect( default )
+
+ if i == 2:
+ main.log.error( "Unable to run as Sudo user" )
+
return handle
-
- def onfail(self):
- if main.componentDictionary[self.name].has_key('onfail'):
- commandList = main.componentDictionary[self.name]['onfail'].split(",")
- for command in commandList :
- response = self.execute(cmd=command,prompt="(.*)",timeout=120)
- def secureCopy(self,user_name, ip_address,filepath, pwd,dst_path):
-
- #scp openflow@192.168.56.101:/home/openflow/sample /home/paxterra/Desktop/
+ def onfail( self ):
+ if 'onfail' in main.componentDictionary[ self.name ]:
+ commandList = main.componentDictionary[
+ self.name ][ 'onfail' ].split( "," )
+ for command in commandList:
+ response = self.execute(
+ cmd=command,
+ prompt="(.*)",
+ timeout=120 )
- '''
+ def secureCopy( self, user_name, ip_address, filepath, pwd, dst_path ):
+
+ # scp openflow@192.168.56.101:/home/openflow/sample
+ # /home/paxterra/Desktop/
+ """
Connection will establish to the remote host using ssh.
It will take user_name ,ip_address and password as arguments<br>
- and will return the handle.
- '''
+ and will return the handle.
+ """
ssh_newkey = 'Are you sure you want to continue connecting'
- refused = "ssh: connect to host "+ip_address+" port 22: Connection refused"
- cmd = 'scp '+str(user_name)+'@'+str(ip_address)+':'+str(filepath)+' '+str(dst_path)
- main.log.info("Sending: " + cmd )
- self.handle =pexpect.spawn( cmd )
- i=self.handle.expect([ssh_newkey,'password:',pexpect.EOF,pexpect.TIMEOUT,refused],120)
+ refused = "ssh: connect to host " + \
+ ip_address + " port 22: Connection refused"
- if i==0:
- main.log.info("ssh key confirmation received, send yes")
- self.handle.sendline('yes')
- i=self.handle.expect([ssh_newkey,'password:',pexpect.EOF])
- if i==1:
- main.log.info("ssh connection asked for password, gave password")
- self.handle.sendline(pwd)
- #self.handle.expect(user_name)
-
- elif i==2:
- main.log.error("Connection timeout")
+ cmd = 'scp ' + str( user_name ) + '@' + str( ip_address ) + ':' + \
+ str( filepath ) + ' ' + str(dst_path )
+
+ main.log.info( "Sending: " + cmd )
+ self.handle = pexpect.spawn( cmd )
+ i = self.handle.expect( [
+ ssh_newkey,
+ 'password:',
+ pexpect.EOF,
+ pexpect.TIMEOUT,
+ refused ],
+ 120 )
+
+ if i == 0:
+ main.log.info( "ssh key confirmation received, send yes" )
+ self.handle.sendline( 'yes' )
+ i = self.handle.expect( [ ssh_newkey, 'password:', pexpect.EOF ] )
+ if i == 1:
+ main.log.info( "ssh connection asked for password, gave password" )
+ self.handle.sendline( pwd )
+ # self.handle.expect( user_name )
+
+ elif i == 2:
+ main.log.error( "Connection timeout" )
pass
- elif i==3: #timeout
- main.log.error("No route to the Host "+user_name+"@"+ip_address)
+ elif i == 3: # timeout
+ main.log.error(
+ "No route to the Host " +
+ user_name +
+ "@" +
+ ip_address )
return main.FALSE
- elif i==4:
- main.log.error("ssh: connect to host "+ip_address+" port 22: Connection refused")
+ elif i == 4:
+ main.log.error(
+ "ssh: connect to host " +
+ ip_address +
+ " port 22: Connection refused" )
return main.FALSE
- self.handle.sendline("")
- self.handle.expect("$")
+ self.handle.sendline( "" )
+ self.handle.expect( "$" )
print self.handle.before
-
+
return self.handle
-
+
diff --git a/TestON/drivers/component.py b/TestON/drivers/component.py
index ec94283..1e87d03 100644
--- a/TestON/drivers/component.py
+++ b/TestON/drivers/component.py
@@ -1,16 +1,16 @@
#!/usr/bin/env python
import logging
-'''
+"""
Created on 24-Oct-2012
-
-@authors: Anil Kumar (anilkumar.s@paxterrasolutions.com),
- Raghav Kashyap(raghavkashyap@paxterrasolutions.com)
+
+author:s: Anil Kumar ( anilkumar.s@paxterrasolutions.com ),
+ Raghav Kashyap( raghavkashyap@paxterrasolutions.com )
TestON is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
+ ( at your option ) any later version.
TestON is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,99 +18,104 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with TestON. If not, see <http://www.gnu.org/licenses/>.
+ along with TestON. If not, see <http://www.gnu.org/licenses/>.
-
-'''
+"""
import re
from logging import Logger
-class Component(object):
- '''
+
+class Component( object ):
+
+ """
This is the tempalte class for components
- '''
- def __init__(self):
+ """
+ def __init__( self ):
self.default = ''
- self.wrapped = sys.modules[__name__]
-
- def __getattr__(self, name):
- '''
+ self.wrapped = sys.modules[ __name__ ]
+
+ def __getattr__( self, name ):
+ """
This will invoke, if the attribute wasn't found the usual ways.
Here it will look for assert_attribute and will execute when AttributeError occurs.
It will return the result of the assert_attribute.
- '''
+ """
try:
- return getattr(self.wrapped, name)
+ return getattr( self.wrapped, name )
except AttributeError:
try:
- def experimentHandling(**kwargs):
+ def experimentHandling( **kwargs ):
if main.EXPERIMENTAL_MODE == main.TRUE:
- result = self.experimentRun(**kwargs)
- main.log.info("EXPERIMENTAL MODE. API "+str(name)+" not yet implemented. Returning dummy values")
- return result
+ result = self.experimentRun( **kwargs )
+ main.log.info( "EXPERIMENTAL MODE. API " + str(
+ name ) + " not yet implemented. Returning dummy values" )
+ return result
else:
return main.FALSE
return experimentHandling
- except TypeError,e:
- main.log.error("Arguments for experimental mode does not have key 'retruns'" + e)
-
-
- def connect(self):
-
- vars(main)[self.name+'log'] = logging.getLogger(self.name)
-
- session_file = main.logdir+"/"+self.name+".session"
- self.log_handler = logging.FileHandler(session_file)
- self.log_handler.setLevel(logging.DEBUG)
-
- vars(main)[self.name+'log'].setLevel(logging.DEBUG)
- _formatter = logging.Formatter("%(asctime)s %(name)-10s: %(levelname)-8s: %(message)s")
- self.log_handler.setFormatter(_formatter)
- vars(main)[self.name+'log'].addHandler(self.log_handler)
- # Adding header for the component log
- vars(main)[self.name+'log'].info(main.logHeader)
+ except TypeError as e:
+ main.log.error(
+ "Arguments for experimental mode does not have key 'retruns'" +
+ e )
+
+ def connect( self ):
+
+ vars( main )[ self.name + 'log' ] = logging.getLogger( self.name )
+
+ session_file = main.logdir + "/" + self.name + ".session"
+ self.log_handler = logging.FileHandler( session_file )
+ self.log_handler.setLevel( logging.DEBUG )
+
+ vars( main )[ self.name + 'log' ].setLevel( logging.DEBUG )
+ _formatter = logging.Formatter(
+ "%(asctime)s %(name)-10s: %(levelname)-8s: %(message)s" )
+ self.log_handler.setFormatter( _formatter )
+ vars( main )[ self.name + 'log' ].addHandler( self.log_handler )
+ # Adding header for the component log
+ vars( main )[ self.name + 'log' ].info( main.logHeader )
# Opening the session log to append command's execution output
- self.logfile_handler = open(session_file,"a")
-
+ self.logfile_handler = open( session_file, "a" )
+
return "Dummy"
-
- def execute(self,cmd):
+
+ def execute( self, cmd ):
return main.TRUE
- #import commands
- #return commands.getoutput(cmd)
-
- def disconnect(self):
- return main.TRUE
-
- def config(self):
+ # import commands
+ # return commands.getoutput( cmd )
+
+ def disconnect( self ):
+ return main.TRUE
+
+ def config( self ):
self = self
# Need to update the configuration code
-
- def cleanup(self):
+
+ def cleanup( self ):
return main.TRUE
-
- def log(self,message):
- '''
- Here finding the for the component to which the
+
+ def log( self, message ):
+ """
+ Here finding the for the component to which the
log message based on the called child object.
- '''
- vars(main)[self.name+'log'].info("\n"+message+"\n")
-
- def close_log_handles(self) :
- vars(main)[self.name+'log'].removeHandler(self.log_handler)
+ """
+ vars( main )[ self.name + 'log' ].info( "\n" + message + "\n" )
+
+ def close_log_handles( self ):
+ vars( main )[ self.name + 'log' ].removeHandler( self.log_handler )
if self.logfile_handler:
self.logfile_handler.close()
-
- def get_version(self):
+
+ def get_version( self ):
return "Version unknown"
- def experimentRun(self,**kwargs):
- args = utilities.parse_args(["RETURNS"],**kwargs)
- return args["RETURNS"]
+ def experimentRun( self, **kwargs ):
+ args = utilities.parse_args( [ "RETURNS" ], **kwargs )
+ return args[ "RETURNS" ]
if __name__ != "__main__":
import sys
- sys.modules[__name__] = Component()
+ sys.modules[ __name__ ] = Component()
+
diff --git a/TestON/tests/ClassTest/ClassTest.py b/TestON/tests/ClassTest/ClassTest.py
index 6d7a153..0fd8ccc 100644
--- a/TestON/tests/ClassTest/ClassTest.py
+++ b/TestON/tests/ClassTest/ClassTest.py
@@ -3,24 +3,25 @@
import os
import re
+
class ClassTest:
- def __init__(self):
+
+ def __init__( self ):
self.default = ''
- def CASE1(self, main):
+ def CASE1( self, main ):
import time
import imp
- init = imp.load_source('ClassInit',
- '/home/admin/ONLabTest/TestON/tests/ClassTest/Dependency/ClassInit.py')
+ init = imp.load_source(
+ 'ClassInit',
+ '/home/admin/ONLabTest/TestON/tests/ClassTest/Dependency/ClassInit.py' )
- ip1_from_class = init.getIp1()
- init.printMain(main)
+ ip1_from_class = init.getIp1()
+ init.printMain( main )
- main.log.info(ip1_from_class)
+ main.log.info( ip1_from_class )
- def CASE2(self, main):
+ def CASE2( self, main ):
-
- main.log.info("Case 2")
-
+ main.log.info( "Case 2" )
diff --git a/TestON/tests/IntentPerfNext/IntentPerfNext.py b/TestON/tests/IntentPerfNext/IntentPerfNext.py
index 5c8bb2f..daa1ae2 100644
--- a/TestON/tests/IntentPerfNext/IntentPerfNext.py
+++ b/TestON/tests/IntentPerfNext/IntentPerfNext.py
@@ -1,379 +1,386 @@
-#Intent Performance Test for ONOS-next
+# Intent Performance Test for ONOS-next
#
-#andrew@onlab.us
+# andrew@onlab.us
#
-#November 5, 2014
+# November 5, 2014
+
class IntentPerfNext:
- def __init__(self):
+
+ def __init__( self ):
self.default = ""
- def CASE1(self, main):
- '''
+ def CASE1( self, main ):
+ """
ONOS startup sequence
- '''
-
+ """
import time
global cluster_count
- cluster_count = 1
+ cluster_count = 1
- cell_name = main.params['ENV']['cellName']
+ cell_name = main.params[ 'ENV' ][ 'cellName' ]
- git_pull = main.params['GIT']['autoPull']
- checkout_branch = main.params['GIT']['checkout']
+ git_pull = main.params[ 'GIT' ][ 'autoPull' ]
+ checkout_branch = main.params[ 'GIT' ][ 'checkout' ]
- ONOS1_ip = main.params['CTRL']['ip1']
- ONOS2_ip = main.params['CTRL']['ip2']
- ONOS3_ip = main.params['CTRL']['ip3']
- ONOS4_ip = main.params['CTRL']['ip4']
- ONOS5_ip = main.params['CTRL']['ip5']
- ONOS6_ip = main.params['CTRL']['ip6']
- ONOS7_ip = main.params['CTRL']['ip7']
+ ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+ ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
+ ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
+ ONOS4_ip = main.params[ 'CTRL' ][ 'ip4' ]
+ ONOS5_ip = main.params[ 'CTRL' ][ 'ip5' ]
+ ONOS6_ip = main.params[ 'CTRL' ][ 'ip6' ]
+ ONOS7_ip = main.params[ 'CTRL' ][ 'ip7' ]
- main.ONOSbench.onos_uninstall(node_ip=ONOS1_ip)
- main.ONOSbench.onos_uninstall(node_ip=ONOS2_ip)
- main.ONOSbench.onos_uninstall(node_ip=ONOS3_ip)
- main.ONOSbench.onos_uninstall(node_ip=ONOS4_ip)
- main.ONOSbench.onos_uninstall(node_ip=ONOS5_ip)
- main.ONOSbench.onos_uninstall(node_ip=ONOS6_ip)
- main.ONOSbench.onos_uninstall(node_ip=ONOS7_ip)
+ main.ONOSbench.onos_uninstall( node_ip=ONOS1_ip )
+ main.ONOSbench.onos_uninstall( node_ip=ONOS2_ip )
+ main.ONOSbench.onos_uninstall( node_ip=ONOS3_ip )
+ main.ONOSbench.onos_uninstall( node_ip=ONOS4_ip )
+ main.ONOSbench.onos_uninstall( node_ip=ONOS5_ip )
+ main.ONOSbench.onos_uninstall( node_ip=ONOS6_ip )
+ main.ONOSbench.onos_uninstall( node_ip=ONOS7_ip )
- MN1_ip = main.params['MN']['ip1']
- BENCH_ip = main.params['BENCH']['ip']
-
- main.case("Setting up test environment")
+ MN1_ip = main.params[ 'MN' ][ 'ip1' ]
+ BENCH_ip = main.params[ 'BENCH' ][ 'ip' ]
- main.step("Creating cell file")
+ main.case( "Setting up test environment" )
+
+ main.step( "Creating cell file" )
cell_file_result = main.ONOSbench.create_cell_file(
- BENCH_ip, cell_name, MN1_ip,
- "onos-core,onos-app-metrics,onos-gui",
- #ONOS1_ip, ONOS2_ip, ONOS3_ip)
- ONOS1_ip)
+ BENCH_ip, cell_name, MN1_ip,
+ "onos-core,onos-app-metrics,onos-gui",
+ # ONOS1_ip, ONOS2_ip, ONOS3_ip )
+ ONOS1_ip )
- main.step("Applying cell file to environment")
- cell_apply_result = main.ONOSbench.set_cell(cell_name)
+ main.step( "Applying cell file to environment" )
+ cell_apply_result = main.ONOSbench.set_cell( cell_name )
verify_cell_result = main.ONOSbench.verify_cell()
- main.step("Removing raft logs")
+ main.step( "Removing raft logs" )
main.ONOSbench.onos_remove_raft_logs()
- main.step("Git checkout and pull "+checkout_branch)
+ main.step( "Git checkout and pull " + checkout_branch )
if git_pull == 'on':
checkout_result = \
- main.ONOSbench.git_checkout(checkout_branch)
+ main.ONOSbench.git_checkout( checkout_branch )
pull_result = main.ONOSbench.git_pull()
-
- #If you used git pull, auto compile
- main.step("Using onos-build to compile ONOS")
+
+ # If you used git pull, auto compile
+ main.step( "Using onos-build to compile ONOS" )
build_result = main.ONOSbench.onos_build()
else:
checkout_result = main.TRUE
pull_result = main.TRUE
build_result = main.TRUE
- main.log.info("Git pull skipped by configuration")
+ main.log.info( "Git pull skipped by configuration" )
- main.log.report("Commit information - ")
- main.ONOSbench.get_version(report=True)
+ main.log.report( "Commit information - " )
+ main.ONOSbench.get_version( report=True )
- main.step("Creating ONOS package")
+ main.step( "Creating ONOS package" )
package_result = main.ONOSbench.onos_package()
- main.step("Installing ONOS package")
- install1_result = main.ONOSbench.onos_install(node=ONOS1_ip)
- #install2_result = main.ONOSbench.onos_install(node=ONOS2_ip)
- #install3_result = main.ONOSbench.onos_install(node=ONOS3_ip)
+ main.step( "Installing ONOS package" )
+ install1_result = main.ONOSbench.onos_install( node=ONOS1_ip )
+ #install2_result = main.ONOSbench.onos_install( node=ONOS2_ip )
+ #install3_result = main.ONOSbench.onos_install( node=ONOS3_ip )
- main.step("Set cell for ONOScli env")
- main.ONOS1cli.set_cell(cell_name)
- #main.ONOS2cli.set_cell(cell_name)
- #main.ONOS3cli.set_cell(cell_name)
+ main.step( "Set cell for ONOScli env" )
+ main.ONOS1cli.set_cell( cell_name )
+ # main.ONOS2cli.set_cell( cell_name )
+ # main.ONOS3cli.set_cell( cell_name )
- time.sleep(5)
+ time.sleep( 5 )
- main.step("Start onos cli")
- cli1 = main.ONOS1cli.start_onos_cli(ONOS1_ip)
- #cli2 = main.ONOS2cli.start_onos_cli(ONOS2_ip)
- #cli3 = main.ONOS3cli.start_onos_cli(ONOS3_ip)
+ main.step( "Start onos cli" )
+ cli1 = main.ONOS1cli.start_onos_cli( ONOS1_ip )
+ #cli2 = main.ONOS2cli.start_onos_cli( ONOS2_ip )
+ #cli3 = main.ONOS3cli.start_onos_cli( ONOS3_ip )
- utilities.assert_equals(expect=main.TRUE,
- actual = cell_file_result and cell_apply_result and\
- verify_cell_result and checkout_result and\
- pull_result and build_result and\
- install1_result, #and install2_result and\
- #install3_result,
- onpass="ONOS started successfully",
- onfail="Failed to start ONOS")
+ utilities.assert_equals( expect=main.TRUE,
+ actual=cell_file_result and cell_apply_result and
+ verify_cell_result and checkout_result and
+ pull_result and build_result and
+ install1_result, # and install2_result and
+ # install3_result,
+ onpass="ONOS started successfully",
+ onfail="Failed to start ONOS" )
- def CASE2(self, main):
- '''
+ def CASE2( self, main ):
+ """
Single intent add latency
- '''
+ """
import time
import json
import requests
import os
import numpy
- ONOS1_ip = main.params['CTRL']['ip1']
- ONOS2_ip = main.params['CTRL']['ip2']
- ONOS3_ip = main.params['CTRL']['ip3']
- ONOS_user = main.params['CTRL']['user']
+ ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+ ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
+ ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
+ ONOS_user = main.params[ 'CTRL' ][ 'user' ]
- default_sw_port = main.params['CTRL']['port1']
+ default_sw_port = main.params[ 'CTRL' ][ 'port1' ]
- #number of iterations of case
- num_iter = main.params['TEST']['numIter']
- num_ignore = int(main.params['TEST']['numIgnore'])
+ # number of iterations of case
+ num_iter = main.params[ 'TEST' ][ 'numIter' ]
+ num_ignore = int( main.params[ 'TEST' ][ 'numIgnore' ] )
- #Timestamp keys for json metrics output
- submit_time = main.params['JSON']['submittedTime']
- install_time = main.params['JSON']['installedTime']
- wdRequest_time = main.params['JSON']['wdRequestTime']
- withdrawn_time = main.params['JSON']['withdrawnTime']
-
+ # Timestamp keys for json metrics output
+ submit_time = main.params[ 'JSON' ][ 'submittedTime' ]
+ install_time = main.params[ 'JSON' ][ 'installedTime' ]
+ wdRequest_time = main.params[ 'JSON' ][ 'wdRequestTime' ]
+ withdrawn_time = main.params[ 'JSON' ][ 'withdrawnTime' ]
+
intent_add_lat_list = []
- #Assign 'linear' switch format for basic intent testing
+ # Assign 'linear' switch format for basic intent testing
main.Mininet1.assign_sw_controller(
- sw="1", ip1=ONOS1_ip,port1=default_sw_port)
+ sw="1", ip1=ONOS1_ip, port1=default_sw_port )
main.Mininet1.assign_sw_controller(
- sw="2", ip1=ONOS2_ip,port1=default_sw_port)
+ sw="2", ip1=ONOS2_ip, port1=default_sw_port )
main.Mininet1.assign_sw_controller(
- sw="3", ip1=ONOS2_ip,port1=default_sw_port)
+ sw="3", ip1=ONOS2_ip, port1=default_sw_port )
main.Mininet1.assign_sw_controller(
- sw="4", ip1=ONOS2_ip,port1=default_sw_port)
+ sw="4", ip1=ONOS2_ip, port1=default_sw_port )
main.Mininet1.assign_sw_controller(
- sw="5", ip1=ONOS3_ip,port1=default_sw_port)
+ sw="5", ip1=ONOS3_ip, port1=default_sw_port )
- time.sleep(10)
+ time.sleep( 10 )
- main.log.report("Single intent add latency test")
+ main.log.report( "Single intent add latency test" )
devices_json_str = main.ONOS1cli.devices()
- devices_json_obj = json.loads(devices_json_str)
+ devices_json_obj = json.loads( devices_json_str )
device_id_list = []
- #Obtain device id list in ONOS format.
- #They should already be in order (1,2,3,10,11,12,13, etc)
+ # Obtain device id list in ONOS format.
+ # They should already be in order ( 1,2,3,10,11,12,13, etc )
for device in devices_json_obj:
- device_id_list.append(device['id'])
+ device_id_list.append( device[ 'id' ] )
- for i in range(0, int(num_iter)):
- #add_point_intent(ingr_device, egr_device,
- # ingr_port, egr_port)
+ for i in range( 0, int( num_iter ) ):
+ # add_point_intent( ingr_device, egr_device,
+ # ingr_port, egr_port )
main.ONOS1cli.add_point_intent(
- device_id_list[0]+"/1", device_id_list[4]+"/1")
-
- #Allow some time for intents to propagate
- time.sleep(5)
+ device_id_list[ 0 ] + "/1", device_id_list[ 4 ] + "/1" )
- #Obtain metrics from ONOS 1, 2, 3
+ # Allow some time for intents to propagate
+ time.sleep( 5 )
+
+ # Obtain metrics from ONOS 1, 2, 3
intents_json_str_1 = main.ONOS1cli.intents_events_metrics()
intents_json_str_2 = main.ONOS2cli.intents_events_metrics()
intents_json_str_3 = main.ONOS3cli.intents_events_metrics()
- intents_json_obj_1 = json.loads(intents_json_str_1)
- intents_json_obj_2 = json.loads(intents_json_str_2)
- intents_json_obj_3 = json.loads(intents_json_str_3)
+ intents_json_obj_1 = json.loads( intents_json_str_1 )
+ intents_json_obj_2 = json.loads( intents_json_str_2 )
+ intents_json_obj_3 = json.loads( intents_json_str_3 )
- #Parse values from the json object
+ # Parse values from the json object
intent_submit_1 = \
- intents_json_obj_1[submit_time]['value']
+ intents_json_obj_1[ submit_time ][ 'value' ]
intent_submit_2 = \
- intents_json_obj_2[submit_time]['value']
+ intents_json_obj_2[ submit_time ][ 'value' ]
intent_submit_3 = \
- intents_json_obj_3[submit_time]['value']
+ intents_json_obj_3[ submit_time ][ 'value' ]
intent_install_1 = \
- intents_json_obj_1[install_time]['value']
+ intents_json_obj_1[ install_time ][ 'value' ]
intent_install_2 = \
- intents_json_obj_2[install_time]['value']
+ intents_json_obj_2[ install_time ][ 'value' ]
intent_install_3 = \
- intents_json_obj_3[install_time]['value']
+ intents_json_obj_3[ install_time ][ 'value' ]
intent_install_lat_1 = \
- int(intent_install_1) - int(intent_submit_1)
+ int( intent_install_1 ) - int( intent_submit_1 )
intent_install_lat_2 = \
- int(intent_install_2) - int(intent_submit_2)
+ int( intent_install_2 ) - int( intent_submit_2 )
intent_install_lat_3 = \
- int(intent_install_3) - int(intent_submit_3)
-
- intent_install_lat_avg = \
- (intent_install_lat_1 +
- intent_install_lat_2 +
- intent_install_lat_3 ) / 3
+ int( intent_install_3 ) - int( intent_submit_3 )
- main.log.info("Intent add latency avg for iteration "+str(i)+
- ": "+str(intent_install_lat_avg)+" ms")
+ intent_install_lat_avg = \
+ ( intent_install_lat_1 +
+ intent_install_lat_2 +
+ intent_install_lat_3 ) / 3
+
+ main.log.info( "Intent add latency avg for iteration " + str( i ) +
+ ": " + str( intent_install_lat_avg ) + " ms" )
if intent_install_lat_avg > 0.0 and \
intent_install_lat_avg < 1000 and i > num_ignore:
- intent_add_lat_list.append(intent_install_lat_avg)
+ intent_add_lat_list.append( intent_install_lat_avg )
else:
- main.log.info("Intent add latency exceeded "+
- "threshold. Skipping iteration "+str(i))
+ main.log.info( "Intent add latency exceeded " +
+ "threshold. Skipping iteration " + str( i ) )
- time.sleep(3)
-
- #TODO: Possibly put this in the driver function
- main.log.info("Removing intents for next iteration")
+ time.sleep( 3 )
+
+ # TODO: Possibly put this in the driver function
+ main.log.info( "Removing intents for next iteration" )
json_temp = \
- main.ONOS1cli.intents(json_format=True)
- json_obj_intents = json.loads(json_temp)
+ main.ONOS1cli.intents( json_format=True )
+ json_obj_intents = json.loads( json_temp )
if json_obj_intents:
for intents in json_obj_intents:
- temp_id = intents['id']
- main.ONOS1cli.remove_intent(temp_id)
- main.log.info("Removing intent id: "+
- str(temp_id))
- main.ONOS1cli.remove_intent(temp_id)
+ temp_id = intents[ 'id' ]
+ main.ONOS1cli.remove_intent( temp_id )
+ main.log.info( "Removing intent id: " +
+ str( temp_id ) )
+ main.ONOS1cli.remove_intent( temp_id )
else:
- main.log.info("Intents were not installed correctly")
+ main.log.info( "Intents were not installed correctly" )
- time.sleep(5)
+ time.sleep( 5 )
- intent_add_lat_avg = sum(intent_add_lat_list) /\
- len(intent_add_lat_list)
+ intent_add_lat_avg = sum( intent_add_lat_list ) /\
+ len( intent_add_lat_list )
intent_add_lat_std = \
- round(numpy.std(intent_add_lat_list),1)
- #END ITERATION FOR LOOP
- main.log.report("Single intent add latency - ")
- main.log.report("Avg: "+str(intent_add_lat_avg)+" ms")
- main.log.report("Std Deviation: "+str(intent_add_lat_std)+" ms")
+ round( numpy.std( intent_add_lat_list ), 1 )
+ # END ITERATION FOR LOOP
+ main.log.report( "Single intent add latency - " )
+ main.log.report( "Avg: " + str( intent_add_lat_avg ) + " ms" )
+ main.log.report(
+ "Std Deviation: " +
+ str( intent_add_lat_std ) +
+ " ms" )
- def CASE3(self, main):
- '''
+ def CASE3( self, main ):
+ """
Intent Reroute latency
- '''
+ """
import time
import json
import requests
import os
import numpy
- ONOS1_ip = main.params['CTRL']['ip1']
- ONOS2_ip = main.params['CTRL']['ip2']
- ONOS3_ip = main.params['CTRL']['ip3']
- ONOS_user = main.params['CTRL']['user']
+ ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+ ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
+ ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
+ ONOS_user = main.params[ 'CTRL' ][ 'user' ]
- default_sw_port = main.params['CTRL']['port1']
+ default_sw_port = main.params[ 'CTRL' ][ 'port1' ]
- #number of iterations of case
- num_iter = main.params['TEST']['numIter']
- num_ignore = int(main.params['TEST']['numIgnore'])
+ # number of iterations of case
+ num_iter = main.params[ 'TEST' ][ 'numIter' ]
+ num_ignore = int( main.params[ 'TEST' ][ 'numIgnore' ] )
- #Timestamp keys for json metrics output
- submit_time = main.params['JSON']['submittedTime']
- install_time = main.params['JSON']['installedTime']
- wdRequest_time = main.params['JSON']['wdRequestTime']
- withdrawn_time = main.params['JSON']['withdrawnTime']
+ # Timestamp keys for json metrics output
+ submit_time = main.params[ 'JSON' ][ 'submittedTime' ]
+ install_time = main.params[ 'JSON' ][ 'installedTime' ]
+ wdRequest_time = main.params[ 'JSON' ][ 'wdRequestTime' ]
+ withdrawn_time = main.params[ 'JSON' ][ 'withdrawnTime' ]
devices_json_str = main.ONOS1cli.devices()
- devices_json_obj = json.loads(devices_json_str)
+ devices_json_obj = json.loads( devices_json_str )
device_id_list = []
- #Obtain device id list in ONOS format.
- #They should already be in order (1,2,3,10,11,12,13, etc)
+ # Obtain device id list in ONOS format.
+ # They should already be in order ( 1,2,3,10,11,12,13, etc )
for device in devices_json_obj:
- device_id_list.append(device['id'])
+ device_id_list.append( device[ 'id' ] )
intent_reroute_lat_list = []
- for i in range(0, int(num_iter)):
- #add_point_intent(ingr_device, ingr_port,
- # egr_device, egr_port)
- if len(device_id_list) > 0:
+ for i in range( 0, int( num_iter ) ):
+ # add_point_intent( ingr_device, ingr_port,
+ # egr_device, egr_port )
+ if len( device_id_list ) > 0:
main.ONOS1cli.add_point_intent(
- device_id_list[0]+"/2", device_id_list[4]+"/1")
+ device_id_list[ 0 ] + "/2", device_id_list[ 4 ] + "/1" )
else:
- main.log.info("Failed to fetch devices from ONOS")
+ main.log.info( "Failed to fetch devices from ONOS" )
- time.sleep(5)
+ time.sleep( 5 )
- intents_str = main.ONOS1cli.intents(json_format=True)
- intents_obj = json.loads(intents_str)
+ intents_str = main.ONOS1cli.intents( json_format=True )
+ intents_obj = json.loads( intents_str )
for intent in intents_obj:
- if intent['state'] == "INSTALLED":
- main.log.info("Intent installed successfully")
- intent_id = intent['id']
+ if intent[ 'state' ] == "INSTALLED":
+ main.log.info( "Intent installed successfully" )
+ intent_id = intent[ 'id' ]
else:
- #TODO: Add error handling
- main.log.info("Intent installation failed")
+ # TODO: Add error handling
+ main.log.info( "Intent installation failed" )
intent_id = ""
- #NOTE: this interface is specific to
+ # NOTE: this interface is specific to
# topo-intentFlower.py topology
# reroute case.
- main.log.info("Disabling interface s2-eth3")
+ main.log.info( "Disabling interface s2-eth3" )
main.Mininet1.handle.sendline(
- "sh ifconfig s2-eth3 down")
- t0_system = time.time()*1000
-
- #TODO: Check for correct intent reroute
- time.sleep(5)
+ "sh ifconfig s2-eth3 down" )
+ t0_system = time.time() * 1000
- #Obtain metrics from ONOS 1, 2, 3
+ # TODO: Check for correct intent reroute
+ time.sleep( 5 )
+
+ # Obtain metrics from ONOS 1, 2, 3
intents_json_str_1 = main.ONOS1cli.intents_events_metrics()
intents_json_str_2 = main.ONOS2cli.intents_events_metrics()
intents_json_str_3 = main.ONOS3cli.intents_events_metrics()
- intents_json_obj_1 = json.loads(intents_json_str_1)
- intents_json_obj_2 = json.loads(intents_json_str_2)
- intents_json_obj_3 = json.loads(intents_json_str_3)
+ intents_json_obj_1 = json.loads( intents_json_str_1 )
+ intents_json_obj_2 = json.loads( intents_json_str_2 )
+ intents_json_obj_3 = json.loads( intents_json_str_3 )
- #Parse values from the json object
+ # Parse values from the json object
intent_install_1 = \
- intents_json_obj_1[install_time]['value']
+ intents_json_obj_1[ install_time ][ 'value' ]
intent_install_2 = \
- intents_json_obj_2[install_time]['value']
+ intents_json_obj_2[ install_time ][ 'value' ]
intent_install_3 = \
- intents_json_obj_3[install_time]['value']
+ intents_json_obj_3[ install_time ][ 'value' ]
intent_reroute_lat_1 = \
- int(intent_install_1) - int(t0_system)
+ int( intent_install_1 ) - int( t0_system )
intent_reroute_lat_2 = \
- int(intent_install_2) - int(t0_system)
+ int( intent_install_2 ) - int( t0_system )
intent_reroute_lat_3 = \
- int(intent_install_3) - int(t0_system)
-
+ int( intent_install_3 ) - int( t0_system )
+
intent_reroute_lat_avg = \
- (intent_reroute_lat_1 +
- intent_reroute_lat_2 +
- intent_reroute_lat_3 ) / 3
-
- main.log.info("Intent reroute latency avg for iteration "+
- str(i)+": "+str(intent_reroute_lat_avg))
+ ( intent_reroute_lat_1 +
+ intent_reroute_lat_2 +
+ intent_reroute_lat_3 ) / 3
+
+ main.log.info( "Intent reroute latency avg for iteration " +
+ str( i ) + ": " + str( intent_reroute_lat_avg ) )
if intent_reroute_lat_avg > 0.0 and \
intent_reroute_lat_avg < 1000 and i > num_ignore:
- intent_reroute_lat_list.append(intent_reroute_lat_avg)
+ intent_reroute_lat_list.append( intent_reroute_lat_avg )
else:
- main.log.info("Intent reroute latency exceeded "+
- "threshold. Skipping iteration "+str(i))
+ main.log.info( "Intent reroute latency exceeded " +
+ "threshold. Skipping iteration " + str( i ) )
- main.log.info("Removing intents for next iteration")
- main.ONOS1cli.remove_intent(intent_id)
-
- main.log.info("Bringing Mininet interface up for next "+
- "iteration")
+ main.log.info( "Removing intents for next iteration" )
+ main.ONOS1cli.remove_intent( intent_id )
+
+ main.log.info( "Bringing Mininet interface up for next " +
+ "iteration" )
main.Mininet1.handle.sendline(
- "sh ifconfig s2-eth3 up")
-
- intent_reroute_lat_avg = sum(intent_reroute_lat_list) /\
- len(intent_reroute_lat_list)
+ "sh ifconfig s2-eth3 up" )
+
+ intent_reroute_lat_avg = sum( intent_reroute_lat_list ) /\
+ len( intent_reroute_lat_list )
intent_reroute_lat_std = \
- round(numpy.std(intent_reroute_lat_list),1)
- #END ITERATION FOR LOOP
- main.log.report("Single intent reroute latency - ")
- main.log.report("Avg: "+str(intent_reroute_lat_avg)+" ms")
- main.log.report("Std Deviation: "+str(intent_reroute_lat_std)+" ms")
-
- def CASE7(self, main):
- '''
+ round( numpy.std( intent_reroute_lat_list ), 1 )
+ # END ITERATION FOR LOOP
+ main.log.report( "Single intent reroute latency - " )
+ main.log.report( "Avg: " + str( intent_reroute_lat_avg ) + " ms" )
+ main.log.report(
+ "Std Deviation: " +
+ str( intent_reroute_lat_std ) +
+ " ms" )
+
+ def CASE7( self, main ):
+ """
Batch intent reroute latency
- '''
+ """
import time
import json
import requests
@@ -381,440 +388,445 @@
import numpy
ONOS_ip_list = []
- for i in range(1, 8):
- ONOS_ip_list.append(main.params['CTRL']['ip'+str(i)])
+ for i in range( 1, 8 ):
+ ONOS_ip_list.append( main.params[ 'CTRL' ][ 'ip' + str( i ) ] )
- ONOS_user = main.params['CTRL']['user']
- default_sw_port = main.params['CTRL']['port1']
-
- batch_intent_size = main.params['TEST']['batchIntentSize']
- batch_thresh_min = int(main.params['TEST']['batchThresholdMin'])
- batch_thresh_max = int(main.params['TEST']['batchThresholdMax'])
- install_time = main.params['JSON']['installedTime']
+ ONOS_user = main.params[ 'CTRL' ][ 'user' ]
+ default_sw_port = main.params[ 'CTRL' ][ 'port1' ]
- #number of iterations of case
- num_iter = main.params['TEST']['numIter']
- num_ignore = int(main.params['TEST']['numIgnore'])
- num_switch = int(main.params['TEST']['numSwitch'])
- n_thread = main.params['TEST']['numMult']
+ batch_intent_size = main.params[ 'TEST' ][ 'batchIntentSize' ]
+ batch_thresh_min = int( main.params[ 'TEST' ][ 'batchThresholdMin' ] )
+ batch_thresh_max = int( main.params[ 'TEST' ][ 'batchThresholdMax' ] )
+ install_time = main.params[ 'JSON' ][ 'installedTime' ]
- main.log.report("Batch intent installation test of "+
- batch_intent_size +" intents")
+ # number of iterations of case
+ num_iter = main.params[ 'TEST' ][ 'numIter' ]
+ num_ignore = int( main.params[ 'TEST' ][ 'numIgnore' ] )
+ num_switch = int( main.params[ 'TEST' ][ 'numSwitch' ] )
+ n_thread = main.params[ 'TEST' ][ 'numMult' ]
+
+ main.log.report( "Batch intent installation test of " +
+ batch_intent_size + " intents" )
batch_result_list = []
- #Assign 'linear' switch format for basic intent testing
+ # Assign 'linear' switch format for basic intent testing
main.Mininet1.assign_sw_controller(
- sw="1", ip1=ONOS1_ip,port1=default_sw_port)
+ sw="1", ip1=ONOS1_ip, port1=default_sw_port )
main.Mininet1.assign_sw_controller(
- sw="2", ip1=ONOS2_ip,port1=default_sw_port)
+ sw="2", ip1=ONOS2_ip, port1=default_sw_port )
main.Mininet1.assign_sw_controller(
- sw="3", ip1=ONOS2_ip,port1=default_sw_port)
+ sw="3", ip1=ONOS2_ip, port1=default_sw_port )
main.Mininet1.assign_sw_controller(
- sw="4", ip1=ONOS2_ip,port1=default_sw_port)
+ sw="4", ip1=ONOS2_ip, port1=default_sw_port )
main.Mininet1.assign_sw_controller(
- sw="5", ip1=ONOS3_ip,port1=default_sw_port)
+ sw="5", ip1=ONOS3_ip, port1=default_sw_port )
- time.sleep(10)
+ time.sleep( 10 )
- main.log.info("Getting list of available devices")
+ main.log.info( "Getting list of available devices" )
device_id_list = []
json_str = main.ONOS1cli.devices()
- json_obj = json.loads(json_str)
+ json_obj = json.loads( json_str )
for device in json_obj:
- device_id_list.append(device['id'])
+ device_id_list.append( device[ 'id' ] )
batch_install_lat = []
batch_withdraw_lat = []
sleep_time = 10
-
+
base_dir = "/tmp/"
max_install_lat = []
- for i in range(0, int(num_iter)):
- main.log.info("Pushing "+
- str(int(batch_intent_size)*int(n_thread))+
- " intents. Iteration "+str(i))
-
+ for i in range( 0, int( num_iter ) ):
+ main.log.info( "Pushing " +
+ str( int( batch_intent_size ) * int( n_thread ) ) +
+ " intents. Iteration " + str( i ) )
+
main.ONOS1cli.push_test_intents(
"of:0000000000000001/1",
"of:0000000000000005/1",
- 1000, num_mult="1", app_id="1")
-
- #TODO: Check for installation success then proceed
- time.sleep(30)
-
- #NOTE: this interface is specific to
+ 1000, num_mult="1", app_id="1" )
+
+ # TODO: Check for installation success then proceed
+ time.sleep( 30 )
+
+ # NOTE: this interface is specific to
# topo-intentFlower.py topology
# reroute case.
- main.log.info("Disabling interface s2-eth3")
+ main.log.info( "Disabling interface s2-eth3" )
main.Mininet1.handle.sendline(
- "sh ifconfig s2-eth3 down")
- t0_system = time.time()*1000
+ "sh ifconfig s2-eth3 down" )
+ t0_system = time.time() * 1000
- #TODO: Wait sufficient time for intents to install
- time.sleep(10)
+ # TODO: Wait sufficient time for intents to install
+ time.sleep( 10 )
- #TODO: get intent installation time
-
- #Obtain metrics from ONOS 1, 2, 3
+ # TODO: get intent installation time
+
+ # Obtain metrics from ONOS 1, 2, 3
intents_json_str_1 = main.ONOS1cli.intents_events_metrics()
intents_json_str_2 = main.ONOS2cli.intents_events_metrics()
intents_json_str_3 = main.ONOS3cli.intents_events_metrics()
- intents_json_obj_1 = json.loads(intents_json_str_1)
- intents_json_obj_2 = json.loads(intents_json_str_2)
- intents_json_obj_3 = json.loads(intents_json_str_3)
+ intents_json_obj_1 = json.loads( intents_json_str_1 )
+ intents_json_obj_2 = json.loads( intents_json_str_2 )
+ intents_json_obj_3 = json.loads( intents_json_str_3 )
- #Parse values from the json object
+ # Parse values from the json object
intent_install_1 = \
- intents_json_obj_1[install_time]['value']
+ intents_json_obj_1[ install_time ][ 'value' ]
intent_install_2 = \
- intents_json_obj_2[install_time]['value']
+ intents_json_obj_2[ install_time ][ 'value' ]
intent_install_3 = \
- intents_json_obj_3[install_time]['value']
+ intents_json_obj_3[ install_time ][ 'value' ]
intent_reroute_lat_1 = \
- int(intent_install_1) - int(t0_system)
+ int( intent_install_1 ) - int( t0_system )
intent_reroute_lat_2 = \
- int(intent_install_2) - int(t0_system)
+ int( intent_install_2 ) - int( t0_system )
intent_reroute_lat_3 = \
- int(intent_install_3) - int(t0_system)
-
+ int( intent_install_3 ) - int( t0_system )
+
intent_reroute_lat_avg = \
- (intent_reroute_lat_1 +
- intent_reroute_lat_2 +
- intent_reroute_lat_3 ) / 3
-
- main.log.info("Intent reroute latency avg for iteration "+
- str(i)+": "+str(intent_reroute_lat_avg))
- #TODO: Remove intents for next iteration
-
- time.sleep(5)
+ ( intent_reroute_lat_1 +
+ intent_reroute_lat_2 +
+ intent_reroute_lat_3 ) / 3
+
+ main.log.info( "Intent reroute latency avg for iteration " +
+ str( i ) + ": " + str( intent_reroute_lat_avg ) )
+ # TODO: Remove intents for next iteration
+
+ time.sleep( 5 )
intents_str = main.ONOS1cli.intents()
- intents_json = json.loads(intents_str)
+ intents_json = json.loads( intents_str )
for intents in intents_json:
- intent_id = intents['id']
+ intent_id = intents[ 'id' ]
if intent_id:
- main.ONOS1cli.remove_intent(intent_id)
+ main.ONOS1cli.remove_intent( intent_id )
main.Mininet1.handle.sendline(
- "sh ifconfig s2-eth3 up")
-
- main.log.info("Intents removed and port back up")
+ "sh ifconfig s2-eth3 up" )
+ main.log.info( "Intents removed and port back up" )
- def CASE4(self, main):
- '''
+ def CASE4( self, main ):
+ """
Batch intent install
- '''
-
+ """
import time
import json
import requests
import os
import numpy
- ONOS1_ip = main.params['CTRL']['ip1']
- ONOS2_ip = main.params['CTRL']['ip2']
- ONOS3_ip = main.params['CTRL']['ip3']
- ONOS4_ip = main.params['CTRL']['ip4']
- ONOS5_ip = main.params['CTRL']['ip5']
- ONOS6_ip = main.params['CTRL']['ip6']
- ONOS7_ip = main.params['CTRL']['ip7']
-
+ ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+ ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
+ ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
+ ONOS4_ip = main.params[ 'CTRL' ][ 'ip4' ]
+ ONOS5_ip = main.params[ 'CTRL' ][ 'ip5' ]
+ ONOS6_ip = main.params[ 'CTRL' ][ 'ip6' ]
+ ONOS7_ip = main.params[ 'CTRL' ][ 'ip7' ]
+
ONOS_ip_list = []
- for i in range(1, 8):
- ONOS_ip_list.append(main.params['CTRL']['ip'+str(i)])
+ for i in range( 1, 8 ):
+ ONOS_ip_list.append( main.params[ 'CTRL' ][ 'ip' + str( i ) ] )
- ONOS_user = main.params['CTRL']['user']
+ ONOS_user = main.params[ 'CTRL' ][ 'user' ]
- default_sw_port = main.params['CTRL']['port1']
-
- batch_intent_size = main.params['TEST']['batchIntentSize']
- batch_thresh_min = int(main.params['TEST']['batchThresholdMin'])
- batch_thresh_max = int(main.params['TEST']['batchThresholdMax'])
+ default_sw_port = main.params[ 'CTRL' ][ 'port1' ]
- #number of iterations of case
- num_iter = main.params['TEST']['numIter']
- num_ignore = int(main.params['TEST']['numIgnore'])
- num_switch = int(main.params['TEST']['numSwitch'])
- n_thread = main.params['TEST']['numMult']
+ batch_intent_size = main.params[ 'TEST' ][ 'batchIntentSize' ]
+ batch_thresh_min = int( main.params[ 'TEST' ][ 'batchThresholdMin' ] )
+ batch_thresh_max = int( main.params[ 'TEST' ][ 'batchThresholdMax' ] )
+
+ # number of iterations of case
+ num_iter = main.params[ 'TEST' ][ 'numIter' ]
+ num_ignore = int( main.params[ 'TEST' ][ 'numIgnore' ] )
+ num_switch = int( main.params[ 'TEST' ][ 'numSwitch' ] )
+ n_thread = main.params[ 'TEST' ][ 'numMult' ]
#n_thread = 105
#*****
global cluster_count
#*****
-
- #Switch assignment NOTE: hardcoded
+
+ # Switch assignment NOTE: hardcoded
if cluster_count == 1:
- for i in range(1, num_switch+1):
+ for i in range( 1, num_switch + 1 ):
main.Mininet1.assign_sw_controller(
- sw=str(i),
+ sw=str( i ),
ip1=ONOS1_ip,
- port1=default_sw_port)
+ port1=default_sw_port )
if cluster_count == 3:
- for i in range(1, 3):
+ for i in range( 1, 3 ):
main.Mininet1.assign_sw_controller(
- sw=str(i),
+ sw=str( i ),
ip1=ONOS1_ip,
- port1=default_sw_port)
- for i in range(3, 6):
+ port1=default_sw_port )
+ for i in range( 3, 6 ):
main.Mininet1.assign_sw_controller(
- sw=str(i),
+ sw=str( i ),
ip1=ONOS2_ip,
- port1=default_sw_port)
- for i in range(6, 9):
+ port1=default_sw_port )
+ for i in range( 6, 9 ):
main.Mininet1.assign_sw_controller(
- sw=str(i),
+ sw=str( i ),
ip1=ONOS3_ip,
- port1=default_sw_port)
+ port1=default_sw_port )
if cluster_count == 5:
main.Mininet1.assign_sw_controller(
- sw="1",
- ip1=ONOS1_ip,
- port1=default_sw_port)
+ sw="1",
+ ip1=ONOS1_ip,
+ port1=default_sw_port )
main.Mininet1.assign_sw_controller(
- sw="2",
- ip1=ONOS2_ip,
- port1=default_sw_port)
- for i in range(3, 6):
+ sw="2",
+ ip1=ONOS2_ip,
+ port1=default_sw_port )
+ for i in range( 3, 6 ):
main.Mininet1.assign_sw_controller(
- sw=str(i),
+ sw=str( i ),
ip1=ONOS3_ip,
- port1=default_sw_port)
+ port1=default_sw_port )
main.Mininet1.assign_sw_controller(
- sw="6",
- ip1=ONOS4_ip,
- port1=default_sw_port)
+ sw="6",
+ ip1=ONOS4_ip,
+ port1=default_sw_port )
main.Mininet1.assign_sw_controller(
- sw="7",
- ip1=ONOS5_ip,
- port1=default_sw_port)
+ sw="7",
+ ip1=ONOS5_ip,
+ port1=default_sw_port )
main.Mininet1.assign_sw_controller(
- sw="8",
- ip1=ONOS5_ip,
- port1=default_sw_port)
-
+ sw="8",
+ ip1=ONOS5_ip,
+ port1=default_sw_port )
+
if cluster_count == 7:
- for i in range(1,9):
+ for i in range( 1, 9 ):
if i < 8:
main.Mininet1.assign_sw_controller(
- sw=str(i),
- ip1=ONOS_ip_list[i-1],
- port1=default_sw_port)
- elif i >= 8:
+ sw=str( i ),
+ ip1=ONOS_ip_list[ i - 1 ],
+ port1=default_sw_port )
+ elif i >= 8:
main.Mininet1.assign_sw_controller(
- sw=str(i),
- ip1=ONOS_ip_list[6],
- port1=default_sw_port)
+ sw=str( i ),
+ ip1=ONOS_ip_list[ 6 ],
+ port1=default_sw_port )
- time.sleep(30)
+ time.sleep( 30 )
- main.log.report("Batch intent installation test of "+
- batch_intent_size +" intents")
+ main.log.report( "Batch intent installation test of " +
+ batch_intent_size + " intents" )
batch_result_list = []
- main.log.info("Getting list of available devices")
+ main.log.info( "Getting list of available devices" )
device_id_list = []
json_str = main.ONOS1cli.devices()
- json_obj = json.loads(json_str)
+ json_obj = json.loads( json_str )
for device in json_obj:
- device_id_list.append(device['id'])
+ device_id_list.append( device[ 'id' ] )
batch_install_lat = []
batch_withdraw_lat = []
sleep_time = 10
-
+
base_dir = "/tmp/"
max_install_lat = []
- for i in range(0, int(num_iter)):
- main.log.info("Pushing "+
- str(int(batch_intent_size)*int(n_thread))+
- " intents. Iteration "+str(i))
-
- for node in range(1, cluster_count+1):
- save_dir = base_dir + "batch_intent_"+str(node)+".txt"
+ for i in range( 0, int( num_iter ) ):
+ main.log.info( "Pushing " +
+ str( int( batch_intent_size ) * int( n_thread ) ) +
+ " intents. Iteration " + str( i ) )
+
+ for node in range( 1, cluster_count + 1 ):
+ save_dir = base_dir + "batch_intent_" + str( node ) + ".txt"
main.ONOSbench.push_test_intents_shell(
- "of:0000000000000001/"+str(node),
- "of:0000000000000008/"+str(node),
- int(batch_intent_size),
- save_dir, ONOS_ip_list[node-1],
- num_mult=n_thread, app_id=node)
-
- #Wait sufficient time for intents to start
- #installing
-
- time.sleep(sleep_time)
- print sleep_time
+ "of:0000000000000001/" + str( node ),
+ "of:0000000000000008/" + str( node ),
+ int( batch_intent_size ),
+ save_dir, ONOS_ip_list[ node - 1 ],
+ num_mult=n_thread, app_id=node )
+
+ # Wait sufficient time for intents to start
+ # installing
+
+ time.sleep( sleep_time )
+ print sleep_time
intent = ""
counter = 300
- while len(intent) > 0 and counter > 0:
+ while len( intent ) > 0 and counter > 0:
main.ONOS1cli.handle.sendline(
- "intents | wc -l")
+ "intents | wc -l" )
main.ONOS1cli.handle.expect(
- "intents | wc -l")
+ "intents | wc -l" )
main.ONOS1cli.handle.expect(
- "onos>")
+ "onos>" )
intent_temp = main.ONOS1cli.handle.before()
print intent_temp
intent = main.ONOS1cli.intents()
- intent = json.loads(intent)
- counter = counter-1
- time.sleep(1)
+ intent = json.loads( intent )
+ counter = counter - 1
+ time.sleep( 1 )
- time.sleep(5)
+ time.sleep( 5 )
- for node in range(1, cluster_count+1):
- save_dir = base_dir + "batch_intent_"+str(node)+".txt"
- with open(save_dir) as f_onos:
+ for node in range( 1, cluster_count + 1 ):
+ save_dir = base_dir + "batch_intent_" + str( node ) + ".txt"
+ with open( save_dir ) as f_onos:
line_count = 0
for line in f_onos:
- line = line[1:]
- line = line.split(": ")
- result = line[1].split(" ")[0]
- #TODO: add parameters before appending latency
+ line = line[ 1: ]
+ line = line.split( ": " )
+ result = line[ 1 ].split( " " )[ 0 ]
+ # TODO: add parameters before appending latency
if line_count == 0:
- batch_install_lat.append(int(result))
+ batch_install_lat.append( int( result ) )
elif line_count == 1:
- batch_withdraw_lat.append(int(result))
+ batch_withdraw_lat.append( int( result ) )
line_count += 1
- main.log.info("Batch install latency for ONOS"+
- str(node)+" with "+\
- str(batch_intent_size) + "intents: "+\
- str(batch_install_lat))
-
- if len(batch_install_lat) > 0 and int(i) > num_ignore:
- max_install_lat.append(max(batch_install_lat))
- elif len(batch_install_lat) == 0:
- #If I failed to read anything from the file,
- #increase the wait time before checking intents
+ main.log.info( "Batch install latency for ONOS" +
+ str( node ) + " with " +
+ str( batch_intent_size ) + "intents: " +
+ str( batch_install_lat ) )
+
+ if len( batch_install_lat ) > 0 and int( i ) > num_ignore:
+ max_install_lat.append( max( batch_install_lat ) )
+ elif len( batch_install_lat ) == 0:
+ # If I failed to read anything from the file,
+ # increase the wait time before checking intents
sleep_time += 30
batch_install_lat = []
- #Sleep in between iterations
- time.sleep(5)
+ # Sleep in between iterations
+ time.sleep( 5 )
- main.log.report("Avg of batch installation latency "+
- ": "+
- str(sum(max_install_lat) / len(max_install_lat)))
- main.log.report("Std Deviation of batch installation latency "+
- ": "+
- str(numpy.std(max_install_lat)))
+ main.log.report( "Avg of batch installation latency " +
+ ": " +
+ str( sum( max_install_lat ) /
+ len( max_install_lat ) ) )
+ main.log.report( "Std Deviation of batch installation latency " +
+ ": " +
+ str( numpy.std( max_install_lat ) ) )
- def CASE5(self,main):
- '''
+ def CASE5( self, main ):
+ """
Increase number of nodes and initiate CLI
- '''
+ """
import time
import json
- ONOS1_ip = main.params['CTRL']['ip1']
- ONOS2_ip = main.params['CTRL']['ip2']
- ONOS3_ip = main.params['CTRL']['ip3']
- ONOS4_ip = main.params['CTRL']['ip4']
- ONOS5_ip = main.params['CTRL']['ip5']
- ONOS6_ip = main.params['CTRL']['ip6']
- ONOS7_ip = main.params['CTRL']['ip7']
+ ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+ ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
+ ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
+ ONOS4_ip = main.params[ 'CTRL' ][ 'ip4' ]
+ ONOS5_ip = main.params[ 'CTRL' ][ 'ip5' ]
+ ONOS6_ip = main.params[ 'CTRL' ][ 'ip6' ]
+ ONOS7_ip = main.params[ 'CTRL' ][ 'ip7' ]
global cluster_count
cluster_count += 2
- main.log.report("Increasing cluster size to "+
- str(cluster_count))
+ main.log.report( "Increasing cluster size to " +
+ str( cluster_count ) )
install_result = main.FALSE
if cluster_count == 3:
install_result1 = \
- main.ONOSbench.onos_install(node=ONOS2_ip)
+ main.ONOSbench.onos_install( node=ONOS2_ip )
install_result2 = \
- main.ONOSbench.onos_install(node=ONOS3_ip)
- time.sleep(5)
+ main.ONOSbench.onos_install( node=ONOS3_ip )
+ time.sleep( 5 )
- main.log.info("Starting ONOS CLI")
- main.ONOS2cli.start_onos_cli(ONOS2_ip)
- main.ONOS3cli.start_onos_cli(ONOS3_ip)
+ main.log.info( "Starting ONOS CLI" )
+ main.ONOS2cli.start_onos_cli( ONOS2_ip )
+ main.ONOS3cli.start_onos_cli( ONOS3_ip )
install_result = install_result1 and install_result2
if cluster_count == 5:
- main.log.info("Installing ONOS on node 4 and 5")
+ main.log.info( "Installing ONOS on node 4 and 5" )
install_result1 = \
- main.ONOSbench.onos_install(node=ONOS4_ip)
+ main.ONOSbench.onos_install( node=ONOS4_ip )
install_result2 = \
- main.ONOSbench.onos_install(node=ONOS5_ip)
+ main.ONOSbench.onos_install( node=ONOS5_ip )
- main.log.info("Starting ONOS CLI")
- main.ONOS4cli.start_onos_cli(ONOS4_ip)
- main.ONOS5cli.start_onos_cli(ONOS5_ip)
+ main.log.info( "Starting ONOS CLI" )
+ main.ONOS4cli.start_onos_cli( ONOS4_ip )
+ main.ONOS5cli.start_onos_cli( ONOS5_ip )
install_result = install_result1 and install_result2
if cluster_count == 7:
- main.log.info("Installing ONOS on node 6 and 7")
+ main.log.info( "Installing ONOS on node 6 and 7" )
install_result1 = \
- main.ONOSbench.onos_install(node=ONOS6_ip)
+ main.ONOSbench.onos_install( node=ONOS6_ip )
install_result2 = \
- main.ONOSbench.onos_install(node=ONOS7_ip)
+ main.ONOSbench.onos_install( node=ONOS7_ip )
- main.log.info("Starting ONOS CLI")
- main.ONOS6cli.start_onos_cli(ONOS6_ip)
- main.ONOS7cli.start_onos_cli(ONOS7_ip)
+ main.log.info( "Starting ONOS CLI" )
+ main.ONOS6cli.start_onos_cli( ONOS6_ip )
+ main.ONOS7cli.start_onos_cli( ONOS7_ip )
install_result = install_result1 and install_result2
- time.sleep(5)
+ time.sleep( 5 )
if install_result == main.TRUE:
assertion = main.TRUE
else:
assertion = main.FALSE
- utilities.assert_equals(expect=main.TRUE, actual=assertion,
- onpass="Scale out to "+str(cluster_count)+\
- " nodes successful",
- onfail="Scale out to "+str(cluster_count)+\
- " nodes failed")
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=assertion,
+ onpass="Scale out to " +
+ str( cluster_count ) +
+ " nodes successful",
+ onfail="Scale out to " +
+ str( cluster_count ) +
+ " nodes failed" )
- def CASE9(self, main):
+ def CASE9( self, main ):
count = 0
- sw_num1 = 1
+ sw_num1 = 1
sw_num2 = 1
appid = 0
port_num1 = 1
port_num2 = 1
-
- time.sleep(30)
+
+ time.sleep( 30 )
while True:
- #main.ONOS1cli.push_test_intents(
+ # main.ONOS1cli.push_test_intents(
#"of:0000000000001001/1",
#"of:0000000000002001/1",
- # 100, num_mult="10", app_id="1")
- #main.ONOS2cli.push_test_intents(
+ # 100, num_mult="10", app_id="1" )
+ # main.ONOS2cli.push_test_intents(
# "of:0000000000001002/1",
# "of:0000000000002002/1",
- # 100, num_mult="10", app_id="2")
- #main.ONOS2cli.push_test_intents(
+ # 100, num_mult="10", app_id="2" )
+ # main.ONOS2cli.push_test_intents(
# "of:0000000000001003/1",
# "of:0000000000002003/1",
- # 100, num_mult="10", app_id="3")
+ # 100, num_mult="10", app_id="3" )
count += 1
-
+
if count >= 100:
main.ONOSbench.handle.sendline(
- "onos 10.128.174.1 intents-events-metrics >>"+\
- " /tmp/metrics_intents_temp.txt &")
+ "onos 10.128.174.1 intents-events-metrics >>" +
+ " /tmp/metrics_intents_temp.txt &" )
count = 0
- arg1 = "of:000000000000100"+str(sw_num1)+"/"+str(port_num1)
- arg2 = "of:000000000000200"+str(sw_num2)+"/"+str(port_num2)
-
+ arg1 = "of:000000000000100" + \
+ str( sw_num1 ) + "/" + str( port_num1 )
+ arg2 = "of:000000000000200" + \
+ str( sw_num2 ) + "/" + str( port_num2 )
+
sw_num1 += 1
if sw_num1 > 7:
@@ -825,22 +837,21 @@
if sw_num2 > 7:
sw_num2 = 1
-
+
main.ONOSbench.push_test_intents_shell(
arg1,
- arg2,
+ arg2,
100, "/tmp/temp.txt", "10.128.174.1",
- num_mult="10", app_id=appid,report=False)
- #main.ONOSbench.push_test_intents_shell(
+ num_mult="10", app_id=appid, report=False )
+ # main.ONOSbench.push_test_intents_shell(
# "of:0000000000001002/1",
# "of:0000000000002002/1",
# 133, "/tmp/temp2.txt", "10.128.174.2",
- # num_mult="6", app_id="2",report=False)
- #main.ONOSbench.push_test_intents_shell(
+ # num_mult="6", app_id="2",report=False )
+ # main.ONOSbench.push_test_intents_shell(
# "of:0000000000001003/1",
# "of:0000000000002003/1",
# 133, "/tmp/temp3.txt", "10.128.174.3",
- # num_mult="6", app_id="3",report=False)
-
- time.sleep(0.2)
+ # num_mult="6", app_id="3",report=False )
+ time.sleep( 0.2 )
diff --git a/TestON/tests/LincOETest/LincOETest.py b/TestON/tests/LincOETest/LincOETest.py
old mode 100755
new mode 100644
index bb52ca8..6c59c5b
--- a/TestON/tests/LincOETest/LincOETest.py
+++ b/TestON/tests/LincOETest/LincOETest.py
@@ -1,8 +1,8 @@
-#LincOETest
+# LincOETest
#
-#Packet-Optical Intent Testing
+# Packet-Optical Intent Testing
#
-#andrew@onlab.us
+# andrew@onlab.us
import time
@@ -10,12 +10,14 @@
import os
import re
+
class LincOETest:
- def __init__(self):
+
+ def __init__( self ):
self.default = ''
- def CASE1(self, main):
- '''
+ def CASE1( self, main ):
+ """
Startup sequence:
git pull
mvn clean install
@@ -24,91 +26,93 @@
onos-verify-cell
onos-install -f
onos-wait-for-start
- '''
+ """
import time
- cell_name = main.params['ENV']['cellName']
+ cell_name = main.params[ 'ENV' ][ 'cellName' ]
- ONOS1_ip = main.params['CTRL']['ip1']
- ONOS1_port = main.params['CTRL']['port1']
-
- git_pull_trigger = main.params['GIT']['autoPull']
- git_checkout_branch = main.params['GIT']['checkout']
+ ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+ ONOS1_port = main.params[ 'CTRL' ][ 'port1' ]
- main.case("Setting up test environment")
-
- main.step("Creating cell file")
- #params: (bench ip, cell name, mininet ip, *onos ips)
+ git_pull_trigger = main.params[ 'GIT' ][ 'autoPull' ]
+ git_checkout_branch = main.params[ 'GIT' ][ 'checkout' ]
+
+ main.case( "Setting up test environment" )
+
+ main.step( "Creating cell file" )
+ # params: ( bench ip, cell name, mininet ip, *onos ips )
cell_file_result = main.ONOSbench.create_cell_file(
- "10.128.20.10", cell_name, "10.128.10.90",
- "onos-core-trivial,onos-app-fwd",
- "10.128.174.1")
+ "10.128.20.10", cell_name, "10.128.10.90",
+ "onos-core-trivial,onos-app-fwd",
+ "10.128.174.1" )
- main.step("Applying cell variable to environment")
- #cell_result = main.ONOSbench.set_cell(cell_name)
- cell_result = main.ONOSbench.set_cell("temp_cell_2")
+ main.step( "Applying cell variable to environment" )
+ #cell_result = main.ONOSbench.set_cell( cell_name )
+ cell_result = main.ONOSbench.set_cell( "temp_cell_2" )
verify_result = main.ONOSbench.verify_cell()
-
+
if git_pull_trigger == 'on':
- main.step("Git checkout and pull master")
- main.ONOSbench.git_checkout(git_checkout_branch)
+ main.step( "Git checkout and pull master" )
+ main.ONOSbench.git_checkout( git_checkout_branch )
git_pull_result = main.ONOSbench.git_pull()
else:
- main.log.info("Git checkout and pull skipped by config")
+ main.log.info( "Git checkout and pull skipped by config" )
git_pull_result = main.TRUE
- main.step("Using mvn clean & install")
+ main.step( "Using mvn clean & install" )
#clean_install_result = main.ONOSbench.clean_install()
clean_install_result = main.TRUE
- main.step("Creating ONOS package")
+ main.step( "Creating ONOS package" )
package_result = main.ONOSbench.onos_package()
- main.step("Installing ONOS package")
+ main.step( "Installing ONOS package" )
onos_install_result = main.ONOSbench.onos_install()
onos1_isup = main.ONOSbench.isup()
-
- main.step("Starting ONOS service")
- start_result = main.ONOSbench.onos_start(ONOS1_ip)
- main.step("Setting cell for ONOScli")
- main.ONOScli.set_cell(cell_name)
+ main.step( "Starting ONOS service" )
+ start_result = main.ONOSbench.onos_start( ONOS1_ip )
- main.step("Starting ONOScli")
- main.ONOScli.start_onos_cli(ONOS1_ip)
+ main.step( "Setting cell for ONOScli" )
+ main.ONOScli.set_cell( cell_name )
- case1_result = (clean_install_result and package_result and\
- cell_result and verify_result and onos_install_result and\
- onos1_isup and start_result )
- utilities.assert_equals(expect=main.TRUE, actual=case1_result,
- onpass="Test startup successful",
- onfail="Test startup NOT successful")
+ main.step( "Starting ONOScli" )
+ main.ONOScli.start_onos_cli( ONOS1_ip )
- time.sleep(10)
+ case1_result = ( clean_install_result and package_result and
+ cell_result and verify_result and onos_install_result and
+ onos1_isup and start_result )
+ utilities.assert_equals( expect=main.TRUE, actual=case1_result,
+ onpass="Test startup successful",
+ onfail="Test startup NOT successful" )
- def CASE2(self, main):
- '''
+ time.sleep( 10 )
+
+ def CASE2( self, main ):
+ """
Configure topology
- '''
+ """
import time
- ONOS1_ip = main.params['CTRL']['ip1']
- default_sw_port = main.params['CTRL']['port1']
+ ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+ default_sw_port = main.params[ 'CTRL' ][ 'port1' ]
- #Assign packet level switches to controller
- main.Mininet1.assign_sw_controller(sw="1",
- ip1=ONOS1_ip, port1=default_sw_port)
- main.Mininet1.assign_sw_controller(sw="2",
- ip1=ONOS1_ip, port1=default_sw_port)
+ # Assign packet level switches to controller
+ main.Mininet1.assign_sw_controller(
+ sw="1",
+ ip1=ONOS1_ip,
+ port1=default_sw_port )
+ main.Mininet1.assign_sw_controller(
+ sw="2",
+ ip1=ONOS1_ip,
+ port1=default_sw_port )
- #Check devices in controller
- #This should include Linc-OE devices as well
+ # Check devices in controller
+ # This should include Linc-OE devices as well
devices = main.ONOScli.devices()
- main.log.info(devices)
+ main.log.info( devices )
- def CASE3(self, main):
- '''
+ def CASE3( self, main ):
+ """
Install multi-layer intents
- '''
-
-
+ """
diff --git a/TestON/tests/LincOETest/LincOETest.topo b/TestON/tests/LincOETest/LincOETest.topo
index 221256e..9881845 100755
--- a/TestON/tests/LincOETest/LincOETest.topo
+++ b/TestON/tests/LincOETest/LincOETest.topo
@@ -11,7 +11,7 @@
</ONOSbench>
<ONOScli>
- <host>10.128.20.10</host>
+ <host>10.128.20.10<</host>
<user>admin</user>
<password>onos_test</password>
<type>OnosCliDriver</type>
@@ -20,7 +20,7 @@
</ONOScli>
<ONOS1>
- <host>10.128.174.1</host>
+ <host>10.128.174.1<</host>
<user>sdn</user>
<password>rocks</password>
<type>OnosDriver</type>
diff --git a/TestON/tests/MultiProd/MultiProd.py b/TestON/tests/MultiProd/MultiProd.py
old mode 100755
new mode 100644
index dda3ad4..6b67f63
--- a/TestON/tests/MultiProd/MultiProd.py
+++ b/TestON/tests/MultiProd/MultiProd.py
@@ -1,6 +1,6 @@
-#Testing the basic functionality of ONOS Next
-#For sanity and driver functionality excercises only.
+# Testing the basic functionality of ONOS Next
+# For sanity and driver functionality excercises only.
import time
import sys
@@ -9,527 +9,648 @@
import time
import json
-time.sleep(1)
+time.sleep( 1 )
+
+
class MultiProd:
- def __init__(self):
+
+ def __init__( self ):
self.default = ''
- def CASE1(self, main):
- '''
+ def CASE1( self, main ):
+ """
Startup sequence:
cell <name>
onos-verify-cell
- onos-remove-raft-logs
+ onos-remove-raft-logs
git pull
mvn clean install
onos-package
onos-install -f
onos-wait-for-start
- '''
-
- cell_name = main.params['ENV']['cellName']
- ONOS1_ip = main.params['CTRL']['ip1']
- ONOS2_ip = main.params['CTRL']['ip2']
- ONOS3_ip = main.params['CTRL']['ip3']
- ONOS1_port = main.params['CTRL']['port1']
- ONOS2_port = main.params['CTRL']['port2']
- ONOS3_port = main.params['CTRL']['port3']
-
- main.case("Setting up test environment")
- main.log.report("This testcase is testing setting up test environment")
- main.log.report("__________________________________")
-
- main.step("Applying cell variable to environment")
- cell_result1 = main.ONOSbench.set_cell(cell_name)
- #cell_result2 = main.ONOScli1.set_cell(cell_name)
- #cell_result3 = main.ONOScli2.set_cell(cell_name)
- #cell_result4 = main.ONOScli3.set_cell(cell_name)
- verify_result = main.ONOSbench.verify_cell()
+ """
+ cell_name = main.params[ 'ENV' ][ 'cellName' ]
+ ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+ ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
+ ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
+ ONOS1_port = main.params[ 'CTRL' ][ 'port1' ]
+ ONOS2_port = main.params[ 'CTRL' ][ 'port2' ]
+ ONOS3_port = main.params[ 'CTRL' ][ 'port3' ]
+
+ main.case( "Setting up test environment" )
+ main.log.report(
+ "This testcase is testing setting up test environment" )
+ main.log.report( "__________________________________" )
+
+ main.step( "Applying cell variable to environment" )
+ cell_result1 = main.ONOSbench.set_cell( cell_name )
+ #cell_result2 = main.ONOScli1.set_cell( cell_name )
+ #cell_result3 = main.ONOScli2.set_cell( cell_name )
+ #cell_result4 = main.ONOScli3.set_cell( cell_name )
+ verify_result = main.ONOSbench.verify_cell()
cell_result = cell_result1
- main.step("Removing raft logs before a clen installation of ONOS")
- remove_log_Result = main.ONOSbench.onos_remove_raft_logs()
+ main.step( "Removing raft logs before a clen installation of ONOS" )
+ remove_log_Result = main.ONOSbench.onos_remove_raft_logs()
- main.step("Git checkout and pull master and get version")
- main.ONOSbench.git_checkout("master")
+ main.step( "Git checkout and pull master and get version" )
+ main.ONOSbench.git_checkout( "master" )
git_pull_result = main.ONOSbench.git_pull()
print "git_pull_result = ", git_pull_result
- version_result = main.ONOSbench.get_version(report=True)
+ version_result = main.ONOSbench.get_version( report=True )
if git_pull_result == 1:
- main.step("Using mvn clean & install")
+ main.step( "Using mvn clean & install" )
clean_install_result = main.ONOSbench.clean_install()
- #clean_install_result = main.TRUE
+ #clean_install_result = main.TRUE
- main.step("Creating ONOS package")
+ main.step( "Creating ONOS package" )
package_result = main.ONOSbench.onos_package()
- #main.step("Creating a cell")
- #cell_create_result = main.ONOSbench.create_cell_file(**************)
+ #main.step( "Creating a cell" )
+ # cell_create_result = main.ONOSbench.create_cell_file( **************
+ # )
- main.step("Installing ONOS package")
- onos1_install_result = main.ONOSbench.onos_install(options="-f", node=ONOS1_ip)
- onos2_install_result = main.ONOSbench.onos_install(options="-f", node=ONOS2_ip)
- onos3_install_result = main.ONOSbench.onos_install(options="-f", node=ONOS3_ip)
- onos_install_result = onos1_install_result and onos2_install_result and onos3_install_result
+ main.step( "Installing ONOS package" )
+ onos1_install_result = main.ONOSbench.onos_install(
+ options="-f",
+ node=ONOS1_ip )
+ onos2_install_result = main.ONOSbench.onos_install(
+ options="-f",
+ node=ONOS2_ip )
+ onos3_install_result = main.ONOSbench.onos_install(
+ options="-f",
+ node=ONOS3_ip )
+ onos_install_result = onos1_install_result and onos2_install_result and onos3_install_result
if onos_install_result == main.TRUE:
- main.log.report("Installing ONOS package successful")
+ main.log.report( "Installing ONOS package successful" )
else:
- main.log.report("Installing ONOS package failed")
-
- onos1_isup = main.ONOSbench.isup(ONOS1_ip)
- onos2_isup = main.ONOSbench.isup(ONOS2_ip)
- onos3_isup = main.ONOSbench.isup(ONOS3_ip)
+ main.log.report( "Installing ONOS package failed" )
+
+ onos1_isup = main.ONOSbench.isup( ONOS1_ip )
+ onos2_isup = main.ONOSbench.isup( ONOS2_ip )
+ onos3_isup = main.ONOSbench.isup( ONOS3_ip )
onos_isup = onos1_isup and onos2_isup and onos3_isup
if onos_isup == main.TRUE:
- main.log.report("ONOS instances are up and ready")
+ main.log.report( "ONOS instances are up and ready" )
else:
- main.log.report("ONOS instances may not be up")
+ main.log.report( "ONOS instances may not be up" )
- main.step("Starting ONOS service")
+ main.step( "Starting ONOS service" )
start_result = main.TRUE
- #start_result = main.ONOSbench.onos_start(ONOS1_ip)
- startcli1 = main.ONOScli1.start_onos_cli(ONOS_ip = ONOS1_ip)
- startcli2 = main.ONOScli2.start_onos_cli(ONOS_ip = ONOS2_ip)
- startcli3 = main.ONOScli3.start_onos_cli(ONOS_ip = ONOS3_ip)
+ #start_result = main.ONOSbench.onos_start( ONOS1_ip )
+ startcli1 = main.ONOScli1.start_onos_cli( ONOS_ip=ONOS1_ip )
+ startcli2 = main.ONOScli2.start_onos_cli( ONOS_ip=ONOS2_ip )
+ startcli3 = main.ONOScli3.start_onos_cli( ONOS_ip=ONOS3_ip )
print startcli1
print startcli2
print startcli3
-
- case1_result = (package_result and\
- cell_result and verify_result and onos_install_result and\
- onos_isup and start_result )
- utilities.assert_equals(expect=main.TRUE, actual=case1_result,
- onpass="Test startup successful",
- onfail="Test startup NOT successful")
- def CASE11(self, main):
- '''
+ case1_result = ( package_result and
+ cell_result and verify_result and onos_install_result and
+ onos_isup and start_result )
+ utilities.assert_equals( expect=main.TRUE, actual=case1_result,
+ onpass="Test startup successful",
+ onfail="Test startup NOT successful" )
+
+ def CASE11( self, main ):
+ """
Cleanup sequence:
onos-service <node_ip> stop
onos-uninstall
TODO: Define rest of cleanup
-
- '''
- ONOS1_ip = main.params['CTRL']['ip1']
- ONOS2_ip = main.params['CTRL']['ip2']
- ONOS3_ip = main.params['CTRL']['ip3']
-
- main.case("Cleaning up test environment")
+ """
+ ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+ ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
+ ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
- main.step("Testing ONOS kill function")
- kill_result1 = main.ONOSbench.onos_kill(ONOS1_ip)
- kill_result2 = main.ONOSbench.onos_kill(ONOS2_ip)
- kill_result3 = main.ONOSbench.onos_kill(ONOS3_ip)
-
- main.step("Stopping ONOS service")
- stop_result1 = main.ONOSbench.onos_stop(ONOS1_ip)
- stop_result2 = main.ONOSbench.onos_stop(ONOS2_ip)
- stop_result3 = main.ONOSbench.onos_stop(ONOS3_ip)
+ main.case( "Cleaning up test environment" )
- main.step("Uninstalling ONOS service")
+ main.step( "Testing ONOS kill function" )
+ kill_result1 = main.ONOSbench.onos_kill( ONOS1_ip )
+ kill_result2 = main.ONOSbench.onos_kill( ONOS2_ip )
+ kill_result3 = main.ONOSbench.onos_kill( ONOS3_ip )
+
+ main.step( "Stopping ONOS service" )
+ stop_result1 = main.ONOSbench.onos_stop( ONOS1_ip )
+ stop_result2 = main.ONOSbench.onos_stop( ONOS2_ip )
+ stop_result3 = main.ONOSbench.onos_stop( ONOS3_ip )
+
+ main.step( "Uninstalling ONOS service" )
uninstall_result = main.ONOSbench.onos_uninstall()
- def CASE3(self, main):
- '''
+ def CASE3( self, main ):
+ """
Test 'onos' command and its functionality in driver
- '''
-
- ONOS1_ip = main.params['CTRL']['ip1']
- ONOS2_ip = main.params['CTRL']['ip2']
- ONOS3_ip = main.params['CTRL']['ip3']
+ """
+ ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+ ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
+ ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
- main.case("Testing 'onos' command")
+ main.case( "Testing 'onos' command" )
- main.step("Sending command 'onos -w <onos-ip> system:name'")
+ main.step( "Sending command 'onos -w <onos-ip> system:name'" )
cmdstr1 = "system:name"
- cmd_result1 = main.ONOSbench.onos_cli(ONOS1_ip, cmdstr1)
- main.log.info("onos command returned: "+cmd_result1)
- cmd_result2 = main.ONOSbench.onos_cli(ONOS2_ip, cmdstr1)
- main.log.info("onos command returned: "+cmd_result2)
- cmd_result3 = main.ONOSbench.onos_cli(ONOS3_ip, cmdstr1)
- main.log.info("onos command returned: "+cmd_result3)
+ cmd_result1 = main.ONOSbench.onos_cli( ONOS1_ip, cmdstr1 )
+ main.log.info( "onos command returned: " + cmd_result1 )
+ cmd_result2 = main.ONOSbench.onos_cli( ONOS2_ip, cmdstr1 )
+ main.log.info( "onos command returned: " + cmd_result2 )
+ cmd_result3 = main.ONOSbench.onos_cli( ONOS3_ip, cmdstr1 )
+ main.log.info( "onos command returned: " + cmd_result3 )
- main.step("Sending command 'onos -w <onos-ip> onos:topology'")
+ main.step( "Sending command 'onos -w <onos-ip> onos:topology'" )
cmdstr2 = "onos:topology"
- cmd_result4 = main.ONOSbench.onos_cli(ONOS1_ip, cmdstr2)
- main.log.info("onos command returned: "+cmd_result4)
- cmd_result5 = main.ONOSbench.onos_cli(ONOS2_ip, cmdstr2)
- main.log.info("onos command returned: "+cmd_result5)
- cmd_result6 = main.ONOSbench.onos_cli(ONOS6_ip, cmdstr2)
- main.log.info("onos command returned: "+cmd_result6)
+ cmd_result4 = main.ONOSbench.onos_cli( ONOS1_ip, cmdstr2 )
+ main.log.info( "onos command returned: " + cmd_result4 )
+ cmd_result5 = main.ONOSbench.onos_cli( ONOS2_ip, cmdstr2 )
+ main.log.info( "onos command returned: " + cmd_result5 )
+ cmd_result6 = main.ONOSbench.onos_cli( ONOS6_ip, cmdstr2 )
+ main.log.info( "onos command returned: " + cmd_result6 )
-
- def CASE4(self, main):
+ def CASE4( self, main ):
import re
import time
- ONOS1_ip = main.params['CTRL']['ip1']
- ONOS2_ip = main.params['CTRL']['ip2']
- ONOS3_ip = main.params['CTRL']['ip3']
- ONOS1_port = main.params['CTRL']['port1']
- ONOS2_port = main.params['CTRL']['port2']
- ONOS3_port = main.params['CTRL']['port3']
-
- main.log.report("This testcase is testing the assignment of all the switches to all controllers and discovering the hosts in reactive mode")
- main.log.report("__________________________________")
- main.case("Pingall Test(No intents are added)")
- main.step("Assigning switches to controllers")
- for i in range(1,29): #1 to (num of switches +1)
- main.Mininet1.assign_sw_controller(sw=str(i),count=3,
- ip1=ONOS1_ip, port1=ONOS1_port,
- ip2=ONOS2_ip, port2=ONOS2_port,
- ip3=ONOS3_ip, port3=ONOS3_port)
+ ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+ ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
+ ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
+ ONOS1_port = main.params[ 'CTRL' ][ 'port1' ]
+ ONOS2_port = main.params[ 'CTRL' ][ 'port2' ]
+ ONOS3_port = main.params[ 'CTRL' ][ 'port3' ]
+
+ main.log.report(
+ "This testcase is testing the assignment of all the switches to all controllers and discovering the hosts in reactive mode" )
+ main.log.report( "__________________________________" )
+ main.case( "Pingall Test(No intents are added)" )
+ main.step( "Assigning switches to controllers" )
+ for i in range( 1, 29 ): # 1 to ( num of switches +1 )
+ main.Mininet1.assign_sw_controller(
+ sw=str( i ),
+ count=3,
+ ip1=ONOS1_ip,
+ port1=ONOS1_port,
+ ip2=ONOS2_ip,
+ port2=ONOS2_port,
+ ip3=ONOS3_ip,
+ port3=ONOS3_port )
switch_mastership = main.TRUE
- for i in range (1,29):
- response = main.Mininet1.get_sw_controller("s"+str(i))
- print("Response is " + str(response))
- if re.search("tcp:"+ONOS1_ip,response):
+ for i in range( 1, 29 ):
+ response = main.Mininet1.get_sw_controller( "s" + str( i ) )
+ print( "Response is " + str( response ) )
+ if re.search( "tcp:" + ONOS1_ip, response ):
switch_mastership = switch_mastership and main.TRUE
else:
switch_mastership = main.FALSE
if switch_mastership == main.TRUE:
- main.log.report("Controller assignment successfull")
+ main.log.report( "Controller assignment successfull" )
else:
- main.log.report("Controller assignment failed")
- #REACTIVE FWD test
- main.step("Pingall")
+ main.log.report( "Controller assignment failed" )
+ # REACTIVE FWD test
+ main.step( "Pingall" )
ping_result = main.FALSE
time1 = time.time()
ping_result = main.Mininet1.pingall()
time2 = time.time()
- print "Time for pingall: %2f seconds" % (time2 - time1)
-
+ print "Time for pingall: %2f seconds" % ( time2 - time1 )
+
case4_result = switch_mastership and ping_result
if ping_result == main.TRUE:
- main.log.report("Pingall Test in reactive mode to discover the hosts successful")
+ main.log.report(
+ "Pingall Test in reactive mode to discover the hosts successful" )
else:
- main.log.report("Pingall Test in reactive mode to discover the hosts failed")
+ main.log.report(
+ "Pingall Test in reactive mode to discover the hosts failed" )
- utilities.assert_equals(expect=main.TRUE, actual=case4_result,onpass="Controller assignment and Pingall Test successful",onfail="Controller assignment and Pingall Test NOT successful")
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case4_result,
+ onpass="Controller assignment and Pingall Test successful",
+ onfail="Controller assignment and Pingall Test NOT successful" )
-
-
- def CASE5(self,main) :
+ def CASE5( self, main ):
import json
from subprocess import Popen, PIPE
- from sts.topology.teston_topology import TestONTopology # assumes that sts is already in you PYTHONPATH
- ONOS1_ip = main.params['CTRL']['ip1']
- ONOS2_ip = main.params['CTRL']['ip2']
- ONOS3_ip = main.params['CTRL']['ip3']
-
- main.log.report("This testcase is testing if all ONOS nodes are in topology sync with mininet and its peer ONOS nodes")
- main.log.report("__________________________________")
- main.case ("Testing Mininet topology with the topology of multi instances ONOS")
- main.step("Collecting topology information from ONOS")
+ # assumes that sts is already in you PYTHONPATH
+ from sts.topology.teston_topology import TestONTopology
+ ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+ ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
+ ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
+
+ main.log.report(
+ "This testcase is testing if all ONOS nodes are in topology sync with mininet and its peer ONOS nodes" )
+ main.log.report( "__________________________________" )
+ main.case(
+ "Testing Mininet topology with the topology of multi instances ONOS" )
+ main.step( "Collecting topology information from ONOS" )
devices1 = main.ONOScli1.devices()
devices2 = main.ONOScli2.devices()
devices3 = main.ONOScli3.devices()
- #print "devices1 = ", devices1
- #print "devices2 = ", devices2
- #print "devices3 = ", devices3
+ # print "devices1 = ", devices1
+ # print "devices2 = ", devices2
+ # print "devices3 = ", devices3
hosts1 = main.ONOScli1.hosts()
hosts2 = main.ONOScli2.hosts()
hosts3 = main.ONOScli3.hosts()
- #print "hosts1 = ", hosts1
- #print "hosts2 = ", hosts2
- #print "hosts3 = ", hosts3
+ # print "hosts1 = ", hosts1
+ # print "hosts2 = ", hosts2
+ # print "hosts3 = ", hosts3
ports1 = main.ONOScli1.ports()
ports2 = main.ONOScli2.ports()
ports3 = main.ONOScli3.ports()
- #print "ports1 = ", ports1
- #print "ports2 = ", ports2
- #print "ports3 = ", ports3
+ # print "ports1 = ", ports1
+ # print "ports2 = ", ports2
+ # print "ports3 = ", ports3
links1 = main.ONOScli1.links()
links2 = main.ONOScli2.links()
links3 = main.ONOScli3.links()
- #print "links1 = ", links1
- #print "links2 = ", links2
- #print "links3 = ", links3
-
- print "**************"
-
- main.step("Start continuous pings")
- main.Mininet2.pingLong(src=main.params['PING']['source1'],
- target=main.params['PING']['target1'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source2'],
- target=main.params['PING']['target2'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source3'],
- target=main.params['PING']['target3'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source4'],
- target=main.params['PING']['target4'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source5'],
- target=main.params['PING']['target5'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source6'],
- target=main.params['PING']['target6'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source7'],
- target=main.params['PING']['target7'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source8'],
- target=main.params['PING']['target8'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source9'],
- target=main.params['PING']['target9'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source10'],
- target=main.params['PING']['target10'],pingTime=500)
+ # print "links1 = ", links1
+ # print "links2 = ", links2
+ # print "links3 = ", links3
- main.step("Create TestONTopology object")
+ print "**************"
+
+ main.step( "Start continuous pings" )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source1' ],
+ target=main.params[ 'PING' ][ 'target1' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source2' ],
+ target=main.params[ 'PING' ][ 'target2' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source3' ],
+ target=main.params[ 'PING' ][ 'target3' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source4' ],
+ target=main.params[ 'PING' ][ 'target4' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source5' ],
+ target=main.params[ 'PING' ][ 'target5' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source6' ],
+ target=main.params[ 'PING' ][ 'target6' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source7' ],
+ target=main.params[ 'PING' ][ 'target7' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source8' ],
+ target=main.params[ 'PING' ][ 'target8' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source9' ],
+ target=main.params[ 'PING' ][ 'target9' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source10' ],
+ target=main.params[ 'PING' ][ 'target10' ],
+ pingTime=500 )
+
+ main.step( "Create TestONTopology object" )
global ctrls
ctrls = []
count = 1
while True:
temp = ()
- if ('ip' + str(count)) in main.params['CTRL']:
- temp = temp + (getattr(main,('ONOS' + str(count))),)
- temp = temp + ("ONOS"+str(count),)
- temp = temp + (main.params['CTRL']['ip'+str(count)],)
- temp = temp + (eval(main.params['CTRL']['port'+str(count)]),)
- ctrls.append(temp)
+ if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]:
+ temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), )
+ temp = temp + ( "ONOS" + str( count ), )
+ temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], )
+ temp = temp + \
+ ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), )
+ ctrls.append( temp )
count = count + 1
else:
break
global MNTopo
- Topo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations
+ Topo = TestONTopology(
+ main.Mininet1,
+ ctrls ) # can also add Intent API info for intent operations
MNTopo = Topo
Topology_Check = main.TRUE
- main.step("Compare ONOS Topology to MN Topology")
-
- switches_results1 = main.Mininet1.compare_switches(MNTopo, json.loads(devices1))
+ main.step( "Compare ONOS Topology to MN Topology" )
+
+ switches_results1 = main.Mininet1.compare_switches(
+ MNTopo,
+ json.loads( devices1 ) )
print "switches_Result1 = ", switches_results1
- utilities.assert_equals(expect=main.TRUE, actual=switches_results1,
- onpass="ONOS1 Switches view is correct",
- onfail="ONOS1 Switches view is incorrect")
+ utilities.assert_equals( expect=main.TRUE, actual=switches_results1,
+ onpass="ONOS1 Switches view is correct",
+ onfail="ONOS1 Switches view is incorrect" )
- switches_results2 = main.Mininet1.compare_switches(MNTopo, json.loads(devices2))
- utilities.assert_equals(expect=main.TRUE, actual=switches_results2,
- onpass="ONOS2 Switches view is correct",
- onfail="ONOS2 Switches view is incorrect")
-
- switches_results3 = main.Mininet1.compare_switches(MNTopo, json.loads(devices3))
- utilities.assert_equals(expect=main.TRUE, actual=switches_results3,
- onpass="ONOS3 Switches view is correct",
- onfail="ONOS3 Switches view is incorrect")
+ switches_results2 = main.Mininet1.compare_switches(
+ MNTopo,
+ json.loads( devices2 ) )
+ utilities.assert_equals( expect=main.TRUE, actual=switches_results2,
+ onpass="ONOS2 Switches view is correct",
+ onfail="ONOS2 Switches view is incorrect" )
- '''
- ports_results1 = main.Mininet1.compare_ports(MNTopo, json.loads(ports1))
- utilities.assert_equals(expect=main.TRUE, actual=ports_results1,
+ switches_results3 = main.Mininet1.compare_switches(
+ MNTopo,
+ json.loads( devices3 ) )
+ utilities.assert_equals( expect=main.TRUE, actual=switches_results3,
+ onpass="ONOS3 Switches view is correct",
+ onfail="ONOS3 Switches view is incorrect" )
+
+ """
+ ports_results1 = main.Mininet1.compare_ports( MNTopo, json.loads( ports1 ) )
+ utilities.assert_equals( expect=main.TRUE, actual=ports_results1,
onpass="ONOS1 Ports view is correct",
- onfail="ONOS1 Ports view is incorrect")
+ onfail="ONOS1 Ports view is incorrect" )
- ports_results2 = main.Mininet1.compare_ports(MNTopo, json.loads(ports2))
- utilities.assert_equals(expect=main.TRUE, actual=ports_results2,
+ ports_results2 = main.Mininet1.compare_ports( MNTopo, json.loads( ports2 ) )
+ utilities.assert_equals( expect=main.TRUE, actual=ports_results2,
onpass="ONOS2 Ports view is correct",
- onfail="ONOS2 Ports view is incorrect")
+ onfail="ONOS2 Ports view is incorrect" )
- ports_results3 = main.Mininet1.compare_ports(MNTopo, json.loads(ports3))
- utilities.assert_equals(expect=main.TRUE, actual=ports_results3,
+ ports_results3 = main.Mininet1.compare_ports( MNTopo, json.loads( ports3 ) )
+ utilities.assert_equals( expect=main.TRUE, actual=ports_results3,
onpass="ONOS3 Ports view is correct",
- onfail="ONOS3 Ports view is incorrect")
- '''
+ onfail="ONOS3 Ports view is incorrect" )
+ """
+ links_results1 = main.Mininet1.compare_links(
+ MNTopo,
+ json.loads( links1 ) )
+ utilities.assert_equals( expect=main.TRUE, actual=links_results1,
+ onpass="ONOS1 Links view is correct",
+ onfail="ONOS1 Links view is incorrect" )
- links_results1 = main.Mininet1.compare_links(MNTopo, json.loads(links1))
- utilities.assert_equals(expect=main.TRUE, actual=links_results1,
- onpass="ONOS1 Links view is correct",
- onfail="ONOS1 Links view is incorrect")
+ links_results2 = main.Mininet1.compare_links(
+ MNTopo,
+ json.loads( links2 ) )
+ utilities.assert_equals( expect=main.TRUE, actual=links_results2,
+ onpass="ONOS2 Links view is correct",
+ onfail="ONOS2 Links view is incorrect" )
- links_results2 = main.Mininet1.compare_links(MNTopo, json.loads(links2))
- utilities.assert_equals(expect=main.TRUE, actual=links_results2,
- onpass="ONOS2 Links view is correct",
- onfail="ONOS2 Links view is incorrect")
-
- links_results3 = main.Mininet1.compare_links(MNTopo, json.loads(links3))
- utilities.assert_equals(expect=main.TRUE, actual=links_results3,
- onpass="ONOS2 Links view is correct",
- onfail="ONOS2 Links view is incorrect")
+ links_results3 = main.Mininet1.compare_links(
+ MNTopo,
+ json.loads( links3 ) )
+ utilities.assert_equals( expect=main.TRUE, actual=links_results3,
+ onpass="ONOS2 Links view is correct",
+ onfail="ONOS2 Links view is incorrect" )
#topo_result = switches_results1 and switches_results2 and switches_results3\
- #and ports_results1 and ports_results2 and ports_results3\
- #and links_results1 and links_results2 and links_results3
-
+ # and ports_results1 and ports_results2 and ports_results3\
+ # and links_results1 and links_results2 and links_results3
+
topo_result = switches_results1 and switches_results2 and switches_results3\
- and links_results1 and links_results2 and links_results3
+ and links_results1 and links_results2 and links_results3
if topo_result == main.TRUE:
- main.log.report("Topology Check Test with mininet and ONOS instances successful")
+ main.log.report(
+ "Topology Check Test with mininet and ONOS instances successful" )
else:
- main.log.report("Topology Check Test with mininet and ONOS instances failed")
+ main.log.report(
+ "Topology Check Test with mininet and ONOS instances failed" )
- utilities.assert_equals(expect=main.TRUE, actual=topo_result,
- onpass="Topology Check Test successful",
- onfail="Topology Check Test NOT successful")
+ utilities.assert_equals( expect=main.TRUE, actual=topo_result,
+ onpass="Topology Check Test successful",
+ onfail="Topology Check Test NOT successful" )
+ def CASE10( self ):
+ main.log.report(
+ "This testcase uninstalls the reactive forwarding app" )
+ main.log.report( "__________________________________" )
+ main.case( "Uninstalling reactive forwarding app" )
+ # Unistall onos-app-fwd app to disable reactive forwarding
+ appUninstall_result1 = main.ONOScli1.feature_uninstall(
+ "onos-app-fwd" )
+ appUninstall_result2 = main.ONOScli2.feature_uninstall(
+ "onos-app-fwd" )
+ appUninstall_result3 = main.ONOScli3.feature_uninstall(
+ "onos-app-fwd" )
+ main.log.info( "onos-app-fwd uninstalled" )
+ # After reactive forwarding is disabled, the reactive flows on switches timeout in 10-15s
+ # So sleep for 15s
+ time.sleep( 15 )
-
- def CASE10(self):
- main.log.report("This testcase uninstalls the reactive forwarding app")
- main.log.report("__________________________________")
- main.case("Uninstalling reactive forwarding app")
- #Unistall onos-app-fwd app to disable reactive forwarding
- appUninstall_result1 = main.ONOScli1.feature_uninstall("onos-app-fwd")
- appUninstall_result2 = main.ONOScli2.feature_uninstall("onos-app-fwd")
- appUninstall_result3 = main.ONOScli3.feature_uninstall("onos-app-fwd")
- main.log.info("onos-app-fwd uninstalled")
-
- #After reactive forwarding is disabled, the reactive flows on switches timeout in 10-15s
- #So sleep for 15s
- time.sleep(15)
-
hosts = main.ONOScli1.hosts()
- main.log.info(hosts)
-
+ main.log.info( hosts )
+
case10_result = appUninstall_result1 and appUninstall_result2 and appUninstall_result3
- utilities.assert_equals(expect=main.TRUE, actual=case10_result,onpass="Reactive forwarding app uninstallation successful",onfail="Reactive forwarding app uninstallation failed")
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case10_result,
+ onpass="Reactive forwarding app uninstallation successful",
+ onfail="Reactive forwarding app uninstallation failed" )
-
- def CASE6(self):
- main.log.report("This testcase is testing the addition of host intents and then doing pingall")
- main.log.report("__________________________________")
- main.case("Obtaining hostsfor adding host intents")
- main.step("Get hosts")
+ def CASE6( self ):
+ main.log.report(
+ "This testcase is testing the addition of host intents and then doing pingall" )
+ main.log.report( "__________________________________" )
+ main.case( "Obtaining hostsfor adding host intents" )
+ main.step( "Get hosts" )
hosts = main.ONOScli1.hosts()
- main.log.info(hosts)
+ main.log.info( hosts )
- main.step("Get all devices id")
+ main.step( "Get all devices id" )
devices_id_list = main.ONOScli1.get_all_devices_id()
- main.log.info(devices_id_list)
+ main.log.info( devices_id_list )
- #ONOS displays the hosts in hex format unlike mininet which does in decimal format
- #So take care while adding intents
-
- '''
- main.step("Add host intents for mn hosts(h8-h18,h9-h19,h10-h20,h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)")
- hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1")
- hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1")
- hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:0A/-1", "00:00:00:00:00:14/-1")
- hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:0B/-1", "00:00:00:00:00:15/-1")
- hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:0C/-1", "00:00:00:00:00:16/-1")
- hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:0D/-1", "00:00:00:00:00:17/-1")
- hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:0E/-1", "00:00:00:00:00:18/-1")
- hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1")
- hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1")
- hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1")
- '''
+ # ONOS displays the hosts in hex format unlike mininet which does in decimal format
+ # So take care while adding intents
- for i in range(8,18):
- main.log.info("Adding host intent between h"+str(i)+" and h"+str(i+10))
- host1 = "00:00:00:00:00:" + str(hex(i)[2:]).zfill(2).upper()
- host2 = "00:00:00:00:00:" + str(hex(i+10)[2:]).zfill(2).upper()
- #NOTE: get host can return None
- #TODO: handle this
- host1_id = main.ONOScli1.get_host(host1)['id']
- host2_id = main.ONOScli1.get_host(host2)['id']
- tmp_result = main.ONOScli1.add_host_intent(host1_id, host2_id )
+ """
+ main.step( "Add host intents for mn hosts(h8-h18,h9-h19,h10-h20,h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)" )
+ hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1" )
+ hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1" )
+ hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:0A/-1", "00:00:00:00:00:14/-1" )
+ hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:0B/-1", "00:00:00:00:00:15/-1" )
+ hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:0C/-1", "00:00:00:00:00:16/-1" )
+ hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:0D/-1", "00:00:00:00:00:17/-1" )
+ hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:0E/-1", "00:00:00:00:00:18/-1" )
+ hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1" )
+ hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1" )
+ hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1" )
+ """
+ for i in range( 8, 18 ):
+ main.log.info(
+ "Adding host intent between h" + str( i ) + " and h" + str( i + 10 ) )
+ host1 = "00:00:00:00:00:" + \
+ str( hex( i )[ 2: ] ).zfill( 2 ).upper()
+ host2 = "00:00:00:00:00:" + \
+ str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
+ # NOTE: get host can return None
+ # TODO: handle this
+ host1_id = main.ONOScli1.get_host( host1 )[ 'id' ]
+ host2_id = main.ONOScli1.get_host( host2 )[ 'id' ]
+ tmp_result = main.ONOScli1.add_host_intent( host1_id, host2_id )
flowHandle = main.ONOScli1.flows()
- #print "flowHandle = ", flowHandle
- main.log.info("flows:" +flowHandle)
+ # print "flowHandle = ", flowHandle
+ main.log.info( "flows:" + flowHandle )
count = 1
i = 8
Ping_Result = main.TRUE
- while i <18 :
- main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10))
- ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
- if ping == main.FALSE and count <5:
- count+=1
+ while i < 18:
+ main.log.info(
+ "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
+ ping = main.Mininet1.pingHost(
+ src="h" + str( i ), target="h" + str( i + 10 ) )
+ if ping == main.FALSE and count < 5:
+ count += 1
#i = 8
Ping_Result = main.FALSE
- main.log.report("Ping between h" + str(i) + " and h" + str(i+10) + " failed. Making attempt number "+str(count) + " in 2 seconds")
- time.sleep(2)
- elif ping==main.FALSE:
- main.log.report("All ping attempts between h" + str(i) + " and h" + str(i+10) +"have failed")
- i=19
+ main.log.report( "Ping between h" +
+ str( i ) +
+ " and h" +
+ str( i +
+ 10 ) +
+ " failed. Making attempt number " +
+ str( count ) +
+ " in 2 seconds" )
+ time.sleep( 2 )
+ elif ping == main.FALSE:
+ main.log.report( "All ping attempts between h" +
+ str( i ) +
+ " and h" +
+ str( i +
+ 10 ) +
+ "have failed" )
+ i = 19
Ping_Result = main.FALSE
- elif ping==main.TRUE:
- main.log.info("Ping test between h" + str(i) + " and h" + str(i+10) + "passed!")
- i+=1
+ elif ping == main.TRUE:
+ main.log.info( "Ping test between h" +
+ str( i ) +
+ " and h" +
+ str( i +
+ 10 ) +
+ "passed!" )
+ i += 1
Ping_Result = main.TRUE
else:
- main.log.info("Unknown error")
+ main.log.info( "Unknown error" )
Ping_Result = main.ERROR
- if Ping_Result==main.FALSE:
- main.log.report("Host intents have not ben installed correctly. Cleaning up")
- #main.cleanup()
- #main.exit()
- if Ping_Result==main.TRUE:
- main.log.report("Host intents have been installed correctly")
+ if Ping_Result == main.FALSE:
+ main.log.report(
+ "Host intents have not ben installed correctly. Cleaning up" )
+ # main.cleanup()
+ # main.exit()
+ if Ping_Result == main.TRUE:
+ main.log.report( "Host intents have been installed correctly" )
case6_result = Ping_Result
- utilities.assert_equals(expect=main.TRUE, actual=case6_result,
- onpass="Host intent addition and Pingall Test successful",
- onfail="Host intent addition and Pingall Test NOT successful")
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case6_result,
+ onpass="Host intent addition and Pingall Test successful",
+ onfail="Host intent addition and Pingall Test NOT successful" )
+ def CASE7( self, main ):
- def CASE7 (self,main):
-
- ONOS1_ip = main.params['CTRL']['ip1']
+ ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
- link_sleep = int(main.params['timers']['LinkDiscovery'])
+ link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
- main.log.report("This testscase is killing a link to ensure that link discovery is consistent")
- main.log.report("__________________________________")
- main.case("Killing a link to Ensure that Link Discovery is Working Properly")
- main.step("Start continuous pings")
-
- main.Mininet2.pingLong(src=main.params['PING']['source1'],
- target=main.params['PING']['target1'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source2'],
- target=main.params['PING']['target2'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source3'],
- target=main.params['PING']['target3'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source4'],
- target=main.params['PING']['target4'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source5'],
- target=main.params['PING']['target5'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source6'],
- target=main.params['PING']['target6'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source7'],
- target=main.params['PING']['target7'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source8'],
- target=main.params['PING']['target8'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source9'],
- target=main.params['PING']['target9'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source10'],
- target=main.params['PING']['target10'],pingTime=500)
+ main.log.report(
+ "This testscase is killing a link to ensure that link discovery is consistent" )
+ main.log.report( "__________________________________" )
+ main.case(
+ "Killing a link to Ensure that Link Discovery is Working Properly" )
+ main.step( "Start continuous pings" )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source1' ],
+ target=main.params[ 'PING' ][ 'target1' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source2' ],
+ target=main.params[ 'PING' ][ 'target2' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source3' ],
+ target=main.params[ 'PING' ][ 'target3' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source4' ],
+ target=main.params[ 'PING' ][ 'target4' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source5' ],
+ target=main.params[ 'PING' ][ 'target5' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source6' ],
+ target=main.params[ 'PING' ][ 'target6' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source7' ],
+ target=main.params[ 'PING' ][ 'target7' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source8' ],
+ target=main.params[ 'PING' ][ 'target8' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source9' ],
+ target=main.params[ 'PING' ][ 'target9' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source10' ],
+ target=main.params[ 'PING' ][ 'target10' ],
+ pingTime=500 )
- main.step("Determine the current number of switches and links")
+ main.step( "Determine the current number of switches and links" )
topology_output = main.ONOScli1.topology()
- topology_result = main.ONOSbench.get_topology(topology_output)
- activeSwitches = topology_result['devices']
- links = topology_result['links']
- print "activeSwitches = ", type(activeSwitches)
- print "links = ", type(links)
- main.log.info("Currently there are %s switches and %s links" %(str(activeSwitches), str(links)))
+ topology_result = main.ONOSbench.get_topology( topology_output )
+ activeSwitches = topology_result[ 'devices' ]
+ links = topology_result[ 'links' ]
+ print "activeSwitches = ", type( activeSwitches )
+ print "links = ", type( links )
+ main.log.info(
+ "Currently there are %s switches and %s links" %
+ ( str( activeSwitches ), str( links ) ) )
- main.step("Kill Link between s3 and s28")
- main.Mininet1.link(END1="s3",END2="s28",OPTION="down")
- time.sleep(link_sleep)
+ main.step( "Kill Link between s3 and s28" )
+ main.Mininet1.link( END1="s3", END2="s28", OPTION="down" )
+ time.sleep( link_sleep )
topology_output = main.ONOScli2.topology()
- Link_Down = main.ONOSbench.check_status(topology_output,activeSwitches,str(int(links)-2))
+ Link_Down = main.ONOSbench.check_status(
+ topology_output, activeSwitches, str(
+ int( links ) - 2 ) )
if Link_Down == main.TRUE:
- main.log.report("Link Down discovered properly")
- utilities.assert_equals(expect=main.TRUE,actual=Link_Down,
- onpass="Link Down discovered properly",
- onfail="Link down was not discovered in "+ str(link_sleep) + " seconds")
-
- main.step("Bring link between s3 and s28 back up")
- Link_Up = main.Mininet1.link(END1="s3",END2="s28",OPTION="up")
- time.sleep(link_sleep)
- topology_output = main.ONOScli2.topology()
- Link_Up = main.ONOSbench.check_status(topology_output,activeSwitches,str(links))
- if Link_Up == main.TRUE:
- main.log.report("Link up discovered properly")
- utilities.assert_equals(expect=main.TRUE,actual=Link_Up,
- onpass="Link up discovered properly",
- onfail="Link up was not discovered in "+ str(link_sleep) + " seconds")
+ main.log.report( "Link Down discovered properly" )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=Link_Down,
+ onpass="Link Down discovered properly",
+ onfail="Link down was not discovered in " +
+ str( link_sleep ) +
+ " seconds" )
- main.step("Compare ONOS Topology to MN Topology")
- main.case ("Testing Mininet topology with the topology of multi instances ONOS")
- main.step("Collecting topology information from ONOS")
+ main.step( "Bring link between s3 and s28 back up" )
+ Link_Up = main.Mininet1.link( END1="s3", END2="s28", OPTION="up" )
+ time.sleep( link_sleep )
+ topology_output = main.ONOScli2.topology()
+ Link_Up = main.ONOSbench.check_status(
+ topology_output,
+ activeSwitches,
+ str( links ) )
+ if Link_Up == main.TRUE:
+ main.log.report( "Link up discovered properly" )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=Link_Up,
+ onpass="Link up discovered properly",
+ onfail="Link up was not discovered in " +
+ str( link_sleep ) +
+ " seconds" )
+
+ main.step( "Compare ONOS Topology to MN Topology" )
+ main.case(
+ "Testing Mininet topology with the topology of multi instances ONOS" )
+ main.step( "Collecting topology information from ONOS" )
devices1 = main.ONOScli1.devices()
devices2 = main.ONOScli2.devices()
devices3 = main.ONOScli3.devices()
@@ -539,625 +660,864 @@
hosts1 = main.ONOScli1.hosts()
hosts2 = main.ONOScli2.hosts()
hosts3 = main.ONOScli3.hosts()
- #print "hosts1 = ", hosts1
- #print "hosts2 = ", hosts2
- #print "hosts3 = ", hosts3
+ # print "hosts1 = ", hosts1
+ # print "hosts2 = ", hosts2
+ # print "hosts3 = ", hosts3
ports1 = main.ONOScli1.ports()
ports2 = main.ONOScli2.ports()
ports3 = main.ONOScli3.ports()
- #print "ports1 = ", ports1
- #print "ports2 = ", ports2
- #print "ports3 = ", ports3
+ # print "ports1 = ", ports1
+ # print "ports2 = ", ports2
+ # print "ports3 = ", ports3
links1 = main.ONOScli1.links()
links2 = main.ONOScli2.links()
links3 = main.ONOScli3.links()
- #print "links1 = ", links1
- #print "links2 = ", links2
- #print "links3 = ", links3
-
- print "**************"
-
- main.step("Start continuous pings")
- main.Mininet2.pingLong(src=main.params['PING']['source1'],
- target=main.params['PING']['target1'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source2'],
- target=main.params['PING']['target2'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source3'],
- target=main.params['PING']['target3'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source4'],
- target=main.params['PING']['target4'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source5'],
- target=main.params['PING']['target5'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source6'],
- target=main.params['PING']['target6'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source7'],
- target=main.params['PING']['target7'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source8'],
- target=main.params['PING']['target8'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source9'],
- target=main.params['PING']['target9'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source10'],
- target=main.params['PING']['target10'],pingTime=500)
+ # print "links1 = ", links1
+ # print "links2 = ", links2
+ # print "links3 = ", links3
- main.step("Create TestONTopology object")
+ print "**************"
+
+ main.step( "Start continuous pings" )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source1' ],
+ target=main.params[ 'PING' ][ 'target1' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source2' ],
+ target=main.params[ 'PING' ][ 'target2' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source3' ],
+ target=main.params[ 'PING' ][ 'target3' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source4' ],
+ target=main.params[ 'PING' ][ 'target4' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source5' ],
+ target=main.params[ 'PING' ][ 'target5' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source6' ],
+ target=main.params[ 'PING' ][ 'target6' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source7' ],
+ target=main.params[ 'PING' ][ 'target7' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source8' ],
+ target=main.params[ 'PING' ][ 'target8' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source9' ],
+ target=main.params[ 'PING' ][ 'target9' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source10' ],
+ target=main.params[ 'PING' ][ 'target10' ],
+ pingTime=500 )
+
+ main.step( "Create TestONTopology object" )
global ctrls
ctrls = []
count = 1
while True:
temp = ()
- if ('ip' + str(count)) in main.params['CTRL']:
- temp = temp + (getattr(main,('ONOS' + str(count))),)
- temp = temp + ("ONOS"+str(count),)
- temp = temp + (main.params['CTRL']['ip'+str(count)],)
- temp = temp + (eval(main.params['CTRL']['port'+str(count)]),)
- ctrls.append(temp)
+ if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]:
+ temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), )
+ temp = temp + ( "ONOS" + str( count ), )
+ temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], )
+ temp = temp + \
+ ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), )
+ ctrls.append( temp )
count = count + 1
else:
break
global MNTopo
- Topo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations
+ Topo = TestONTopology(
+ main.Mininet1,
+ ctrls ) # can also add Intent API info for intent operations
MNTopo = Topo
Topology_Check = main.TRUE
- main.step("Compare ONOS Topology to MN Topology")
-
- switches_results1 = main.Mininet1.compare_switches(MNTopo, json.loads(devices1))
+ main.step( "Compare ONOS Topology to MN Topology" )
+
+ switches_results1 = main.Mininet1.compare_switches(
+ MNTopo,
+ json.loads( devices1 ) )
print "switches_Result1 = ", switches_results1
- utilities.assert_equals(expect=main.TRUE, actual=switches_results1,
- onpass="ONOS1 Switches view is correct",
- onfail="ONOS1 Switches view is incorrect")
+ utilities.assert_equals( expect=main.TRUE, actual=switches_results1,
+ onpass="ONOS1 Switches view is correct",
+ onfail="ONOS1 Switches view is incorrect" )
- switches_results2 = main.Mininet1.compare_switches(MNTopo, json.loads(devices2))
- utilities.assert_equals(expect=main.TRUE, actual=switches_results2,
- onpass="ONOS2 Switches view is correct",
- onfail="ONOS2 Switches view is incorrect")
-
- switches_results3 = main.Mininet1.compare_switches(MNTopo, json.loads(devices3))
- utilities.assert_equals(expect=main.TRUE, actual=switches_results3,
- onpass="ONOS3 Switches view is correct",
- onfail="ONOS3 Switches view is incorrect")
+ switches_results2 = main.Mininet1.compare_switches(
+ MNTopo,
+ json.loads( devices2 ) )
+ utilities.assert_equals( expect=main.TRUE, actual=switches_results2,
+ onpass="ONOS2 Switches view is correct",
+ onfail="ONOS2 Switches view is incorrect" )
- '''
- ports_results1 = main.Mininet1.compare_ports(MNTopo, json.loads(ports1))
- utilities.assert_equals(expect=main.TRUE, actual=ports_results1,
+ switches_results3 = main.Mininet1.compare_switches(
+ MNTopo,
+ json.loads( devices3 ) )
+ utilities.assert_equals( expect=main.TRUE, actual=switches_results3,
+ onpass="ONOS3 Switches view is correct",
+ onfail="ONOS3 Switches view is incorrect" )
+
+ """
+ ports_results1 = main.Mininet1.compare_ports( MNTopo, json.loads( ports1 ) )
+ utilities.assert_equals( expect=main.TRUE, actual=ports_results1,
onpass="ONOS1 Ports view is correct",
- onfail="ONOS1 Ports view is incorrect")
+ onfail="ONOS1 Ports view is incorrect" )
- ports_results2 = main.Mininet1.compare_ports(MNTopo, json.loads(ports2))
- utilities.assert_equals(expect=main.TRUE, actual=ports_results2,
+ ports_results2 = main.Mininet1.compare_ports( MNTopo, json.loads( ports2 ) )
+ utilities.assert_equals( expect=main.TRUE, actual=ports_results2,
onpass="ONOS2 Ports view is correct",
- onfail="ONOS2 Ports view is incorrect")
+ onfail="ONOS2 Ports view is incorrect" )
- ports_results3 = main.Mininet1.compare_ports(MNTopo, json.loads(ports3))
- utilities.assert_equals(expect=main.TRUE, actual=ports_results3,
+ ports_results3 = main.Mininet1.compare_ports( MNTopo, json.loads( ports3 ) )
+ utilities.assert_equals( expect=main.TRUE, actual=ports_results3,
onpass="ONOS3 Ports view is correct",
- onfail="ONOS3 Ports view is incorrect")
- '''
+ onfail="ONOS3 Ports view is incorrect" )
+ """
+ links_results1 = main.Mininet1.compare_links(
+ MNTopo,
+ json.loads( links1 ) )
+ utilities.assert_equals( expect=main.TRUE, actual=links_results1,
+ onpass="ONOS1 Links view is correct",
+ onfail="ONOS1 Links view is incorrect" )
- links_results1 = main.Mininet1.compare_links(MNTopo, json.loads(links1))
- utilities.assert_equals(expect=main.TRUE, actual=links_results1,
- onpass="ONOS1 Links view is correct",
- onfail="ONOS1 Links view is incorrect")
+ links_results2 = main.Mininet1.compare_links(
+ MNTopo,
+ json.loads( links2 ) )
+ utilities.assert_equals( expect=main.TRUE, actual=links_results2,
+ onpass="ONOS2 Links view is correct",
+ onfail="ONOS2 Links view is incorrect" )
- links_results2 = main.Mininet1.compare_links(MNTopo, json.loads(links2))
- utilities.assert_equals(expect=main.TRUE, actual=links_results2,
- onpass="ONOS2 Links view is correct",
- onfail="ONOS2 Links view is incorrect")
+ links_results3 = main.Mininet1.compare_links(
+ MNTopo,
+ json.loads( links3 ) )
+ utilities.assert_equals( expect=main.TRUE, actual=links_results3,
+ onpass="ONOS2 Links view is correct",
+ onfail="ONOS2 Links view is incorrect" )
- links_results3 = main.Mininet1.compare_links(MNTopo, json.loads(links3))
- utilities.assert_equals(expect=main.TRUE, actual=links_results3,
- onpass="ONOS2 Links view is correct",
- onfail="ONOS2 Links view is incorrect")
-
#topo_result = switches_results1 and switches_results2 and switches_results3\
- #and ports_results1 and ports_results2 and ports_results3\
- #and links_results1 and links_results2 and links_results3
-
+ # and ports_results1 and ports_results2 and ports_results3\
+ # and links_results1 and links_results2 and links_results3
+
topo_result = switches_results1 and switches_results2 and switches_results3\
- and links_results1 and links_results2 and links_results3
+ and links_results1 and links_results2 and links_results3
- utilities.assert_equals(expect=main.TRUE, actual=topo_result and Link_Up and Link_Down,
- onpass="Topology Check Test successful",
- onfail="Topology Check Test NOT successful")
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=topo_result and Link_Up and Link_Down,
+ onpass="Topology Check Test successful",
+ onfail="Topology Check Test NOT successful" )
-
- def CASE8(self):
- '''
+ def CASE8( self ):
+ """
Intent removal
- '''
- main.log.report("This testcase removes host any previously added intents")
- main.log.report("__________________________________")
- main.log.info("Removing any previously installed intents")
- main.case("Removing intents")
- main.step("Obtain the intent id's")
- intent_result = main.ONOScli1.intents(json_format = False)
-
- intent_linewise = intent_result.split("\n")
+ """
+ main.log.report(
+ "This testcase removes host any previously added intents" )
+ main.log.report( "__________________________________" )
+ main.log.info( "Removing any previously installed intents" )
+ main.case( "Removing intents" )
+ main.step( "Obtain the intent id's" )
+ intent_result = main.ONOScli1.intents( json_format=False )
+
+ intent_linewise = intent_result.split( "\n" )
intentList = []
for line in intent_linewise:
- if line.startswith("id="):
- intentList.append(line)
+ if line.startswith( "id=" ):
+ intentList.append( line )
intentids = []
for line in intentList:
- intentids.append(line.split(",")[0].split("=")[1])
+ intentids.append( line.split( "," )[ 0 ].split( "=" )[ 1 ] )
for id in intentids:
- main.log.info("id = " +id)
+ main.log.info( "id = " + id )
- main.step("Iterate through the intentids list and remove each intent")
+ main.step(
+ "Iterate through the intentids list and remove each intent" )
for id in intentids:
- main.ONOScli1.remove_intent(intent_id = id)
+ main.ONOScli1.remove_intent( intent_id=id )
- intent_result = main.ONOScli1.intents(json_format = False)
- main.log.info("intent_result = " +intent_result)
+ intent_result = main.ONOScli1.intents( json_format=False )
+ main.log.info( "intent_result = " + intent_result )
case8_result = main.TRUE
-
+
i = 8
Ping_Result = main.TRUE
- while i <18 :
- main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10))
- ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
- if ping==main.TRUE:
+ while i < 18:
+ main.log.info(
+ "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
+ ping = main.Mininet1.pingHost(
+ src="h" + str( i ), target="h" + str( i + 10 ) )
+ if ping == main.TRUE:
i = 19
Ping_Result = main.TRUE
- elif ping==main.FALSE:
- i+=1
+ elif ping == main.FALSE:
+ i += 1
Ping_Result = main.FALSE
else:
- main.log.info("Unknown error")
+ main.log.info( "Unknown error" )
Ping_Result = main.ERROR
-
- #Note: If the ping result failed, that means the intents have been withdrawn correctly.
- if Ping_Result==main.TRUE:
- main.log.report("Host intents have not been withdrawn correctly")
- #main.cleanup()
- #main.exit()
- if Ping_Result==main.FALSE:
- main.log.report("Host intents have been withdrawn correctly")
+
+ # Note: If the ping result failed, that means the intents have been
+ # withdrawn correctly.
+ if Ping_Result == main.TRUE:
+ main.log.report( "Host intents have not been withdrawn correctly" )
+ # main.cleanup()
+ # main.exit()
+ if Ping_Result == main.FALSE:
+ main.log.report( "Host intents have been withdrawn correctly" )
case8_result = case8_result and Ping_Result
if case8_result == main.FALSE:
- main.log.report("Intent removal successful")
+ main.log.report( "Intent removal successful" )
else:
- main.log.report("Intent removal failed")
-
- utilities.assert_equals(expect=main.FALSE, actual=case8_result,
- onpass="Intent removal test failed",
- onfail="Intent removal test successful")
-
+ main.log.report( "Intent removal failed" )
- def CASE9(self):
- '''
+ utilities.assert_equals( expect=main.FALSE, actual=case8_result,
+ onpass="Intent removal test failed",
+ onfail="Intent removal test successful" )
+
+ def CASE9( self ):
+ """
This test case adds point intents. Make sure you run test case 8 which is host intent removal before executing this test case.
Else the host intent's flows will persist on switches and the pings would work even if there is some issue with the point intent's flows
- '''
- main.log.report("This testcase adds point intents and then does pingall")
- main.log.report("__________________________________")
- main.log.info("Adding point intents")
- main.case("Adding bidirectional point for mn hosts(h8-h18,h9-h19,h10-h20,h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)")
- main.step("Add point-to-point intents for mininet hosts h8 and h18 or ONOS hosts h8 and h12")
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003008/1", "of:0000000000006018/1")
+ """
+ main.log.report(
+ "This testcase adds point intents and then does pingall" )
+ main.log.report( "__________________________________" )
+ main.log.info( "Adding point intents" )
+ main.case(
+ "Adding bidirectional point for mn hosts(h8-h18,h9-h19,h10-h20,h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)" )
+ main.step(
+ "Add point-to-point intents for mininet hosts h8 and h18 or ONOS hosts h8 and h12" )
+ ptp_intent_result = main.ONOScli1.add_point_intent(
+ "of:0000000000003008/1",
+ "of:0000000000006018/1" )
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOScli1.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006018/1", "of:0000000000003008/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- main.step("Add point-to-point intents for mininet hosts h9 and h19 or ONOS hosts h9 and h13")
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003009/1", "of:0000000000006019/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006019/1", "of:0000000000003009/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- main.step("Add point-to-point intents for mininet hosts h10 and h20 or ONOS hosts hA and h14")
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003010/1", "of:0000000000006020/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006020/1", "of:0000000000003010/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
- main.step("Add point-to-point intents for mininet hosts h11 and h21 or ONOS hosts hB and h15")
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003011/1", "of:0000000000006021/1")
+ ptp_intent_result = main.ONOScli1.add_point_intent(
+ "of:0000000000006018/1",
+ "of:0000000000003008/1" )
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOScli1.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006021/1", "of:0000000000003011/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- main.step("Add point-to-point intents for mininet hosts h12 and h22 or ONOS hosts hC and h16")
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003012/1", "of:0000000000006022/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006022/1", "of:0000000000003012/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- main.step("Add point-to-point intents for mininet hosts h13 and h23 or ONOS hosts hD and h17")
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003013/1", "of:0000000000006023/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006023/1", "of:0000000000003013/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
- main.step("Add point-to-point intents for mininet hosts h14 and h24 or ONOS hosts hE and h18")
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003014/1", "of:0000000000006024/1")
+ main.step(
+ "Add point-to-point intents for mininet hosts h9 and h19 or ONOS hosts h9 and h13" )
+ ptp_intent_result = main.ONOScli1.add_point_intent(
+ "of:0000000000003009/1",
+ "of:0000000000006019/1" )
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOScli1.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006024/1", "of:0000000000003014/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- main.step("Add point-to-point intents for mininet hosts h15 and h25 or ONOS hosts hF and h19")
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003015/1", "of:0000000000006025/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006025/1", "of:0000000000003015/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- main.step("Add point-to-point intents for mininet hosts h16 and h26 or ONOS hosts h10 and h1A")
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003016/1", "of:0000000000006026/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006026/1", "of:0000000000003016/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
-
- main.step("Add point-to-point intents for mininet hosts h17 and h27 or ONOS hosts h11 and h1B")
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003017/1", "of:0000000000006027/1")
+ ptp_intent_result = main.ONOScli1.add_point_intent(
+ "of:0000000000006019/1",
+ "of:0000000000003009/1" )
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOScli1.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006027/1", "of:0000000000003017/1")
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ main.step(
+ "Add point-to-point intents for mininet hosts h10 and h20 or ONOS hosts hA and h14" )
+ ptp_intent_result = main.ONOScli1.add_point_intent(
+ "of:0000000000003010/1",
+ "of:0000000000006020/1" )
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOScli1.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
- print("_______________________________________________________________________________________")
+ ptp_intent_result = main.ONOScli1.add_point_intent(
+ "of:0000000000006020/1",
+ "of:0000000000003010/1" )
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOScli1.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ main.step(
+ "Add point-to-point intents for mininet hosts h11 and h21 or ONOS hosts hB and h15" )
+ ptp_intent_result = main.ONOScli1.add_point_intent(
+ "of:0000000000003011/1",
+ "of:0000000000006021/1" )
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOScli1.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ ptp_intent_result = main.ONOScli1.add_point_intent(
+ "of:0000000000006021/1",
+ "of:0000000000003011/1" )
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOScli1.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ main.step(
+ "Add point-to-point intents for mininet hosts h12 and h22 or ONOS hosts hC and h16" )
+ ptp_intent_result = main.ONOScli1.add_point_intent(
+ "of:0000000000003012/1",
+ "of:0000000000006022/1" )
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOScli1.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ ptp_intent_result = main.ONOScli1.add_point_intent(
+ "of:0000000000006022/1",
+ "of:0000000000003012/1" )
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOScli1.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ main.step(
+ "Add point-to-point intents for mininet hosts h13 and h23 or ONOS hosts hD and h17" )
+ ptp_intent_result = main.ONOScli1.add_point_intent(
+ "of:0000000000003013/1",
+ "of:0000000000006023/1" )
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOScli1.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ ptp_intent_result = main.ONOScli1.add_point_intent(
+ "of:0000000000006023/1",
+ "of:0000000000003013/1" )
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOScli1.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ main.step(
+ "Add point-to-point intents for mininet hosts h14 and h24 or ONOS hosts hE and h18" )
+ ptp_intent_result = main.ONOScli1.add_point_intent(
+ "of:0000000000003014/1",
+ "of:0000000000006024/1" )
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOScli1.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ ptp_intent_result = main.ONOScli1.add_point_intent(
+ "of:0000000000006024/1",
+ "of:0000000000003014/1" )
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOScli1.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ main.step(
+ "Add point-to-point intents for mininet hosts h15 and h25 or ONOS hosts hF and h19" )
+ ptp_intent_result = main.ONOScli1.add_point_intent(
+ "of:0000000000003015/1",
+ "of:0000000000006025/1" )
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOScli1.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ ptp_intent_result = main.ONOScli1.add_point_intent(
+ "of:0000000000006025/1",
+ "of:0000000000003015/1" )
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOScli1.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ main.step(
+ "Add point-to-point intents for mininet hosts h16 and h26 or ONOS hosts h10 and h1A" )
+ ptp_intent_result = main.ONOScli1.add_point_intent(
+ "of:0000000000003016/1",
+ "of:0000000000006026/1" )
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOScli1.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ ptp_intent_result = main.ONOScli1.add_point_intent(
+ "of:0000000000006026/1",
+ "of:0000000000003016/1" )
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOScli1.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ main.step(
+ "Add point-to-point intents for mininet hosts h17 and h27 or ONOS hosts h11 and h1B" )
+ ptp_intent_result = main.ONOScli1.add_point_intent(
+ "of:0000000000003017/1",
+ "of:0000000000006027/1" )
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOScli1.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ ptp_intent_result = main.ONOScli1.add_point_intent(
+ "of:0000000000006027/1",
+ "of:0000000000003017/1" )
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOScli1.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ print(
+ "_______________________________________________________________________________________" )
flowHandle = main.ONOScli1.flows()
- #print "flowHandle = ", flowHandle
- main.log.info("flows :" + flowHandle)
+ # print "flowHandle = ", flowHandle
+ main.log.info( "flows :" + flowHandle )
count = 1
i = 8
Ping_Result = main.TRUE
- while i <18 :
- main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10))
- ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
- if ping == main.FALSE and count <5:
- count+=1
+ while i < 18:
+ main.log.info(
+ "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
+ ping = main.Mininet1.pingHost(
+ src="h" + str( i ), target="h" + str( i + 10 ) )
+ if ping == main.FALSE and count < 5:
+ count += 1
#i = 8
Ping_Result = main.FALSE
- main.log.report("Ping between h" + str(i) + " and h" + str(i+10) + " failed. Making attempt number "+str(count) + " in 2 seconds")
- time.sleep(2)
- elif ping==main.FALSE:
- main.log.report("All ping attempts between h" + str(i) + " and h" + str(i+10) +"have failed")
- i=19
+ main.log.report( "Ping between h" +
+ str( i ) +
+ " and h" +
+ str( i +
+ 10 ) +
+ " failed. Making attempt number " +
+ str( count ) +
+ " in 2 seconds" )
+ time.sleep( 2 )
+ elif ping == main.FALSE:
+ main.log.report( "All ping attempts between h" +
+ str( i ) +
+ " and h" +
+ str( i +
+ 10 ) +
+ "have failed" )
+ i = 19
Ping_Result = main.FALSE
- elif ping==main.TRUE:
- main.log.info("Ping test between h" + str(i) + " and h" + str(i+10) + "passed!")
- i+=1
+ elif ping == main.TRUE:
+ main.log.info( "Ping test between h" +
+ str( i ) +
+ " and h" +
+ str( i +
+ 10 ) +
+ "passed!" )
+ i += 1
Ping_Result = main.TRUE
else:
- main.log.info("Unknown error")
+ main.log.info( "Unknown error" )
Ping_Result = main.ERROR
- if Ping_Result==main.FALSE:
- main.log.report("Ping all test after Point intents addition failed. Cleaning up")
- #main.cleanup()
- #main.exit()
- if Ping_Result==main.TRUE:
- main.log.report("Ping all test after Point intents addition successful")
+ if Ping_Result == main.FALSE:
+ main.log.report(
+ "Ping all test after Point intents addition failed. Cleaning up" )
+ # main.cleanup()
+ # main.exit()
+ if Ping_Result == main.TRUE:
+ main.log.report(
+ "Ping all test after Point intents addition successful" )
case8_result = Ping_Result
- utilities.assert_equals(expect=main.TRUE, actual=case8_result,
- onpass="Ping all test after Point intents addition successful",
- onfail="Ping all test after Point intents addition failed")
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case8_result,
+ onpass="Ping all test after Point intents addition successful",
+ onfail="Ping all test after Point intents addition failed" )
- def CASE31(self):
- '''
- This test case adds point intent related to SDN-IP matching on ICMP (ethertype=IPV4, ipProto=1)
- '''
+ def CASE31( self ):
+ """
+ This test case adds point intent related to SDN-IP matching on ICMP ( ethertype=IPV4, ipProto=1 )
+ """
import json
- main.log.report("This test case adds point intent related to SDN-IP matching on ICMP")
- main.case("Adding bidirectional point intent related to SDN-IP matching on ICMP")
- main.step("Adding bidirectional point intent")
- #add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32 --ethType=IPV4 --ipProto=1 of:0000000000003008/1 of:0000000000006018/1
-
- hosts_json = json.loads(main.ONOScli1.hosts())
- for i in range(8,11):
- main.log.info("Adding point intent between h"+str(i)+" and h"+str(i+10))
- host1 = "00:00:00:00:00:" + str(hex(i)[2:]).zfill(2).upper()
- host2 = "00:00:00:00:00:" + str(hex(i+10)[2:]).zfill(2).upper()
- host1_id = main.ONOScli1.get_host(host1)['id']
- host2_id = main.ONOScli1.get_host(host2)['id']
+ main.log.report(
+ "This test case adds point intent related to SDN-IP matching on ICMP" )
+ main.case(
+ "Adding bidirectional point intent related to SDN-IP matching on ICMP" )
+ main.step( "Adding bidirectional point intent" )
+ # add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32
+ # --ethType=IPV4 --ipProto=1 of:0000000000003008/1
+ # of:0000000000006018/1
+
+ hosts_json = json.loads( main.ONOScli1.hosts() )
+ for i in range( 8, 11 ):
+ main.log.info(
+ "Adding point intent between h" + str( i ) + " and h" + str( i + 10 ) )
+ host1 = "00:00:00:00:00:" + \
+ str( hex( i )[ 2: ] ).zfill( 2 ).upper()
+ host2 = "00:00:00:00:00:" + \
+ str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
+ host1_id = main.ONOScli1.get_host( host1 )[ 'id' ]
+ host2_id = main.ONOScli1.get_host( host2 )[ 'id' ]
for host in hosts_json:
- if host['id'] == host1_id:
- ip1 = host['ips'][0]
- ip1 = str(ip1+"/32")
- device1 = host['location']['device']
- device1 = str(device1+"/1")
- elif host['id'] == host2_id:
- ip2 = str(host['ips'][0])+"/32"
- device2 = host['location']["device"]
- device2 = str(device2+"/1")
-
- p_intent_result1 = main.ONOScli1.add_point_intent(ingress_device=device1, egress_device=device2, ipSrc=ip1, ipDst=ip2,
- ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['icmpProto'])
-
- get_intent_result = main.ONOScli1.intents(json_format = False)
- main.log.info(get_intent_result)
-
- p_intent_result2 = main.ONOScli1.add_point_intent(ingress_device=device2, egress_device=device1, ipSrc=ip2, ipDst=ip1,
- ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['icmpProto'])
-
- get_intent_result = main.ONOScli1.intents(json_format = False)
- main.log.info(get_intent_result)
- if (p_intent_result1 and p_intent_result2) == main.TRUE:
+ if host[ 'id' ] == host1_id:
+ ip1 = host[ 'ips' ][ 0 ]
+ ip1 = str( ip1 + "/32" )
+ device1 = host[ 'location' ][ 'device' ]
+ device1 = str( device1 + "/1" )
+ elif host[ 'id' ] == host2_id:
+ ip2 = str( host[ 'ips' ][ 0 ] ) + "/32"
+ device2 = host[ 'location' ][ "device" ]
+ device2 = str( device2 + "/1" )
+
+ p_intent_result1 = main.ONOScli1.add_point_intent(
+ ingress_device=device1,
+ egress_device=device2,
+ ipSrc=ip1,
+ ipDst=ip2,
+ ethType=main.params[ 'SDNIP' ][ 'ethType' ],
+ ipProto=main.params[ 'SDNIP' ][ 'icmpProto' ] )
+
+ get_intent_result = main.ONOScli1.intents( json_format=False )
+ main.log.info( get_intent_result )
+
+ p_intent_result2 = main.ONOScli1.add_point_intent(
+ ingress_device=device2,
+ egress_device=device1,
+ ipSrc=ip2,
+ ipDst=ip1,
+ ethType=main.params[ 'SDNIP' ][ 'ethType' ],
+ ipProto=main.params[ 'SDNIP' ][ 'icmpProto' ] )
+
+ get_intent_result = main.ONOScli1.intents( json_format=False )
+ main.log.info( get_intent_result )
+ if ( p_intent_result1 and p_intent_result2 ) == main.TRUE:
#get_intent_result = main.ONOScli1.intents()
- #main.log.info(get_intent_result)
- main.log.info("Point intent related to SDN-IP matching on ICMP install successful")
-
- time.sleep(15)
- get_intent_result = main.ONOScli1.intents(json_format = False)
- main.log.info("intents = "+ get_intent_result)
+ # main.log.info( get_intent_result )
+ main.log.info(
+ "Point intent related to SDN-IP matching on ICMP install successful" )
+
+ time.sleep( 15 )
+ get_intent_result = main.ONOScli1.intents( json_format=False )
+ main.log.info( "intents = " + get_intent_result )
get_flows_result = main.ONOScli1.flows()
- main.log.info("flows = " + get_flows_result)
-
+ main.log.info( "flows = " + get_flows_result )
+
count = 1
i = 8
Ping_Result = main.TRUE
- while i <11 :
- main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10))
- ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
- if ping == main.FALSE and count <3:
- count+=1
+ while i < 11:
+ main.log.info(
+ "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
+ ping = main.Mininet1.pingHost(
+ src="h" + str( i ), target="h" + str( i + 10 ) )
+ if ping == main.FALSE and count < 3:
+ count += 1
#i = 8
Ping_Result = main.FALSE
- main.log.report("Ping between h" + str(i) + " and h" + str(i+10) + " failed. Making attempt number "+str(count) + " in 2 seconds")
- time.sleep(2)
- elif ping==main.FALSE:
- main.log.report("All ping attempts between h" + str(i) + " and h" + str(i+10) +"have failed")
- i=19
+ main.log.report( "Ping between h" +
+ str( i ) +
+ " and h" +
+ str( i +
+ 10 ) +
+ " failed. Making attempt number " +
+ str( count ) +
+ " in 2 seconds" )
+ time.sleep( 2 )
+ elif ping == main.FALSE:
+ main.log.report( "All ping attempts between h" +
+ str( i ) +
+ " and h" +
+ str( i +
+ 10 ) +
+ "have failed" )
+ i = 19
Ping_Result = main.FALSE
- elif ping==main.TRUE:
- main.log.info("Ping test between h" + str(i) + " and h" + str(i+10) + "passed!")
- i+=1
+ elif ping == main.TRUE:
+ main.log.info( "Ping test between h" +
+ str( i ) +
+ " and h" +
+ str( i +
+ 10 ) +
+ "passed!" )
+ i += 1
Ping_Result = main.TRUE
else:
- main.log.info("Unknown error")
+ main.log.info( "Unknown error" )
Ping_Result = main.ERROR
- if Ping_Result==main.FALSE:
- main.log.report("Ping test after Point intents related to SDN-IP matching on ICMP failed.")
- #main.cleanup()
- #main.exit()
- if Ping_Result==main.TRUE:
- main.log.report("Ping all test after Point intents related to SDN-IP matching on ICMP successful")
-
+ if Ping_Result == main.FALSE:
+ main.log.report(
+ "Ping test after Point intents related to SDN-IP matching on ICMP failed." )
+ # main.cleanup()
+ # main.exit()
+ if Ping_Result == main.TRUE:
+ main.log.report(
+ "Ping all test after Point intents related to SDN-IP matching on ICMP successful" )
+
case31_result = Ping_Result and p_intent_result1 and p_intent_result2
- utilities.assert_equals(expect=main.TRUE, actual=case31_result,
- onpass="Point intent related to SDN-IP matching on ICMP and ping test successful",
- onfail="Point intent related to SDN-IP matching on ICMP and ping test failed")
-
- def CASE32(self):
- '''
- This test case adds point intent related to SDN-IP matching on TCP (ethertype=IPV4, ipProto=6, DefaultPort for iperf=5001)
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case31_result,
+ onpass="Point intent related to SDN-IP matching on ICMP and ping test successful",
+ onfail="Point intent related to SDN-IP matching on ICMP and ping test failed" )
+
+ def CASE32( self ):
+ """
+ This test case adds point intent related to SDN-IP matching on TCP ( ethertype=IPV4, ipProto=6, DefaultPort for iperf=5001 )
Note: Although BGP port is 179, we are using 5001 because iperf is used for verifying and iperf's default port is 5001
- '''
+ """
import json
- main.log.report("This test case adds point intent related to SDN-IP matching on TCP")
- main.case("Adding bidirectional point intent related to SDN-IP matching on TCP")
- main.step("Adding bidirectional point intent")
+ main.log.report(
+ "This test case adds point intent related to SDN-IP matching on TCP" )
+ main.case(
+ "Adding bidirectional point intent related to SDN-IP matching on TCP" )
+ main.step( "Adding bidirectional point intent" )
"""
add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32 --ethType=IPV4 --ipProto=6 --tcpDst=5001 of:0000000000003008/1 of:0000000000006018/1
add-point-intent --ipSrc=10.0.0.18/32 --ipDst=10.0.0.8/32 --ethType=IPV4 --ipProto=6 --tcpDst=5001 of:0000000000006018/1 of:0000000000003008/1
-
+
add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32 --ethType=IPV4 --ipProto=6 --tcpSrc=5001 of:0000000000003008/1 of:0000000000006018/1
add-point-intent --ipSrc=10.0.0.18/32 --ipDst=10.0.0.8/32 --ethType=IPV4 --ipProto=6 --tcpSrc=5001 of:0000000000006018/1 of:0000000000003008/1
- """
-
- hosts_json = json.loads(main.ONOScli1.hosts())
- for i in range(8,9):
- main.log.info("Adding point intent between h"+str(i)+" and h"+str(i+10))
- host1 = "00:00:00:00:00:" + str(hex(i)[2:]).zfill(2).upper()
- host2 = "00:00:00:00:00:" + str(hex(i+10)[2:]).zfill(2).upper()
- host1_id = main.ONOScli1.get_host(host1)['id']
- host2_id = main.ONOScli1.get_host(host2)['id']
+ """
+ hosts_json = json.loads( main.ONOScli1.hosts() )
+ for i in range( 8, 9 ):
+ main.log.info(
+ "Adding point intent between h" + str( i ) + " and h" + str( i + 10 ) )
+ host1 = "00:00:00:00:00:" + \
+ str( hex( i )[ 2: ] ).zfill( 2 ).upper()
+ host2 = "00:00:00:00:00:" + \
+ str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
+ host1_id = main.ONOScli1.get_host( host1 )[ 'id' ]
+ host2_id = main.ONOScli1.get_host( host2 )[ 'id' ]
for host in hosts_json:
- if host['id'] == host1_id:
- ip1 = host['ips'][0]
- ip1 = str(ip1+"/32")
- device1 = host['location']['device']
- device1 = str(device1+"/1")
- elif host['id'] == host2_id:
- ip2 = str(host['ips'][0])+"/32"
- device2 = host['location']["device"]
- device2 = str(device2+"/1")
-
- p_intent_result1 = main.ONOScli1.add_point_intent(ingress_device=device1, egress_device=device2, ipSrc=ip1, ipDst=ip2,
- ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['tcpProto'], tcpDst=main.params['SDNIP']['dstPort'])
- p_intent_result2 = main.ONOScli1.add_point_intent(ingress_device=device2, egress_device=device1, ipSrc=ip2, ipDst=ip1,
- ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['tcpProto'], tcpDst=main.params['SDNIP']['dstPort'])
+ if host[ 'id' ] == host1_id:
+ ip1 = host[ 'ips' ][ 0 ]
+ ip1 = str( ip1 + "/32" )
+ device1 = host[ 'location' ][ 'device' ]
+ device1 = str( device1 + "/1" )
+ elif host[ 'id' ] == host2_id:
+ ip2 = str( host[ 'ips' ][ 0 ] ) + "/32"
+ device2 = host[ 'location' ][ "device" ]
+ device2 = str( device2 + "/1" )
- p_intent_result3 = main.ONOScli1.add_point_intent(ingress_device=device1, egress_device=device2, ipSrc=ip1, ipDst=ip2,
- ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['tcpProto'], tcpSrc=main.params['SDNIP']['srcPort'])
- p_intent_result4 = main.ONOScli1.add_point_intent(ingress_device=device2, egress_device=device1, ipSrc=ip2, ipDst=ip1,
- ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['tcpProto'], tcpSrc=main.params['SDNIP']['srcPort'])
+ p_intent_result1 = main.ONOScli1.add_point_intent(
+ ingress_device=device1,
+ egress_device=device2,
+ ipSrc=ip1,
+ ipDst=ip2,
+ ethType=main.params[ 'SDNIP' ][ 'ethType' ],
+ ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
+ tcpDst=main.params[ 'SDNIP' ][ 'dstPort' ] )
+ p_intent_result2 = main.ONOScli1.add_point_intent(
+ ingress_device=device2,
+ egress_device=device1,
+ ipSrc=ip2,
+ ipDst=ip1,
+ ethType=main.params[ 'SDNIP' ][ 'ethType' ],
+ ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
+ tcpDst=main.params[ 'SDNIP' ][ 'dstPort' ] )
+
+ p_intent_result3 = main.ONOScli1.add_point_intent(
+ ingress_device=device1,
+ egress_device=device2,
+ ipSrc=ip1,
+ ipDst=ip2,
+ ethType=main.params[ 'SDNIP' ][ 'ethType' ],
+ ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
+ tcpSrc=main.params[ 'SDNIP' ][ 'srcPort' ] )
+ p_intent_result4 = main.ONOScli1.add_point_intent(
+ ingress_device=device2,
+ egress_device=device1,
+ ipSrc=ip2,
+ ipDst=ip1,
+ ethType=main.params[ 'SDNIP' ][ 'ethType' ],
+ ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
+ tcpSrc=main.params[ 'SDNIP' ][ 'srcPort' ] )
p_intent_result = p_intent_result1 and p_intent_result2 and p_intent_result3 and p_intent_result4
- if p_intent_result ==main.TRUE:
- get_intent_result = main.ONOScli1.intents(json_format = False)
- main.log.info(get_intent_result)
- main.log.info("Point intent related to SDN-IP matching on TCP install successful")
-
- iperf_result = main.Mininet1.iperf('h8', 'h18')
- if iperf_result == main.TRUE:
- main.log.report("iperf test successful")
- else:
- main.log.report("iperf test failed")
+ if p_intent_result == main.TRUE:
+ get_intent_result = main.ONOScli1.intents( json_format=False )
+ main.log.info( get_intent_result )
+ main.log.info(
+ "Point intent related to SDN-IP matching on TCP install successful" )
+ iperf_result = main.Mininet1.iperf( 'h8', 'h18' )
+ if iperf_result == main.TRUE:
+ main.log.report( "iperf test successful" )
+ else:
+ main.log.report( "iperf test failed" )
case32_result = p_intent_result and iperf_result
- utilities.assert_equals(expect=main.TRUE, actual=case32_result,
- onpass="Ping all test after Point intents addition related to SDN-IP on TCP match successful",
- onfail="Ping all test after Point intents addition related to SDN-IP on TCP match failed")
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case32_result,
+ onpass="Ping all test after Point intents addition related to SDN-IP on TCP match successful",
+ onfail="Ping all test after Point intents addition related to SDN-IP on TCP match failed" )
-
- def CASE33(self):
- '''
- This test case adds multipoint to singlepoint intent related to SDN-IP matching on destination ip and the action is to rewrite the mac address
+ def CASE33( self ):
+ """
+ This test case adds multipoint to singlepoint intent related to SDN-IP matching on destination ip and the action is to rewrite the mac address
Here the mac address to be rewritten is the mac address of the egress device
- '''
+ """
import json
import time
- main.log.report("This test case adds multipoint to singlepoint intent related to SDN-IP matching on destination ip and rewrite mac address action")
- main.case("Adding multipoint to singlepoint intent related to SDN-IP matching on destination ip")
- main.step("Adding bidirectional multipoint to singlepoint intent")
+ main.log.report(
+ "This test case adds multipoint to singlepoint intent related to SDN-IP matching on destination ip and rewrite mac address action" )
+ main.case(
+ "Adding multipoint to singlepoint intent related to SDN-IP matching on destination ip" )
+ main.step( "Adding bidirectional multipoint to singlepoint intent" )
"""
add-multi-to-single-intent --ipDst=10.0.3.0/24 --setEthDst=00:00:00:00:00:12 of:0000000000003008/1 0000000000003009/1 of:0000000000006018/1
-
- add-multi-to-single-intent --ipDst=10.0.1.0/24 --setEthDst=00:00:00:00:00:08 of:0000000000006018/1 0000000000003009/1 of:0000000000003008/1
- """
-
- main.case("Installing multipoint to single point intent with rewrite mac address")
- main.step("Uninstalling proxy arp app")
- #Unistall onos-app-proxyarp app to disable reactive forwarding
- appUninstall_result1 = main.ONOScli1.feature_uninstall("onos-app-proxyarp")
- appUninstall_result2 = main.ONOScli2.feature_uninstall("onos-app-proxyarp")
- appUninstall_result3 = main.ONOScli3.feature_uninstall("onos-app-proxyarp")
- main.log.info("onos-app-proxyarp uninstalled")
- main.step("Changing ipaddress of hosts h8,h9 and h18")
- main.Mininet1.changeIP(host='h8', intf='h8-eth0', newIP='10.0.1.1', newNetmask='255.255.255.0')
- main.Mininet1.changeIP(host='h9', intf='h9-eth0', newIP='10.0.2.1', newNetmask='255.255.255.0')
- main.Mininet1.changeIP(host='h10', intf='h10-eth0', newIP='10.0.3.1', newNetmask='255.255.255.0')
+ add-multi-to-single-intent --ipDst=10.0.1.0/24 --setEthDst=00:00:00:00:00:08 of:0000000000006018/1 0000000000003009/1 of:0000000000003008/1
+ """
+ main.case(
+ "Installing multipoint to single point intent with rewrite mac address" )
+ main.step( "Uninstalling proxy arp app" )
+ # Unistall onos-app-proxyarp app to disable reactive forwarding
+ appUninstall_result1 = main.ONOScli1.feature_uninstall(
+ "onos-app-proxyarp" )
+ appUninstall_result2 = main.ONOScli2.feature_uninstall(
+ "onos-app-proxyarp" )
+ appUninstall_result3 = main.ONOScli3.feature_uninstall(
+ "onos-app-proxyarp" )
+ main.log.info( "onos-app-proxyarp uninstalled" )
- main.step("Changing default gateway of hosts h8,h9 and h18")
- main.Mininet1.changeDefaultGateway(host='h8', newGW='10.0.1.254')
- main.Mininet1.changeDefaultGateway(host='h9', newGW='10.0.2.254')
- main.Mininet1.changeDefaultGateway(host='h10', newGW='10.0.3.254')
+ main.step( "Changing ipaddress of hosts h8,h9 and h18" )
+ main.Mininet1.changeIP(
+ host='h8',
+ intf='h8-eth0',
+ newIP='10.0.1.1',
+ newNetmask='255.255.255.0' )
+ main.Mininet1.changeIP(
+ host='h9',
+ intf='h9-eth0',
+ newIP='10.0.2.1',
+ newNetmask='255.255.255.0' )
+ main.Mininet1.changeIP(
+ host='h10',
+ intf='h10-eth0',
+ newIP='10.0.3.1',
+ newNetmask='255.255.255.0' )
- main.step("Assigning random mac address to the default gateways since proxyarp app is uninstalled")
- main.Mininet1.addStaticMACAddress(host='h8', GW='10.0.1.254', macaddr='00:00:00:00:11:11')
- main.Mininet1.addStaticMACAddress(host='h9', GW='10.0.2.254', macaddr='00:00:00:00:22:22')
- main.Mininet1.addStaticMACAddress(host='h10', GW='10.0.3.254', macaddr='00:00:00:00:33:33')
-
- main.step("Verify static gateway and MAC address assignment")
- main.Mininet1.verifyStaticGWandMAC(host='h8')
- main.Mininet1.verifyStaticGWandMAC(host='h9')
- main.Mininet1.verifyStaticGWandMAC(host='h10')
-
- main.step("Adding multipoint to singlepoint intent")
- p_intent_result1 = main.ONOScli1.add_multipoint_to_singlepoint_intent(ingress_device1=main.params['MULTIPOINT_INTENT']['device1'], ingress_device2=main.params['MULTIPOINT_INTENT']['device2'],
- egress_device=main.params['MULTIPOINT_INTENT']['device3'], ipDst=main.params['MULTIPOINT_INTENT']['ip1'], setEthDst=main.params['MULTIPOINT_INTENT']['mac1'])
-
- p_intent_result2 = main.ONOScli1.add_multipoint_to_singlepoint_intent(ingress_device1=main.params['MULTIPOINT_INTENT']['device3'], ingress_device2=main.params['MULTIPOINT_INTENT']['device2'],
- egress_device=main.params['MULTIPOINT_INTENT']['device1'], ipDst=main.params['MULTIPOINT_INTENT']['ip2'], setEthDst=main.params['MULTIPOINT_INTENT']['mac2'])
+ main.step( "Changing default gateway of hosts h8,h9 and h18" )
+ main.Mininet1.changeDefaultGateway( host='h8', newGW='10.0.1.254' )
+ main.Mininet1.changeDefaultGateway( host='h9', newGW='10.0.2.254' )
+ main.Mininet1.changeDefaultGateway( host='h10', newGW='10.0.3.254' )
+ main.step(
+ "Assigning random mac address to the default gateways since proxyarp app is uninstalled" )
+ main.Mininet1.addStaticMACAddress(
+ host='h8',
+ GW='10.0.1.254',
+ macaddr='00:00:00:00:11:11' )
+ main.Mininet1.addStaticMACAddress(
+ host='h9',
+ GW='10.0.2.254',
+ macaddr='00:00:00:00:22:22' )
+ main.Mininet1.addStaticMACAddress(
+ host='h10',
+ GW='10.0.3.254',
+ macaddr='00:00:00:00:33:33' )
- get_intent_result = main.ONOScli1.intents(json_format = False)
- main.log.info("intents = "+ get_intent_result)
-
- time.sleep(10)
- get_flows_result = main.ONOScli1.flows(json_format = False)
- main.log.info("flows = " + get_flows_result)
+ main.step( "Verify static gateway and MAC address assignment" )
+ main.Mininet1.verifyStaticGWandMAC( host='h8' )
+ main.Mininet1.verifyStaticGWandMAC( host='h9' )
+ main.Mininet1.verifyStaticGWandMAC( host='h10' )
+
+ main.step( "Adding multipoint to singlepoint intent" )
+ p_intent_result1 = main.ONOScli1.add_multipoint_to_singlepoint_intent(
+ ingress_device1=main.params[ 'MULTIPOINT_INTENT' ][ 'device1' ],
+ ingress_device2=main.params[ 'MULTIPOINT_INTENT' ][ 'device2' ],
+ egress_device=main.params[ 'MULTIPOINT_INTENT' ][ 'device3' ],
+ ipDst=main.params[ 'MULTIPOINT_INTENT' ][ 'ip1' ],
+ setEthDst=main.params[ 'MULTIPOINT_INTENT' ][ 'mac1' ] )
+
+ p_intent_result2 = main.ONOScli1.add_multipoint_to_singlepoint_intent(
+ ingress_device1=main.params[ 'MULTIPOINT_INTENT' ][ 'device3' ],
+ ingress_device2=main.params[ 'MULTIPOINT_INTENT' ][ 'device2' ],
+ egress_device=main.params[ 'MULTIPOINT_INTENT' ][ 'device1' ],
+ ipDst=main.params[ 'MULTIPOINT_INTENT' ][ 'ip2' ],
+ setEthDst=main.params[ 'MULTIPOINT_INTENT' ][ 'mac2' ] )
+
+ get_intent_result = main.ONOScli1.intents( json_format=False )
+ main.log.info( "intents = " + get_intent_result )
+
+ time.sleep( 10 )
+ get_flows_result = main.ONOScli1.flows( json_format=False )
+ main.log.info( "flows = " + get_flows_result )
count = 1
i = 8
Ping_Result = main.TRUE
-
- main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+2))
- ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+2))
- if ping == main.FALSE and count <3:
- count+=1
+
+ main.log.info( "\n\nh" + str( i ) + " is Pinging h" + str( i + 2 ) )
+ ping = main.Mininet1.pingHost(
+ src="h" + str( i ), target="h" + str( i + 2 ) )
+ if ping == main.FALSE and count < 3:
+ count += 1
Ping_Result = main.FALSE
- main.log.report("Ping between h" + str(i) + " and h" + str(i+2) + " failed. Making attempt number "+str(count) + " in 2 seconds")
- time.sleep(2)
- elif ping==main.FALSE:
- main.log.report("All ping attempts between h" + str(i) + " and h" + str(i+10) +"have failed")
+ main.log.report( "Ping between h" +
+ str( i ) +
+ " and h" +
+ str( i +
+ 2 ) +
+ " failed. Making attempt number " +
+ str( count ) +
+ " in 2 seconds" )
+ time.sleep( 2 )
+ elif ping == main.FALSE:
+ main.log.report( "All ping attempts between h" +
+ str( i ) +
+ " and h" +
+ str( i +
+ 10 ) +
+ "have failed" )
Ping_Result = main.FALSE
- elif ping==main.TRUE:
- main.log.info("Ping test between h" + str(i) + " and h" + str(i+2) + "passed!")
+ elif ping == main.TRUE:
+ main.log.info( "Ping test between h" +
+ str( i ) +
+ " and h" +
+ str( i +
+ 2 ) +
+ "passed!" )
Ping_Result = main.TRUE
else:
- main.log.info("Unknown error")
+ main.log.info( "Unknown error" )
Ping_Result = main.ERROR
-
- if Ping_Result==main.FALSE:
- main.log.report("Ping test failed.")
- #main.cleanup()
- #main.exit()
- if Ping_Result==main.TRUE:
- main.log.report("Ping all successful")
+ if Ping_Result == main.FALSE:
+ main.log.report( "Ping test failed." )
+ # main.cleanup()
+ # main.exit()
+ if Ping_Result == main.TRUE:
+ main.log.report( "Ping all successful" )
p_intent_result = p_intent_result1 and p_intent_result2
- if p_intent_result ==main.TRUE:
- main.log.info("Multi point intent with rewrite mac address installation successful")
+ if p_intent_result == main.TRUE:
+ main.log.info(
+ "Multi point intent with rewrite mac address installation successful" )
else:
- main.log.info("Multi point intent with rewrite mac address installation failed")
-
+ main.log.info(
+ "Multi point intent with rewrite mac address installation failed" )
+
case33_result = p_intent_result and Ping_Result
- utilities.assert_equals(expect=main.TRUE, actual=case33_result,
- onpass="Ping all test after multipoint to single point intent addition with rewrite mac address successful",
- onfail="Ping all test after multipoint to single point intent addition with rewrite mac address failed")
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case33_result,
+ onpass="Ping all test after multipoint to single point intent addition with rewrite mac address successful",
+ onfail="Ping all test after multipoint to single point intent addition with rewrite mac address failed" )
diff --git a/TestON/tests/MultiProd13/MultiProd13.py b/TestON/tests/MultiProd13/MultiProd13.py
old mode 100755
new mode 100644
index 1276d33..f26cd5c
--- a/TestON/tests/MultiProd13/MultiProd13.py
+++ b/TestON/tests/MultiProd13/MultiProd13.py
@@ -1,6 +1,6 @@
-#Testing the basic functionality of ONOS Next
-#For sanity and driver functionality excercises only.
+# Testing the basic functionality of ONOS Next
+# For sanity and driver functionality excercises only.
import time
import sys
@@ -9,527 +9,648 @@
import time
import json
-time.sleep(1)
+time.sleep( 1 )
+
+
class MultiProd13:
- def __init__(self):
+
+ def __init__( self ):
self.default = ''
- def CASE1(self, main):
- '''
+ def CASE1( self, main ):
+ """
Startup sequence:
cell <name>
onos-verify-cell
- onos-remove-raft-logs
+ onos-remove-raft-logs
git pull
mvn clean install
onos-package
onos-install -f
onos-wait-for-start
- '''
-
- cell_name = main.params['ENV']['cellName']
- ONOS1_ip = main.params['CTRL']['ip1']
- ONOS2_ip = main.params['CTRL']['ip2']
- ONOS3_ip = main.params['CTRL']['ip3']
- ONOS1_port = main.params['CTRL']['port1']
- ONOS2_port = main.params['CTRL']['port2']
- ONOS3_port = main.params['CTRL']['port3']
-
- main.case("Setting up test environment")
- main.log.report("This testcase is testing setting up test environment")
- main.log.report("__________________________________")
-
- main.step("Applying cell variable to environment")
- cell_result1 = main.ONOSbench.set_cell(cell_name)
- #cell_result2 = main.ONOScli1.set_cell(cell_name)
- #cell_result3 = main.ONOScli2.set_cell(cell_name)
- #cell_result4 = main.ONOScli3.set_cell(cell_name)
- verify_result = main.ONOSbench.verify_cell()
+ """
+ cell_name = main.params[ 'ENV' ][ 'cellName' ]
+ ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+ ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
+ ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
+ ONOS1_port = main.params[ 'CTRL' ][ 'port1' ]
+ ONOS2_port = main.params[ 'CTRL' ][ 'port2' ]
+ ONOS3_port = main.params[ 'CTRL' ][ 'port3' ]
+
+ main.case( "Setting up test environment" )
+ main.log.report(
+ "This testcase is testing setting up test environment" )
+ main.log.report( "__________________________________" )
+
+ main.step( "Applying cell variable to environment" )
+ cell_result1 = main.ONOSbench.set_cell( cell_name )
+ #cell_result2 = main.ONOScli1.set_cell( cell_name )
+ #cell_result3 = main.ONOScli2.set_cell( cell_name )
+ #cell_result4 = main.ONOScli3.set_cell( cell_name )
+ verify_result = main.ONOSbench.verify_cell()
cell_result = cell_result1
- main.step("Removing raft logs before a clen installation of ONOS")
- remove_log_Result = main.ONOSbench.onos_remove_raft_logs()
+ main.step( "Removing raft logs before a clen installation of ONOS" )
+ remove_log_Result = main.ONOSbench.onos_remove_raft_logs()
- main.step("Git checkout and pull master and get version")
- main.ONOSbench.git_checkout("master")
+ main.step( "Git checkout and pull master and get version" )
+ main.ONOSbench.git_checkout( "master" )
git_pull_result = main.ONOSbench.git_pull()
print "git_pull_result = ", git_pull_result
- version_result = main.ONOSbench.get_version(report=True)
+ version_result = main.ONOSbench.get_version( report=True )
if git_pull_result == 1:
- main.step("Using mvn clean & install")
+ main.step( "Using mvn clean & install" )
clean_install_result = main.ONOSbench.clean_install()
- #clean_install_result = main.TRUE
+ #clean_install_result = main.TRUE
- main.step("Creating ONOS package")
+ main.step( "Creating ONOS package" )
package_result = main.ONOSbench.onos_package()
- #main.step("Creating a cell")
- #cell_create_result = main.ONOSbench.create_cell_file(**************)
+ #main.step( "Creating a cell" )
+ # cell_create_result = main.ONOSbench.create_cell_file( **************
+ # )
- main.step("Installing ONOS package")
- onos1_install_result = main.ONOSbench.onos_install(options="-f", node=ONOS1_ip)
- onos2_install_result = main.ONOSbench.onos_install(options="-f", node=ONOS2_ip)
- onos3_install_result = main.ONOSbench.onos_install(options="-f", node=ONOS3_ip)
- onos_install_result = onos1_install_result and onos2_install_result and onos3_install_result
+ main.step( "Installing ONOS package" )
+ onos1_install_result = main.ONOSbench.onos_install(
+ options="-f",
+ node=ONOS1_ip )
+ onos2_install_result = main.ONOSbench.onos_install(
+ options="-f",
+ node=ONOS2_ip )
+ onos3_install_result = main.ONOSbench.onos_install(
+ options="-f",
+ node=ONOS3_ip )
+ onos_install_result = onos1_install_result and onos2_install_result and onos3_install_result
if onos_install_result == main.TRUE:
- main.log.report("Installing ONOS package successful")
+ main.log.report( "Installing ONOS package successful" )
else:
- main.log.report("Installing ONOS package failed")
-
- onos1_isup = main.ONOSbench.isup(ONOS1_ip)
- onos2_isup = main.ONOSbench.isup(ONOS2_ip)
- onos3_isup = main.ONOSbench.isup(ONOS3_ip)
+ main.log.report( "Installing ONOS package failed" )
+
+ onos1_isup = main.ONOSbench.isup( ONOS1_ip )
+ onos2_isup = main.ONOSbench.isup( ONOS2_ip )
+ onos3_isup = main.ONOSbench.isup( ONOS3_ip )
onos_isup = onos1_isup and onos2_isup and onos3_isup
if onos_isup == main.TRUE:
- main.log.report("ONOS instances are up and ready")
+ main.log.report( "ONOS instances are up and ready" )
else:
- main.log.report("ONOS instances may not be up")
+ main.log.report( "ONOS instances may not be up" )
- main.step("Starting ONOS service")
+ main.step( "Starting ONOS service" )
start_result = main.TRUE
- #start_result = main.ONOSbench.onos_start(ONOS1_ip)
- startcli1 = main.ONOScli1.start_onos_cli(ONOS_ip = ONOS1_ip)
- startcli2 = main.ONOScli2.start_onos_cli(ONOS_ip = ONOS2_ip)
- startcli3 = main.ONOScli3.start_onos_cli(ONOS_ip = ONOS3_ip)
+ #start_result = main.ONOSbench.onos_start( ONOS1_ip )
+ startcli1 = main.ONOScli1.start_onos_cli( ONOS_ip=ONOS1_ip )
+ startcli2 = main.ONOScli2.start_onos_cli( ONOS_ip=ONOS2_ip )
+ startcli3 = main.ONOScli3.start_onos_cli( ONOS_ip=ONOS3_ip )
print startcli1
print startcli2
print startcli3
-
- case1_result = (package_result and\
- cell_result and verify_result and onos_install_result and\
- onos_isup and start_result )
- utilities.assert_equals(expect=main.TRUE, actual=case1_result,
- onpass="Test startup successful",
- onfail="Test startup NOT successful")
- def CASE11(self, main):
- '''
+ case1_result = ( package_result and
+ cell_result and verify_result and onos_install_result and
+ onos_isup and start_result )
+ utilities.assert_equals( expect=main.TRUE, actual=case1_result,
+ onpass="Test startup successful",
+ onfail="Test startup NOT successful" )
+
+ def CASE11( self, main ):
+ """
Cleanup sequence:
onos-service <node_ip> stop
onos-uninstall
TODO: Define rest of cleanup
-
- '''
- ONOS1_ip = main.params['CTRL']['ip1']
- ONOS2_ip = main.params['CTRL']['ip2']
- ONOS3_ip = main.params['CTRL']['ip3']
-
- main.case("Cleaning up test environment")
+ """
+ ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+ ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
+ ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
- main.step("Testing ONOS kill function")
- kill_result1 = main.ONOSbench.onos_kill(ONOS1_ip)
- kill_result2 = main.ONOSbench.onos_kill(ONOS2_ip)
- kill_result3 = main.ONOSbench.onos_kill(ONOS3_ip)
-
- main.step("Stopping ONOS service")
- stop_result1 = main.ONOSbench.onos_stop(ONOS1_ip)
- stop_result2 = main.ONOSbench.onos_stop(ONOS2_ip)
- stop_result3 = main.ONOSbench.onos_stop(ONOS3_ip)
+ main.case( "Cleaning up test environment" )
- main.step("Uninstalling ONOS service")
+ main.step( "Testing ONOS kill function" )
+ kill_result1 = main.ONOSbench.onos_kill( ONOS1_ip )
+ kill_result2 = main.ONOSbench.onos_kill( ONOS2_ip )
+ kill_result3 = main.ONOSbench.onos_kill( ONOS3_ip )
+
+ main.step( "Stopping ONOS service" )
+ stop_result1 = main.ONOSbench.onos_stop( ONOS1_ip )
+ stop_result2 = main.ONOSbench.onos_stop( ONOS2_ip )
+ stop_result3 = main.ONOSbench.onos_stop( ONOS3_ip )
+
+ main.step( "Uninstalling ONOS service" )
uninstall_result = main.ONOSbench.onos_uninstall()
- def CASE3(self, main):
- '''
+ def CASE3( self, main ):
+ """
Test 'onos' command and its functionality in driver
- '''
-
- ONOS1_ip = main.params['CTRL']['ip1']
- ONOS2_ip = main.params['CTRL']['ip2']
- ONOS3_ip = main.params['CTRL']['ip3']
+ """
+ ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+ ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
+ ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
- main.case("Testing 'onos' command")
+ main.case( "Testing 'onos' command" )
- main.step("Sending command 'onos -w <onos-ip> system:name'")
+ main.step( "Sending command 'onos -w <onos-ip> system:name'" )
cmdstr1 = "system:name"
- cmd_result1 = main.ONOSbench.onos_cli(ONOS1_ip, cmdstr1)
- main.log.info("onos command returned: "+cmd_result1)
- cmd_result2 = main.ONOSbench.onos_cli(ONOS2_ip, cmdstr1)
- main.log.info("onos command returned: "+cmd_result2)
- cmd_result3 = main.ONOSbench.onos_cli(ONOS3_ip, cmdstr1)
- main.log.info("onos command returned: "+cmd_result3)
+ cmd_result1 = main.ONOSbench.onos_cli( ONOS1_ip, cmdstr1 )
+ main.log.info( "onos command returned: " + cmd_result1 )
+ cmd_result2 = main.ONOSbench.onos_cli( ONOS2_ip, cmdstr1 )
+ main.log.info( "onos command returned: " + cmd_result2 )
+ cmd_result3 = main.ONOSbench.onos_cli( ONOS3_ip, cmdstr1 )
+ main.log.info( "onos command returned: " + cmd_result3 )
- main.step("Sending command 'onos -w <onos-ip> onos:topology'")
+ main.step( "Sending command 'onos -w <onos-ip> onos:topology'" )
cmdstr2 = "onos:topology"
- cmd_result4 = main.ONOSbench.onos_cli(ONOS1_ip, cmdstr2)
- main.log.info("onos command returned: "+cmd_result4)
- cmd_result5 = main.ONOSbench.onos_cli(ONOS2_ip, cmdstr2)
- main.log.info("onos command returned: "+cmd_result5)
- cmd_result6 = main.ONOSbench.onos_cli(ONOS6_ip, cmdstr2)
- main.log.info("onos command returned: "+cmd_result6)
+ cmd_result4 = main.ONOSbench.onos_cli( ONOS1_ip, cmdstr2 )
+ main.log.info( "onos command returned: " + cmd_result4 )
+ cmd_result5 = main.ONOSbench.onos_cli( ONOS2_ip, cmdstr2 )
+ main.log.info( "onos command returned: " + cmd_result5 )
+ cmd_result6 = main.ONOSbench.onos_cli( ONOS6_ip, cmdstr2 )
+ main.log.info( "onos command returned: " + cmd_result6 )
-
- def CASE4(self, main):
+ def CASE4( self, main ):
import re
import time
- ONOS1_ip = main.params['CTRL']['ip1']
- ONOS2_ip = main.params['CTRL']['ip2']
- ONOS3_ip = main.params['CTRL']['ip3']
- ONOS1_port = main.params['CTRL']['port1']
- ONOS2_port = main.params['CTRL']['port2']
- ONOS3_port = main.params['CTRL']['port3']
-
- main.log.report("This testcase is testing the assignment of all the switches to all controllers and discovering the hosts in reactive mode")
- main.log.report("__________________________________")
- main.case("Pingall Test(No intents are added)")
- main.step("Assigning switches to controllers")
- for i in range(1,29): #1 to (num of switches +1)
- main.Mininet1.assign_sw_controller(sw=str(i),count=3,
- ip1=ONOS1_ip, port1=ONOS1_port,
- ip2=ONOS2_ip, port2=ONOS2_port,
- ip3=ONOS3_ip, port3=ONOS3_port)
+ ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+ ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
+ ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
+ ONOS1_port = main.params[ 'CTRL' ][ 'port1' ]
+ ONOS2_port = main.params[ 'CTRL' ][ 'port2' ]
+ ONOS3_port = main.params[ 'CTRL' ][ 'port3' ]
+
+ main.log.report(
+ "This testcase is testing the assignment of all the switches to all controllers and discovering the hosts in reactive mode" )
+ main.log.report( "__________________________________" )
+ main.case( "Pingall Test(No intents are added)" )
+ main.step( "Assigning switches to controllers" )
+ for i in range( 1, 29 ): # 1 to ( num of switches +1 )
+ main.Mininet1.assign_sw_controller(
+ sw=str( i ),
+ count=3,
+ ip1=ONOS1_ip,
+ port1=ONOS1_port,
+ ip2=ONOS2_ip,
+ port2=ONOS2_port,
+ ip3=ONOS3_ip,
+ port3=ONOS3_port )
switch_mastership = main.TRUE
- for i in range (1,29):
- response = main.Mininet1.get_sw_controller("s"+str(i))
- print("Response is " + str(response))
- if re.search("tcp:"+ONOS1_ip,response):
+ for i in range( 1, 29 ):
+ response = main.Mininet1.get_sw_controller( "s" + str( i ) )
+ print( "Response is " + str( response ) )
+ if re.search( "tcp:" + ONOS1_ip, response ):
switch_mastership = switch_mastership and main.TRUE
else:
switch_mastership = main.FALSE
if switch_mastership == main.TRUE:
- main.log.report("Controller assignment successfull")
+ main.log.report( "Controller assignment successfull" )
else:
- main.log.report("Controller assignment failed")
- #REACTIVE FWD test
- main.step("Pingall")
+ main.log.report( "Controller assignment failed" )
+ # REACTIVE FWD test
+ main.step( "Pingall" )
ping_result = main.FALSE
time1 = time.time()
ping_result = main.Mininet1.pingall()
time2 = time.time()
- print "Time for pingall: %2f seconds" % (time2 - time1)
-
+ print "Time for pingall: %2f seconds" % ( time2 - time1 )
+
case4_result = switch_mastership and ping_result
if ping_result == main.TRUE:
- main.log.report("Pingall Test in reactive mode to discover the hosts successful")
+ main.log.report(
+ "Pingall Test in reactive mode to discover the hosts successful" )
else:
- main.log.report("Pingall Test in reactive mode to discover the hosts failed")
+ main.log.report(
+ "Pingall Test in reactive mode to discover the hosts failed" )
- utilities.assert_equals(expect=main.TRUE, actual=case4_result,onpass="Controller assignment and Pingall Test successful",onfail="Controller assignment and Pingall Test NOT successful")
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case4_result,
+ onpass="Controller assignment and Pingall Test successful",
+ onfail="Controller assignment and Pingall Test NOT successful" )
-
-
- def CASE5(self,main) :
+ def CASE5( self, main ):
import json
from subprocess import Popen, PIPE
- from sts.topology.teston_topology import TestONTopology # assumes that sts is already in you PYTHONPATH
- ONOS1_ip = main.params['CTRL']['ip1']
- ONOS2_ip = main.params['CTRL']['ip2']
- ONOS3_ip = main.params['CTRL']['ip3']
-
- main.log.report("This testcase is testing if all ONOS nodes are in topology sync with mininet and its peer ONOS nodes")
- main.log.report("__________________________________")
- main.case ("Testing Mininet topology with the topology of multi instances ONOS")
- main.step("Collecting topology information from ONOS")
+ # assumes that sts is already in you PYTHONPATH
+ from sts.topology.teston_topology import TestONTopology
+ ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+ ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
+ ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
+
+ main.log.report(
+ "This testcase is testing if all ONOS nodes are in topology sync with mininet and its peer ONOS nodes" )
+ main.log.report( "__________________________________" )
+ main.case(
+ "Testing Mininet topology with the topology of multi instances ONOS" )
+ main.step( "Collecting topology information from ONOS" )
devices1 = main.ONOScli1.devices()
devices2 = main.ONOScli2.devices()
devices3 = main.ONOScli3.devices()
- #print "devices1 = ", devices1
- #print "devices2 = ", devices2
- #print "devices3 = ", devices3
+ # print "devices1 = ", devices1
+ # print "devices2 = ", devices2
+ # print "devices3 = ", devices3
hosts1 = main.ONOScli1.hosts()
hosts2 = main.ONOScli2.hosts()
hosts3 = main.ONOScli3.hosts()
- #print "hosts1 = ", hosts1
- #print "hosts2 = ", hosts2
- #print "hosts3 = ", hosts3
+ # print "hosts1 = ", hosts1
+ # print "hosts2 = ", hosts2
+ # print "hosts3 = ", hosts3
ports1 = main.ONOScli1.ports()
ports2 = main.ONOScli2.ports()
ports3 = main.ONOScli3.ports()
- #print "ports1 = ", ports1
- #print "ports2 = ", ports2
- #print "ports3 = ", ports3
+ # print "ports1 = ", ports1
+ # print "ports2 = ", ports2
+ # print "ports3 = ", ports3
links1 = main.ONOScli1.links()
links2 = main.ONOScli2.links()
links3 = main.ONOScli3.links()
- #print "links1 = ", links1
- #print "links2 = ", links2
- #print "links3 = ", links3
-
- print "**************"
-
- main.step("Start continuous pings")
- main.Mininet2.pingLong(src=main.params['PING']['source1'],
- target=main.params['PING']['target1'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source2'],
- target=main.params['PING']['target2'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source3'],
- target=main.params['PING']['target3'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source4'],
- target=main.params['PING']['target4'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source5'],
- target=main.params['PING']['target5'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source6'],
- target=main.params['PING']['target6'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source7'],
- target=main.params['PING']['target7'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source8'],
- target=main.params['PING']['target8'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source9'],
- target=main.params['PING']['target9'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source10'],
- target=main.params['PING']['target10'],pingTime=500)
+ # print "links1 = ", links1
+ # print "links2 = ", links2
+ # print "links3 = ", links3
- main.step("Create TestONTopology object")
+ print "**************"
+
+ main.step( "Start continuous pings" )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source1' ],
+ target=main.params[ 'PING' ][ 'target1' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source2' ],
+ target=main.params[ 'PING' ][ 'target2' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source3' ],
+ target=main.params[ 'PING' ][ 'target3' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source4' ],
+ target=main.params[ 'PING' ][ 'target4' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source5' ],
+ target=main.params[ 'PING' ][ 'target5' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source6' ],
+ target=main.params[ 'PING' ][ 'target6' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source7' ],
+ target=main.params[ 'PING' ][ 'target7' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source8' ],
+ target=main.params[ 'PING' ][ 'target8' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source9' ],
+ target=main.params[ 'PING' ][ 'target9' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source10' ],
+ target=main.params[ 'PING' ][ 'target10' ],
+ pingTime=500 )
+
+ main.step( "Create TestONTopology object" )
global ctrls
ctrls = []
count = 1
while True:
temp = ()
- if ('ip' + str(count)) in main.params['CTRL']:
- temp = temp + (getattr(main,('ONOS' + str(count))),)
- temp = temp + ("ONOS"+str(count),)
- temp = temp + (main.params['CTRL']['ip'+str(count)],)
- temp = temp + (eval(main.params['CTRL']['port'+str(count)]),)
- ctrls.append(temp)
+ if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]:
+ temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), )
+ temp = temp + ( "ONOS" + str( count ), )
+ temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], )
+ temp = temp + \
+ ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), )
+ ctrls.append( temp )
count = count + 1
else:
break
global MNTopo
- Topo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations
+ Topo = TestONTopology(
+ main.Mininet1,
+ ctrls ) # can also add Intent API info for intent operations
MNTopo = Topo
Topology_Check = main.TRUE
- main.step("Compare ONOS Topology to MN Topology")
-
- switches_results1 = main.Mininet1.compare_switches(MNTopo, json.loads(devices1))
+ main.step( "Compare ONOS Topology to MN Topology" )
+
+ switches_results1 = main.Mininet1.compare_switches(
+ MNTopo,
+ json.loads( devices1 ) )
print "switches_Result1 = ", switches_results1
- utilities.assert_equals(expect=main.TRUE, actual=switches_results1,
- onpass="ONOS1 Switches view is correct",
- onfail="ONOS1 Switches view is incorrect")
+ utilities.assert_equals( expect=main.TRUE, actual=switches_results1,
+ onpass="ONOS1 Switches view is correct",
+ onfail="ONOS1 Switches view is incorrect" )
- switches_results2 = main.Mininet1.compare_switches(MNTopo, json.loads(devices2))
- utilities.assert_equals(expect=main.TRUE, actual=switches_results2,
- onpass="ONOS2 Switches view is correct",
- onfail="ONOS2 Switches view is incorrect")
-
- switches_results3 = main.Mininet1.compare_switches(MNTopo, json.loads(devices3))
- utilities.assert_equals(expect=main.TRUE, actual=switches_results3,
- onpass="ONOS3 Switches view is correct",
- onfail="ONOS3 Switches view is incorrect")
+ switches_results2 = main.Mininet1.compare_switches(
+ MNTopo,
+ json.loads( devices2 ) )
+ utilities.assert_equals( expect=main.TRUE, actual=switches_results2,
+ onpass="ONOS2 Switches view is correct",
+ onfail="ONOS2 Switches view is incorrect" )
- '''
- ports_results1 = main.Mininet1.compare_ports(MNTopo, json.loads(ports1))
- utilities.assert_equals(expect=main.TRUE, actual=ports_results1,
+ switches_results3 = main.Mininet1.compare_switches(
+ MNTopo,
+ json.loads( devices3 ) )
+ utilities.assert_equals( expect=main.TRUE, actual=switches_results3,
+ onpass="ONOS3 Switches view is correct",
+ onfail="ONOS3 Switches view is incorrect" )
+
+ """
+ ports_results1 = main.Mininet1.compare_ports( MNTopo, json.loads( ports1 ) )
+ utilities.assert_equals( expect=main.TRUE, actual=ports_results1,
onpass="ONOS1 Ports view is correct",
- onfail="ONOS1 Ports view is incorrect")
+ onfail="ONOS1 Ports view is incorrect" )
- ports_results2 = main.Mininet1.compare_ports(MNTopo, json.loads(ports2))
- utilities.assert_equals(expect=main.TRUE, actual=ports_results2,
+ ports_results2 = main.Mininet1.compare_ports( MNTopo, json.loads( ports2 ) )
+ utilities.assert_equals( expect=main.TRUE, actual=ports_results2,
onpass="ONOS2 Ports view is correct",
- onfail="ONOS2 Ports view is incorrect")
+ onfail="ONOS2 Ports view is incorrect" )
- ports_results3 = main.Mininet1.compare_ports(MNTopo, json.loads(ports3))
- utilities.assert_equals(expect=main.TRUE, actual=ports_results3,
+ ports_results3 = main.Mininet1.compare_ports( MNTopo, json.loads( ports3 ) )
+ utilities.assert_equals( expect=main.TRUE, actual=ports_results3,
onpass="ONOS3 Ports view is correct",
- onfail="ONOS3 Ports view is incorrect")
- '''
+ onfail="ONOS3 Ports view is incorrect" )
+ """
+ links_results1 = main.Mininet1.compare_links(
+ MNTopo,
+ json.loads( links1 ) )
+ utilities.assert_equals( expect=main.TRUE, actual=links_results1,
+ onpass="ONOS1 Links view is correct",
+ onfail="ONOS1 Links view is incorrect" )
- links_results1 = main.Mininet1.compare_links(MNTopo, json.loads(links1))
- utilities.assert_equals(expect=main.TRUE, actual=links_results1,
- onpass="ONOS1 Links view is correct",
- onfail="ONOS1 Links view is incorrect")
+ links_results2 = main.Mininet1.compare_links(
+ MNTopo,
+ json.loads( links2 ) )
+ utilities.assert_equals( expect=main.TRUE, actual=links_results2,
+ onpass="ONOS2 Links view is correct",
+ onfail="ONOS2 Links view is incorrect" )
- links_results2 = main.Mininet1.compare_links(MNTopo, json.loads(links2))
- utilities.assert_equals(expect=main.TRUE, actual=links_results2,
- onpass="ONOS2 Links view is correct",
- onfail="ONOS2 Links view is incorrect")
-
- links_results3 = main.Mininet1.compare_links(MNTopo, json.loads(links3))
- utilities.assert_equals(expect=main.TRUE, actual=links_results3,
- onpass="ONOS2 Links view is correct",
- onfail="ONOS2 Links view is incorrect")
+ links_results3 = main.Mininet1.compare_links(
+ MNTopo,
+ json.loads( links3 ) )
+ utilities.assert_equals( expect=main.TRUE, actual=links_results3,
+ onpass="ONOS2 Links view is correct",
+ onfail="ONOS2 Links view is incorrect" )
#topo_result = switches_results1 and switches_results2 and switches_results3\
- #and ports_results1 and ports_results2 and ports_results3\
- #and links_results1 and links_results2 and links_results3
-
+ # and ports_results1 and ports_results2 and ports_results3\
+ # and links_results1 and links_results2 and links_results3
+
topo_result = switches_results1 and switches_results2 and switches_results3\
- and links_results1 and links_results2 and links_results3
+ and links_results1 and links_results2 and links_results3
if topo_result == main.TRUE:
- main.log.report("Topology Check Test with mininet and ONOS instances successful")
+ main.log.report(
+ "Topology Check Test with mininet and ONOS instances successful" )
else:
- main.log.report("Topology Check Test with mininet and ONOS instances failed")
+ main.log.report(
+ "Topology Check Test with mininet and ONOS instances failed" )
- utilities.assert_equals(expect=main.TRUE, actual=topo_result,
- onpass="Topology Check Test successful",
- onfail="Topology Check Test NOT successful")
+ utilities.assert_equals( expect=main.TRUE, actual=topo_result,
+ onpass="Topology Check Test successful",
+ onfail="Topology Check Test NOT successful" )
+ def CASE10( self ):
+ main.log.report(
+ "This testcase uninstalls the reactive forwarding app" )
+ main.log.report( "__________________________________" )
+ main.case( "Uninstalling reactive forwarding app" )
+ # Unistall onos-app-fwd app to disable reactive forwarding
+ appUninstall_result1 = main.ONOScli1.feature_uninstall(
+ "onos-app-fwd" )
+ appUninstall_result2 = main.ONOScli2.feature_uninstall(
+ "onos-app-fwd" )
+ appUninstall_result3 = main.ONOScli3.feature_uninstall(
+ "onos-app-fwd" )
+ main.log.info( "onos-app-fwd uninstalled" )
+ # After reactive forwarding is disabled, the reactive flows on switches timeout in 10-15s
+ # So sleep for 15s
+ time.sleep( 15 )
-
- def CASE10(self):
- main.log.report("This testcase uninstalls the reactive forwarding app")
- main.log.report("__________________________________")
- main.case("Uninstalling reactive forwarding app")
- #Unistall onos-app-fwd app to disable reactive forwarding
- appUninstall_result1 = main.ONOScli1.feature_uninstall("onos-app-fwd")
- appUninstall_result2 = main.ONOScli2.feature_uninstall("onos-app-fwd")
- appUninstall_result3 = main.ONOScli3.feature_uninstall("onos-app-fwd")
- main.log.info("onos-app-fwd uninstalled")
-
- #After reactive forwarding is disabled, the reactive flows on switches timeout in 10-15s
- #So sleep for 15s
- time.sleep(15)
-
hosts = main.ONOScli1.hosts()
- main.log.info(hosts)
-
+ main.log.info( hosts )
+
case10_result = appUninstall_result1 and appUninstall_result2 and appUninstall_result3
- utilities.assert_equals(expect=main.TRUE, actual=case10_result,onpass="Reactive forwarding app uninstallation successful",onfail="Reactive forwarding app uninstallation failed")
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case10_result,
+ onpass="Reactive forwarding app uninstallation successful",
+ onfail="Reactive forwarding app uninstallation failed" )
-
- def CASE6(self):
- main.log.report("This testcase is testing the addition of host intents and then doing pingall")
- main.log.report("__________________________________")
- main.case("Obtaining hostsfor adding host intents")
- main.step("Get hosts")
+ def CASE6( self ):
+ main.log.report(
+ "This testcase is testing the addition of host intents and then doing pingall" )
+ main.log.report( "__________________________________" )
+ main.case( "Obtaining hostsfor adding host intents" )
+ main.step( "Get hosts" )
hosts = main.ONOScli1.hosts()
- main.log.info(hosts)
+ main.log.info( hosts )
- main.step("Get all devices id")
+ main.step( "Get all devices id" )
devices_id_list = main.ONOScli1.get_all_devices_id()
- main.log.info(devices_id_list)
+ main.log.info( devices_id_list )
- #ONOS displays the hosts in hex format unlike mininet which does in decimal format
- #So take care while adding intents
-
- '''
- main.step("Add host intents for mn hosts(h8-h18,h9-h19,h10-h20,h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)")
- hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1")
- hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1")
- hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:0A/-1", "00:00:00:00:00:14/-1")
- hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:0B/-1", "00:00:00:00:00:15/-1")
- hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:0C/-1", "00:00:00:00:00:16/-1")
- hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:0D/-1", "00:00:00:00:00:17/-1")
- hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:0E/-1", "00:00:00:00:00:18/-1")
- hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1")
- hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1")
- hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1")
- '''
+ # ONOS displays the hosts in hex format unlike mininet which does in decimal format
+ # So take care while adding intents
- for i in range(8,18):
- main.log.info("Adding host intent between h"+str(i)+" and h"+str(i+10))
- host1 = "00:00:00:00:00:" + str(hex(i)[2:]).zfill(2).upper()
- host2 = "00:00:00:00:00:" + str(hex(i+10)[2:]).zfill(2).upper()
- #NOTE: get host can return None
- #TODO: handle this
- host1_id = main.ONOScli1.get_host(host1)['id']
- host2_id = main.ONOScli1.get_host(host2)['id']
- tmp_result = main.ONOScli1.add_host_intent(host1_id, host2_id )
+ """
+ main.step( "Add host intents for mn hosts(h8-h18,h9-h19,h10-h20,h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)" )
+ hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1" )
+ hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1" )
+ hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:0A/-1", "00:00:00:00:00:14/-1" )
+ hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:0B/-1", "00:00:00:00:00:15/-1" )
+ hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:0C/-1", "00:00:00:00:00:16/-1" )
+ hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:0D/-1", "00:00:00:00:00:17/-1" )
+ hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:0E/-1", "00:00:00:00:00:18/-1" )
+ hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1" )
+ hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1" )
+ hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1" )
+ """
+ for i in range( 8, 18 ):
+ main.log.info(
+ "Adding host intent between h" + str( i ) + " and h" + str( i + 10 ) )
+ host1 = "00:00:00:00:00:" + \
+ str( hex( i )[ 2: ] ).zfill( 2 ).upper()
+ host2 = "00:00:00:00:00:" + \
+ str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
+ # NOTE: get host can return None
+ # TODO: handle this
+ host1_id = main.ONOScli1.get_host( host1 )[ 'id' ]
+ host2_id = main.ONOScli1.get_host( host2 )[ 'id' ]
+ tmp_result = main.ONOScli1.add_host_intent( host1_id, host2_id )
flowHandle = main.ONOScli1.flows()
- #print "flowHandle = ", flowHandle
- main.log.info("flows:" +flowHandle)
+ # print "flowHandle = ", flowHandle
+ main.log.info( "flows:" + flowHandle )
count = 1
i = 8
Ping_Result = main.TRUE
- while i <18 :
- main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10))
- ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
- if ping == main.FALSE and count <5:
- count+=1
+ while i < 18:
+ main.log.info(
+ "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
+ ping = main.Mininet1.pingHost(
+ src="h" + str( i ), target="h" + str( i + 10 ) )
+ if ping == main.FALSE and count < 5:
+ count += 1
#i = 8
Ping_Result = main.FALSE
- main.log.report("Ping between h" + str(i) + " and h" + str(i+10) + " failed. Making attempt number "+str(count) + " in 2 seconds")
- time.sleep(2)
- elif ping==main.FALSE:
- main.log.report("All ping attempts between h" + str(i) + " and h" + str(i+10) +"have failed")
- i=19
+ main.log.report( "Ping between h" +
+ str( i ) +
+ " and h" +
+ str( i +
+ 10 ) +
+ " failed. Making attempt number " +
+ str( count ) +
+ " in 2 seconds" )
+ time.sleep( 2 )
+ elif ping == main.FALSE:
+ main.log.report( "All ping attempts between h" +
+ str( i ) +
+ " and h" +
+ str( i +
+ 10 ) +
+ "have failed" )
+ i = 19
Ping_Result = main.FALSE
- elif ping==main.TRUE:
- main.log.info("Ping test between h" + str(i) + " and h" + str(i+10) + "passed!")
- i+=1
+ elif ping == main.TRUE:
+ main.log.info( "Ping test between h" +
+ str( i ) +
+ " and h" +
+ str( i +
+ 10 ) +
+ "passed!" )
+ i += 1
Ping_Result = main.TRUE
else:
- main.log.info("Unknown error")
+ main.log.info( "Unknown error" )
Ping_Result = main.ERROR
- if Ping_Result==main.FALSE:
- main.log.report("Host intents have not ben installed correctly. Cleaning up")
- #main.cleanup()
- #main.exit()
- if Ping_Result==main.TRUE:
- main.log.report("Host intents have been installed correctly")
+ if Ping_Result == main.FALSE:
+ main.log.report(
+ "Host intents have not ben installed correctly. Cleaning up" )
+ # main.cleanup()
+ # main.exit()
+ if Ping_Result == main.TRUE:
+ main.log.report( "Host intents have been installed correctly" )
case6_result = Ping_Result
- utilities.assert_equals(expect=main.TRUE, actual=case6_result,
- onpass="Host intent addition and Pingall Test successful",
- onfail="Host intent addition and Pingall Test NOT successful")
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case6_result,
+ onpass="Host intent addition and Pingall Test successful",
+ onfail="Host intent addition and Pingall Test NOT successful" )
+ def CASE7( self, main ):
- def CASE7 (self,main):
-
- ONOS1_ip = main.params['CTRL']['ip1']
+ ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
- link_sleep = int(main.params['timers']['LinkDiscovery'])
+ link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
- main.log.report("This testscase is killing a link to ensure that link discovery is consistent")
- main.log.report("__________________________________")
- main.case("Killing a link to Ensure that Link Discovery is Working Properly")
- main.step("Start continuous pings")
-
- main.Mininet2.pingLong(src=main.params['PING']['source1'],
- target=main.params['PING']['target1'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source2'],
- target=main.params['PING']['target2'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source3'],
- target=main.params['PING']['target3'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source4'],
- target=main.params['PING']['target4'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source5'],
- target=main.params['PING']['target5'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source6'],
- target=main.params['PING']['target6'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source7'],
- target=main.params['PING']['target7'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source8'],
- target=main.params['PING']['target8'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source9'],
- target=main.params['PING']['target9'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source10'],
- target=main.params['PING']['target10'],pingTime=500)
+ main.log.report(
+ "This testscase is killing a link to ensure that link discovery is consistent" )
+ main.log.report( "__________________________________" )
+ main.case(
+ "Killing a link to Ensure that Link Discovery is Working Properly" )
+ main.step( "Start continuous pings" )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source1' ],
+ target=main.params[ 'PING' ][ 'target1' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source2' ],
+ target=main.params[ 'PING' ][ 'target2' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source3' ],
+ target=main.params[ 'PING' ][ 'target3' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source4' ],
+ target=main.params[ 'PING' ][ 'target4' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source5' ],
+ target=main.params[ 'PING' ][ 'target5' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source6' ],
+ target=main.params[ 'PING' ][ 'target6' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source7' ],
+ target=main.params[ 'PING' ][ 'target7' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source8' ],
+ target=main.params[ 'PING' ][ 'target8' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source9' ],
+ target=main.params[ 'PING' ][ 'target9' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source10' ],
+ target=main.params[ 'PING' ][ 'target10' ],
+ pingTime=500 )
- main.step("Determine the current number of switches and links")
+ main.step( "Determine the current number of switches and links" )
topology_output = main.ONOScli1.topology()
- topology_result = main.ONOSbench.get_topology(topology_output)
- activeSwitches = topology_result['devices']
- links = topology_result['links']
- print "activeSwitches = ", type(activeSwitches)
- print "links = ", type(links)
- main.log.info("Currently there are %s switches and %s links" %(str(activeSwitches), str(links)))
+ topology_result = main.ONOSbench.get_topology( topology_output )
+ activeSwitches = topology_result[ 'devices' ]
+ links = topology_result[ 'links' ]
+ print "activeSwitches = ", type( activeSwitches )
+ print "links = ", type( links )
+ main.log.info(
+ "Currently there are %s switches and %s links" %
+ ( str( activeSwitches ), str( links ) ) )
- main.step("Kill Link between s3 and s28")
- main.Mininet1.link(END1="s3",END2="s28",OPTION="down")
- time.sleep(link_sleep)
+ main.step( "Kill Link between s3 and s28" )
+ main.Mininet1.link( END1="s3", END2="s28", OPTION="down" )
+ time.sleep( link_sleep )
topology_output = main.ONOScli2.topology()
- Link_Down = main.ONOSbench.check_status(topology_output,activeSwitches,str(int(links)-2))
+ Link_Down = main.ONOSbench.check_status(
+ topology_output, activeSwitches, str(
+ int( links ) - 2 ) )
if Link_Down == main.TRUE:
- main.log.report("Link Down discovered properly")
- utilities.assert_equals(expect=main.TRUE,actual=Link_Down,
- onpass="Link Down discovered properly",
- onfail="Link down was not discovered in "+ str(link_sleep) + " seconds")
-
- main.step("Bring link between s3 and s28 back up")
- Link_Up = main.Mininet1.link(END1="s3",END2="s28",OPTION="up")
- time.sleep(link_sleep)
- topology_output = main.ONOScli2.topology()
- Link_Up = main.ONOSbench.check_status(topology_output,activeSwitches,str(links))
- if Link_Up == main.TRUE:
- main.log.report("Link up discovered properly")
- utilities.assert_equals(expect=main.TRUE,actual=Link_Up,
- onpass="Link up discovered properly",
- onfail="Link up was not discovered in "+ str(link_sleep) + " seconds")
+ main.log.report( "Link Down discovered properly" )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=Link_Down,
+ onpass="Link Down discovered properly",
+ onfail="Link down was not discovered in " +
+ str( link_sleep ) +
+ " seconds" )
- main.step("Compare ONOS Topology to MN Topology")
- main.case ("Testing Mininet topology with the topology of multi instances ONOS")
- main.step("Collecting topology information from ONOS")
+ main.step( "Bring link between s3 and s28 back up" )
+ Link_Up = main.Mininet1.link( END1="s3", END2="s28", OPTION="up" )
+ time.sleep( link_sleep )
+ topology_output = main.ONOScli2.topology()
+ Link_Up = main.ONOSbench.check_status(
+ topology_output,
+ activeSwitches,
+ str( links ) )
+ if Link_Up == main.TRUE:
+ main.log.report( "Link up discovered properly" )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=Link_Up,
+ onpass="Link up discovered properly",
+ onfail="Link up was not discovered in " +
+ str( link_sleep ) +
+ " seconds" )
+
+ main.step( "Compare ONOS Topology to MN Topology" )
+ main.case(
+ "Testing Mininet topology with the topology of multi instances ONOS" )
+ main.step( "Collecting topology information from ONOS" )
devices1 = main.ONOScli1.devices()
devices2 = main.ONOScli2.devices()
devices3 = main.ONOScli3.devices()
@@ -539,625 +660,864 @@
hosts1 = main.ONOScli1.hosts()
hosts2 = main.ONOScli2.hosts()
hosts3 = main.ONOScli3.hosts()
- #print "hosts1 = ", hosts1
- #print "hosts2 = ", hosts2
- #print "hosts3 = ", hosts3
+ # print "hosts1 = ", hosts1
+ # print "hosts2 = ", hosts2
+ # print "hosts3 = ", hosts3
ports1 = main.ONOScli1.ports()
ports2 = main.ONOScli2.ports()
ports3 = main.ONOScli3.ports()
- #print "ports1 = ", ports1
- #print "ports2 = ", ports2
- #print "ports3 = ", ports3
+ # print "ports1 = ", ports1
+ # print "ports2 = ", ports2
+ # print "ports3 = ", ports3
links1 = main.ONOScli1.links()
links2 = main.ONOScli2.links()
links3 = main.ONOScli3.links()
- #print "links1 = ", links1
- #print "links2 = ", links2
- #print "links3 = ", links3
-
- print "**************"
-
- main.step("Start continuous pings")
- main.Mininet2.pingLong(src=main.params['PING']['source1'],
- target=main.params['PING']['target1'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source2'],
- target=main.params['PING']['target2'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source3'],
- target=main.params['PING']['target3'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source4'],
- target=main.params['PING']['target4'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source5'],
- target=main.params['PING']['target5'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source6'],
- target=main.params['PING']['target6'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source7'],
- target=main.params['PING']['target7'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source8'],
- target=main.params['PING']['target8'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source9'],
- target=main.params['PING']['target9'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source10'],
- target=main.params['PING']['target10'],pingTime=500)
+ # print "links1 = ", links1
+ # print "links2 = ", links2
+ # print "links3 = ", links3
- main.step("Create TestONTopology object")
+ print "**************"
+
+ main.step( "Start continuous pings" )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source1' ],
+ target=main.params[ 'PING' ][ 'target1' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source2' ],
+ target=main.params[ 'PING' ][ 'target2' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source3' ],
+ target=main.params[ 'PING' ][ 'target3' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source4' ],
+ target=main.params[ 'PING' ][ 'target4' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source5' ],
+ target=main.params[ 'PING' ][ 'target5' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source6' ],
+ target=main.params[ 'PING' ][ 'target6' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source7' ],
+ target=main.params[ 'PING' ][ 'target7' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source8' ],
+ target=main.params[ 'PING' ][ 'target8' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source9' ],
+ target=main.params[ 'PING' ][ 'target9' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source10' ],
+ target=main.params[ 'PING' ][ 'target10' ],
+ pingTime=500 )
+
+ main.step( "Create TestONTopology object" )
global ctrls
ctrls = []
count = 1
while True:
temp = ()
- if ('ip' + str(count)) in main.params['CTRL']:
- temp = temp + (getattr(main,('ONOS' + str(count))),)
- temp = temp + ("ONOS"+str(count),)
- temp = temp + (main.params['CTRL']['ip'+str(count)],)
- temp = temp + (eval(main.params['CTRL']['port'+str(count)]),)
- ctrls.append(temp)
+ if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]:
+ temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), )
+ temp = temp + ( "ONOS" + str( count ), )
+ temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], )
+ temp = temp + \
+ ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), )
+ ctrls.append( temp )
count = count + 1
else:
break
global MNTopo
- Topo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations
+ Topo = TestONTopology(
+ main.Mininet1,
+ ctrls ) # can also add Intent API info for intent operations
MNTopo = Topo
Topology_Check = main.TRUE
- main.step("Compare ONOS Topology to MN Topology")
-
- switches_results1 = main.Mininet1.compare_switches(MNTopo, json.loads(devices1))
+ main.step( "Compare ONOS Topology to MN Topology" )
+
+ switches_results1 = main.Mininet1.compare_switches(
+ MNTopo,
+ json.loads( devices1 ) )
print "switches_Result1 = ", switches_results1
- utilities.assert_equals(expect=main.TRUE, actual=switches_results1,
- onpass="ONOS1 Switches view is correct",
- onfail="ONOS1 Switches view is incorrect")
+ utilities.assert_equals( expect=main.TRUE, actual=switches_results1,
+ onpass="ONOS1 Switches view is correct",
+ onfail="ONOS1 Switches view is incorrect" )
- switches_results2 = main.Mininet1.compare_switches(MNTopo, json.loads(devices2))
- utilities.assert_equals(expect=main.TRUE, actual=switches_results2,
- onpass="ONOS2 Switches view is correct",
- onfail="ONOS2 Switches view is incorrect")
-
- switches_results3 = main.Mininet1.compare_switches(MNTopo, json.loads(devices3))
- utilities.assert_equals(expect=main.TRUE, actual=switches_results3,
- onpass="ONOS3 Switches view is correct",
- onfail="ONOS3 Switches view is incorrect")
+ switches_results2 = main.Mininet1.compare_switches(
+ MNTopo,
+ json.loads( devices2 ) )
+ utilities.assert_equals( expect=main.TRUE, actual=switches_results2,
+ onpass="ONOS2 Switches view is correct",
+ onfail="ONOS2 Switches view is incorrect" )
- '''
- ports_results1 = main.Mininet1.compare_ports(MNTopo, json.loads(ports1))
- utilities.assert_equals(expect=main.TRUE, actual=ports_results1,
+ switches_results3 = main.Mininet1.compare_switches(
+ MNTopo,
+ json.loads( devices3 ) )
+ utilities.assert_equals( expect=main.TRUE, actual=switches_results3,
+ onpass="ONOS3 Switches view is correct",
+ onfail="ONOS3 Switches view is incorrect" )
+
+ """
+ ports_results1 = main.Mininet1.compare_ports( MNTopo, json.loads( ports1 ) )
+ utilities.assert_equals( expect=main.TRUE, actual=ports_results1,
onpass="ONOS1 Ports view is correct",
- onfail="ONOS1 Ports view is incorrect")
+ onfail="ONOS1 Ports view is incorrect" )
- ports_results2 = main.Mininet1.compare_ports(MNTopo, json.loads(ports2))
- utilities.assert_equals(expect=main.TRUE, actual=ports_results2,
+ ports_results2 = main.Mininet1.compare_ports( MNTopo, json.loads( ports2 ) )
+ utilities.assert_equals( expect=main.TRUE, actual=ports_results2,
onpass="ONOS2 Ports view is correct",
- onfail="ONOS2 Ports view is incorrect")
+ onfail="ONOS2 Ports view is incorrect" )
- ports_results3 = main.Mininet1.compare_ports(MNTopo, json.loads(ports3))
- utilities.assert_equals(expect=main.TRUE, actual=ports_results3,
+ ports_results3 = main.Mininet1.compare_ports( MNTopo, json.loads( ports3 ) )
+ utilities.assert_equals( expect=main.TRUE, actual=ports_results3,
onpass="ONOS3 Ports view is correct",
- onfail="ONOS3 Ports view is incorrect")
- '''
+ onfail="ONOS3 Ports view is incorrect" )
+ """
+ links_results1 = main.Mininet1.compare_links(
+ MNTopo,
+ json.loads( links1 ) )
+ utilities.assert_equals( expect=main.TRUE, actual=links_results1,
+ onpass="ONOS1 Links view is correct",
+ onfail="ONOS1 Links view is incorrect" )
- links_results1 = main.Mininet1.compare_links(MNTopo, json.loads(links1))
- utilities.assert_equals(expect=main.TRUE, actual=links_results1,
- onpass="ONOS1 Links view is correct",
- onfail="ONOS1 Links view is incorrect")
+ links_results2 = main.Mininet1.compare_links(
+ MNTopo,
+ json.loads( links2 ) )
+ utilities.assert_equals( expect=main.TRUE, actual=links_results2,
+ onpass="ONOS2 Links view is correct",
+ onfail="ONOS2 Links view is incorrect" )
- links_results2 = main.Mininet1.compare_links(MNTopo, json.loads(links2))
- utilities.assert_equals(expect=main.TRUE, actual=links_results2,
- onpass="ONOS2 Links view is correct",
- onfail="ONOS2 Links view is incorrect")
+ links_results3 = main.Mininet1.compare_links(
+ MNTopo,
+ json.loads( links3 ) )
+ utilities.assert_equals( expect=main.TRUE, actual=links_results3,
+ onpass="ONOS2 Links view is correct",
+ onfail="ONOS2 Links view is incorrect" )
- links_results3 = main.Mininet1.compare_links(MNTopo, json.loads(links3))
- utilities.assert_equals(expect=main.TRUE, actual=links_results3,
- onpass="ONOS2 Links view is correct",
- onfail="ONOS2 Links view is incorrect")
-
#topo_result = switches_results1 and switches_results2 and switches_results3\
- #and ports_results1 and ports_results2 and ports_results3\
- #and links_results1 and links_results2 and links_results3
-
+ # and ports_results1 and ports_results2 and ports_results3\
+ # and links_results1 and links_results2 and links_results3
+
topo_result = switches_results1 and switches_results2 and switches_results3\
- and links_results1 and links_results2 and links_results3
+ and links_results1 and links_results2 and links_results3
- utilities.assert_equals(expect=main.TRUE, actual=topo_result and Link_Up and Link_Down,
- onpass="Topology Check Test successful",
- onfail="Topology Check Test NOT successful")
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=topo_result and Link_Up and Link_Down,
+ onpass="Topology Check Test successful",
+ onfail="Topology Check Test NOT successful" )
-
- def CASE8(self):
- '''
+ def CASE8( self ):
+ """
Intent removal
- '''
- main.log.report("This testcase removes host any previously added intents")
- main.log.report("__________________________________")
- main.log.info("Removing any previously installed intents")
- main.case("Removing intents")
- main.step("Obtain the intent id's")
- intent_result = main.ONOScli1.intents(json_format = False)
-
- intent_linewise = intent_result.split("\n")
+ """
+ main.log.report(
+ "This testcase removes host any previously added intents" )
+ main.log.report( "__________________________________" )
+ main.log.info( "Removing any previously installed intents" )
+ main.case( "Removing intents" )
+ main.step( "Obtain the intent id's" )
+ intent_result = main.ONOScli1.intents( json_format=False )
+
+ intent_linewise = intent_result.split( "\n" )
intentList = []
for line in intent_linewise:
- if line.startswith("id="):
- intentList.append(line)
+ if line.startswith( "id=" ):
+ intentList.append( line )
intentids = []
for line in intentList:
- intentids.append(line.split(",")[0].split("=")[1])
+ intentids.append( line.split( "," )[ 0 ].split( "=" )[ 1 ] )
for id in intentids:
- main.log.info("id = " +id)
+ main.log.info( "id = " + id )
- main.step("Iterate through the intentids list and remove each intent")
+ main.step(
+ "Iterate through the intentids list and remove each intent" )
for id in intentids:
- main.ONOScli1.remove_intent(intent_id = id)
+ main.ONOScli1.remove_intent( intent_id=id )
- intent_result = main.ONOScli1.intents(json_format = False)
- main.log.info("intent_result = " +intent_result)
+ intent_result = main.ONOScli1.intents( json_format=False )
+ main.log.info( "intent_result = " + intent_result )
case8_result = main.TRUE
-
+
i = 8
Ping_Result = main.TRUE
- while i <18 :
- main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10))
- ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
- if ping==main.TRUE:
+ while i < 18:
+ main.log.info(
+ "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
+ ping = main.Mininet1.pingHost(
+ src="h" + str( i ), target="h" + str( i + 10 ) )
+ if ping == main.TRUE:
i = 19
Ping_Result = main.TRUE
- elif ping==main.FALSE:
- i+=1
+ elif ping == main.FALSE:
+ i += 1
Ping_Result = main.FALSE
else:
- main.log.info("Unknown error")
+ main.log.info( "Unknown error" )
Ping_Result = main.ERROR
-
- #Note: If the ping result failed, that means the intents have been withdrawn correctly.
- if Ping_Result==main.TRUE:
- main.log.report("Host intents have not been withdrawn correctly")
- #main.cleanup()
- #main.exit()
- if Ping_Result==main.FALSE:
- main.log.report("Host intents have been withdrawn correctly")
+
+ # Note: If the ping result failed, that means the intents have been
+ # withdrawn correctly.
+ if Ping_Result == main.TRUE:
+ main.log.report( "Host intents have not been withdrawn correctly" )
+ # main.cleanup()
+ # main.exit()
+ if Ping_Result == main.FALSE:
+ main.log.report( "Host intents have been withdrawn correctly" )
case8_result = case8_result and Ping_Result
if case8_result == main.FALSE:
- main.log.report("Intent removal successful")
+ main.log.report( "Intent removal successful" )
else:
- main.log.report("Intent removal failed")
-
- utilities.assert_equals(expect=main.FALSE, actual=case8_result,
- onpass="Intent removal test failed",
- onfail="Intent removal test successful")
-
+ main.log.report( "Intent removal failed" )
- def CASE9(self):
- '''
+ utilities.assert_equals( expect=main.FALSE, actual=case8_result,
+ onpass="Intent removal test failed",
+ onfail="Intent removal test successful" )
+
+ def CASE9( self ):
+ """
This test case adds point intents. Make sure you run test case 8 which is host intent removal before executing this test case.
Else the host intent's flows will persist on switches and the pings would work even if there is some issue with the point intent's flows
- '''
- main.log.report("This testcase adds point intents and then does pingall")
- main.log.report("__________________________________")
- main.log.info("Adding point intents")
- main.case("Adding bidirectional point for mn hosts(h8-h18,h9-h19,h10-h20,h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)")
- main.step("Add point-to-point intents for mininet hosts h8 and h18 or ONOS hosts h8 and h12")
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003008/1", "of:0000000000006018/1")
+ """
+ main.log.report(
+ "This testcase adds point intents and then does pingall" )
+ main.log.report( "__________________________________" )
+ main.log.info( "Adding point intents" )
+ main.case(
+ "Adding bidirectional point for mn hosts(h8-h18,h9-h19,h10-h20,h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)" )
+ main.step(
+ "Add point-to-point intents for mininet hosts h8 and h18 or ONOS hosts h8 and h12" )
+ ptp_intent_result = main.ONOScli1.add_point_intent(
+ "of:0000000000003008/1",
+ "of:0000000000006018/1" )
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOScli1.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006018/1", "of:0000000000003008/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- main.step("Add point-to-point intents for mininet hosts h9 and h19 or ONOS hosts h9 and h13")
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003009/1", "of:0000000000006019/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006019/1", "of:0000000000003009/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- main.step("Add point-to-point intents for mininet hosts h10 and h20 or ONOS hosts hA and h14")
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003010/1", "of:0000000000006020/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006020/1", "of:0000000000003010/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
- main.step("Add point-to-point intents for mininet hosts h11 and h21 or ONOS hosts hB and h15")
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003011/1", "of:0000000000006021/1")
+ ptp_intent_result = main.ONOScli1.add_point_intent(
+ "of:0000000000006018/1",
+ "of:0000000000003008/1" )
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOScli1.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006021/1", "of:0000000000003011/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- main.step("Add point-to-point intents for mininet hosts h12 and h22 or ONOS hosts hC and h16")
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003012/1", "of:0000000000006022/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006022/1", "of:0000000000003012/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- main.step("Add point-to-point intents for mininet hosts h13 and h23 or ONOS hosts hD and h17")
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003013/1", "of:0000000000006023/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006023/1", "of:0000000000003013/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
- main.step("Add point-to-point intents for mininet hosts h14 and h24 or ONOS hosts hE and h18")
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003014/1", "of:0000000000006024/1")
+ main.step(
+ "Add point-to-point intents for mininet hosts h9 and h19 or ONOS hosts h9 and h13" )
+ ptp_intent_result = main.ONOScli1.add_point_intent(
+ "of:0000000000003009/1",
+ "of:0000000000006019/1" )
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOScli1.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006024/1", "of:0000000000003014/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- main.step("Add point-to-point intents for mininet hosts h15 and h25 or ONOS hosts hF and h19")
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003015/1", "of:0000000000006025/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006025/1", "of:0000000000003015/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- main.step("Add point-to-point intents for mininet hosts h16 and h26 or ONOS hosts h10 and h1A")
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003016/1", "of:0000000000006026/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006026/1", "of:0000000000003016/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
-
- main.step("Add point-to-point intents for mininet hosts h17 and h27 or ONOS hosts h11 and h1B")
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003017/1", "of:0000000000006027/1")
+ ptp_intent_result = main.ONOScli1.add_point_intent(
+ "of:0000000000006019/1",
+ "of:0000000000003009/1" )
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOScli1.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006027/1", "of:0000000000003017/1")
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ main.step(
+ "Add point-to-point intents for mininet hosts h10 and h20 or ONOS hosts hA and h14" )
+ ptp_intent_result = main.ONOScli1.add_point_intent(
+ "of:0000000000003010/1",
+ "of:0000000000006020/1" )
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOScli1.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
- print("_______________________________________________________________________________________")
+ ptp_intent_result = main.ONOScli1.add_point_intent(
+ "of:0000000000006020/1",
+ "of:0000000000003010/1" )
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOScli1.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ main.step(
+ "Add point-to-point intents for mininet hosts h11 and h21 or ONOS hosts hB and h15" )
+ ptp_intent_result = main.ONOScli1.add_point_intent(
+ "of:0000000000003011/1",
+ "of:0000000000006021/1" )
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOScli1.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ ptp_intent_result = main.ONOScli1.add_point_intent(
+ "of:0000000000006021/1",
+ "of:0000000000003011/1" )
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOScli1.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ main.step(
+ "Add point-to-point intents for mininet hosts h12 and h22 or ONOS hosts hC and h16" )
+ ptp_intent_result = main.ONOScli1.add_point_intent(
+ "of:0000000000003012/1",
+ "of:0000000000006022/1" )
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOScli1.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ ptp_intent_result = main.ONOScli1.add_point_intent(
+ "of:0000000000006022/1",
+ "of:0000000000003012/1" )
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOScli1.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ main.step(
+ "Add point-to-point intents for mininet hosts h13 and h23 or ONOS hosts hD and h17" )
+ ptp_intent_result = main.ONOScli1.add_point_intent(
+ "of:0000000000003013/1",
+ "of:0000000000006023/1" )
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOScli1.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ ptp_intent_result = main.ONOScli1.add_point_intent(
+ "of:0000000000006023/1",
+ "of:0000000000003013/1" )
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOScli1.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ main.step(
+ "Add point-to-point intents for mininet hosts h14 and h24 or ONOS hosts hE and h18" )
+ ptp_intent_result = main.ONOScli1.add_point_intent(
+ "of:0000000000003014/1",
+ "of:0000000000006024/1" )
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOScli1.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ ptp_intent_result = main.ONOScli1.add_point_intent(
+ "of:0000000000006024/1",
+ "of:0000000000003014/1" )
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOScli1.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ main.step(
+ "Add point-to-point intents for mininet hosts h15 and h25 or ONOS hosts hF and h19" )
+ ptp_intent_result = main.ONOScli1.add_point_intent(
+ "of:0000000000003015/1",
+ "of:0000000000006025/1" )
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOScli1.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ ptp_intent_result = main.ONOScli1.add_point_intent(
+ "of:0000000000006025/1",
+ "of:0000000000003015/1" )
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOScli1.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ main.step(
+ "Add point-to-point intents for mininet hosts h16 and h26 or ONOS hosts h10 and h1A" )
+ ptp_intent_result = main.ONOScli1.add_point_intent(
+ "of:0000000000003016/1",
+ "of:0000000000006026/1" )
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOScli1.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ ptp_intent_result = main.ONOScli1.add_point_intent(
+ "of:0000000000006026/1",
+ "of:0000000000003016/1" )
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOScli1.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ main.step(
+ "Add point-to-point intents for mininet hosts h17 and h27 or ONOS hosts h11 and h1B" )
+ ptp_intent_result = main.ONOScli1.add_point_intent(
+ "of:0000000000003017/1",
+ "of:0000000000006027/1" )
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOScli1.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ ptp_intent_result = main.ONOScli1.add_point_intent(
+ "of:0000000000006027/1",
+ "of:0000000000003017/1" )
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOScli1.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ print(
+ "_______________________________________________________________________________________" )
flowHandle = main.ONOScli1.flows()
- #print "flowHandle = ", flowHandle
- main.log.info("flows :" + flowHandle)
+ # print "flowHandle = ", flowHandle
+ main.log.info( "flows :" + flowHandle )
count = 1
i = 8
Ping_Result = main.TRUE
- while i <18 :
- main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10))
- ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
- if ping == main.FALSE and count <5:
- count+=1
+ while i < 18:
+ main.log.info(
+ "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
+ ping = main.Mininet1.pingHost(
+ src="h" + str( i ), target="h" + str( i + 10 ) )
+ if ping == main.FALSE and count < 5:
+ count += 1
#i = 8
Ping_Result = main.FALSE
- main.log.report("Ping between h" + str(i) + " and h" + str(i+10) + " failed. Making attempt number "+str(count) + " in 2 seconds")
- time.sleep(2)
- elif ping==main.FALSE:
- main.log.report("All ping attempts between h" + str(i) + " and h" + str(i+10) +"have failed")
- i=19
+ main.log.report( "Ping between h" +
+ str( i ) +
+ " and h" +
+ str( i +
+ 10 ) +
+ " failed. Making attempt number " +
+ str( count ) +
+ " in 2 seconds" )
+ time.sleep( 2 )
+ elif ping == main.FALSE:
+ main.log.report( "All ping attempts between h" +
+ str( i ) +
+ " and h" +
+ str( i +
+ 10 ) +
+ "have failed" )
+ i = 19
Ping_Result = main.FALSE
- elif ping==main.TRUE:
- main.log.info("Ping test between h" + str(i) + " and h" + str(i+10) + "passed!")
- i+=1
+ elif ping == main.TRUE:
+ main.log.info( "Ping test between h" +
+ str( i ) +
+ " and h" +
+ str( i +
+ 10 ) +
+ "passed!" )
+ i += 1
Ping_Result = main.TRUE
else:
- main.log.info("Unknown error")
+ main.log.info( "Unknown error" )
Ping_Result = main.ERROR
- if Ping_Result==main.FALSE:
- main.log.report("Ping all test after Point intents addition failed. Cleaning up")
- #main.cleanup()
- #main.exit()
- if Ping_Result==main.TRUE:
- main.log.report("Ping all test after Point intents addition successful")
+ if Ping_Result == main.FALSE:
+ main.log.report(
+ "Ping all test after Point intents addition failed. Cleaning up" )
+ # main.cleanup()
+ # main.exit()
+ if Ping_Result == main.TRUE:
+ main.log.report(
+ "Ping all test after Point intents addition successful" )
case8_result = Ping_Result
- utilities.assert_equals(expect=main.TRUE, actual=case8_result,
- onpass="Ping all test after Point intents addition successful",
- onfail="Ping all test after Point intents addition failed")
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case8_result,
+ onpass="Ping all test after Point intents addition successful",
+ onfail="Ping all test after Point intents addition failed" )
- def CASE31(self):
- '''
- This test case adds point intent related to SDN-IP matching on ICMP (ethertype=IPV4, ipProto=1)
- '''
+ def CASE31( self ):
+ """
+ This test case adds point intent related to SDN-IP matching on ICMP ( ethertype=IPV4, ipProto=1 )
+ """
import json
- main.log.report("This test case adds point intent related to SDN-IP matching on ICMP")
- main.case("Adding bidirectional point intent related to SDN-IP matching on ICMP")
- main.step("Adding bidirectional point intent")
- #add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32 --ethType=IPV4 --ipProto=1 of:0000000000003008/1 of:0000000000006018/1
-
- hosts_json = json.loads(main.ONOScli1.hosts())
- for i in range(8,11):
- main.log.info("Adding point intent between h"+str(i)+" and h"+str(i+10))
- host1 = "00:00:00:00:00:" + str(hex(i)[2:]).zfill(2).upper()
- host2 = "00:00:00:00:00:" + str(hex(i+10)[2:]).zfill(2).upper()
- host1_id = main.ONOScli1.get_host(host1)['id']
- host2_id = main.ONOScli1.get_host(host2)['id']
+ main.log.report(
+ "This test case adds point intent related to SDN-IP matching on ICMP" )
+ main.case(
+ "Adding bidirectional point intent related to SDN-IP matching on ICMP" )
+ main.step( "Adding bidirectional point intent" )
+ # add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32
+ # --ethType=IPV4 --ipProto=1 of:0000000000003008/1
+ # of:0000000000006018/1
+
+ hosts_json = json.loads( main.ONOScli1.hosts() )
+ for i in range( 8, 11 ):
+ main.log.info(
+ "Adding point intent between h" + str( i ) + " and h" + str( i + 10 ) )
+ host1 = "00:00:00:00:00:" + \
+ str( hex( i )[ 2: ] ).zfill( 2 ).upper()
+ host2 = "00:00:00:00:00:" + \
+ str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
+ host1_id = main.ONOScli1.get_host( host1 )[ 'id' ]
+ host2_id = main.ONOScli1.get_host( host2 )[ 'id' ]
for host in hosts_json:
- if host['id'] == host1_id:
- ip1 = host['ips'][0]
- ip1 = str(ip1+"/32")
- device1 = host['location']['device']
- device1 = str(device1+"/1")
- elif host['id'] == host2_id:
- ip2 = str(host['ips'][0])+"/32"
- device2 = host['location']["device"]
- device2 = str(device2+"/1")
-
- p_intent_result1 = main.ONOScli1.add_point_intent(ingress_device=device1, egress_device=device2, ipSrc=ip1, ipDst=ip2,
- ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['icmpProto'])
-
- get_intent_result = main.ONOScli1.intents(json_format = False)
- main.log.info(get_intent_result)
-
- p_intent_result2 = main.ONOScli1.add_point_intent(ingress_device=device2, egress_device=device1, ipSrc=ip2, ipDst=ip1,
- ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['icmpProto'])
-
- get_intent_result = main.ONOScli1.intents(json_format = False)
- main.log.info(get_intent_result)
- if (p_intent_result1 and p_intent_result2) == main.TRUE:
+ if host[ 'id' ] == host1_id:
+ ip1 = host[ 'ips' ][ 0 ]
+ ip1 = str( ip1 + "/32" )
+ device1 = host[ 'location' ][ 'device' ]
+ device1 = str( device1 + "/1" )
+ elif host[ 'id' ] == host2_id:
+ ip2 = str( host[ 'ips' ][ 0 ] ) + "/32"
+ device2 = host[ 'location' ][ "device" ]
+ device2 = str( device2 + "/1" )
+
+ p_intent_result1 = main.ONOScli1.add_point_intent(
+ ingress_device=device1,
+ egress_device=device2,
+ ipSrc=ip1,
+ ipDst=ip2,
+ ethType=main.params[ 'SDNIP' ][ 'ethType' ],
+ ipProto=main.params[ 'SDNIP' ][ 'icmpProto' ] )
+
+ get_intent_result = main.ONOScli1.intents( json_format=False )
+ main.log.info( get_intent_result )
+
+ p_intent_result2 = main.ONOScli1.add_point_intent(
+ ingress_device=device2,
+ egress_device=device1,
+ ipSrc=ip2,
+ ipDst=ip1,
+ ethType=main.params[ 'SDNIP' ][ 'ethType' ],
+ ipProto=main.params[ 'SDNIP' ][ 'icmpProto' ] )
+
+ get_intent_result = main.ONOScli1.intents( json_format=False )
+ main.log.info( get_intent_result )
+ if ( p_intent_result1 and p_intent_result2 ) == main.TRUE:
#get_intent_result = main.ONOScli1.intents()
- #main.log.info(get_intent_result)
- main.log.info("Point intent related to SDN-IP matching on ICMP install successful")
-
- time.sleep(15)
- get_intent_result = main.ONOScli1.intents(json_format = False)
- main.log.info("intents = "+ get_intent_result)
+ # main.log.info( get_intent_result )
+ main.log.info(
+ "Point intent related to SDN-IP matching on ICMP install successful" )
+
+ time.sleep( 15 )
+ get_intent_result = main.ONOScli1.intents( json_format=False )
+ main.log.info( "intents = " + get_intent_result )
get_flows_result = main.ONOScli1.flows()
- main.log.info("flows = " + get_flows_result)
-
+ main.log.info( "flows = " + get_flows_result )
+
count = 1
i = 8
Ping_Result = main.TRUE
- while i <11 :
- main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10))
- ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
- if ping == main.FALSE and count <3:
- count+=1
+ while i < 11:
+ main.log.info(
+ "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
+ ping = main.Mininet1.pingHost(
+ src="h" + str( i ), target="h" + str( i + 10 ) )
+ if ping == main.FALSE and count < 3:
+ count += 1
#i = 8
Ping_Result = main.FALSE
- main.log.report("Ping between h" + str(i) + " and h" + str(i+10) + " failed. Making attempt number "+str(count) + " in 2 seconds")
- time.sleep(2)
- elif ping==main.FALSE:
- main.log.report("All ping attempts between h" + str(i) + " and h" + str(i+10) +"have failed")
- i=19
+ main.log.report( "Ping between h" +
+ str( i ) +
+ " and h" +
+ str( i +
+ 10 ) +
+ " failed. Making attempt number " +
+ str( count ) +
+ " in 2 seconds" )
+ time.sleep( 2 )
+ elif ping == main.FALSE:
+ main.log.report( "All ping attempts between h" +
+ str( i ) +
+ " and h" +
+ str( i +
+ 10 ) +
+ "have failed" )
+ i = 19
Ping_Result = main.FALSE
- elif ping==main.TRUE:
- main.log.info("Ping test between h" + str(i) + " and h" + str(i+10) + "passed!")
- i+=1
+ elif ping == main.TRUE:
+ main.log.info( "Ping test between h" +
+ str( i ) +
+ " and h" +
+ str( i +
+ 10 ) +
+ "passed!" )
+ i += 1
Ping_Result = main.TRUE
else:
- main.log.info("Unknown error")
+ main.log.info( "Unknown error" )
Ping_Result = main.ERROR
- if Ping_Result==main.FALSE:
- main.log.report("Ping test after Point intents related to SDN-IP matching on ICMP failed.")
- #main.cleanup()
- #main.exit()
- if Ping_Result==main.TRUE:
- main.log.report("Ping all test after Point intents related to SDN-IP matching on ICMP successful")
-
+ if Ping_Result == main.FALSE:
+ main.log.report(
+ "Ping test after Point intents related to SDN-IP matching on ICMP failed." )
+ # main.cleanup()
+ # main.exit()
+ if Ping_Result == main.TRUE:
+ main.log.report(
+ "Ping all test after Point intents related to SDN-IP matching on ICMP successful" )
+
case31_result = Ping_Result and p_intent_result1 and p_intent_result2
- utilities.assert_equals(expect=main.TRUE, actual=case31_result,
- onpass="Point intent related to SDN-IP matching on ICMP and ping test successful",
- onfail="Point intent related to SDN-IP matching on ICMP and ping test failed")
-
- def CASE32(self):
- '''
- This test case adds point intent related to SDN-IP matching on TCP (ethertype=IPV4, ipProto=6, DefaultPort for iperf=5001)
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case31_result,
+ onpass="Point intent related to SDN-IP matching on ICMP and ping test successful",
+ onfail="Point intent related to SDN-IP matching on ICMP and ping test failed" )
+
+ def CASE32( self ):
+ """
+ This test case adds point intent related to SDN-IP matching on TCP ( ethertype=IPV4, ipProto=6, DefaultPort for iperf=5001 )
Note: Although BGP port is 179, we are using 5001 because iperf is used for verifying and iperf's default port is 5001
- '''
+ """
import json
- main.log.report("This test case adds point intent related to SDN-IP matching on TCP")
- main.case("Adding bidirectional point intent related to SDN-IP matching on TCP")
- main.step("Adding bidirectional point intent")
+ main.log.report(
+ "This test case adds point intent related to SDN-IP matching on TCP" )
+ main.case(
+ "Adding bidirectional point intent related to SDN-IP matching on TCP" )
+ main.step( "Adding bidirectional point intent" )
"""
add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32 --ethType=IPV4 --ipProto=6 --tcpDst=5001 of:0000000000003008/1 of:0000000000006018/1
add-point-intent --ipSrc=10.0.0.18/32 --ipDst=10.0.0.8/32 --ethType=IPV4 --ipProto=6 --tcpDst=5001 of:0000000000006018/1 of:0000000000003008/1
-
+
add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32 --ethType=IPV4 --ipProto=6 --tcpSrc=5001 of:0000000000003008/1 of:0000000000006018/1
add-point-intent --ipSrc=10.0.0.18/32 --ipDst=10.0.0.8/32 --ethType=IPV4 --ipProto=6 --tcpSrc=5001 of:0000000000006018/1 of:0000000000003008/1
- """
-
- hosts_json = json.loads(main.ONOScli1.hosts())
- for i in range(8,9):
- main.log.info("Adding point intent between h"+str(i)+" and h"+str(i+10))
- host1 = "00:00:00:00:00:" + str(hex(i)[2:]).zfill(2).upper()
- host2 = "00:00:00:00:00:" + str(hex(i+10)[2:]).zfill(2).upper()
- host1_id = main.ONOScli1.get_host(host1)['id']
- host2_id = main.ONOScli1.get_host(host2)['id']
+ """
+ hosts_json = json.loads( main.ONOScli1.hosts() )
+ for i in range( 8, 9 ):
+ main.log.info(
+ "Adding point intent between h" + str( i ) + " and h" + str( i + 10 ) )
+ host1 = "00:00:00:00:00:" + \
+ str( hex( i )[ 2: ] ).zfill( 2 ).upper()
+ host2 = "00:00:00:00:00:" + \
+ str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
+ host1_id = main.ONOScli1.get_host( host1 )[ 'id' ]
+ host2_id = main.ONOScli1.get_host( host2 )[ 'id' ]
for host in hosts_json:
- if host['id'] == host1_id:
- ip1 = host['ips'][0]
- ip1 = str(ip1+"/32")
- device1 = host['location']['device']
- device1 = str(device1+"/1")
- elif host['id'] == host2_id:
- ip2 = str(host['ips'][0])+"/32"
- device2 = host['location']["device"]
- device2 = str(device2+"/1")
-
- p_intent_result1 = main.ONOScli1.add_point_intent(ingress_device=device1, egress_device=device2, ipSrc=ip1, ipDst=ip2,
- ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['tcpProto'], tcpDst=main.params['SDNIP']['dstPort'])
- p_intent_result2 = main.ONOScli1.add_point_intent(ingress_device=device2, egress_device=device1, ipSrc=ip2, ipDst=ip1,
- ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['tcpProto'], tcpDst=main.params['SDNIP']['dstPort'])
+ if host[ 'id' ] == host1_id:
+ ip1 = host[ 'ips' ][ 0 ]
+ ip1 = str( ip1 + "/32" )
+ device1 = host[ 'location' ][ 'device' ]
+ device1 = str( device1 + "/1" )
+ elif host[ 'id' ] == host2_id:
+ ip2 = str( host[ 'ips' ][ 0 ] ) + "/32"
+ device2 = host[ 'location' ][ "device" ]
+ device2 = str( device2 + "/1" )
- p_intent_result3 = main.ONOScli1.add_point_intent(ingress_device=device1, egress_device=device2, ipSrc=ip1, ipDst=ip2,
- ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['tcpProto'], tcpSrc=main.params['SDNIP']['srcPort'])
- p_intent_result4 = main.ONOScli1.add_point_intent(ingress_device=device2, egress_device=device1, ipSrc=ip2, ipDst=ip1,
- ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['tcpProto'], tcpSrc=main.params['SDNIP']['srcPort'])
+ p_intent_result1 = main.ONOScli1.add_point_intent(
+ ingress_device=device1,
+ egress_device=device2,
+ ipSrc=ip1,
+ ipDst=ip2,
+ ethType=main.params[ 'SDNIP' ][ 'ethType' ],
+ ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
+ tcpDst=main.params[ 'SDNIP' ][ 'dstPort' ] )
+ p_intent_result2 = main.ONOScli1.add_point_intent(
+ ingress_device=device2,
+ egress_device=device1,
+ ipSrc=ip2,
+ ipDst=ip1,
+ ethType=main.params[ 'SDNIP' ][ 'ethType' ],
+ ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
+ tcpDst=main.params[ 'SDNIP' ][ 'dstPort' ] )
+
+ p_intent_result3 = main.ONOScli1.add_point_intent(
+ ingress_device=device1,
+ egress_device=device2,
+ ipSrc=ip1,
+ ipDst=ip2,
+ ethType=main.params[ 'SDNIP' ][ 'ethType' ],
+ ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
+ tcpSrc=main.params[ 'SDNIP' ][ 'srcPort' ] )
+ p_intent_result4 = main.ONOScli1.add_point_intent(
+ ingress_device=device2,
+ egress_device=device1,
+ ipSrc=ip2,
+ ipDst=ip1,
+ ethType=main.params[ 'SDNIP' ][ 'ethType' ],
+ ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
+ tcpSrc=main.params[ 'SDNIP' ][ 'srcPort' ] )
p_intent_result = p_intent_result1 and p_intent_result2 and p_intent_result3 and p_intent_result4
- if p_intent_result ==main.TRUE:
- get_intent_result = main.ONOScli1.intents(json_format = False)
- main.log.info(get_intent_result)
- main.log.info("Point intent related to SDN-IP matching on TCP install successful")
-
- iperf_result = main.Mininet1.iperf('h8', 'h18')
- if iperf_result == main.TRUE:
- main.log.report("iperf test successful")
- else:
- main.log.report("iperf test failed")
+ if p_intent_result == main.TRUE:
+ get_intent_result = main.ONOScli1.intents( json_format=False )
+ main.log.info( get_intent_result )
+ main.log.info(
+ "Point intent related to SDN-IP matching on TCP install successful" )
+ iperf_result = main.Mininet1.iperf( 'h8', 'h18' )
+ if iperf_result == main.TRUE:
+ main.log.report( "iperf test successful" )
+ else:
+ main.log.report( "iperf test failed" )
case32_result = p_intent_result and iperf_result
- utilities.assert_equals(expect=main.TRUE, actual=case32_result,
- onpass="Ping all test after Point intents addition related to SDN-IP on TCP match successful",
- onfail="Ping all test after Point intents addition related to SDN-IP on TCP match failed")
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case32_result,
+ onpass="Ping all test after Point intents addition related to SDN-IP on TCP match successful",
+ onfail="Ping all test after Point intents addition related to SDN-IP on TCP match failed" )
-
- def CASE33(self):
- '''
- This test case adds multipoint to singlepoint intent related to SDN-IP matching on destination ip and the action is to rewrite the mac address
+ def CASE33( self ):
+ """
+ This test case adds multipoint to singlepoint intent related to SDN-IP matching on destination ip and the action is to rewrite the mac address
Here the mac address to be rewritten is the mac address of the egress device
- '''
+ """
import json
import time
- main.log.report("This test case adds multipoint to singlepoint intent related to SDN-IP matching on destination ip and rewrite mac address action")
- main.case("Adding multipoint to singlepoint intent related to SDN-IP matching on destination ip")
- main.step("Adding bidirectional multipoint to singlepoint intent")
+ main.log.report(
+ "This test case adds multipoint to singlepoint intent related to SDN-IP matching on destination ip and rewrite mac address action" )
+ main.case(
+ "Adding multipoint to singlepoint intent related to SDN-IP matching on destination ip" )
+ main.step( "Adding bidirectional multipoint to singlepoint intent" )
"""
add-multi-to-single-intent --ipDst=10.0.3.0/24 --setEthDst=00:00:00:00:00:12 of:0000000000003008/1 0000000000003009/1 of:0000000000006018/1
-
- add-multi-to-single-intent --ipDst=10.0.1.0/24 --setEthDst=00:00:00:00:00:08 of:0000000000006018/1 0000000000003009/1 of:0000000000003008/1
- """
-
- main.case("Installing multipoint to single point intent with rewrite mac address")
- main.step("Uninstalling proxy arp app")
- #Unistall onos-app-proxyarp app to disable reactive forwarding
- appUninstall_result1 = main.ONOScli1.feature_uninstall("onos-app-proxyarp")
- appUninstall_result2 = main.ONOScli2.feature_uninstall("onos-app-proxyarp")
- appUninstall_result3 = main.ONOScli3.feature_uninstall("onos-app-proxyarp")
- main.log.info("onos-app-proxyarp uninstalled")
- main.step("Changing ipaddress of hosts h8,h9 and h18")
- main.Mininet1.changeIP(host='h8', intf='h8-eth0', newIP='10.0.1.1', newNetmask='255.255.255.0')
- main.Mininet1.changeIP(host='h9', intf='h9-eth0', newIP='10.0.2.1', newNetmask='255.255.255.0')
- main.Mininet1.changeIP(host='h10', intf='h10-eth0', newIP='10.0.3.1', newNetmask='255.255.255.0')
+ add-multi-to-single-intent --ipDst=10.0.1.0/24 --setEthDst=00:00:00:00:00:08 of:0000000000006018/1 0000000000003009/1 of:0000000000003008/1
+ """
+ main.case(
+ "Installing multipoint to single point intent with rewrite mac address" )
+ main.step( "Uninstalling proxy arp app" )
+ # Unistall onos-app-proxyarp app to disable reactive forwarding
+ appUninstall_result1 = main.ONOScli1.feature_uninstall(
+ "onos-app-proxyarp" )
+ appUninstall_result2 = main.ONOScli2.feature_uninstall(
+ "onos-app-proxyarp" )
+ appUninstall_result3 = main.ONOScli3.feature_uninstall(
+ "onos-app-proxyarp" )
+ main.log.info( "onos-app-proxyarp uninstalled" )
- main.step("Changing default gateway of hosts h8,h9 and h18")
- main.Mininet1.changeDefaultGateway(host='h8', newGW='10.0.1.254')
- main.Mininet1.changeDefaultGateway(host='h9', newGW='10.0.2.254')
- main.Mininet1.changeDefaultGateway(host='h10', newGW='10.0.3.254')
+ main.step( "Changing ipaddress of hosts h8,h9 and h18" )
+ main.Mininet1.changeIP(
+ host='h8',
+ intf='h8-eth0',
+ newIP='10.0.1.1',
+ newNetmask='255.255.255.0' )
+ main.Mininet1.changeIP(
+ host='h9',
+ intf='h9-eth0',
+ newIP='10.0.2.1',
+ newNetmask='255.255.255.0' )
+ main.Mininet1.changeIP(
+ host='h10',
+ intf='h10-eth0',
+ newIP='10.0.3.1',
+ newNetmask='255.255.255.0' )
- main.step("Assigning random mac address to the default gateways since proxyarp app is uninstalled")
- main.Mininet1.addStaticMACAddress(host='h8', GW='10.0.1.254', macaddr='00:00:00:00:11:11')
- main.Mininet1.addStaticMACAddress(host='h9', GW='10.0.2.254', macaddr='00:00:00:00:22:22')
- main.Mininet1.addStaticMACAddress(host='h10', GW='10.0.3.254', macaddr='00:00:00:00:33:33')
-
- main.step("Verify static gateway and MAC address assignment")
- main.Mininet1.verifyStaticGWandMAC(host='h8')
- main.Mininet1.verifyStaticGWandMAC(host='h9')
- main.Mininet1.verifyStaticGWandMAC(host='h10')
-
- main.step("Adding multipoint to singlepoint intent")
- p_intent_result1 = main.ONOScli1.add_multipoint_to_singlepoint_intent(ingress_device1=main.params['MULTIPOINT_INTENT']['device1'], ingress_device2=main.params['MULTIPOINT_INTENT']['device2'],
- egress_device=main.params['MULTIPOINT_INTENT']['device3'], ipDst=main.params['MULTIPOINT_INTENT']['ip1'], setEthDst=main.params['MULTIPOINT_INTENT']['mac1'])
-
- p_intent_result2 = main.ONOScli1.add_multipoint_to_singlepoint_intent(ingress_device1=main.params['MULTIPOINT_INTENT']['device3'], ingress_device2=main.params['MULTIPOINT_INTENT']['device2'],
- egress_device=main.params['MULTIPOINT_INTENT']['device1'], ipDst=main.params['MULTIPOINT_INTENT']['ip2'], setEthDst=main.params['MULTIPOINT_INTENT']['mac2'])
+ main.step( "Changing default gateway of hosts h8,h9 and h18" )
+ main.Mininet1.changeDefaultGateway( host='h8', newGW='10.0.1.254' )
+ main.Mininet1.changeDefaultGateway( host='h9', newGW='10.0.2.254' )
+ main.Mininet1.changeDefaultGateway( host='h10', newGW='10.0.3.254' )
+ main.step(
+ "Assigning random mac address to the default gateways since proxyarp app is uninstalled" )
+ main.Mininet1.addStaticMACAddress(
+ host='h8',
+ GW='10.0.1.254',
+ macaddr='00:00:00:00:11:11' )
+ main.Mininet1.addStaticMACAddress(
+ host='h9',
+ GW='10.0.2.254',
+ macaddr='00:00:00:00:22:22' )
+ main.Mininet1.addStaticMACAddress(
+ host='h10',
+ GW='10.0.3.254',
+ macaddr='00:00:00:00:33:33' )
- get_intent_result = main.ONOScli1.intents(json_format = False)
- main.log.info("intents = "+ get_intent_result)
-
- time.sleep(10)
- get_flows_result = main.ONOScli1.flows(json_format = False)
- main.log.info("flows = " + get_flows_result)
+ main.step( "Verify static gateway and MAC address assignment" )
+ main.Mininet1.verifyStaticGWandMAC( host='h8' )
+ main.Mininet1.verifyStaticGWandMAC( host='h9' )
+ main.Mininet1.verifyStaticGWandMAC( host='h10' )
+
+ main.step( "Adding multipoint to singlepoint intent" )
+ p_intent_result1 = main.ONOScli1.add_multipoint_to_singlepoint_intent(
+ ingress_device1=main.params[ 'MULTIPOINT_INTENT' ][ 'device1' ],
+ ingress_device2=main.params[ 'MULTIPOINT_INTENT' ][ 'device2' ],
+ egress_device=main.params[ 'MULTIPOINT_INTENT' ][ 'device3' ],
+ ipDst=main.params[ 'MULTIPOINT_INTENT' ][ 'ip1' ],
+ setEthDst=main.params[ 'MULTIPOINT_INTENT' ][ 'mac1' ] )
+
+ p_intent_result2 = main.ONOScli1.add_multipoint_to_singlepoint_intent(
+ ingress_device1=main.params[ 'MULTIPOINT_INTENT' ][ 'device3' ],
+ ingress_device2=main.params[ 'MULTIPOINT_INTENT' ][ 'device2' ],
+ egress_device=main.params[ 'MULTIPOINT_INTENT' ][ 'device1' ],
+ ipDst=main.params[ 'MULTIPOINT_INTENT' ][ 'ip2' ],
+ setEthDst=main.params[ 'MULTIPOINT_INTENT' ][ 'mac2' ] )
+
+ get_intent_result = main.ONOScli1.intents( json_format=False )
+ main.log.info( "intents = " + get_intent_result )
+
+ time.sleep( 10 )
+ get_flows_result = main.ONOScli1.flows( json_format=False )
+ main.log.info( "flows = " + get_flows_result )
count = 1
i = 8
Ping_Result = main.TRUE
-
- main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+2))
- ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+2))
- if ping == main.FALSE and count <3:
- count+=1
+
+ main.log.info( "\n\nh" + str( i ) + " is Pinging h" + str( i + 2 ) )
+ ping = main.Mininet1.pingHost(
+ src="h" + str( i ), target="h" + str( i + 2 ) )
+ if ping == main.FALSE and count < 3:
+ count += 1
Ping_Result = main.FALSE
- main.log.report("Ping between h" + str(i) + " and h" + str(i+2) + " failed. Making attempt number "+str(count) + " in 2 seconds")
- time.sleep(2)
- elif ping==main.FALSE:
- main.log.report("All ping attempts between h" + str(i) + " and h" + str(i+10) +"have failed")
+ main.log.report( "Ping between h" +
+ str( i ) +
+ " and h" +
+ str( i +
+ 2 ) +
+ " failed. Making attempt number " +
+ str( count ) +
+ " in 2 seconds" )
+ time.sleep( 2 )
+ elif ping == main.FALSE:
+ main.log.report( "All ping attempts between h" +
+ str( i ) +
+ " and h" +
+ str( i +
+ 10 ) +
+ "have failed" )
Ping_Result = main.FALSE
- elif ping==main.TRUE:
- main.log.info("Ping test between h" + str(i) + " and h" + str(i+2) + "passed!")
+ elif ping == main.TRUE:
+ main.log.info( "Ping test between h" +
+ str( i ) +
+ " and h" +
+ str( i +
+ 2 ) +
+ "passed!" )
Ping_Result = main.TRUE
else:
- main.log.info("Unknown error")
+ main.log.info( "Unknown error" )
Ping_Result = main.ERROR
-
- if Ping_Result==main.FALSE:
- main.log.report("Ping test failed.")
- #main.cleanup()
- #main.exit()
- if Ping_Result==main.TRUE:
- main.log.report("Ping all successful")
+ if Ping_Result == main.FALSE:
+ main.log.report( "Ping test failed." )
+ # main.cleanup()
+ # main.exit()
+ if Ping_Result == main.TRUE:
+ main.log.report( "Ping all successful" )
p_intent_result = p_intent_result1 and p_intent_result2
- if p_intent_result ==main.TRUE:
- main.log.info("Multi point intent with rewrite mac address installation successful")
+ if p_intent_result == main.TRUE:
+ main.log.info(
+ "Multi point intent with rewrite mac address installation successful" )
else:
- main.log.info("Multi point intent with rewrite mac address installation failed")
-
+ main.log.info(
+ "Multi point intent with rewrite mac address installation failed" )
+
case33_result = p_intent_result and Ping_Result
- utilities.assert_equals(expect=main.TRUE, actual=case33_result,
- onpass="Ping all test after multipoint to single point intent addition with rewrite mac address successful",
- onfail="Ping all test after multipoint to single point intent addition with rewrite mac address failed")
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case33_result,
+ onpass="Ping all test after multipoint to single point intent addition with rewrite mac address successful",
+ onfail="Ping all test after multipoint to single point intent addition with rewrite mac address failed" )
diff --git a/TestON/tests/OnosCHO/OnosCHO.params b/TestON/tests/OnosCHO/OnosCHO.params
index 7856a28..c0325a9 100644
--- a/TestON/tests/OnosCHO/OnosCHO.params
+++ b/TestON/tests/OnosCHO/OnosCHO.params
@@ -12,7 +12,7 @@
# 10. Remove all intents on ONOS
# 1,2,3,[4,5,6,5,7,8,5,10,5,9,5,7,8,5,10,5]*2
- <testcases>1,2,3,9</testcases>
+ <testcases>1,2,3,[4,5,6,5,70,80,5,10,5,9,5,71,81,5,10,5]*100</testcases>
<ENV>
<cellName>choTest5</cellName>
</ENV>
diff --git a/TestON/tests/OnosCHO/OnosCHO.py b/TestON/tests/OnosCHO/OnosCHO.py
index 3a838fa..3be5cbb 100644
--- a/TestON/tests/OnosCHO/OnosCHO.py
+++ b/TestON/tests/OnosCHO/OnosCHO.py
@@ -6,8 +6,10 @@
import json
import itertools
+
class OnosCHO:
- def __init__(self):
+
+ def __init__( self ):
self.default = ''
global deviceDPIDs
global hostMACs
@@ -16,8 +18,9 @@
global devicePortsEnabledCount
global installedIntents
global randomLink1, randomLink2, randomLink3, numSwitches, numLinks
- def CASE1(self, main):
- '''
+
+ def CASE1( self, main ):
+ """
Startup sequence:
git pull
mvn clean install
@@ -26,167 +29,187 @@
onos-verify-cell
onos-install -f
onos-wait-for-start
- '''
+ """
import time
- cell_name = main.params['ENV']['cellName']
- git_pull = main.params['GIT']['autoPull']
- numCtrls = main.params['CTRL']['numCtrl']
- git_branch = main.params['GIT']['branch']
+ cell_name = main.params[ 'ENV' ][ 'cellName' ]
+ git_pull = main.params[ 'GIT' ][ 'autoPull' ]
+ numCtrls = main.params[ 'CTRL' ][ 'numCtrl' ]
+ git_branch = main.params[ 'GIT' ][ 'branch' ]
- main.case("Set up test environment")
- main.log.report("Set up test environment")
- main.log.report("_______________________")
-
- main.step("Git checkout and pull "+git_branch)
+ main.case( "Set up test environment" )
+ main.log.report( "Set up test environment" )
+ main.log.report( "_______________________" )
+
+ main.step( "Git checkout and pull " + git_branch )
if git_pull == 'on':
- checkout_result = main.ONOSbench.git_checkout(git_branch)
+ checkout_result = main.ONOSbench.git_checkout( git_branch )
pull_result = main.ONOSbench.git_pull()
- cp_result = (checkout_result and pull_result)
+ cp_result = ( checkout_result and pull_result )
else:
checkout_result = main.TRUE
pull_result = main.TRUE
- main.log.info("Skipped git checkout and pull")
- cp_result = (checkout_result and pull_result)
- utilities.assert_equals(expect=main.TRUE, actual=cp_result,
- onpass="Test step PASS",
- onfail="Test step FAIL")
-
- main.step("mvn clean & install")
+ main.log.info( "Skipped git checkout and pull" )
+ cp_result = ( checkout_result and pull_result )
+ utilities.assert_equals( expect=main.TRUE, actual=cp_result,
+ onpass="Test step PASS",
+ onfail="Test step FAIL" )
+
+ main.step( "mvn clean & install" )
mvn_result = main.ONOSbench.clean_install()
- utilities.assert_equals(expect=main.TRUE, actual=mvn_result,
- onpass="Test step PASS",
- onfail="Test step FAIL")
+ utilities.assert_equals( expect=main.TRUE, actual=mvn_result,
+ onpass="Test step PASS",
+ onfail="Test step FAIL" )
- main.ONOSbench.get_version(report=True)
+ main.ONOSbench.get_version( report=True )
- main.step("Apply Cell environment for ONOS")
- cell_result = main.ONOSbench.set_cell(cell_name)
- utilities.assert_equals(expect=main.TRUE, actual=cell_result,
- onpass="Test step PASS",
- onfail="Test step FAIL")
+ main.step( "Apply Cell environment for ONOS" )
+ cell_result = main.ONOSbench.set_cell( cell_name )
+ utilities.assert_equals( expect=main.TRUE, actual=cell_result,
+ onpass="Test step PASS",
+ onfail="Test step FAIL" )
- main.step("Create ONOS package")
+ main.step( "Create ONOS package" )
packageResult = main.ONOSbench.onos_package()
- utilities.assert_equals(expect=main.TRUE, actual=packageResult,
- onpass="Test step PASS",
- onfail="Test step FAIL")
+ utilities.assert_equals( expect=main.TRUE, actual=packageResult,
+ onpass="Test step PASS",
+ onfail="Test step FAIL" )
- main.step("Uninstall ONOS package on all Nodes")
- uninstallResult=main.TRUE
- for i in range(1,int(numCtrls)+1):
- ONOS_ip = main.params['CTRL']['ip'+str(i)]
- main.log.info("Unintsalling package on ONOS Node IP: "+ONOS_ip)
- u_result= main.ONOSbench.onos_uninstall(ONOS_ip)
- utilities.assert_equals(expect=main.TRUE, actual=u_result,
- onpass="Test step PASS",
- onfail="Test step FAIL")
- uninstallResult=(uninstallResult and u_result)
+ main.step( "Uninstall ONOS package on all Nodes" )
+ uninstallResult = main.TRUE
+ for i in range( 1, int( numCtrls ) + 1 ):
+ ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
+ main.log.info( "Unintsalling package on ONOS Node IP: " + ONOS_ip )
+ u_result = main.ONOSbench.onos_uninstall( ONOS_ip )
+ utilities.assert_equals( expect=main.TRUE, actual=u_result,
+ onpass="Test step PASS",
+ onfail="Test step FAIL" )
+ uninstallResult = ( uninstallResult and u_result )
- main.step("Removing copy-cat logs from ONOS nodes")
+ main.step( "Removing copy-cat logs from ONOS nodes" )
main.ONOSbench.onos_remove_raft_logs()
- main.step("Install ONOS package on all Nodes")
- installResult=main.TRUE
- for i in range(1,int(numCtrls)+1):
- ONOS_ip = main.params['CTRL']['ip'+str(i)]
- main.log.info("Intsalling package on ONOS Node IP: "+ONOS_ip)
- i_result= main.ONOSbench.onos_install(node=ONOS_ip)
- utilities.assert_equals(expect=main.TRUE, actual=i_result,
- onpass="Test step PASS",
- onfail="Test step FAIL")
- installResult=(installResult and i_result)
+ main.step( "Install ONOS package on all Nodes" )
+ installResult = main.TRUE
+ for i in range( 1, int( numCtrls ) + 1 ):
+ ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
+ main.log.info( "Intsalling package on ONOS Node IP: " + ONOS_ip )
+ i_result = main.ONOSbench.onos_install( node=ONOS_ip )
+ utilities.assert_equals( expect=main.TRUE, actual=i_result,
+ onpass="Test step PASS",
+ onfail="Test step FAIL" )
+ installResult = ( installResult and i_result )
- main.step("Verify ONOS nodes UP status")
- statusResult=main.TRUE
- for i in range(1,int(numCtrls)+1):
- ONOS_ip = main.params['CTRL']['ip'+str(i)]
- main.log.info("ONOS Node "+ONOS_ip+" status:")
- onos_status = main.ONOSbench.onos_status(node=ONOS_ip)
- utilities.assert_equals(expect=main.TRUE, actual=onos_status,
- onpass="Test step PASS",
- onfail="Test step FAIL")
- statusResult=(statusResult and onos_status)
+ main.step( "Verify ONOS nodes UP status" )
+ statusResult = main.TRUE
+ for i in range( 1, int( numCtrls ) + 1 ):
+ ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
+ main.log.info( "ONOS Node " + ONOS_ip + " status:" )
+ onos_status = main.ONOSbench.onos_status( node=ONOS_ip )
+ utilities.assert_equals( expect=main.TRUE, actual=onos_status,
+ onpass="Test step PASS",
+ onfail="Test step FAIL" )
+ statusResult = ( statusResult and onos_status )
- main.step("Start ONOS CLI on all nodes")
+ main.step( "Start ONOS CLI on all nodes" )
cliResult = main.TRUE
- time.sleep(15) # need to wait here for sometime. This will be removed once ONOS is stable enough
- for i in range(1,int(numCtrls)+1):
- ONOS_ip = main.params['CTRL']['ip'+str(i)]
- ONOScli = 'ONOScli'+str(i)
- main.log.info("ONOS Node "+ONOS_ip+" cli start:")
- exec "startcli=main."+ONOScli+".start_onos_cli(ONOS_ip)"
- utilities.assert_equals(expect=main.TRUE, actual=startcli,
- onpass="Test step PASS",
- onfail="Test step FAIL")
- cliResult = (cliResult and startcli)
+ karafTimeout = "3600000"
+ # need to wait here for sometime. This will be removed once ONOS is
+ # stable enough
+ time.sleep( 15 )
+ for i in range( 1, int( numCtrls ) + 1 ):
+ ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
+ ONOScli = 'ONOScli' + str( i )
+ main.log.info( "ONOS Node " + ONOS_ip + " cli start:" )
+ exec "startcli=main." + ONOScli + \
+ ".start_onos_cli(ONOS_ip, karafTimeout=karafTimeout)"
+ utilities.assert_equals( expect=main.TRUE, actual=startcli,
+ onpass="Test step PASS",
+ onfail="Test step FAIL" )
+ cliResult = ( cliResult and startcli )
- case1Result = (cp_result and cell_result
- and packageResult and installResult and statusResult and cliResult)
- utilities.assert_equals(expect=main.TRUE, actual=case1Result,
- onpass="Set up test environment PASS",
- onfail="Set up test environment FAIL")
+ case1Result = ( cp_result and cell_result
+ and packageResult and installResult and statusResult and cliResult )
+ utilities.assert_equals( expect=main.TRUE, actual=case1Result,
+ onpass="Set up test environment PASS",
+ onfail="Set up test environment FAIL" )
- def CASE2(self, main):
- '''
+ def CASE2( self, main ):
+ """
This test script still needs more refactoring
- '''
+ """
import re
import time
import copy
- numCtrls = main.params['CTRL']['numCtrl']
- ONOS1_ip = main.params['CTRL']['ip1']
- ONOS2_ip = main.params['CTRL']['ip2']
- ONOS3_ip = main.params['CTRL']['ip3']
- ONOS4_ip = main.params['CTRL']['ip4']
- ONOS5_ip = main.params['CTRL']['ip5']
- ONOS1_port = main.params['CTRL']['port1']
- ONOS2_port = main.params['CTRL']['port2']
- ONOS3_port = main.params['CTRL']['port3']
- ONOS4_port = main.params['CTRL']['port4']
- ONOS5_port = main.params['CTRL']['port5']
+ numCtrls = main.params[ 'CTRL' ][ 'numCtrl' ]
+ ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+ ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
+ ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
+ ONOS4_ip = main.params[ 'CTRL' ][ 'ip4' ]
+ ONOS5_ip = main.params[ 'CTRL' ][ 'ip5' ]
+ ONOS1_port = main.params[ 'CTRL' ][ 'port1' ]
+ ONOS2_port = main.params[ 'CTRL' ][ 'port2' ]
+ ONOS3_port = main.params[ 'CTRL' ][ 'port3' ]
+ ONOS4_port = main.params[ 'CTRL' ][ 'port4' ]
+ ONOS5_port = main.params[ 'CTRL' ][ 'port5' ]
- numCtrls = main.params['CTRL']['numCtrl']
- main.log.report("Assign and Balance all Mininet switches across controllers")
- main.log.report("_________________________________________________________")
- time.sleep(15) # need to wait here for sometime. This will be removed once ONOS is stable enough
- main.case("Assign and Balance all Mininet switches across controllers")
- main.step("Assign switches to controllers")
- for i in range(1,26): #1 to (num of switches +1)
- main.Mininet1.assign_sw_controller(sw=str(i),count=int(numCtrls),
- ip1=ONOS1_ip, port1=ONOS1_port,
- ip2=ONOS2_ip, port2=ONOS2_port,
- ip3=ONOS3_ip, port3=ONOS3_port, ip4=ONOS4_ip, port4=ONOS4_port,
- ip5=ONOS5_ip, port5=ONOS5_port)
+ numCtrls = main.params[ 'CTRL' ][ 'numCtrl' ]
+ main.log.report(
+ "Assign and Balance all Mininet switches across controllers" )
+ main.log.report(
+ "_________________________________________________________" )
+ # need to wait here for sometime. This will be removed once ONOS is
+ # stable enough
+ time.sleep( 15 )
+ main.case(
+ "Assign and Balance all Mininet switches across controllers" )
+ main.step( "Assign switches to controllers" )
+ for i in range( 1, 26 ): # 1 to ( num of switches +1 )
+ main.Mininet1.assign_sw_controller(
+ sw=str( i ),
+ count=int( numCtrls ),
+ ip1=ONOS1_ip,
+ port1=ONOS1_port,
+ ip2=ONOS2_ip,
+ port2=ONOS2_port,
+ ip3=ONOS3_ip,
+ port3=ONOS3_port,
+ ip4=ONOS4_ip,
+ port4=ONOS4_port,
+ ip5=ONOS5_ip,
+ port5=ONOS5_port )
switch_mastership = main.TRUE
- for i in range (1,26):
- response = main.Mininet1.get_sw_controller("s"+str(i))
- print("Response is " + str(response))
- if re.search("tcp:"+ONOS1_ip,response):
+ for i in range( 1, 26 ):
+ response = main.Mininet1.get_sw_controller( "s" + str( i ) )
+ print( "Response is " + str( response ) )
+ if re.search( "tcp:" + ONOS1_ip, response ):
switch_mastership = switch_mastership and main.TRUE
else:
switch_mastership = main.FALSE
if switch_mastership == main.TRUE:
- main.log.report("Controller assignment successfull")
+ main.log.report( "Controller assignment successfull" )
else:
- main.log.report("Controller assignment failed")
- time.sleep(5)
+ main.log.report( "Controller assignment failed" )
+ time.sleep( 5 )
- main.step("Balance devices across controllers")
- for i in range(int(numCtrls)):
+ main.step( "Balance devices across controllers" )
+ for i in range( int( numCtrls ) ):
balanceResult = main.ONOScli1.balance_masters()
- time.sleep(3) # giving some breathing time for ONOS to complete re-balance
+ # giving some breathing time for ONOS to complete re-balance
+ time.sleep( 3 )
- utilities.assert_equals(expect=main.TRUE, actual=balanceResult,
- onpass="Assign and Balance devices test PASS",
- onfail="Assign and Balance devices test FAIL")
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=balanceResult,
+ onpass="Assign and Balance devices test PASS",
+ onfail="Assign and Balance devices test FAIL" )
- def CASE3(self,main) :
- '''
+ def CASE3( self, main ):
+ """
This Test case will be extended to collect and store more data related
ONOS state.
- '''
+ """
import re
import copy
deviceDPIDs = []
@@ -195,117 +218,136 @@
deviceActiveLinksCount = []
devicePortsEnabledCount = []
- main.log.report("Collect and Store topology details from ONOS before running any Tests")
- main.log.report("____________________________________________________________________")
- main.case ("Collect and Store Topology Deatils from ONOS")
+ main.log.report(
+ "Collect and Store topology details from ONOS before running any Tests" )
+ main.log.report(
+ "____________________________________________________________________" )
+ main.case( "Collect and Store Topology Deatils from ONOS" )
- main.step("Collect and store current number of switches and links")
+ main.step( "Collect and store current number of switches and links" )
topology_output = main.ONOScli1.topology()
- topology_result = main.ONOSbench.get_topology(topology_output)
- numSwitches = topology_result['devices']
- numLinks = topology_result['links']
- main.log.info("Currently there are %s switches and %s links" %(str(numSwitches), str(numLinks)))
+ topology_result = main.ONOSbench.get_topology( topology_output )
+ numSwitches = topology_result[ 'devices' ]
+ numLinks = topology_result[ 'links' ]
+ main.log.info(
+ "Currently there are %s switches and %s links" %
+ ( str( numSwitches ), str( numLinks ) ) )
- main.step("Store Device DPIDs")
- for i in range(1,26):
- deviceDPIDs.append("of:00000000000000"+format(i, '02x'))
- print "Device DPIDs in Store: \n", str(deviceDPIDs)
+ main.step( "Store Device DPIDs" )
+ for i in range( 1, 26 ):
+ deviceDPIDs.append( "of:00000000000000" + format( i, '02x' ) )
+ print "Device DPIDs in Store: \n", str( deviceDPIDs )
- main.step("Store Host MACs")
- for i in range(1,26):
- hostMACs.append("00:00:00:00:00:"+format(i, '02x')+"/-1")
- print "Host MACs in Store: \n", str(hostMACs)
+ main.step( "Store Host MACs" )
+ for i in range( 1, 26 ):
+ hostMACs.append( "00:00:00:00:00:" + format( i, '02x' ) + "/-1" )
+ print "Host MACs in Store: \n", str( hostMACs )
- main.step("Collect and store all Devices Links")
- linksResult = main.ONOScli1.links(json_format=False)
- ansi_escape = re.compile(r'\x1b[^m]*m')
- linksResult = ansi_escape.sub('', linksResult)
- linksResult = linksResult.replace(" links","").replace("\r\r","")
- linksResult=linksResult.splitlines()
- linksResult = linksResult[1:]
- deviceLinks = copy.copy(linksResult)
- print "Device Links Stored: \n", str(deviceLinks)
- print "Length of Links Store", len(deviceLinks) # this will be asserted to check with the params provided count of links
+ main.step( "Collect and store all Devices Links" )
+ linksResult = main.ONOScli1.links( json_format=False )
+ ansi_escape = re.compile( r'\x1b[^m]*m' )
+ linksResult = ansi_escape.sub( '', linksResult )
+ linksResult = linksResult.replace( " links", "" ).replace( "\r\r", "" )
+ linksResult = linksResult.splitlines()
+ linksResult = linksResult[ 1: ]
+ deviceLinks = copy.copy( linksResult )
+ print "Device Links Stored: \n", str( deviceLinks )
+ # this will be asserted to check with the params provided count of
+ # links
+ print "Length of Links Store", len( deviceLinks )
- main.step("Collect and store each Device ports enabled Count")
- for i in range(1,26):
- portResult = main.ONOScli1.getDevicePortsEnabledCount("of:00000000000000"+format(i, '02x'))
- portTemp = re.split(r'\t+', portResult)
- portCount = portTemp[1].replace("\r\r\n\x1b[32m","")
- devicePortsEnabledCount.append(portCount)
- print "Device Enabled Port Counts Stored: \n", str(devicePortsEnabledCount)
+ main.step( "Collect and store each Device ports enabled Count" )
+ for i in range( 1, 26 ):
+ portResult = main.ONOScli1.getDevicePortsEnabledCount(
+ "of:00000000000000" +
+ format(
+ i,
+ '02x' ) )
+ portTemp = re.split( r'\t+', portResult )
+ portCount = portTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
+ devicePortsEnabledCount.append( portCount )
+ print "Device Enabled Port Counts Stored: \n", str( devicePortsEnabledCount )
- main.step("Collect and store each Device active links Count")
- for i in range(1,26):
- linkCountResult = main.ONOScli1.getDeviceLinksActiveCount("of:00000000000000"+format(i, '02x'))
- linkCountTemp = re.split(r'\t+', linkCountResult)
- linkCount = linkCountTemp[1].replace("\r\r\n\x1b[32m","")
- deviceActiveLinksCount.append(linkCount)
- print "Device Active Links Count Stored: \n", str(deviceActiveLinksCount)
+ main.step( "Collect and store each Device active links Count" )
+ for i in range( 1, 26 ):
+ linkCountResult = main.ONOScli1.getDeviceLinksActiveCount(
+ "of:00000000000000" +
+ format(
+ i,
+ '02x' ) )
+ linkCountTemp = re.split( r'\t+', linkCountResult )
+ linkCount = linkCountTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
+ deviceActiveLinksCount.append( linkCount )
+ print "Device Active Links Count Stored: \n", str( deviceActiveLinksCount )
- caseResult = main.TRUE # just returning TRUE for now as this one just collects data
- utilities.assert_equals(expect=main.TRUE, actual=case1Result,
- onpass="Saving ONOS topology data test PASS",
- onfail="Saving ONOS topology data test FAIL")
+ # just returning TRUE for now as this one just collects data
+ caseResult = main.TRUE
+ utilities.assert_equals( expect=main.TRUE, actual=case1Result,
+ onpass="Saving ONOS topology data test PASS",
+ onfail="Saving ONOS topology data test FAIL" )
- def CASE4(self,main) :
- '''
- Enable onos-app-fwd, Verify Reactive forwarding through ping all and Disable it
- '''
+ def CASE4( self, main ):
+ """
+ Enable onos-app-fwd, Verify Reactive forwarding through ping all and Disable it
+ """
import re
import copy
import time
- numCtrls = main.params['CTRL']['numCtrl']
- main.log.report("Enable Reactive forwarding and Verify ping all")
- main.log.report("______________________________________________")
- main.case ("Enable Reactive forwarding and Verify ping all")
- main.step("Enable Reactive forwarding")
+ numCtrls = main.params[ 'CTRL' ][ 'numCtrl' ]
+ main.log.report( "Enable Reactive forwarding and Verify ping all" )
+ main.log.report( "______________________________________________" )
+ main.case( "Enable Reactive forwarding and Verify ping all" )
+ main.step( "Enable Reactive forwarding" )
installResult = main.TRUE
- for i in range(1,int(numCtrls)+1):
+ for i in range( 1, int( numCtrls ) + 1 ):
onosFeature = 'onos-app-fwd'
- ONOS_ip = main.params['CTRL']['ip'+str(i)]
- ONOScli = 'ONOScli'+str(i)
- main.log.info("Enabling Reactive mode on ONOS Node "+ONOS_ip)
- exec "inResult=main."+ONOScli+".feature_install(onosFeature)"
+ ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
+ ONOScli = 'ONOScli' + str( i )
+ main.log.info( "Enabling Reactive mode on ONOS Node " + ONOS_ip )
+ exec "inResult=main." + ONOScli + ".feature_install(onosFeature)"
+ time.sleep( 3 )
installResult = inResult and installResult
- time.sleep(5)
+ time.sleep( 5 )
- main.step("Verify Pingall")
+ main.step( "Verify Pingall" )
ping_result = main.FALSE
time1 = time.time()
ping_result = main.Mininet1.pingall()
time2 = time.time()
- timeDiff = round((time2-time1),2)
- main.log.report("Time taken for Ping All: "+str(timeDiff)+" seconds")
+ timeDiff = round( ( time2 - time1 ), 2 )
+ main.log.report(
+ "Time taken for Ping All: " +
+ str( timeDiff ) +
+ " seconds" )
if ping_result == main.TRUE:
- main.log.report("Pingall Test in Reactive mode successful")
+ main.log.report( "Pingall Test in Reactive mode successful" )
else:
- main.log.report("Pingall Test in Reactive mode failed")
+ main.log.report( "Pingall Test in Reactive mode failed" )
- main.step("Disable Reactive forwarding")
+ main.step( "Disable Reactive forwarding" )
uninstallResult = main.TRUE
- for i in range(1,int(numCtrls)+1):
+ for i in range( 1, int( numCtrls ) + 1 ):
onosFeature = 'onos-app-fwd'
- ONOS_ip = main.params['CTRL']['ip'+str(i)]
- ONOScli = 'ONOScli'+str(i)
- main.log.info("Disabling Reactive mode on ONOS Node "+ONOS_ip)
- exec "unResult=main."+ONOScli+".feature_uninstall(onosFeature)"
+ ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
+ ONOScli = 'ONOScli' + str( i )
+ main.log.info( "Disabling Reactive mode on ONOS Node " + ONOS_ip )
+ exec "unResult=main." + ONOScli + ".feature_uninstall(onosFeature)"
uninstallResult = unResult and uninstallResult
- #Waiting for reative flows to be cleared.
- time.sleep(10)
+ # Waiting for reative flows to be cleared.
+ time.sleep( 10 )
case3Result = installResult and ping_result and uninstallResult
- utilities.assert_equals(expect=main.TRUE, actual=case3Result,
- onpass="Reactive Mode Pingall test PASS",
- onfail="Reactive Mode Pingall test FAIL")
+ utilities.assert_equals( expect=main.TRUE, actual=case3Result,
+ onpass="Reactive Mode Pingall test PASS",
+ onfail="Reactive Mode Pingall test FAIL" )
- def CASE5(self,main) :
- '''
+ def CASE5( self, main ):
+ """
Compare current ONOS topology with reference data
- '''
+ """
import re
devicesDPID_tmp = []
hostMACs_tmp = []
@@ -313,276 +355,529 @@
deviceActiveLinksCount_tmp = []
devicePortsEnabledCount_tmp = []
- main.log.report("Compare ONOS topology with reference data in Stores")
- main.log.report("__________________________________________________")
- main.case ("Compare ONOS topology with reference data")
-
- main.step("Compare current Device ports enabled with reference")
- for i in range(1,26):
- portResult = main.ONOScli1.getDevicePortsEnabledCount("of:00000000000000"+format(i, '02x'))
- portTemp = re.split(r'\t+', portResult)
- portCount = portTemp[1].replace("\r\r\n\x1b[32m","")
- devicePortsEnabledCount_tmp.append(portCount)
- time.sleep(2)
- print ("Device Enabled ports EXPECTED: \n"+ str(devicePortsEnabledCount))
- print ("Device Enabled ports ACTUAL: \n"+ str(devicePortsEnabledCount_tmp))
- if (cmp(devicePortsEnabledCount,devicePortsEnabledCount_tmp)==0):
+ main.log.report(
+ "Compare ONOS topology with reference data in Stores" )
+ main.log.report( "__________________________________________________" )
+ main.case( "Compare ONOS topology with reference data" )
+
+ main.step( "Compare current Device ports enabled with reference" )
+ for i in range( 1, 26 ):
+ portResult = main.ONOScli1.getDevicePortsEnabledCount(
+ "of:00000000000000" +
+ format(
+ i,
+ '02x' ) )
+ portTemp = re.split( r'\t+', portResult )
+ portCount = portTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
+ devicePortsEnabledCount_tmp.append( portCount )
+ time.sleep( 2 )
+ print (
+ "Device Enabled ports EXPECTED: \n" +
+ str( devicePortsEnabledCount ) )
+ print (
+ "Device Enabled ports ACTUAL: \n" +
+ str( devicePortsEnabledCount_tmp ) )
+ if ( cmp( devicePortsEnabledCount,
+ devicePortsEnabledCount_tmp ) == 0 ):
stepResult1 = main.TRUE
else:
stepResult1 = main.FALSE
- main.step("Compare Device active links with reference")
- for i in range(1,26):
- linkResult = main.ONOScli1.getDeviceLinksActiveCount("of:00000000000000"+format(i, '02x'))
- linkTemp = re.split(r'\t+', linkResult)
- linkCount = linkTemp[1].replace("\r\r\n\x1b[32m","")
- deviceActiveLinksCount_tmp.append(linkCount)
- time.sleep(3)
- print ("Device Active links EXPECTED: \n"+str(deviceActiveLinksCount))
- print ("Device Active links ACTUAL: \n"+str(deviceActiveLinksCount_tmp))
- if (cmp(deviceActiveLinksCount,deviceActiveLinksCount_tmp)==0):
+ main.step( "Compare Device active links with reference" )
+ for i in range( 1, 26 ):
+ linkResult = main.ONOScli1.getDeviceLinksActiveCount(
+ "of:00000000000000" +
+ format(
+ i,
+ '02x' ) )
+ linkTemp = re.split( r'\t+', linkResult )
+ linkCount = linkTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
+ deviceActiveLinksCount_tmp.append( linkCount )
+ time.sleep( 3 )
+ print (
+ "Device Active links EXPECTED: \n" +
+ str( deviceActiveLinksCount ) )
+ print (
+ "Device Active links ACTUAL: \n" +
+ str( deviceActiveLinksCount_tmp ) )
+ if ( cmp( deviceActiveLinksCount, deviceActiveLinksCount_tmp ) == 0 ):
stepResult2 = main.TRUE
else:
stepResult2 = main.FALSE
- '''
- place holder for comparing devices, hosts and paths if required.
+ """
+ place holder for comparing devices, hosts and paths if required.
Links and ports data would be incorrect with out devices anyways.
- '''
-
- caseResult=(stepResult1 and stepResult2)
- utilities.assert_equals(expect=main.TRUE, actual=case1Result,
- onpass="Compare Topology test PASS",
- onfail="Compare Topology test FAIL")
+ """
+ caseResult = ( stepResult1 and stepResult2 )
+ utilities.assert_equals( expect=main.TRUE, actual=case1Result,
+ onpass="Compare Topology test PASS",
+ onfail="Compare Topology test FAIL" )
if caseResult == main.TRUE:
- main.log.report("Compare Topology test Pass")
+ main.log.report( "Compare Topology test Pass" )
- def CASE6(self):
- '''
+ def CASE6( self ):
+ """
Install 300 host intents and verify ping all
- '''
- main.log.report("Add 300 host intents and verify pingall")
- main.log.report("_______________________________________")
+ """
+ main.log.report( "Add 300 host intents and verify pingall" )
+ main.log.report( "_______________________________________" )
import itertools
- main.case("Install 300 host intents")
- main.step("Add host Intents")
- intentResult=main.TRUE
- hostCombos = list(itertools.combinations(hostMACs, 2))
- for i in range(len(hostCombos)):
- iResult = main.ONOScli1.add_host_intent(hostCombos[i][0],hostCombos[i][1])
- intentResult=(intentResult and iResult)
+ main.case( "Install 300 host intents" )
+ main.step( "Add host Intents" )
+ intentResult = main.TRUE
+ hostCombos = list( itertools.combinations( hostMACs, 2 ) )
+ for i in range( len( hostCombos ) ):
+ iResult = main.ONOScli1.add_host_intent(
+ hostCombos[ i ][ 0 ],
+ hostCombos[ i ][ 1 ] )
+ intentResult = ( intentResult and iResult )
- main.step("Verify Ping across all hosts")
+ main.step( "Verify Ping across all hosts" )
pingResult = main.FALSE
time1 = time.time()
pingResult = main.Mininet1.pingall()
time2 = time.time()
- timeDiff = round((time2-time1),2)
- main.log.report("Time taken for Ping All: "+str(timeDiff)+" seconds")
- utilities.assert_equals(expect=main.TRUE, actual=pingResult,
- onpass="PING ALL PASS",
- onfail="PING ALL FAIL")
+ timeDiff = round( ( time2 - time1 ), 2 )
+ main.log.report(
+ "Time taken for Ping All: " +
+ str( timeDiff ) +
+ " seconds" )
+ utilities.assert_equals( expect=main.TRUE, actual=pingResult,
+ onpass="PING ALL PASS",
+ onfail="PING ALL FAIL" )
- case4Result=(intentResult and pingResult)
- utilities.assert_equals(expect=main.TRUE, actual=case4Result,
- onpass="Install 300 Host Intents and Ping All test PASS",
- onfail="Install 300 Host Intents and Ping All test FAIL")
+ case4Result = ( intentResult and pingResult )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case4Result,
+ onpass="Install 300 Host Intents and Ping All test PASS",
+ onfail="Install 300 Host Intents and Ping All test FAIL" )
- def CASE7(self,main):
- '''
- Randomly bring some core links down and verify ping all
- '''
+ def CASE70( self, main ):
+ """
+ Randomly bring some core links down and verify ping all ( Host Intents Scenario )
+ """
import random
- ONOS1_ip = main.params['CTRL']['ip1']
- link1End1 = main.params['CORELINKS']['linkS3a']
- link1End2 = main.params['CORELINKS']['linkS3b'].split(',')
- link2End1 = main.params['CORELINKS']['linkS14a']
- link2End2 = main.params['CORELINKS']['linkS14b'].split(',')
- link3End1 = main.params['CORELINKS']['linkS18a']
- link3End2 = main.params['CORELINKS']['linkS18b'].split(',')
- switchLinksToToggle = main.params['CORELINKS']['toggleLinks']
- link_sleep = int(main.params['timers']['LinkDiscovery'])
+ ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+ link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ]
+ link1End2 = main.params[ 'CORELINKS' ][ 'linkS3b' ].split( ',' )
+ link2End1 = main.params[ 'CORELINKS' ][ 'linkS14a' ]
+ link2End2 = main.params[ 'CORELINKS' ][ 'linkS14b' ].split( ',' )
+ link3End1 = main.params[ 'CORELINKS' ][ 'linkS18a' ]
+ link3End2 = main.params[ 'CORELINKS' ][ 'linkS18b' ].split( ',' )
+ switchLinksToToggle = main.params[ 'CORELINKS' ][ 'toggleLinks' ]
+ link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
- main.log.report("Randomly bring some core links down and verify ping all")
- main.log.report("____________________________________________________")
- main.case("Randomly bring some core links down and verify ping all")
- main.step("Verify number of Switch links to toggle on each Core Switch are between 1 - 5")
- if (int(switchLinksToToggle) == 0 or int(switchLinksToToggle) > 5):
- main.log.info("Please check you PARAMS file. Valid range for number of switch links to toggle is between 1 to 5")
+ main.log.report(
+ "Host intents - Randomly bring some core links down and verify ping all" )
+ main.log.report(
+ "_________________________________________________________________" )
+ main.case(
+ "Host intents - Randomly bring some core links down and verify ping all" )
+ main.step(
+ "Verify number of Switch links to toggle on each Core Switch are between 1 - 5" )
+ if ( int( switchLinksToToggle ) ==
+ 0 or int( switchLinksToToggle ) > 5 ):
+ main.log.info(
+ "Please check you PARAMS file. Valid range for number of switch links to toggle is between 1 to 5" )
main.cleanup()
main.exit()
else:
- main.log.info("User provided Core switch links range to toggle is correct, proceeding to run the test")
+ main.log.info(
+ "User provided Core switch links range to toggle is correct, proceeding to run the test" )
- main.step("Cut links on Core devices using user provided range")
- randomLink1 = random.sample(link1End2,int(switchLinksToToggle))
- randomLink2 = random.sample(link2End2,int(switchLinksToToggle))
- randomLink3 = random.sample(link3End2,int(switchLinksToToggle))
- for i in range(int(switchLinksToToggle)):
- main.Mininet1.link(END1=link1End1,END2=randomLink1[i],OPTION="down")
- main.Mininet1.link(END1=link2End1,END2=randomLink2[i],OPTION="down")
- main.Mininet1.link(END1=link3End1,END2=randomLink3[i],OPTION="down")
- time.sleep(link_sleep)
+ main.step( "Cut links on Core devices using user provided range" )
+ randomLink1 = random.sample( link1End2, int( switchLinksToToggle ) )
+ randomLink2 = random.sample( link2End2, int( switchLinksToToggle ) )
+ randomLink3 = random.sample( link3End2, int( switchLinksToToggle ) )
+ for i in range( int( switchLinksToToggle ) ):
+ main.Mininet1.link(
+ END1=link1End1,
+ END2=randomLink1[ i ],
+ OPTION="down" )
+ main.Mininet1.link(
+ END1=link2End1,
+ END2=randomLink2[ i ],
+ OPTION="down" )
+ main.Mininet1.link(
+ END1=link3End1,
+ END2=randomLink3[ i ],
+ OPTION="down" )
+ time.sleep( link_sleep )
topology_output = main.ONOScli2.topology()
- linkDown = main.ONOSbench.check_status(topology_output,numSwitches,str(int(numLinks)-int(switchLinksToToggle)*6))
- utilities.assert_equals(expect=main.TRUE,actual=linkDown,
- onpass="Link Down discovered properly",
- onfail="Link down was not discovered in "+ str(link_sleep) + " seconds")
+ linkDown = main.ONOSbench.check_status(
+ topology_output, numSwitches, str(
+ int( numLinks ) - int( switchLinksToToggle ) * 6 ) )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=linkDown,
+ onpass="Link Down discovered properly",
+ onfail="Link down was not discovered in " +
+ str( link_sleep ) +
+ " seconds" )
- main.step("Verify Ping across all hosts")
+ main.step( "Verify Ping across all hosts" )
pingResultLinkDown = main.FALSE
time1 = time.time()
pingResultLinkDown = main.Mininet1.pingall()
time2 = time.time()
- timeDiff = round((time2-time1),2)
- main.log.report("Time taken for Ping All: "+str(timeDiff)+" seconds")
- utilities.assert_equals(expect=main.TRUE, actual=pingResultLinkDown,
- onpass="PING ALL PASS",
- onfail="PING ALL FAIL")
+ timeDiff = round( ( time2 - time1 ), 2 )
+ main.log.report(
+ "Time taken for Ping All: " +
+ str( timeDiff ) +
+ " seconds" )
+ utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
+ onpass="PING ALL PASS",
+ onfail="PING ALL FAIL" )
caseResult7 = linkDown and pingResultLinkDown
- utilities.assert_equals(expect=main.TRUE, actual=caseResult7,
- onpass="Random Link cut Test PASS",
- onfail="Random Link cut Test FAIL")
+ utilities.assert_equals( expect=main.TRUE, actual=caseResult7,
+ onpass="Random Link cut Test PASS",
+ onfail="Random Link cut Test FAIL" )
- def CASE8(self,main):
- '''
- Bring the core links up that are down and verify ping all
- '''
+ def CASE80( self, main ):
+ """
+ Bring the core links up that are down and verify ping all ( Host Intents Scenario )
+ """
import random
- ONOS1_ip = main.params['CTRL']['ip1']
- link1End1 = main.params['CORELINKS']['linkS3a']
- link2End1 = main.params['CORELINKS']['linkS14a']
- link3End1 = main.params['CORELINKS']['linkS18a']
- link_sleep = int(main.params['timers']['LinkDiscovery'])
- switchLinksToToggle = main.params['CORELINKS']['toggleLinks']
+ ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+ link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ]
+ link2End1 = main.params[ 'CORELINKS' ][ 'linkS14a' ]
+ link3End1 = main.params[ 'CORELINKS' ][ 'linkS18a' ]
+ link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
+ switchLinksToToggle = main.params[ 'CORELINKS' ][ 'toggleLinks' ]
- main.log.report("Bring the core links up that are down and verify ping all")
- main.log.report("_____________________________________________________")
- main.case("Bring the core links up that are down and verify ping all")
- main.step("Bring randomly cut links on Core devices up")
- for i in range(int(switchLinksToToggle)):
- main.Mininet1.link(END1=link1End1,END2=randomLink1[i],OPTION="up")
- main.Mininet1.link(END1=link2End1,END2=randomLink2[i],OPTION="up")
- main.Mininet1.link(END1=link3End1,END2=randomLink3[i],OPTION="up")
- time.sleep(link_sleep)
+ main.log.report(
+ "Host intents - Bring the core links up that are down and verify ping all" )
+ main.log.report(
+ "__________________________________________________________________" )
+ main.case(
+ "Host intents - Bring the core links up that are down and verify ping all" )
+ main.step( "Bring randomly cut links on Core devices up" )
+ for i in range( int( switchLinksToToggle ) ):
+ main.Mininet1.link(
+ END1=link1End1,
+ END2=randomLink1[ i ],
+ OPTION="up" )
+ main.Mininet1.link(
+ END1=link2End1,
+ END2=randomLink2[ i ],
+ OPTION="up" )
+ main.Mininet1.link(
+ END1=link3End1,
+ END2=randomLink3[ i ],
+ OPTION="up" )
+ time.sleep( link_sleep )
topology_output = main.ONOScli2.topology()
- linkUp = main.ONOSbench.check_status(topology_output,numSwitches,str(numLinks))
- utilities.assert_equals(expect=main.TRUE,actual=linkUp,
- onpass="Link up discovered properly",
- onfail="Link up was not discovered in "+ str(link_sleep) + " seconds")
+ linkUp = main.ONOSbench.check_status(
+ topology_output,
+ numSwitches,
+ str( numLinks ) )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=linkUp,
+ onpass="Link up discovered properly",
+ onfail="Link up was not discovered in " +
+ str( link_sleep ) +
+ " seconds" )
- main.step("Verify Ping across all hosts")
+ main.step( "Verify Ping across all hosts" )
pingResultLinkUp = main.FALSE
time1 = time.time()
pingResultLinkUp = main.Mininet1.pingall()
time2 = time.time()
- timeDiff = round((time2-time1),2)
- main.log.report("Time taken for Ping All: "+str(timeDiff)+" seconds")
- utilities.assert_equals(expect=main.TRUE, actual=pingResultLinkUp,
- onpass="PING ALL PASS",
- onfail="PING ALL FAIL")
+ timeDiff = round( ( time2 - time1 ), 2 )
+ main.log.report(
+ "Time taken for Ping All: " +
+ str( timeDiff ) +
+ " seconds" )
+ utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
+ onpass="PING ALL PASS",
+ onfail="PING ALL FAIL" )
caseResult8 = linkUp and pingResultLinkUp
- utilities.assert_equals(expect=main.TRUE, actual=caseResult8,
- onpass="Link Up Test PASS",
- onfail="Link Up Test FAIL")
+ utilities.assert_equals( expect=main.TRUE, actual=caseResult8,
+ onpass="Link Up Test PASS",
+ onfail="Link Up Test FAIL" )
- def CASE9(self):
- '''
+ def CASE71( self, main ):
+ """
+ Randomly bring some core links down and verify ping all ( Point Intents Scenario )
+ """
+ import random
+ ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+ link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ]
+ link1End2 = main.params[ 'CORELINKS' ][ 'linkS3b' ].split( ',' )
+ link2End1 = main.params[ 'CORELINKS' ][ 'linkS14a' ]
+ link2End2 = main.params[ 'CORELINKS' ][ 'linkS14b' ].split( ',' )
+ link3End1 = main.params[ 'CORELINKS' ][ 'linkS18a' ]
+ link3End2 = main.params[ 'CORELINKS' ][ 'linkS18b' ].split( ',' )
+ switchLinksToToggle = main.params[ 'CORELINKS' ][ 'toggleLinks' ]
+ link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
+
+ main.log.report(
+ "Point Intents - Randomly bring some core links down and verify ping all" )
+ main.log.report(
+ "__________________________________________________________________" )
+ main.case(
+ "Point Intents - Randomly bring some core links down and verify ping all" )
+ main.step(
+ "Verify number of Switch links to toggle on each Core Switch are between 1 - 5" )
+ if ( int( switchLinksToToggle ) ==
+ 0 or int( switchLinksToToggle ) > 5 ):
+ main.log.info(
+ "Please check you PARAMS file. Valid range for number of switch links to toggle is between 1 to 5" )
+ main.cleanup()
+ main.exit()
+ else:
+ main.log.info(
+ "User provided Core switch links range to toggle is correct, proceeding to run the test" )
+
+ main.step( "Cut links on Core devices using user provided range" )
+ randomLink1 = random.sample( link1End2, int( switchLinksToToggle ) )
+ randomLink2 = random.sample( link2End2, int( switchLinksToToggle ) )
+ randomLink3 = random.sample( link3End2, int( switchLinksToToggle ) )
+ for i in range( int( switchLinksToToggle ) ):
+ main.Mininet1.link(
+ END1=link1End1,
+ END2=randomLink1[ i ],
+ OPTION="down" )
+ main.Mininet1.link(
+ END1=link2End1,
+ END2=randomLink2[ i ],
+ OPTION="down" )
+ main.Mininet1.link(
+ END1=link3End1,
+ END2=randomLink3[ i ],
+ OPTION="down" )
+ time.sleep( link_sleep )
+
+ topology_output = main.ONOScli2.topology()
+ linkDown = main.ONOSbench.check_status(
+ topology_output, numSwitches, str(
+ int( numLinks ) - int( switchLinksToToggle ) * 6 ) )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=linkDown,
+ onpass="Link Down discovered properly",
+ onfail="Link down was not discovered in " +
+ str( link_sleep ) +
+ " seconds" )
+
+ main.step( "Verify Ping across all hosts" )
+ pingResultLinkDown = main.FALSE
+ time1 = time.time()
+ pingResultLinkDown = main.Mininet1.pingall()
+ time2 = time.time()
+ timeDiff = round( ( time2 - time1 ), 2 )
+ main.log.report(
+ "Time taken for Ping All: " +
+ str( timeDiff ) +
+ " seconds" )
+ utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
+ onpass="PING ALL PASS",
+ onfail="PING ALL FAIL" )
+
+ caseResult7 = linkDown and pingResultLinkDown
+ utilities.assert_equals( expect=main.TRUE, actual=caseResult7,
+ onpass="Random Link cut Test PASS",
+ onfail="Random Link cut Test FAIL" )
+
+ def CASE81( self, main ):
+ """
+ Bring the core links up that are down and verify ping all ( Point Intents Scenario )
+ """
+ import random
+ ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+ link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ]
+ link2End1 = main.params[ 'CORELINKS' ][ 'linkS14a' ]
+ link3End1 = main.params[ 'CORELINKS' ][ 'linkS18a' ]
+ link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
+ switchLinksToToggle = main.params[ 'CORELINKS' ][ 'toggleLinks' ]
+
+ main.log.report(
+ "Point intents - Bring the core links up that are down and verify ping all" )
+ main.log.report(
+ "___________________________________________________________________" )
+ main.case(
+ "Point intents - Bring the core links up that are down and verify ping all" )
+ main.step( "Bring randomly cut links on Core devices up" )
+ for i in range( int( switchLinksToToggle ) ):
+ main.Mininet1.link(
+ END1=link1End1,
+ END2=randomLink1[ i ],
+ OPTION="up" )
+ main.Mininet1.link(
+ END1=link2End1,
+ END2=randomLink2[ i ],
+ OPTION="up" )
+ main.Mininet1.link(
+ END1=link3End1,
+ END2=randomLink3[ i ],
+ OPTION="up" )
+ time.sleep( link_sleep )
+
+ topology_output = main.ONOScli2.topology()
+ linkUp = main.ONOSbench.check_status(
+ topology_output,
+ numSwitches,
+ str( numLinks ) )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=linkUp,
+ onpass="Link up discovered properly",
+ onfail="Link up was not discovered in " +
+ str( link_sleep ) +
+ " seconds" )
+
+ main.step( "Verify Ping across all hosts" )
+ pingResultLinkUp = main.FALSE
+ time1 = time.time()
+ pingResultLinkUp = main.Mininet1.pingall()
+ time2 = time.time()
+ timeDiff = round( ( time2 - time1 ), 2 )
+ main.log.report(
+ "Time taken for Ping All: " +
+ str( timeDiff ) +
+ " seconds" )
+ utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
+ onpass="PING ALL PASS",
+ onfail="PING ALL FAIL" )
+
+ caseResult8 = linkUp and pingResultLinkUp
+ utilities.assert_equals( expect=main.TRUE, actual=caseResult8,
+ onpass="Link Up Test PASS",
+ onfail="Link Up Test FAIL" )
+
+ def CASE9( self ):
+ """
Install 114 point intents and verify Ping all works
- '''
+ """
import copy
- main.log.report("Install 114 point intents and verify Ping all")
- main.log.report("___________________________________________")
- main.case("Install 114 point intents and Ping all")
- deviceLinks_copy = copy.copy(deviceLinks)
- main.step("Install 114 point intents")
- for i in range(len(deviceLinks_copy)):
- pointLink = str(deviceLinks_copy[i]).replace("src=","").replace("dst=","").split(',')
- point1 = pointLink[0].split('/')
- point2 = pointLink[1].split('/')
- installResult = main.ONOScli1.add_point_intent(point1[0],point2[0],int(point1[1]),int(point2[1]))
+ main.log.report( "Install 114 point intents and verify Ping all" )
+ main.log.report( "___________________________________________" )
+ main.case( "Install 114 point intents and Ping all" )
+ deviceLinks_copy = copy.copy( deviceLinks )
+ main.step( "Install 114 point intents" )
+ for i in range( len( deviceLinks_copy ) ):
+ pointLink = str(
+ deviceLinks_copy[ i ] ).replace(
+ "src=",
+ "" ).replace(
+ "dst=",
+ "" ).split( ',' )
+ point1 = pointLink[ 0 ].split( '/' )
+ point2 = pointLink[ 1 ].split( '/' )
+ installResult = main.ONOScli1.add_point_intent(
+ point1[ 0 ], point2[ 0 ], int(
+ point1[ 1 ] ), int(
+ point2[ 1 ] ) )
if installResult == main.TRUE:
- print "Installed Point intent between :",point1[0], int(point1[1]), point2[0], int(point2[1])
+ print "Installed Point intent between :", point1[ 0 ], int( point1[ 1 ] ), point2[ 0 ], int( point2[ 1 ] )
- main.step("Obtain the intent id's")
+ main.step( "Obtain the intent id's" )
intentsList = main.ONOScli1.getAllIntentIds()
- ansi_escape = re.compile(r'\x1b[^m]*m')
- intentsList = ansi_escape.sub('', intentsList)
- intentsList = intentsList.replace(" onos:intents | grep id=","").replace("id=","").replace("\r\r","")
- intentsList=intentsList.splitlines()
- intentsList = intentsList[1:]
+ ansi_escape = re.compile( r'\x1b[^m]*m' )
+ intentsList = ansi_escape.sub( '', intentsList )
+ intentsList = intentsList.replace(
+ " onos:intents | grep id=",
+ "" ).replace(
+ "id=",
+ "" ).replace(
+ "\r\r",
+ "" )
+ intentsList = intentsList.splitlines()
+ intentsList = intentsList[ 1: ]
intentIdList = []
- for i in range(len(intentsList)):
- intentsTemp = intentsList[i].split(',')
- intentIdList.append(intentsTemp[0])
+ for i in range( len( intentsList ) ):
+ intentsTemp = intentsList[ i ].split( ',' )
+ intentIdList.append( intentsTemp[ 0 ] )
print "Intent IDs: ", intentIdList
- print "Total Intents installed: ", len(intentIdList)
+ print "Total Intents installed: ", len( intentIdList )
- main.step("Verify Ping across all hosts")
+ main.step( "Verify Ping across all hosts" )
pingResult = main.FALSE
time1 = time.time()
pingResult = main.Mininet1.pingall()
time2 = time.time()
- timeDiff = round((time2-time1),2)
- main.log.report("Time taken for Ping All: "+str(timeDiff)+" seconds")
- utilities.assert_equals(expect=main.TRUE, actual=pingResult,
- onpass="PING ALL PASS",
- onfail="PING ALL FAIL")
+ timeDiff = round( ( time2 - time1 ), 2 )
+ main.log.report(
+ "Time taken for Ping All: " +
+ str( timeDiff ) +
+ " seconds" )
+ utilities.assert_equals( expect=main.TRUE, actual=pingResult,
+ onpass="PING ALL PASS",
+ onfail="PING ALL FAIL" )
case8_result = installResult and pingResult
- utilities.assert_equals(expect=main.TRUE, actual=case8_result,
- onpass="Ping all test after Point intents addition successful",
- onfail="Ping all test after Point intents addition failed")
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case8_result,
+ onpass="Ping all test after Point intents addition successful",
+ onfail="Ping all test after Point intents addition failed" )
- def CASE10(self):
- '''
+ def CASE10( self ):
+ """
Remove all Intents
- '''
- main.log.report("Remove all intents that were installed previously")
- main.log.report("______________________________________________")
- main.log.info("Remove all intents")
- main.case("Removing intents")
- main.step("Obtain the intent id's first")
+ """
+ main.log.report( "Remove all intents that were installed previously" )
+ main.log.report( "______________________________________________" )
+ main.log.info( "Remove all intents" )
+ main.case( "Removing intents" )
+ main.step( "Obtain the intent id's first" )
intentsList = main.ONOScli1.getAllIntentIds()
- ansi_escape = re.compile(r'\x1b[^m]*m')
- intentsList = ansi_escape.sub('', intentsList)
- intentsList = intentsList.replace(" onos:intents | grep id=","").replace("id=","").replace("\r\r","")
- intentsList=intentsList.splitlines()
- intentsList = intentsList[1:]
+ ansi_escape = re.compile( r'\x1b[^m]*m' )
+ intentsList = ansi_escape.sub( '', intentsList )
+ intentsList = intentsList.replace(
+ " onos:intents | grep id=",
+ "" ).replace(
+ "id=",
+ "" ).replace(
+ "\r\r",
+ "" )
+ intentsList = intentsList.splitlines()
+ intentsList = intentsList[ 1: ]
intentIdList = []
step1Result = main.TRUE
- if (len(intentsList) > 1):
- for i in range(len(intentsList)):
- intentsTemp = intentsList[i].split(',')
- intentIdList.append(intentsTemp[0])
+ if ( len( intentsList ) > 1 ):
+ for i in range( len( intentsList ) ):
+ intentsTemp = intentsList[ i ].split( ',' )
+ intentIdList.append( intentsTemp[ 0 ] )
print "Intent IDs: ", intentIdList
- for id in range(len(intentIdList)):
- print "Removing intent id (round 1) :", intentIdList[id]
- main.ONOScli1.remove_intent(intent_id = intentIdList[id])
- time.sleep(1)
+ for id in range( len( intentIdList ) ):
+ print "Removing intent id (round 1) :", intentIdList[ id ]
+ main.ONOScli1.remove_intent( intent_id=intentIdList[ id ] )
+ time.sleep( 1 )
- main.log.info("Verify all intents are removed and if any leftovers try remove one more time")
+ main.log.info(
+ "Verify all intents are removed and if any leftovers try remove one more time" )
intentsList1 = main.ONOScli1.getAllIntentIds()
- ansi_escape = re.compile(r'\x1b[^m]*m')
- intentsList1 = ansi_escape.sub('', intentsList1)
- intentsList1 = intentsList1.replace(" onos:intents | grep id=","").replace(" state=","").replace("\r\r","")
- intentsList1=intentsList1.splitlines()
- intentsList1 = intentsList1[1:]
+ ansi_escape = re.compile( r'\x1b[^m]*m' )
+ intentsList1 = ansi_escape.sub( '', intentsList1 )
+ intentsList1 = intentsList1.replace(
+ " onos:intents | grep id=",
+ "" ).replace(
+ " state=",
+ "" ).replace(
+ "\r\r",
+ "" )
+ intentsList1 = intentsList1.splitlines()
+ intentsList1 = intentsList1[ 1: ]
print "Round 2 (leftover) intents to remove: ", intentsList1
intentIdList1 = []
- if (len(intentsList1) > 1):
- for i in range(len(intentsList1)):
- intentsTemp1 = intentsList[i].split(',')
- intentIdList1.append(intentsTemp1[0])
+ if ( len( intentsList1 ) > 1 ):
+ for i in range( len( intentsList1 ) ):
+ intentsTemp1 = intentsList[ i ].split( ',' )
+ intentIdList1.append( intentsTemp1[ 0 ] )
print "Leftover Intent IDs: ", intentIdList1
- for id in range(len(intentIdList1)):
- print "Removing intent id (round 2):", intentIdList1[id]
- main.ONOScli1.remove_intent(intent_id = intentIdList1[id])
- time.sleep(2)
+ for id in range( len( intentIdList1 ) ):
+ print "Removing intent id (round 2):", intentIdList1[ id ]
+ main.ONOScli1.remove_intent(
+ intent_id=intentIdList1[ id ] )
+ time.sleep( 2 )
else:
print "There are no more intents that need to be removed"
step1Result = main.TRUE
@@ -591,6 +886,6 @@
step1Result = main.FALSE
caseResult7 = step1Result
- utilities.assert_equals(expect=main.TRUE, actual=caseResult7,
- onpass="Intent removal test successful",
- onfail="Intent removal test failed")
\ No newline at end of file
+ utilities.assert_equals( expect=main.TRUE, actual=caseResult7,
+ onpass="Intent removal test successful",
+ onfail="Intent removal test failed" )
diff --git a/TestON/tests/PingallExample/PingallExample.params b/TestON/tests/PingallExample/PingallExample.params
index aecaab6..8d0d10b 100644
--- a/TestON/tests/PingallExample/PingallExample.params
+++ b/TestON/tests/PingallExample/PingallExample.params
@@ -1,12 +1,12 @@
<PARAMS>
<testcases>1,2,3</testcases>
<ENV>
- <cellName>HA</cellName>
+ <cellName>kelvin</cellName>
</ENV>
<Git>True</Git>
<CTRL>
- <ip1>10.128.30.11</ip1>
+ <ip1>10.128.10.21</ip1>
<port1>6633</port1>
</CTRL>
</PARAMS>
diff --git a/TestON/tests/PingallExample/PingallExample.topo b/TestON/tests/PingallExample/PingallExample.topo
index 1712756..dba7a5d 100644
--- a/TestON/tests/PingallExample/PingallExample.topo
+++ b/TestON/tests/PingallExample/PingallExample.topo
@@ -2,7 +2,7 @@
<COMPONENT>
<ONOSbench>
- <host>10.128.30.10</host>
+ <host>10.128.10.20</host>
<user>admin</user>
<password></password>
<type>OnosDriver</type>
@@ -11,7 +11,7 @@
</ONOSbench>
<ONOScli1>
- <host>10.128.30.10</host>
+ <host>10.128.10.20</host>
<user>admin</user>
<password></password>
<type>OnosCliDriver</type>
@@ -20,16 +20,16 @@
</ONOScli1>
<ONOS1>
- <host>10.128.30.11</host>
- <user>sdn</user>
- <password>rocks</password>
+ <host>10.128.10.21</host>
+ <user>admin</user>
+ <password></password>
<type>OnosDriver</type>
<connect_order>3</connect_order>
<COMPONENTS> </COMPONENTS>
</ONOS1>
<Mininet1>
- <host>10.128.30.9</host>
+ <host>10.128.10.20</host>
<user>admin</user>
<password></password>
<type>MininetCliDriver</type>
diff --git a/TestON/tests/ProdFunc/ProdFunc.py b/TestON/tests/ProdFunc/ProdFunc.py
old mode 100755
new mode 100644
index a9a9bb6..62d1ec8
--- a/TestON/tests/ProdFunc/ProdFunc.py
+++ b/TestON/tests/ProdFunc/ProdFunc.py
@@ -1,6 +1,6 @@
-#Testing the basic functionality of ONOS Next
-#For sanity and driver functionality excercises only.
+# Testing the basic functionality of ONOS Next
+# For sanity and driver functionality excercises only.
import time
import sys
@@ -8,13 +8,16 @@
import re
import json
-time.sleep(1)
+time.sleep( 1 )
+
+
class ProdFunc:
- def __init__(self):
+
+ def __init__( self ):
self.default = ''
- def CASE1(self, main):
- '''
+ def CASE1( self, main ):
+ """
Startup sequence:
cell <name>
onos-verify-cell
@@ -24,1077 +27,1312 @@
onos-package
onos-install -f
onos-wait-for-start
- '''
-
- cell_name = main.params['ENV']['cellName']
- ONOS1_ip = main.params['CTRL']['ip1']
- ONOS1_port = main.params['CTRL']['port1']
-
- main.case("Setting up test environment")
- main.log.report("This testcase is testing setting up test environment")
- main.log.report("__________________________________")
+ """
+ cell_name = main.params[ 'ENV' ][ 'cellName' ]
+ ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+ ONOS1_port = main.params[ 'CTRL' ][ 'port1' ]
- main.step("Applying cell variable to environment")
- cell_result = main.ONOSbench.set_cell(cell_name)
+ main.case( "Setting up test environment" )
+ main.log.report(
+ "This testcase is testing setting up test environment" )
+ main.log.report( "__________________________________" )
+
+ main.step( "Applying cell variable to environment" )
+ cell_result = main.ONOSbench.set_cell( cell_name )
verify_result = main.ONOSbench.verify_cell()
-
- main.step("Removing raft logs before a clen installation of ONOS")
+
+ main.step( "Removing raft logs before a clen installation of ONOS" )
main.ONOSbench.onos_remove_raft_logs()
- main.step("Git checkout and pull master and get version")
- main.ONOSbench.git_checkout("master")
+ main.step( "Git checkout and pull master and get version" )
+ main.ONOSbench.git_checkout( "master" )
git_pull_result = main.ONOSbench.git_pull()
- main.log.info("git_pull_result = " +git_pull_result)
- version_result = main.ONOSbench.get_version(report=True)
-
+ main.log.info( "git_pull_result = " + git_pull_result )
+ version_result = main.ONOSbench.get_version( report=True )
+
if git_pull_result == 1:
- main.step("Using mvn clean & install")
+ main.step( "Using mvn clean & install" )
clean_install_result = main.ONOSbench.clean_install()
#clean_install_result = main.TRUE
elif git_pull_result == 0:
- main.log.report("Git Pull Failed, look into logs for detailed reason")
+ main.log.report(
+ "Git Pull Failed, look into logs for detailed reason" )
main.cleanup()
- main.exit()
-
- main.step("Creating ONOS package")
+ main.exit()
+
+ main.step( "Creating ONOS package" )
package_result = main.ONOSbench.onos_package()
-
- main.step("Installing ONOS package")
+ main.step( "Installing ONOS package" )
onos_install_result = main.ONOSbench.onos_install()
if onos_install_result == main.TRUE:
- main.log.report("Installing ONOS package successful")
+ main.log.report( "Installing ONOS package successful" )
else:
- main.log.report("Installing ONOS package failed")
+ main.log.report( "Installing ONOS package failed" )
onos1_isup = main.ONOSbench.isup()
if onos1_isup == main.TRUE:
- main.log.report("ONOS instance is up and ready")
+ main.log.report( "ONOS instance is up and ready" )
else:
- main.log.report("ONOS instance may not be up")
-
- main.step("Starting ONOS service")
- start_result = main.ONOSbench.onos_start(ONOS1_ip)
-
- main.ONOS2.start_onos_cli(ONOS_ip=main.params['CTRL']['ip1'])
+ main.log.report( "ONOS instance may not be up" )
- case1_result = (package_result and\
- cell_result and verify_result and onos_install_result and\
- onos1_isup and start_result )
- utilities.assert_equals(expect=main.TRUE, actual=case1_result,
- onpass="Test startup successful",
- onfail="Test startup NOT successful")
+ main.step( "Starting ONOS service" )
+ start_result = main.ONOSbench.onos_start( ONOS1_ip )
- def CASE2(self, main) :
- '''
+ main.ONOS2.start_onos_cli( ONOS_ip=main.params[ 'CTRL' ][ 'ip1' ] )
+
+ case1_result = ( package_result and
+ cell_result and verify_result and onos_install_result and
+ onos1_isup and start_result )
+ utilities.assert_equals( expect=main.TRUE, actual=case1_result,
+ onpass="Test startup successful",
+ onfail="Test startup NOT successful" )
+
+ def CASE2( self, main ):
+ """
Switch Down
- '''
- #NOTE: You should probably run a topology check after this
- import time
+ """
+ # NOTE: You should probably run a topology check after this
+ import time
import json
-
- main.case("Switch down discovery")
- main.log.report("This testcase is testing a switch down discovery")
- main.log.report("__________________________________")
- switch_sleep = int(main.params['timers']['SwitchDiscovery'])
+ main.case( "Switch down discovery" )
+ main.log.report( "This testcase is testing a switch down discovery" )
+ main.log.report( "__________________________________" )
+
+ switch_sleep = int( main.params[ 'timers' ][ 'SwitchDiscovery' ] )
description = "Killing a switch to ensure it is discovered correctly"
- main.log.report(description)
- main.case(description)
+ main.log.report( description )
+ main.case( description )
- #TODO: Make this switch parameterizable
- main.step("Kill s28 ")
- main.log.report("Deleting s28")
- #FIXME: use new dynamic topo functions
- main.Mininet1.del_switch("s28")
- main.log.info("Waiting " + str(switch_sleep) + " seconds for switch down to be discovered")
- time.sleep(switch_sleep)
- #Peek at the deleted switch
- device = main.ONOS2.get_device(dpid="0028")
+ # TODO: Make this switch parameterizable
+ main.step( "Kill s28 " )
+ main.log.report( "Deleting s28" )
+ # FIXME: use new dynamic topo functions
+ main.Mininet1.del_switch( "s28" )
+ main.log.info(
+ "Waiting " +
+ str( switch_sleep ) +
+ " seconds for switch down to be discovered" )
+ time.sleep( switch_sleep )
+ # Peek at the deleted switch
+ device = main.ONOS2.get_device( dpid="0028" )
print "device = ", device
- if device[u'available'] == 'False':
+ if device[ u'available' ] == 'False':
case2_result = main.FALSE
else:
case2_result = main.TRUE
- utilities.assert_equals(expect=main.TRUE, actual=case2_result,
- onpass="Switch down discovery successful",
- onfail="Switch down discovery failed")
+ utilities.assert_equals( expect=main.TRUE, actual=case2_result,
+ onpass="Switch down discovery successful",
+ onfail="Switch down discovery failed" )
- def CASE11(self, main):
- '''
+ def CASE11( self, main ):
+ """
Cleanup sequence:
onos-service <node_ip> stop
onos-uninstall
TODO: Define rest of cleanup
-
- '''
- ONOS1_ip = main.params['CTRL']['ip1']
+ """
+ ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
- main.case("Cleaning up test environment")
+ main.case( "Cleaning up test environment" )
- main.step("Testing ONOS kill function")
- kill_result = main.ONOSbench.onos_kill(ONOS1_ip)
+ main.step( "Testing ONOS kill function" )
+ kill_result = main.ONOSbench.onos_kill( ONOS1_ip )
- main.step("Stopping ONOS service")
- stop_result = main.ONOSbench.onos_stop(ONOS1_ip)
+ main.step( "Stopping ONOS service" )
+ stop_result = main.ONOSbench.onos_stop( ONOS1_ip )
- main.step("Uninstalling ONOS service")
+ main.step( "Uninstalling ONOS service" )
uninstall_result = main.ONOSbench.onos_uninstall()
- def CASE3(self, main):
- '''
+ def CASE3( self, main ):
+ """
Test 'onos' command and its functionality in driver
- '''
-
- ONOS1_ip = main.params['CTRL']['ip1']
+ """
+ ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
- main.case("Testing 'onos' command")
+ main.case( "Testing 'onos' command" )
- main.step("Sending command 'onos -w <onos-ip> system:name'")
+ main.step( "Sending command 'onos -w <onos-ip> system:name'" )
cmdstr1 = "system:name"
- cmd_result1 = main.ONOSbench.onos_cli(ONOS1_ip, cmdstr1)
- main.log.info("onos command returned: "+cmd_result1)
+ cmd_result1 = main.ONOSbench.onos_cli( ONOS1_ip, cmdstr1 )
+ main.log.info( "onos command returned: " + cmd_result1 )
- main.step("Sending command 'onos -w <onos-ip> onos:topology'")
+ main.step( "Sending command 'onos -w <onos-ip> onos:topology'" )
cmdstr2 = "onos:topology"
- cmd_result2 = main.ONOSbench.onos_cli(ONOS1_ip, cmdstr2)
- main.log.info("onos command returned: "+cmd_result2)
+ cmd_result2 = main.ONOSbench.onos_cli( ONOS1_ip, cmdstr2 )
+ main.log.info( "onos command returned: " + cmd_result2 )
-
- def CASE20(self):
- '''
+ def CASE20( self ):
+ """
Exit from mininet cli
reinstall ONOS
- '''
- cell_name = main.params['ENV']['cellName']
- ONOS1_ip = main.params['CTRL']['ip1']
- ONOS1_port = main.params['CTRL']['port1']
-
- main.log.report("This testcase exits the mininet cli and reinstalls ONOS to switch over to Packet Optical topology")
- main.log.report("_____________________________________________")
- main.case("Disconnecting mininet and restarting ONOS")
- main.step("Disconnecting mininet and restarting ONOS")
+ """
+ cell_name = main.params[ 'ENV' ][ 'cellName' ]
+ ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+ ONOS1_port = main.params[ 'CTRL' ][ 'port1' ]
+
+ main.log.report(
+ "This testcase exits the mininet cli and reinstalls ONOS to switch over to Packet Optical topology" )
+ main.log.report( "_____________________________________________" )
+ main.case( "Disconnecting mininet and restarting ONOS" )
+ main.step( "Disconnecting mininet and restarting ONOS" )
mininet_disconnect = main.Mininet1.disconnect()
- main.step("Removing raft logs before a clen installation of ONOS")
+ main.step( "Removing raft logs before a clen installation of ONOS" )
main.ONOSbench.onos_remove_raft_logs()
- main.step("Applying cell variable to environment")
- cell_result = main.ONOSbench.set_cell(cell_name)
+ main.step( "Applying cell variable to environment" )
+ cell_result = main.ONOSbench.set_cell( cell_name )
verify_result = main.ONOSbench.verify_cell()
onos_install_result = main.ONOSbench.onos_install()
if onos_install_result == main.TRUE:
- main.log.report("Installing ONOS package successful")
+ main.log.report( "Installing ONOS package successful" )
else:
- main.log.report("Installing ONOS package failed")
+ main.log.report( "Installing ONOS package failed" )
onos1_isup = main.ONOSbench.isup()
if onos1_isup == main.TRUE:
- main.log.report("ONOS instance is up and ready")
+ main.log.report( "ONOS instance is up and ready" )
else:
- main.log.report("ONOS instance may not be up")
+ main.log.report( "ONOS instance may not be up" )
- main.step("Starting ONOS service")
- start_result = main.ONOSbench.onos_start(ONOS1_ip)
-
- main.ONOS2.start_onos_cli(ONOS_ip=main.params['CTRL']['ip1'])
+ main.step( "Starting ONOS service" )
+ start_result = main.ONOSbench.onos_start( ONOS1_ip )
+
+ main.ONOS2.start_onos_cli( ONOS_ip=main.params[ 'CTRL' ][ 'ip1' ] )
print "mininet_disconnect =", mininet_disconnect
print "onos_install_result =", onos_install_result
print "onos1_isup =", onos1_isup
print "start_result =", start_result
-
- case20_result = mininet_disconnect and cell_result and onos_install_result and onos1_isup and start_result
- utilities.assert_equals(expect=main.TRUE, actual=case20_result,
- onpass="Exiting functionality mininet topology and reinstalling ONOS successful",
- onfail="Exiting functionality mininet topology and reinstalling ONOS failed")
- def CASE21(self, main):
+ case20_result = mininet_disconnect and cell_result and onos_install_result and onos1_isup and start_result
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case20_result,
+ onpass="Exiting functionality mininet topology and reinstalling ONOS successful",
+ onfail="Exiting functionality mininet topology and reinstalling ONOS failed" )
+
+ def CASE21( self, main ):
import time
- '''
+ """
On ONOS bench, run this command: ./~/ONOS/tools/test/bin/onos-topo-cfg
which starts the rest and copies the links json file to the onos instance
- Note that in case of Packet Optical, the links are not learnt from the topology, instead the links are learnt
+ Note that in case of Packet Optical, the links are not learnt from the topology, instead the links are learnt
from the json config file
- '''
- main.log.report("This testcase starts the packet layer topology and REST")
- main.log.report("_____________________________________________")
- main.case("Starting LINC-OE and other components")
- main.step("Starting LINC-OE and other components")
+ """
+ main.log.report(
+ "This testcase starts the packet layer topology and REST" )
+ main.log.report( "_____________________________________________" )
+ main.case( "Starting LINC-OE and other components" )
+ main.step( "Starting LINC-OE and other components" )
start_console_result = main.LincOE1.start_console()
optical_mn_script = main.LincOE2.run_optical_mn_script()
- onos_topo_cfg_result = main.ONOSbench.run_onos_topo_cfg(instance_name = main.params['CTRL']['ip1'], json_file = main.params['OPTICAL']['jsonfile'])
-
- print "start_console_result =",start_console_result
- print "optical_mn_script = ",optical_mn_script
- print "onos_topo_cfg_result =",onos_topo_cfg_result
+ onos_topo_cfg_result = main.ONOSbench.run_onos_topo_cfg(
+ instance_name=main.params[ 'CTRL' ][ 'ip1' ],
+ json_file=main.params[ 'OPTICAL' ][ 'jsonfile' ] )
+
+ print "start_console_result =", start_console_result
+ print "optical_mn_script = ", optical_mn_script
+ print "onos_topo_cfg_result =", onos_topo_cfg_result
case21_result = start_console_result and optical_mn_script and onos_topo_cfg_result
- utilities.assert_equals(expect=main.TRUE, actual=case21_result,
- onpass="Packet optical topology spawned successsfully",
- onfail="Packet optical topology spawning failed")
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case21_result,
+ onpass="Packet optical topology spawned successsfully",
+ onfail="Packet optical topology spawning failed" )
-
- def CASE22(self, main):
- '''
+ def CASE22( self, main ):
+ """
Curretly we use, 4 linear switch optical topology and 2 packet layer mininet switches each with one host.
Therefore, the roadmCount variable = 4, packetLayerSWCount variable = 2, hostCount =2
and this is hardcoded in the testcase. If the topology changes, these hardcoded values need to be changed
- '''
-
- main.log.report("This testcase compares the optical+packet topology against what is expected")
- main.case("Topology comparision")
- main.step("Topology comparision")
- main.ONOS3.start_onos_cli(ONOS_ip=main.params['CTRL']['ip1'])
- devices_result = main.ONOS3.devices(json_format = False)
+ """
+ main.log.report(
+ "This testcase compares the optical+packet topology against what is expected" )
+ main.case( "Topology comparision" )
+ main.step( "Topology comparision" )
+ main.ONOS3.start_onos_cli( ONOS_ip=main.params[ 'CTRL' ][ 'ip1' ] )
+ devices_result = main.ONOS3.devices( json_format=False )
print "devices_result = ", devices_result
- devices_linewise = devices_result.split("\n")
- devices_linewise = devices_linewise[1:-1]
+ devices_linewise = devices_result.split( "\n" )
+ devices_linewise = devices_linewise[ 1:-1 ]
roadmCount = 0
packetLayerSWCount = 0
for line in devices_linewise:
- components = line.split(",")
- availability = components[1].split("=")[1]
- type = components[3].split("=")[1]
+ components = line.split( "," )
+ availability = components[ 1 ].split( "=" )[ 1 ]
+ type = components[ 3 ].split( "=" )[ 1 ]
if availability == 'true' and type == 'ROADM':
roadmCount += 1
- elif availability == 'true' and type =='SWITCH':
+ elif availability == 'true' and type == 'SWITCH':
packetLayerSWCount += 1
if roadmCount == 4:
- print "Number of Optical Switches = %d and is correctly detected" %roadmCount
- main.log.info ("Number of Optical Switches = " +str(roadmCount) +" and is correctly detected")
+ print "Number of Optical Switches = %d and is correctly detected" % roadmCount
+ main.log.info(
+ "Number of Optical Switches = " +
+ str( roadmCount ) +
+ " and is correctly detected" )
opticalSW_result = main.TRUE
else:
- print "Number of Optical Switches = %d and is wrong" %roadCount
- main.log.info ("Number of Optical Switches = " +str(roadmCount) +" and is wrong")
+ print "Number of Optical Switches = %d and is wrong" % roadCount
+ main.log.info(
+ "Number of Optical Switches = " +
+ str( roadmCount ) +
+ " and is wrong" )
opticalSW_result = main.FALSE
if packetLayerSWCount == 2:
- print "Number of Packet layer or mininet Switches = %d and is correctly detected" %packetLayerSWCount
- main.log.info("Number of Packet layer or mininet Switches = " +str(packetLayerSWCount) + " and is correctly detected")
+ print "Number of Packet layer or mininet Switches = %d and is correctly detected" % packetLayerSWCount
+ main.log.info(
+ "Number of Packet layer or mininet Switches = " +
+ str( packetLayerSWCount ) +
+ " and is correctly detected" )
packetSW_result = main.TRUE
else:
- print "Number of Packet layer or mininet Switches = %d and is wrong" %packetLayerSWCount
- main.log.info("Number of Packet layer or mininet Switches = " +str(packetLayerSWCount) + " and is wrong")
+ print "Number of Packet layer or mininet Switches = %d and is wrong" % packetLayerSWCount
+ main.log.info(
+ "Number of Packet layer or mininet Switches = " +
+ str( packetLayerSWCount ) +
+ " and is wrong" )
packetSW_result = main.FALSE
print "_________________________________"
-
- links_result = main.ONOS3.links(json_format = False)
+
+ links_result = main.ONOS3.links( json_format=False )
print "links_result = ", links_result
print "_________________________________"
-
- #NOTE:Since only point intents are added, there is no requirement to discover the hosts
- #Therfore, the below portion of the code is commented.
- '''
+
+ # NOTE:Since only point intents are added, there is no requirement to discover the hosts
+ # Therfore, the below portion of the code is commented.
+ """
#Discover hosts using pingall
- pingall_result = main.LincOE2.pingall()
-
- hosts_result = main.ONOS3.hosts(json_format = False)
- main.log.info("hosts_result = "+hosts_result)
- main.log.info("_________________________________")
- hosts_linewise = hosts_result.split("\n")
- hosts_linewise = hosts_linewise[1:-1]
+ pingall_result = main.LincOE2.pingall()
+
+ hosts_result = main.ONOS3.hosts( json_format=False )
+ main.log.info( "hosts_result = "+hosts_result )
+ main.log.info( "_________________________________" )
+ hosts_linewise = hosts_result.split( "\n" )
+ hosts_linewise = hosts_linewise[ 1:-1 ]
hostCount = 0
for line in hosts_linewise:
- hostid = line.split(",")[0].split("=")[1]
+ hostid = line.split( "," )[ 0 ].split( "=" )[ 1 ]
hostCount +=1
if hostCount ==2:
print "Number of hosts = %d and is correctly detected" %hostCount
- main.log.info("Number of hosts = " + str(hostCount) +" and is correctly detected")
+ main.log.info( "Number of hosts = " + str( hostCount ) +" and is correctly detected" )
hostDiscovery = main.TRUE
else:
print "Number of hosts = %d and is wrong" %hostCount
- main.log.info("Number of hosts = " + str(hostCount) +" and is wrong")
+ main.log.info( "Number of hosts = " + str( hostCount ) +" and is wrong" )
hostDiscovery = main.FALSE
- '''
-
+ """
case22_result = opticalSW_result and packetSW_result
- utilities.assert_equals(expect=main.TRUE, actual=case22_result,
- onpass="Packet optical topology discovery successful",
- onfail="Packet optical topology discovery failed")
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case22_result,
+ onpass="Packet optical topology discovery successful",
+ onfail="Packet optical topology discovery failed" )
- def CASE23(self, main):
+ def CASE23( self, main ):
import time
- '''
- Add bidirectional point intents between 2 packet layer(mininet) devices and
+ """
+ Add bidirectional point intents between 2 packet layer( mininet ) devices and
ping mininet hosts
- '''
- main.log.report("This testcase adds bidirectional point intents between 2 packet layer(mininet) devices and ping mininet hosts")
- main.case("Topology comparision")
- main.step("Adding point intents")
- ptp_intent_result = main.ONOS3.add_point_intent("of:0000ffffffff0001/1", "of:0000ffffffff0002/1")
+ """
+ main.log.report(
+ "This testcase adds bidirectional point intents between 2 packet layer(mininet) devices and ping mininet hosts" )
+ main.case( "Topology comparision" )
+ main.step( "Adding point intents" )
+ ptp_intent_result = main.ONOS3.add_point_intent(
+ "of:0000ffffffff0001/1",
+ "of:0000ffffffff0002/1" )
if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS3.intents(json_format = False)
- main.log.info("Point to point intent install successful")
+ get_intent_result = main.ONOS3.intents( json_format=False )
+ main.log.info( "Point to point intent install successful" )
- ptp_intent_result = main.ONOS3.add_point_intent("of:0000ffffffff0002/1", "of:0000ffffffff0001/1")
+ ptp_intent_result = main.ONOS3.add_point_intent(
+ "of:0000ffffffff0002/1",
+ "of:0000ffffffff0001/1" )
if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS3.intents(json_format = False)
- main.log.info("Point to point intent install successful")
+ get_intent_result = main.ONOS3.intents( json_format=False )
+ main.log.info( "Point to point intent install successful" )
- time.sleep(10)
+ time.sleep( 10 )
flowHandle = main.ONOS3.flows()
- main.log.info("flows :" + flowHandle)
+ main.log.info( "flows :" + flowHandle )
# Sleep for 30 seconds to provide time for the intent state to change
- time.sleep(30)
- intentHandle = main.ONOS3.intents(json_format = False)
- main.log.info("intents :" + intentHandle)
-
+ time.sleep( 30 )
+ intentHandle = main.ONOS3.intents( json_format=False )
+ main.log.info( "intents :" + intentHandle )
+
Ping_Result = main.TRUE
count = 1
- main.log.info("\n\nh1 is Pinging h2")
- ping = main.LincOE2.pingHostOptical(src="h1", target="h2")
+ main.log.info( "\n\nh1 is Pinging h2" )
+ ping = main.LincOE2.pingHostOptical( src="h1", target="h2" )
#ping = main.LincOE2.pinghost()
- if ping == main.FALSE and count<5:
- count+=1
+ if ping == main.FALSE and count < 5:
+ count += 1
Ping_Result = main.FALSE
- main.log.info("Ping between h1 and h2 failed. Making attempt number "+str(count) + " in 2 seconds")
- time.sleep(2)
- elif ping==main.FALSE:
- main.log.info("All ping attempts between h1 and h2 have failed")
+ main.log.info(
+ "Ping between h1 and h2 failed. Making attempt number " +
+ str( count ) +
+ " in 2 seconds" )
+ time.sleep( 2 )
+ elif ping == main.FALSE:
+ main.log.info( "All ping attempts between h1 and h2 have failed" )
Ping_Result = main.FALSE
- elif ping==main.TRUE:
- main.log.info("Ping test between h1 and h2 passed!")
+ elif ping == main.TRUE:
+ main.log.info( "Ping test between h1 and h2 passed!" )
Ping_Result = main.TRUE
else:
- main.log.info("Unknown error")
+ main.log.info( "Unknown error" )
Ping_Result = main.ERROR
-
- if Ping_Result==main.FALSE:
- main.log.report("Point intents for packet optical have not ben installed correctly. Cleaning up")
- if Ping_Result==main.TRUE:
- main.log.report("Point Intents for packet optical have been installed correctly")
+
+ if Ping_Result == main.FALSE:
+ main.log.report(
+ "Point intents for packet optical have not ben installed correctly. Cleaning up" )
+ if Ping_Result == main.TRUE:
+ main.log.report(
+ "Point Intents for packet optical have been installed correctly" )
case23_result = Ping_Result
- utilities.assert_equals(expect=main.TRUE, actual=case23_result,
- onpass="Point intents addition for packet optical and Pingall Test successful",
- onfail="Point intents addition for packet optical and Pingall Test NOT successful")
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case23_result,
+ onpass="Point intents addition for packet optical and Pingall Test successful",
+ onfail="Point intents addition for packet optical and Pingall Test NOT successful" )
-
-
- def CASE24(self, main):
+ def CASE24( self, main ):
import time
import json
- '''
- Test Rerouting of Packet Optical by bringing a port down (port 22) of a switch(switchID=1), so that link (between switch1 port22 - switch4-port30) is inactive
+ """
+ Test Rerouting of Packet Optical by bringing a port down ( port 22 ) of a switch( switchID=1 ), so that link ( between switch1 port22 - switch4-port30 ) is inactive
and do a ping test. If rerouting is successful, ping should pass. also check the flows
- '''
- main.log.report("This testcase tests rerouting and pings mininet hosts")
- main.case("Test rerouting and pings mininet hosts")
- main.step("Bring a port down and verify the link state")
- main.LincOE1.port_down(sw_id="1", pt_id="22")
- links_nonjson = main.ONOS3.links(json_format = False)
- main.log.info("links = " +links_nonjson)
+ """
+ main.log.report(
+ "This testcase tests rerouting and pings mininet hosts" )
+ main.case( "Test rerouting and pings mininet hosts" )
+ main.step( "Bring a port down and verify the link state" )
+ main.LincOE1.port_down( sw_id="1", pt_id="22" )
+ links_nonjson = main.ONOS3.links( json_format=False )
+ main.log.info( "links = " + links_nonjson )
links = main.ONOS3.links()
- main.log.info("links = " +links)
-
- links_result = json.loads(links)
+ main.log.info( "links = " + links )
+
+ links_result = json.loads( links )
links_state_result = main.FALSE
for item in links_result:
- if item['src']['device'] == "of:0000ffffffffff01" and item['src']['port'] == "22":
- if item['dst']['device'] == "of:0000ffffffffff04" and item['dst']['port'] == "30":
- links_state = item['state']
+ if item[ 'src' ][ 'device' ] == "of:0000ffffffffff01" and item[
+ 'src' ][ 'port' ] == "22":
+ if item[ 'dst' ][ 'device' ] == "of:0000ffffffffff04" and item[
+ 'dst' ][ 'port' ] == "30":
+ links_state = item[ 'state' ]
if links_state == "INACTIVE":
- main.log.info("Links state is inactive as expected due to one of the ports being down")
- main.log.report("Links state is inactive as expected due to one of the ports being down")
+ main.log.info(
+ "Links state is inactive as expected due to one of the ports being down" )
+ main.log.report(
+ "Links state is inactive as expected due to one of the ports being down" )
links_state_result = main.TRUE
break
else:
- main.log.info("Links state is not inactive as expected")
- main.log.report("Links state is not inactive as expected")
+ main.log.info(
+ "Links state is not inactive as expected" )
+ main.log.report(
+ "Links state is not inactive as expected" )
links_state_result = main.FALSE
print "links_state_result = ", links_state_result
- time.sleep(10)
+ time.sleep( 10 )
flowHandle = main.ONOS3.flows()
- main.log.info("flows :" + flowHandle)
+ main.log.info( "flows :" + flowHandle )
- main.step("Verify Rerouting by a ping test")
+ main.step( "Verify Rerouting by a ping test" )
Ping_Result = main.TRUE
- count = 1
- main.log.info("\n\nh1 is Pinging h2")
- ping = main.LincOE2.pingHostOptical(src="h1", target="h2")
+ count = 1
+ main.log.info( "\n\nh1 is Pinging h2" )
+ ping = main.LincOE2.pingHostOptical( src="h1", target="h2" )
#ping = main.LincOE2.pinghost()
- if ping == main.FALSE and count<5:
- count+=1
+ if ping == main.FALSE and count < 5:
+ count += 1
Ping_Result = main.FALSE
- main.log.info("Ping between h1 and h2 failed. Making attempt number "+str(count) + " in 2 seconds")
- time.sleep(2)
- elif ping==main.FALSE:
- main.log.info("All ping attempts between h1 and h2 have failed")
+ main.log.info(
+ "Ping between h1 and h2 failed. Making attempt number " +
+ str( count ) +
+ " in 2 seconds" )
+ time.sleep( 2 )
+ elif ping == main.FALSE:
+ main.log.info( "All ping attempts between h1 and h2 have failed" )
Ping_Result = main.FALSE
- elif ping==main.TRUE:
- main.log.info("Ping test between h1 and h2 passed!")
+ elif ping == main.TRUE:
+ main.log.info( "Ping test between h1 and h2 passed!" )
Ping_Result = main.TRUE
else:
- main.log.info("Unknown error")
+ main.log.info( "Unknown error" )
Ping_Result = main.ERROR
- if Ping_Result==main.TRUE:
- main.log.report("Ping test successful ")
- if Ping_Result==main.FALSE:
- main.log.report("Ping test failed")
+ if Ping_Result == main.TRUE:
+ main.log.report( "Ping test successful " )
+ if Ping_Result == main.FALSE:
+ main.log.report( "Ping test failed" )
case24_result = Ping_Result and links_state_result
- utilities.assert_equals(expect=main.TRUE, actual=case24_result,
- onpass="Packet optical rerouting successful",
- onfail="Packet optical rerouting failed")
+ utilities.assert_equals( expect=main.TRUE, actual=case24_result,
+ onpass="Packet optical rerouting successful",
+ onfail="Packet optical rerouting failed" )
- def CASE4(self, main):
+ def CASE4( self, main ):
import re
import time
- main.log.report("This testcase is testing the assignment of all the switches to all the controllers and discovering the hosts in reactive mode")
- main.log.report("__________________________________")
- main.case("Pingall Test")
- main.step("Assigning switches to controllers")
- for i in range(1,29):
- if i ==1:
- main.Mininet1.assign_sw_controller(sw=str(i),ip1=ONOS1_ip,port1=ONOS1_port)
- elif i>=2 and i<5:
- main.Mininet1.assign_sw_controller(sw=str(i),ip1=ONOS1_ip,port1=ONOS1_port)
- elif i>=5 and i<8:
- main.Mininet1.assign_sw_controller(sw=str(i),ip1=ONOS1_ip,port1=ONOS1_port)
- elif i>=8 and i<18:
- main.Mininet1.assign_sw_controller(sw=str(i),ip1=ONOS1_ip,port1=ONOS1_port)
- elif i>=18 and i<28:
- main.Mininet1.assign_sw_controller(sw=str(i),ip1=ONOS1_ip,port1=ONOS1_port)
+ main.log.report(
+ "This testcase is testing the assignment of all the switches to all the controllers and discovering the hosts in reactive mode" )
+ main.log.report( "__________________________________" )
+ main.case( "Pingall Test" )
+ main.step( "Assigning switches to controllers" )
+ for i in range( 1, 29 ):
+ if i == 1:
+ main.Mininet1.assign_sw_controller(
+ sw=str( i ),
+ ip1=ONOS1_ip,
+ port1=ONOS1_port )
+ elif i >= 2 and i < 5:
+ main.Mininet1.assign_sw_controller(
+ sw=str( i ),
+ ip1=ONOS1_ip,
+ port1=ONOS1_port )
+ elif i >= 5 and i < 8:
+ main.Mininet1.assign_sw_controller(
+ sw=str( i ),
+ ip1=ONOS1_ip,
+ port1=ONOS1_port )
+ elif i >= 8 and i < 18:
+ main.Mininet1.assign_sw_controller(
+ sw=str( i ),
+ ip1=ONOS1_ip,
+ port1=ONOS1_port )
+ elif i >= 18 and i < 28:
+ main.Mininet1.assign_sw_controller(
+ sw=str( i ),
+ ip1=ONOS1_ip,
+ port1=ONOS1_port )
else:
- main.Mininet1.assign_sw_controller(sw=str(i),ip1=ONOS1_ip,port1=ONOS1_port)
+ main.Mininet1.assign_sw_controller(
+ sw=str( i ),
+ ip1=ONOS1_ip,
+ port1=ONOS1_port )
Switch_Mastership = main.TRUE
- for i in range (1,29):
- if i==1:
- response = main.Mininet1.get_sw_controller("s"+str(i))
- print("Response is " + str(response))
- if re.search("tcp:"+ONOS1_ip,response):
+ for i in range( 1, 29 ):
+ if i == 1:
+ response = main.Mininet1.get_sw_controller( "s" + str( i ) )
+ print( "Response is " + str( response ) )
+ if re.search( "tcp:" + ONOS1_ip, response ):
Switch_Mastership = Switch_Mastership and main.TRUE
else:
Switch_Mastership = main.FALSE
- elif i>=2 and i<5:
- response = main.Mininet1.get_sw_controller("s"+str(i))
- print("Response is " + str(response))
- if re.search("tcp:"+ONOS1_ip,response):
+ elif i >= 2 and i < 5:
+ response = main.Mininet1.get_sw_controller( "s" + str( i ) )
+ print( "Response is " + str( response ) )
+ if re.search( "tcp:" + ONOS1_ip, response ):
Switch_Mastership = Switch_Mastership and main.TRUE
else:
Switch_Mastership = main.FALSE
- elif i>=5 and i<8:
- response = main.Mininet1.get_sw_controller("s"+str(i))
- print("Response is " + str(response))
- if re.search("tcp:"+ONOS1_ip,response):
+ elif i >= 5 and i < 8:
+ response = main.Mininet1.get_sw_controller( "s" + str( i ) )
+ print( "Response is " + str( response ) )
+ if re.search( "tcp:" + ONOS1_ip, response ):
Switch_Mastership = Switch_Mastership and main.TRUE
else:
Switch_Mastership = main.FALSE
- elif i>=8 and i<18:
- response = main.Mininet1.get_sw_controller("s"+str(i))
- print("Response is " + str(response))
- if re.search("tcp:"+ONOS1_ip,response):
+ elif i >= 8 and i < 18:
+ response = main.Mininet1.get_sw_controller( "s" + str( i ) )
+ print( "Response is " + str( response ) )
+ if re.search( "tcp:" + ONOS1_ip, response ):
Switch_Mastership = Switch_Mastership and main.TRUE
else:
Switch_Mastership = main.FALSE
- elif i>=18 and i<28:
- response = main.Mininet1.get_sw_controller("s"+str(i))
- print("Response is " + str(response))
- if re.search("tcp:"+ONOS1_ip,response):
+ elif i >= 18 and i < 28:
+ response = main.Mininet1.get_sw_controller( "s" + str( i ) )
+ print( "Response is " + str( response ) )
+ if re.search( "tcp:" + ONOS1_ip, response ):
Switch_Mastership = Switch_Mastership and main.TRUE
else:
Switch_Mastership = main.FALSE
else:
- response = main.Mininet1.get_sw_controller("s"+str(i))
- print("Response is" + str(response))
- if re.search("tcp:" +ONOS1_ip,response):
+ response = main.Mininet1.get_sw_controller( "s" + str( i ) )
+ print( "Response is" + str( response ) )
+ if re.search( "tcp:" + ONOS1_ip, response ):
Switch_Mastership = Switch_Mastership and main.TRUE
else:
Switch_Mastership = main.FALSE
if Switch_Mastership == main.TRUE:
- main.log.report("Controller assignmnet successful")
+ main.log.report( "Controller assignmnet successful" )
else:
- main.log.report("Controller assignmnet failed")
- utilities.assert_equals(expect = main.TRUE,actual=Switch_Mastership,
- onpass="MasterControllers assigned correctly")
- '''
- for i in range (1,29):
- main.Mininet1.assign_sw_controller(sw=str(i),count=5,
+ main.log.report( "Controller assignmnet failed" )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=Switch_Mastership,
+ onpass="MasterControllers assigned correctly" )
+ """
+ for i in range ( 1,29 ):
+ main.Mininet1.assign_sw_controller( sw=str( i ),count=5,
ip1=ONOS1_ip,port1=ONOS1_port,
ip2=ONOS2_ip,port2=ONOS2_port,
ip3=ONOS3_ip,port3=ONOS3_port,
ip4=ONOS4_ip,port4=ONOS4_port,
- ip5=ONOS5_ip,port5=ONOS5_port)
- '''
- #REACTIVE FWD test
+ ip5=ONOS5_ip,port5=ONOS5_port )
+ """
+ # REACTIVE FWD test
- main.step("Get list of hosts from Mininet")
+ main.step( "Get list of hosts from Mininet" )
host_list = main.Mininet1.get_hosts()
- main.log.info(host_list)
+ main.log.info( host_list )
- main.step("Get host list in ONOS format")
- host_onos_list = main.ONOS2.get_hosts_id(host_list)
- main.log.info(host_onos_list)
- #time.sleep(5)
-
- main.step("Pingall")
+ main.step( "Get host list in ONOS format" )
+ host_onos_list = main.ONOS2.get_hosts_id( host_list )
+ main.log.info( host_onos_list )
+ # time.sleep( 5 )
+
+ main.step( "Pingall" )
ping_result = main.FALSE
while ping_result == main.FALSE:
time1 = time.time()
ping_result = main.Mininet1.pingall()
time2 = time.time()
- print "Time for pingall: %2f seconds" % (time2 - time1)
-
- #Start onos cli again because u might have dropped out of onos prompt to the shell prompt
- #if there was no activity
- main.ONOS2.start_onos_cli(ONOS_ip=main.params['CTRL']['ip1'])
+ print "Time for pingall: %2f seconds" % ( time2 - time1 )
+
+ # Start onos cli again because u might have dropped out of onos prompt to the shell prompt
+ # if there was no activity
+ main.ONOS2.start_onos_cli( ONOS_ip=main.params[ 'CTRL' ][ 'ip1' ] )
case4_result = Switch_Mastership and ping_result
if ping_result == main.TRUE:
- main.log.report("Pingall Test in reactive mode to discover the hosts successful")
+ main.log.report(
+ "Pingall Test in reactive mode to discover the hosts successful" )
else:
- main.log.report("Pingall Test in reactive mode to discover the hosts failed")
+ main.log.report(
+ "Pingall Test in reactive mode to discover the hosts failed" )
- utilities.assert_equals(expect=main.TRUE, actual=case4_result,onpass="Controller assignment and Pingall Test successful",onfail="Controller assignment and Pingall Test NOT successful")
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case4_result,
+ onpass="Controller assignment and Pingall Test successful",
+ onfail="Controller assignment and Pingall Test NOT successful" )
- def CASE10(self):
- main.log.report("This testcase uninstalls the reactive forwarding app")
- main.log.report("__________________________________")
- main.case("Uninstalling reactive forwarding app")
- #Unistall onos-app-fwd app to disable reactive forwarding
- appUninstall_result = main.ONOS2.feature_uninstall("onos-app-fwd")
- main.log.info("onos-app-fwd uninstalled")
+ def CASE10( self ):
+ main.log.report(
+ "This testcase uninstalls the reactive forwarding app" )
+ main.log.report( "__________________________________" )
+ main.case( "Uninstalling reactive forwarding app" )
+ # Unistall onos-app-fwd app to disable reactive forwarding
+ appUninstall_result = main.ONOS2.feature_uninstall( "onos-app-fwd" )
+ main.log.info( "onos-app-fwd uninstalled" )
- #After reactive forwarding is disabled, the reactive flows on switches timeout in 10-15s
- #So sleep for 15s
- time.sleep(15)
+ # After reactive forwarding is disabled, the reactive flows on switches timeout in 10-15s
+ # So sleep for 15s
+ time.sleep( 15 )
flows = main.ONOS2.flows()
- main.log.info(flows)
+ main.log.info( flows )
case10_result = appUninstall_result
- utilities.assert_equals(expect=main.TRUE, actual=case10_result,onpass="Reactive forwarding app uninstallation successful",onfail="Reactive forwarding app uninstallation failed")
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case10_result,
+ onpass="Reactive forwarding app uninstallation successful",
+ onfail="Reactive forwarding app uninstallation failed" )
-
- def CASE6(self):
- main.log.report("This testcase is testing the addition of host intents and then does pingall")
- main.log.report("__________________________________")
- main.case("Obtaining host id's")
- main.step("Get hosts")
+ def CASE6( self ):
+ main.log.report(
+ "This testcase is testing the addition of host intents and then does pingall" )
+ main.log.report( "__________________________________" )
+ main.case( "Obtaining host id's" )
+ main.step( "Get hosts" )
hosts = main.ONOS2.hosts()
- #main.log.info(hosts)
+ # main.log.info( hosts )
- main.step("Get all devices id")
+ main.step( "Get all devices id" )
devices_id_list = main.ONOS2.get_all_devices_id()
- #main.log.info(devices_id_list)
-
- #ONOS displays the hosts in hex format unlike mininet which does in decimal format
- #So take care while adding intents
- '''
- main.step("Add host-to-host intents for mininet hosts h8 and h18 or ONOS hosts h8 and h12")
- hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1")
- hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1")
- hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0A/-1", "00:00:00:00:00:14/-1")
- hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0B/-1", "00:00:00:00:00:15/-1")
- hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0C/-1", "00:00:00:00:00:16/-1")
- hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0D/-1", "00:00:00:00:00:17/-1")
- hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0E/-1", "00:00:00:00:00:18/-1")
- hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1")
- hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1")
- hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1")
- print "_____________________________________________________________________________________"
- '''
-
- for i in range(8,18):
- main.log.info("Adding host intent between h"+str(i)+" and h"+str(i+10))
- host1 = "00:00:00:00:00:" + str(hex(i)[2:]).zfill(2).upper()
- host2 = "00:00:00:00:00:" + str(hex(i+10)[2:]).zfill(2).upper()
- #NOTE: get host can return None
- #TODO: handle this
- host1_id = main.ONOS2.get_host(host1)['id']
- host2_id = main.ONOS2.get_host(host2)['id']
- tmp_result = main.ONOS2.add_host_intent(host1_id, host2_id )
+ # main.log.info( devices_id_list )
- time.sleep(10)
- h_intents = main.ONOS2.intents(json_format = False)
- main.log.info("intents:" +h_intents)
+ # ONOS displays the hosts in hex format unlike mininet which does in decimal format
+ # So take care while adding intents
+ """
+ main.step( "Add host-to-host intents for mininet hosts h8 and h18 or ONOS hosts h8 and h12" )
+ hth_intent_result = main.ONOS2.add_host_intent( "00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1" )
+ hth_intent_result = main.ONOS2.add_host_intent( "00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1" )
+ hth_intent_result = main.ONOS2.add_host_intent( "00:00:00:00:00:0A/-1", "00:00:00:00:00:14/-1" )
+ hth_intent_result = main.ONOS2.add_host_intent( "00:00:00:00:00:0B/-1", "00:00:00:00:00:15/-1" )
+ hth_intent_result = main.ONOS2.add_host_intent( "00:00:00:00:00:0C/-1", "00:00:00:00:00:16/-1" )
+ hth_intent_result = main.ONOS2.add_host_intent( "00:00:00:00:00:0D/-1", "00:00:00:00:00:17/-1" )
+ hth_intent_result = main.ONOS2.add_host_intent( "00:00:00:00:00:0E/-1", "00:00:00:00:00:18/-1" )
+ hth_intent_result = main.ONOS2.add_host_intent( "00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1" )
+ hth_intent_result = main.ONOS2.add_host_intent( "00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1" )
+ hth_intent_result = main.ONOS2.add_host_intent( "00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1" )
+ print "_____________________________________________________________________________________"
+ """
+ for i in range( 8, 18 ):
+ main.log.info(
+ "Adding host intent between h" + str( i ) + " and h" + str( i + 10 ) )
+ host1 = "00:00:00:00:00:" + \
+ str( hex( i )[ 2: ] ).zfill( 2 ).upper()
+ host2 = "00:00:00:00:00:" + \
+ str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
+ # NOTE: get host can return None
+ # TODO: handle this
+ host1_id = main.ONOS2.get_host( host1 )[ 'id' ]
+ host2_id = main.ONOS2.get_host( host2 )[ 'id' ]
+ tmp_result = main.ONOS2.add_host_intent( host1_id, host2_id )
+
+ time.sleep( 10 )
+ h_intents = main.ONOS2.intents( json_format=False )
+ main.log.info( "intents:" + h_intents )
flowHandle = main.ONOS2.flows()
- #main.log.info("flow:" +flowHandle)
+ #main.log.info( "flow:" +flowHandle )
count = 1
i = 8
Ping_Result = main.TRUE
- #while i<10:
- while i <18 :
- main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10))
- ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
- if ping == main.FALSE and count <5:
- count+=1
+ # while i<10:
+ while i < 18:
+ main.log.info(
+ "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
+ ping = main.Mininet1.pingHost(
+ src="h" + str( i ), target="h" + str( i + 10 ) )
+ if ping == main.FALSE and count < 5:
+ count += 1
#i = 8
Ping_Result = main.FALSE
- main.log.report("Ping between h" + str(i) + " and h" + str(i+10) + " failed. Making attempt number "+str(count) + " in 2 seconds")
- time.sleep(2)
- elif ping==main.FALSE:
- main.log.report("All ping attempts between h" + str(i) + " and h" + str(i+10) +"have failed")
- i=19
+ main.log.report( "Ping between h" +
+ str( i ) +
+ " and h" +
+ str( i +
+ 10 ) +
+ " failed. Making attempt number " +
+ str( count ) +
+ " in 2 seconds" )
+ time.sleep( 2 )
+ elif ping == main.FALSE:
+ main.log.report( "All ping attempts between h" +
+ str( i ) +
+ " and h" +
+ str( i +
+ 10 ) +
+ "have failed" )
+ i = 19
Ping_Result = main.FALSE
- elif ping==main.TRUE:
- main.log.info("Ping test between h" + str(i) + " and h" + str(i+10) + "passed!")
- i+=1
+ elif ping == main.TRUE:
+ main.log.info( "Ping test between h" +
+ str( i ) +
+ " and h" +
+ str( i +
+ 10 ) +
+ "passed!" )
+ i += 1
Ping_Result = main.TRUE
else:
- main.log.info("Unknown error")
+ main.log.info( "Unknown error" )
Ping_Result = main.ERROR
- if Ping_Result==main.FALSE:
- main.log.report("Ping all test after Host intent addition failed. Cleaning up")
- #main.cleanup()
- #main.exit()
- if Ping_Result==main.TRUE:
- main.log.report("Ping all test after Host intent addition successful")
-
+ if Ping_Result == main.FALSE:
+ main.log.report(
+ "Ping all test after Host intent addition failed. Cleaning up" )
+ # main.cleanup()
+ # main.exit()
+ if Ping_Result == main.TRUE:
+ main.log.report(
+ "Ping all test after Host intent addition successful" )
+
case6_result = Ping_Result
- utilities.assert_equals(expect=main.TRUE, actual=case6_result,
- onpass="Pingall Test after Host intents addition successful",
- onfail="Pingall Test after Host intents addition failed")
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case6_result,
+ onpass="Pingall Test after Host intents addition successful",
+ onfail="Pingall Test after Host intents addition failed" )
-
- def CASE5(self,main) :
+ def CASE5( self, main ):
import json
from subprocess import Popen, PIPE
- from sts.topology.teston_topology import TestONTopology # assumes that sts is already in you PYTHONPATH
- #main.ONOS2.start_onos_cli(ONOS_ip=main.params['CTRL']['ip1'])
+ # assumes that sts is already in you PYTHONPATH
+ from sts.topology.teston_topology import TestONTopology
+ # main.ONOS2.start_onos_cli( ONOS_ip=main.params[ 'CTRL' ][ 'ip1' ] )
deviceResult = main.ONOS2.devices()
linksResult = main.ONOS2.links()
#portsResult = main.ONOS2.ports()
print "**************"
- main.log.report("This testcase is testing if all ONOS nodes are in topology sync with mininet")
- main.log.report("__________________________________")
- main.case("Comparing Mininet topology with the topology of ONOS")
- main.step("Start continuous pings")
- main.Mininet2.pingLong(src=main.params['PING']['source1'],
- target=main.params['PING']['target1'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source2'],
- target=main.params['PING']['target2'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source3'],
- target=main.params['PING']['target3'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source4'],
- target=main.params['PING']['target4'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source5'],
- target=main.params['PING']['target5'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source6'],
- target=main.params['PING']['target6'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source7'],
- target=main.params['PING']['target7'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source8'],
- target=main.params['PING']['target8'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source9'],
- target=main.params['PING']['target9'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source10'],
- target=main.params['PING']['target10'],pingTime=500)
+ main.log.report(
+ "This testcase is testing if all ONOS nodes are in topology sync with mininet" )
+ main.log.report( "__________________________________" )
+ main.case( "Comparing Mininet topology with the topology of ONOS" )
+ main.step( "Start continuous pings" )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source1' ],
+ target=main.params[ 'PING' ][ 'target1' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source2' ],
+ target=main.params[ 'PING' ][ 'target2' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source3' ],
+ target=main.params[ 'PING' ][ 'target3' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source4' ],
+ target=main.params[ 'PING' ][ 'target4' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source5' ],
+ target=main.params[ 'PING' ][ 'target5' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source6' ],
+ target=main.params[ 'PING' ][ 'target6' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source7' ],
+ target=main.params[ 'PING' ][ 'target7' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source8' ],
+ target=main.params[ 'PING' ][ 'target8' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source9' ],
+ target=main.params[ 'PING' ][ 'target9' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source10' ],
+ target=main.params[ 'PING' ][ 'target10' ],
+ pingTime=500 )
- main.step("Create TestONTopology object")
+ main.step( "Create TestONTopology object" )
global ctrls
ctrls = []
count = 1
while True:
temp = ()
- if ('ip' + str(count)) in main.params['CTRL']:
- temp = temp + (getattr(main,('ONOS' + str(count))),)
- temp = temp + ("ONOS"+str(count),)
- temp = temp + (main.params['CTRL']['ip'+str(count)],)
- temp = temp + (eval(main.params['CTRL']['port'+str(count)]),)
- ctrls.append(temp)
+ if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]:
+ temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), )
+ temp = temp + ( "ONOS" + str( count ), )
+ temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], )
+ temp = temp + \
+ ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), )
+ ctrls.append( temp )
count = count + 1
else:
break
global MNTopo
- Topo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations
+ Topo = TestONTopology(
+ main.Mininet1,
+ ctrls ) # can also add Intent API info for intent operations
MNTopo = Topo
Topology_Check = main.TRUE
- main.step("Compare ONOS Topology to MN Topology")
+ main.step( "Compare ONOS Topology to MN Topology" )
devices_json = main.ONOS2.devices()
links_json = main.ONOS2.links()
#ports_json = main.ONOS2.ports()
print "devices_json= ", devices_json
-
- result1 = main.Mininet1.compare_switches(MNTopo, json.loads(devices_json))
- result2 = main.Mininet1.compare_links(MNTopo, json.loads(links_json))
- #result3 = main.Mininet1.compare_ports(MNTopo, json.loads(ports_json))
-
+
+ result1 = main.Mininet1.compare_switches(
+ MNTopo,
+ json.loads( devices_json ) )
+ result2 = main.Mininet1.compare_links(
+ MNTopo,
+ json.loads( links_json ) )
+ #result3 = main.Mininet1.compare_ports( MNTopo, json.loads( ports_json ) )
+
#result = result1 and result2 and result3
result = result1 and result2
-
+
print "***********************"
if result == main.TRUE:
- main.log.report("ONOS"+ " Topology matches MN Topology")
+ main.log.report( "ONOS" + " Topology matches MN Topology" )
else:
- main.log.report("ONOS"+ " Topology does not match MN Topology")
+ main.log.report( "ONOS" + " Topology does not match MN Topology" )
- utilities.assert_equals(expect=main.TRUE,actual=result,
- onpass="ONOS" + " Topology matches MN Topology",
- onfail="ONOS" + " Topology does not match MN Topology")
-
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=result,
+ onpass="ONOS" +
+ " Topology matches MN Topology",
+ onfail="ONOS" +
+ " Topology does not match MN Topology" )
+
Topology_Check = Topology_Check and result
- utilities.assert_equals(expect=main.TRUE,actual=Topology_Check,
- onpass="Topology checks passed", onfail="Topology checks failed")
-
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=Topology_Check,
+ onpass="Topology checks passed",
+ onfail="Topology checks failed" )
- def CASE7 (self,main):
-
- ONOS1_ip = main.params['CTRL']['ip1']
+ def CASE7( self, main ):
- link_sleep = int(main.params['timers']['LinkDiscovery'])
+ ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
- main.log.report("This testscase is killing a link to ensure that link discovery is consistent")
- main.log.report("__________________________________")
- main.log.report("Killing a link to ensure that link discovery is consistent")
- main.case("Killing a link to Ensure that Link Discovery is Working Properly")
- '''
- main.step("Start continuous pings")
-
- main.Mininet2.pingLong(src=main.params['PING']['source1'],
- target=main.params['PING']['target1'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source2'],
- target=main.params['PING']['target2'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source3'],
- target=main.params['PING']['target3'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source4'],
- target=main.params['PING']['target4'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source5'],
- target=main.params['PING']['target5'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source6'],
- target=main.params['PING']['target6'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source7'],
- target=main.params['PING']['target7'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source8'],
- target=main.params['PING']['target8'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source9'],
- target=main.params['PING']['target9'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source10'],
- target=main.params['PING']['target10'],pingTime=500)
- '''
+ link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
- main.step("Determine the current number of switches and links")
+ main.log.report(
+ "This testscase is killing a link to ensure that link discovery is consistent" )
+ main.log.report( "__________________________________" )
+ main.log.report(
+ "Killing a link to ensure that link discovery is consistent" )
+ main.case(
+ "Killing a link to Ensure that Link Discovery is Working Properly" )
+ """
+ main.step( "Start continuous pings" )
+
+ main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source1' ],
+ target=main.params[ 'PING' ][ 'target1' ],pingTime=500 )
+ main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source2' ],
+ target=main.params[ 'PING' ][ 'target2' ],pingTime=500 )
+ main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source3' ],
+ target=main.params[ 'PING' ][ 'target3' ],pingTime=500 )
+ main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source4' ],
+ target=main.params[ 'PING' ][ 'target4' ],pingTime=500 )
+ main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source5' ],
+ target=main.params[ 'PING' ][ 'target5' ],pingTime=500 )
+ main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source6' ],
+ target=main.params[ 'PING' ][ 'target6' ],pingTime=500 )
+ main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source7' ],
+ target=main.params[ 'PING' ][ 'target7' ],pingTime=500 )
+ main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source8' ],
+ target=main.params[ 'PING' ][ 'target8' ],pingTime=500 )
+ main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source9' ],
+ target=main.params[ 'PING' ][ 'target9' ],pingTime=500 )
+ main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source10' ],
+ target=main.params[ 'PING' ][ 'target10' ],pingTime=500 )
+ """
+ main.step( "Determine the current number of switches and links" )
topology_output = main.ONOS2.topology()
- topology_result = main.ONOS1.get_topology(topology_output)
- activeSwitches = topology_result['devices']
- links = topology_result['links']
- print "activeSwitches = ", type(activeSwitches)
- print "links = ", type(links)
- main.log.info("Currently there are %s switches and %s links" %(str(activeSwitches), str(links)))
+ topology_result = main.ONOS1.get_topology( topology_output )
+ activeSwitches = topology_result[ 'devices' ]
+ links = topology_result[ 'links' ]
+ print "activeSwitches = ", type( activeSwitches )
+ print "links = ", type( links )
+ main.log.info(
+ "Currently there are %s switches and %s links" %
+ ( str( activeSwitches ), str( links ) ) )
- main.step("Kill Link between s3 and s28")
- main.Mininet1.link(END1="s3",END2="s28",OPTION="down")
- time.sleep(link_sleep)
+ main.step( "Kill Link between s3 and s28" )
+ main.Mininet1.link( END1="s3", END2="s28", OPTION="down" )
+ time.sleep( link_sleep )
topology_output = main.ONOS2.topology()
- Link_Down = main.ONOS1.check_status(topology_output,activeSwitches,str(int(links)-2))
+ Link_Down = main.ONOS1.check_status(
+ topology_output, activeSwitches, str(
+ int( links ) - 2 ) )
if Link_Down == main.TRUE:
- main.log.report("Link Down discovered properly")
- utilities.assert_equals(expect=main.TRUE,actual=Link_Down,
- onpass="Link Down discovered properly",
- onfail="Link down was not discovered in "+ str(link_sleep) + " seconds")
-
- #Check ping result here..add code for it
-
- main.step("Bring link between s3 and s28 back up")
- Link_Up = main.Mininet1.link(END1="s3",END2="s28",OPTION="up")
- time.sleep(link_sleep)
+ main.log.report( "Link Down discovered properly" )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=Link_Down,
+ onpass="Link Down discovered properly",
+ onfail="Link down was not discovered in " +
+ str( link_sleep ) +
+ " seconds" )
+
+ # Check ping result here..add code for it
+
+ main.step( "Bring link between s3 and s28 back up" )
+ Link_Up = main.Mininet1.link( END1="s3", END2="s28", OPTION="up" )
+ time.sleep( link_sleep )
topology_output = main.ONOS2.topology()
- Link_Up = main.ONOS1.check_status(topology_output,activeSwitches,str(links))
+ Link_Up = main.ONOS1.check_status(
+ topology_output,
+ activeSwitches,
+ str( links ) )
if Link_Up == main.TRUE:
- main.log.report("Link up discovered properly")
- utilities.assert_equals(expect=main.TRUE,actual=Link_Up,
- onpass="Link up discovered properly",
- onfail="Link up was not discovered in "+ str(link_sleep) + " seconds")
-
- #NOTE Check ping result here..add code for it
-
-
- main.step("Compare ONOS Topology to MN Topology")
- Topo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations
+ main.log.report( "Link up discovered properly" )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=Link_Up,
+ onpass="Link up discovered properly",
+ onfail="Link up was not discovered in " +
+ str( link_sleep ) +
+ " seconds" )
+
+ # NOTE Check ping result here..add code for it
+
+ main.step( "Compare ONOS Topology to MN Topology" )
+ Topo = TestONTopology(
+ main.Mininet1,
+ ctrls ) # can also add Intent API info for intent operations
MNTopo = Topo
Topology_Check = main.TRUE
-
+
devices_json = main.ONOS2.devices()
links_json = main.ONOS2.links()
ports_json = main.ONOS2.ports()
print "devices_json= ", devices_json
-
- result1 = main.Mininet1.compare_switches(MNTopo, json.loads(devices_json))
- result2 = main.Mininet1.compare_links(MNTopo, json.loads(links_json))
- #result3 = main.Mininet1.compare_ports(MNTopo, json.loads(ports_json))
-
+
+ result1 = main.Mininet1.compare_switches(
+ MNTopo,
+ json.loads( devices_json ) )
+ result2 = main.Mininet1.compare_links(
+ MNTopo,
+ json.loads( links_json ) )
+ #result3 = main.Mininet1.compare_ports( MNTopo, json.loads( ports_json ) )
+
#result = result1 and result2 and result3
result = result1 and result2
print "***********************"
-
+
if result == main.TRUE:
- main.log.report("ONOS"+ " Topology matches MN Topology")
- utilities.assert_equals(expect=main.TRUE,actual=result,
- onpass="ONOS" + " Topology matches MN Topology",
- onfail="ONOS" + " Topology does not match MN Topology")
-
+ main.log.report( "ONOS" + " Topology matches MN Topology" )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=result,
+ onpass="ONOS" +
+ " Topology matches MN Topology",
+ onfail="ONOS" +
+ " Topology does not match MN Topology" )
+
Topology_Check = Topology_Check and result
- utilities.assert_equals(expect=main.TRUE,actual=Topology_Check,
- onpass="Topology checks passed", onfail="Topology checks failed")
-
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=Topology_Check,
+ onpass="Topology checks passed",
+ onfail="Topology checks failed" )
+
result = Link_Down and Link_Up and Topology_Check
- utilities.assert_equals(expect=main.TRUE,actual=result,
- onpass="Link failure is discovered correctly",
- onfail="Link Discovery failed")
+ utilities.assert_equals( expect=main.TRUE, actual=result,
+ onpass="Link failure is discovered correctly",
+ onfail="Link Discovery failed" )
-
- def CASE8(self):
- '''
+ def CASE8( self ):
+ """
Host intents removal
- '''
- main.log.report("This testcase removes any previously added intents before adding the same intents or point intents")
- main.log.report("__________________________________")
- main.log.info("Host intents removal")
- main.case("Removing host intents")
- main.step("Obtain the intent id's")
- intent_result = main.ONOS2.intents(json_format = False)
- main.log.info("intent_result = " +intent_result)
-
- intent_linewise = intent_result.split("\n")
+ """
+ main.log.report(
+ "This testcase removes any previously added intents before adding the same intents or point intents" )
+ main.log.report( "__________________________________" )
+ main.log.info( "Host intents removal" )
+ main.case( "Removing host intents" )
+ main.step( "Obtain the intent id's" )
+ intent_result = main.ONOS2.intents( json_format=False )
+ main.log.info( "intent_result = " + intent_result )
+
+ intent_linewise = intent_result.split( "\n" )
intentList = []
for line in intent_linewise:
- if line.startswith("id="):
- intentList.append(line)
-
+ if line.startswith( "id=" ):
+ intentList.append( line )
+
intentids = []
for line in intentList:
- intentids.append(line.split(",")[0].split("=")[1])
+ intentids.append( line.split( "," )[ 0 ].split( "=" )[ 1 ] )
for id in intentids:
print "id = ", id
-
- main.step("Iterate through the intentids list and remove each intent")
+
+ main.step(
+ "Iterate through the intentids list and remove each intent" )
for id in intentids:
- main.ONOS2.remove_intent(intent_id = id)
-
- intent_result = main.ONOS2.intents(json_format = False)
- main.log.info("intent_result = " +intent_result)
+ main.ONOS2.remove_intent( intent_id=id )
+
+ intent_result = main.ONOS2.intents( json_format=False )
+ main.log.info( "intent_result = " + intent_result )
case8_result = main.TRUE
if case8_result == main.TRUE:
- main.log.report("Intent removal successful")
+ main.log.report( "Intent removal successful" )
else:
- main.log.report("Intent removal failed")
-
+ main.log.report( "Intent removal failed" )
+
Ping_Result = main.TRUE
if case8_result == main.TRUE:
i = 8
- while i <18 :
- main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10))
- ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
- if ping==main.TRUE:
+ while i < 18:
+ main.log.info(
+ "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
+ ping = main.Mininet1.pingHost(
+ src="h" + str( i ), target="h" + str( i + 10 ) )
+ if ping == main.TRUE:
i = 19
Ping_Result = Ping_Result and main.TRUE
- elif ping==main.FALSE:
- i+=1
+ elif ping == main.FALSE:
+ i += 1
Ping_Result = Ping_Result and main.FALSE
else:
- main.log.info("Unknown error")
+ main.log.info( "Unknown error" )
Ping_Result = main.ERROR
- #Note: If the ping result failed, that means the intents have been withdrawn correctly.
- if Ping_Result==main.TRUE:
- main.log.report("Host intents have not been withdrawn correctly")
- #main.cleanup()
- #main.exit()
- if Ping_Result==main.FALSE:
- main.log.report("Host intents have been withdrawn correctly")
+ # Note: If the ping result failed, that means the intents have been
+ # withdrawn correctly.
+ if Ping_Result == main.TRUE:
+ main.log.report( "Host intents have not been withdrawn correctly" )
+ # main.cleanup()
+ # main.exit()
+ if Ping_Result == main.FALSE:
+ main.log.report( "Host intents have been withdrawn correctly" )
case8_result = case8_result and Ping_Result
if case8_result == main.FALSE:
- main.log.report("Intent removal successful")
+ main.log.report( "Intent removal successful" )
else:
- main.log.report("Intent removal failed")
+ main.log.report( "Intent removal failed" )
- utilities.assert_equals(expect=main.FALSE, actual=case8_result,
- onpass="Intent removal test failed",
- onfail="Intent removal test passed")
+ utilities.assert_equals( expect=main.FALSE, actual=case8_result,
+ onpass="Intent removal test failed",
+ onfail="Intent removal test passed" )
+ def CASE9( self ):
+ main.log.report(
+ "This testcase adds point intents and then does pingall" )
+ main.log.report( "__________________________________" )
+ main.log.info( "Adding point intents" )
+ main.case(
+ "Adding bidirectional point for mn hosts(h8-h18,h9-h19,h10-h20,h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)" )
+ main.step(
+ "Add point-to-point intents for mininet hosts h8 and h18 or ONOS hosts h8 and h12" )
+ ptp_intent_result = main.ONOS2.add_point_intent(
+ "of:0000000000003008/1",
+ "of:0000000000006018/1" )
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
- def CASE9(self):
- main.log.report("This testcase adds point intents and then does pingall")
- main.log.report("__________________________________")
- main.log.info("Adding point intents")
- main.case("Adding bidirectional point for mn hosts(h8-h18,h9-h19,h10-h20,h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)")
- main.step("Add point-to-point intents for mininet hosts h8 and h18 or ONOS hosts h8 and h12")
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003008/1", "of:0000000000006018/1")
+ ptp_intent_result = main.ONOS2.add_point_intent(
+ "of:0000000000006018/1",
+ "of:0000000000003008/1" )
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOS2.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006018/1", "of:0000000000003008/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- main.step("Add point-to-point intents for mininet hosts h9 and h19 or ONOS hosts h9 and h13")
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003009/1", "of:0000000000006019/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006019/1", "of:0000000000003009/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- main.step("Add point-to-point intents for mininet hosts h10 and h20 or ONOS hosts hA and h14")
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003010/1", "of:0000000000006020/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006020/1", "of:0000000000003010/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
- main.step("Add point-to-point intents for mininet hosts h11 and h21 or ONOS hosts hB and h15")
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003011/1", "of:0000000000006021/1")
+ main.step(
+ "Add point-to-point intents for mininet hosts h9 and h19 or ONOS hosts h9 and h13" )
+ ptp_intent_result = main.ONOS2.add_point_intent(
+ "of:0000000000003009/1",
+ "of:0000000000006019/1" )
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOS2.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006021/1", "of:0000000000003011/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- main.step("Add point-to-point intents for mininet hosts h12 and h22 or ONOS hosts hC and h16")
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003012/1", "of:0000000000006022/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006022/1", "of:0000000000003012/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- main.step("Add point-to-point intents for mininet hosts h13 and h23 or ONOS hosts hD and h17")
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003013/1", "of:0000000000006023/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006023/1", "of:0000000000003013/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
- main.step("Add point-to-point intents for mininet hosts h14 and h24 or ONOS hosts hE and h18")
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003014/1", "of:0000000000006024/1")
+ ptp_intent_result = main.ONOS2.add_point_intent(
+ "of:0000000000006019/1",
+ "of:0000000000003009/1" )
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOS2.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006024/1", "of:0000000000003014/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- main.step("Add point-to-point intents for mininet hosts h15 and h25 or ONOS hosts hF and h19")
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003015/1", "of:0000000000006025/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006025/1", "of:0000000000003015/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- main.step("Add point-to-point intents for mininet hosts h16 and h26 or ONOS hosts h10 and h1A")
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003016/1", "of:0000000000006026/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006026/1", "of:0000000000003016/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
-
- main.step("Add point-to-point intents for mininet hosts h17 and h27 or ONOS hosts h11 and h1B")
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003017/1", "of:0000000000006027/1")
+ main.step(
+ "Add point-to-point intents for mininet hosts h10 and h20 or ONOS hosts hA and h14" )
+ ptp_intent_result = main.ONOS2.add_point_intent(
+ "of:0000000000003010/1",
+ "of:0000000000006020/1" )
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOS2.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006027/1", "of:0000000000003017/1")
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ ptp_intent_result = main.ONOS2.add_point_intent(
+ "of:0000000000006020/1",
+ "of:0000000000003010/1" )
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOS2.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
- print("_______________________________________________________________________________________")
+ main.step(
+ "Add point-to-point intents for mininet hosts h11 and h21 or ONOS hosts hB and h15" )
+ ptp_intent_result = main.ONOS2.add_point_intent(
+ "of:0000000000003011/1",
+ "of:0000000000006021/1" )
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ ptp_intent_result = main.ONOS2.add_point_intent(
+ "of:0000000000006021/1",
+ "of:0000000000003011/1" )
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ main.step(
+ "Add point-to-point intents for mininet hosts h12 and h22 or ONOS hosts hC and h16" )
+ ptp_intent_result = main.ONOS2.add_point_intent(
+ "of:0000000000003012/1",
+ "of:0000000000006022/1" )
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ ptp_intent_result = main.ONOS2.add_point_intent(
+ "of:0000000000006022/1",
+ "of:0000000000003012/1" )
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ main.step(
+ "Add point-to-point intents for mininet hosts h13 and h23 or ONOS hosts hD and h17" )
+ ptp_intent_result = main.ONOS2.add_point_intent(
+ "of:0000000000003013/1",
+ "of:0000000000006023/1" )
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ ptp_intent_result = main.ONOS2.add_point_intent(
+ "of:0000000000006023/1",
+ "of:0000000000003013/1" )
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ main.step(
+ "Add point-to-point intents for mininet hosts h14 and h24 or ONOS hosts hE and h18" )
+ ptp_intent_result = main.ONOS2.add_point_intent(
+ "of:0000000000003014/1",
+ "of:0000000000006024/1" )
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ ptp_intent_result = main.ONOS2.add_point_intent(
+ "of:0000000000006024/1",
+ "of:0000000000003014/1" )
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ main.step(
+ "Add point-to-point intents for mininet hosts h15 and h25 or ONOS hosts hF and h19" )
+ ptp_intent_result = main.ONOS2.add_point_intent(
+ "of:0000000000003015/1",
+ "of:0000000000006025/1" )
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ ptp_intent_result = main.ONOS2.add_point_intent(
+ "of:0000000000006025/1",
+ "of:0000000000003015/1" )
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ main.step(
+ "Add point-to-point intents for mininet hosts h16 and h26 or ONOS hosts h10 and h1A" )
+ ptp_intent_result = main.ONOS2.add_point_intent(
+ "of:0000000000003016/1",
+ "of:0000000000006026/1" )
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ ptp_intent_result = main.ONOS2.add_point_intent(
+ "of:0000000000006026/1",
+ "of:0000000000003016/1" )
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ main.step(
+ "Add point-to-point intents for mininet hosts h17 and h27 or ONOS hosts h11 and h1B" )
+ ptp_intent_result = main.ONOS2.add_point_intent(
+ "of:0000000000003017/1",
+ "of:0000000000006027/1" )
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ ptp_intent_result = main.ONOS2.add_point_intent(
+ "of:0000000000006027/1",
+ "of:0000000000003017/1" )
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ print(
+ "_______________________________________________________________________________________" )
flowHandle = main.ONOS2.flows()
- #print "flowHandle = ", flowHandle
- main.log.info("flows :" + flowHandle)
+ # print "flowHandle = ", flowHandle
+ main.log.info( "flows :" + flowHandle )
count = 1
i = 8
Ping_Result = main.TRUE
- while i <18 :
- main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10))
- ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
- if ping == main.FALSE and count <5:
- count+=1
+ while i < 18:
+ main.log.info(
+ "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
+ ping = main.Mininet1.pingHost(
+ src="h" + str( i ), target="h" + str( i + 10 ) )
+ if ping == main.FALSE and count < 5:
+ count += 1
#i = 8
Ping_Result = main.FALSE
- main.log.report("Ping between h" + str(i) + " and h" + str(i+10) + " failed. Making attempt number "+str(count) + " in 2 seconds")
- time.sleep(2)
- elif ping==main.FALSE:
- main.log.report("All ping attempts between h" + str(i) + " and h" + str(i+10) +"have failed")
- i=19
+ main.log.report( "Ping between h" +
+ str( i ) +
+ " and h" +
+ str( i +
+ 10 ) +
+ " failed. Making attempt number " +
+ str( count ) +
+ " in 2 seconds" )
+ time.sleep( 2 )
+ elif ping == main.FALSE:
+ main.log.report( "All ping attempts between h" +
+ str( i ) +
+ " and h" +
+ str( i +
+ 10 ) +
+ "have failed" )
+ i = 19
Ping_Result = main.FALSE
- elif ping==main.TRUE:
- main.log.info("Ping test between h" + str(i) + " and h" + str(i+10) + "passed!")
- i+=1
+ elif ping == main.TRUE:
+ main.log.info( "Ping test between h" +
+ str( i ) +
+ " and h" +
+ str( i +
+ 10 ) +
+ "passed!" )
+ i += 1
Ping_Result = main.TRUE
else:
- main.log.info("Unknown error")
+ main.log.info( "Unknown error" )
Ping_Result = main.ERROR
- if Ping_Result==main.FALSE:
- main.log.report("Point intents have not ben installed correctly. Cleaning up")
- #main.cleanup()
- #main.exit()
- if Ping_Result==main.TRUE:
- main.log.report("Point Intents have been installed correctly")
+ if Ping_Result == main.FALSE:
+ main.log.report(
+ "Point intents have not ben installed correctly. Cleaning up" )
+ # main.cleanup()
+ # main.exit()
+ if Ping_Result == main.TRUE:
+ main.log.report( "Point Intents have been installed correctly" )
case9_result = Ping_Result
- utilities.assert_equals(expect=main.TRUE, actual=case9_result,
- onpass="Point intents addition and Pingall Test successful",
- onfail="Point intents addition and Pingall Test NOT successful")
-
-
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case9_result,
+ onpass="Point intents addition and Pingall Test successful",
+ onfail="Point intents addition and Pingall Test NOT successful" )
diff --git a/TestON/tests/ProdFunc13/ProdFunc13.py b/TestON/tests/ProdFunc13/ProdFunc13.py
old mode 100755
new mode 100644
index a815fea..1775ebb
--- a/TestON/tests/ProdFunc13/ProdFunc13.py
+++ b/TestON/tests/ProdFunc13/ProdFunc13.py
@@ -1,6 +1,6 @@
-#Testing the basic functionality of ONOS Next
-#For sanity and driver functionality excercises only.
+# Testing the basic functionality of ONOS Next
+# For sanity and driver functionality excercises only.
import time
import sys
@@ -8,13 +8,16 @@
import re
import json
-time.sleep(1)
+time.sleep( 1 )
+
+
class ProdFunc13:
- def __init__(self):
+
+ def __init__( self ):
self.default = ''
- def CASE1(self, main):
- '''
+ def CASE1( self, main ):
+ """
Startup sequence:
cell <name>
onos-verify-cell
@@ -24,1077 +27,1312 @@
onos-package
onos-install -f
onos-wait-for-start
- '''
-
- cell_name = main.params['ENV']['cellName']
- ONOS1_ip = main.params['CTRL']['ip1']
- ONOS1_port = main.params['CTRL']['port1']
-
- main.case("Setting up test environment")
- main.log.report("This testcase is testing setting up test environment")
- main.log.report("__________________________________")
+ """
+ cell_name = main.params[ 'ENV' ][ 'cellName' ]
+ ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+ ONOS1_port = main.params[ 'CTRL' ][ 'port1' ]
- main.step("Applying cell variable to environment")
- cell_result = main.ONOSbench.set_cell(cell_name)
+ main.case( "Setting up test environment" )
+ main.log.report(
+ "This testcase is testing setting up test environment" )
+ main.log.report( "__________________________________" )
+
+ main.step( "Applying cell variable to environment" )
+ cell_result = main.ONOSbench.set_cell( cell_name )
verify_result = main.ONOSbench.verify_cell()
-
- main.step("Removing raft logs before a clen installation of ONOS")
+
+ main.step( "Removing raft logs before a clen installation of ONOS" )
main.ONOSbench.onos_remove_raft_logs()
- main.step("Git checkout and pull master and get version")
- main.ONOSbench.git_checkout("master")
+ main.step( "Git checkout and pull master and get version" )
+ main.ONOSbench.git_checkout( "master" )
git_pull_result = main.ONOSbench.git_pull()
- main.log.info("git_pull_result = " +git_pull_result)
- version_result = main.ONOSbench.get_version(report=True)
-
+ main.log.info( "git_pull_result = " + git_pull_result )
+ version_result = main.ONOSbench.get_version( report=True )
+
if git_pull_result == 1:
- main.step("Using mvn clean & install")
+ main.step( "Using mvn clean & install" )
clean_install_result = main.ONOSbench.clean_install()
#clean_install_result = main.TRUE
elif git_pull_result == 0:
- main.log.report("Git Pull Failed, look into logs for detailed reason")
+ main.log.report(
+ "Git Pull Failed, look into logs for detailed reason" )
main.cleanup()
- main.exit()
-
- main.step("Creating ONOS package")
+ main.exit()
+
+ main.step( "Creating ONOS package" )
package_result = main.ONOSbench.onos_package()
-
- main.step("Installing ONOS package")
+ main.step( "Installing ONOS package" )
onos_install_result = main.ONOSbench.onos_install()
if onos_install_result == main.TRUE:
- main.log.report("Installing ONOS package successful")
+ main.log.report( "Installing ONOS package successful" )
else:
- main.log.report("Installing ONOS package failed")
+ main.log.report( "Installing ONOS package failed" )
onos1_isup = main.ONOSbench.isup()
if onos1_isup == main.TRUE:
- main.log.report("ONOS instance is up and ready")
+ main.log.report( "ONOS instance is up and ready" )
else:
- main.log.report("ONOS instance may not be up")
-
- main.step("Starting ONOS service")
- start_result = main.ONOSbench.onos_start(ONOS1_ip)
-
- main.ONOS2.start_onos_cli(ONOS_ip=main.params['CTRL']['ip1'])
+ main.log.report( "ONOS instance may not be up" )
- case1_result = (package_result and\
- cell_result and verify_result and onos_install_result and\
- onos1_isup and start_result )
- utilities.assert_equals(expect=main.TRUE, actual=case1_result,
- onpass="Test startup successful",
- onfail="Test startup NOT successful")
+ main.step( "Starting ONOS service" )
+ start_result = main.ONOSbench.onos_start( ONOS1_ip )
- def CASE2(self, main) :
- '''
+ main.ONOS2.start_onos_cli( ONOS_ip=main.params[ 'CTRL' ][ 'ip1' ] )
+
+ case1_result = ( package_result and
+ cell_result and verify_result and onos_install_result and
+ onos1_isup and start_result )
+ utilities.assert_equals( expect=main.TRUE, actual=case1_result,
+ onpass="Test startup successful",
+ onfail="Test startup NOT successful" )
+
+ def CASE2( self, main ):
+ """
Switch Down
- '''
- #NOTE: You should probably run a topology check after this
- import time
+ """
+ # NOTE: You should probably run a topology check after this
+ import time
import json
-
- main.case("Switch down discovery")
- main.log.report("This testcase is testing a switch down discovery")
- main.log.report("__________________________________")
- switch_sleep = int(main.params['timers']['SwitchDiscovery'])
+ main.case( "Switch down discovery" )
+ main.log.report( "This testcase is testing a switch down discovery" )
+ main.log.report( "__________________________________" )
+
+ switch_sleep = int( main.params[ 'timers' ][ 'SwitchDiscovery' ] )
description = "Killing a switch to ensure it is discovered correctly"
- main.log.report(description)
- main.case(description)
+ main.log.report( description )
+ main.case( description )
- #TODO: Make this switch parameterizable
- main.step("Kill s28 ")
- main.log.report("Deleting s28")
- #FIXME: use new dynamic topo functions
- main.Mininet1.del_switch("s28")
- main.log.info("Waiting " + str(switch_sleep) + " seconds for switch down to be discovered")
- time.sleep(switch_sleep)
- #Peek at the deleted switch
- device = main.ONOS2.get_device(dpid="0028")
+ # TODO: Make this switch parameterizable
+ main.step( "Kill s28 " )
+ main.log.report( "Deleting s28" )
+ # FIXME: use new dynamic topo functions
+ main.Mininet1.del_switch( "s28" )
+ main.log.info(
+ "Waiting " +
+ str( switch_sleep ) +
+ " seconds for switch down to be discovered" )
+ time.sleep( switch_sleep )
+ # Peek at the deleted switch
+ device = main.ONOS2.get_device( dpid="0028" )
print "device = ", device
- if device[u'available'] == 'False':
+ if device[ u'available' ] == 'False':
case2_result = main.FALSE
else:
case2_result = main.TRUE
- utilities.assert_equals(expect=main.TRUE, actual=case2_result,
- onpass="Switch down discovery successful",
- onfail="Switch down discovery failed")
+ utilities.assert_equals( expect=main.TRUE, actual=case2_result,
+ onpass="Switch down discovery successful",
+ onfail="Switch down discovery failed" )
- def CASE11(self, main):
- '''
+ def CASE11( self, main ):
+ """
Cleanup sequence:
onos-service <node_ip> stop
onos-uninstall
TODO: Define rest of cleanup
-
- '''
- ONOS1_ip = main.params['CTRL']['ip1']
+ """
+ ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
- main.case("Cleaning up test environment")
+ main.case( "Cleaning up test environment" )
- main.step("Testing ONOS kill function")
- kill_result = main.ONOSbench.onos_kill(ONOS1_ip)
+ main.step( "Testing ONOS kill function" )
+ kill_result = main.ONOSbench.onos_kill( ONOS1_ip )
- main.step("Stopping ONOS service")
- stop_result = main.ONOSbench.onos_stop(ONOS1_ip)
+ main.step( "Stopping ONOS service" )
+ stop_result = main.ONOSbench.onos_stop( ONOS1_ip )
- main.step("Uninstalling ONOS service")
+ main.step( "Uninstalling ONOS service" )
uninstall_result = main.ONOSbench.onos_uninstall()
- def CASE3(self, main):
- '''
+ def CASE3( self, main ):
+ """
Test 'onos' command and its functionality in driver
- '''
-
- ONOS1_ip = main.params['CTRL']['ip1']
+ """
+ ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
- main.case("Testing 'onos' command")
+ main.case( "Testing 'onos' command" )
- main.step("Sending command 'onos -w <onos-ip> system:name'")
+ main.step( "Sending command 'onos -w <onos-ip> system:name'" )
cmdstr1 = "system:name"
- cmd_result1 = main.ONOSbench.onos_cli(ONOS1_ip, cmdstr1)
- main.log.info("onos command returned: "+cmd_result1)
+ cmd_result1 = main.ONOSbench.onos_cli( ONOS1_ip, cmdstr1 )
+ main.log.info( "onos command returned: " + cmd_result1 )
- main.step("Sending command 'onos -w <onos-ip> onos:topology'")
+ main.step( "Sending command 'onos -w <onos-ip> onos:topology'" )
cmdstr2 = "onos:topology"
- cmd_result2 = main.ONOSbench.onos_cli(ONOS1_ip, cmdstr2)
- main.log.info("onos command returned: "+cmd_result2)
+ cmd_result2 = main.ONOSbench.onos_cli( ONOS1_ip, cmdstr2 )
+ main.log.info( "onos command returned: " + cmd_result2 )
-
- def CASE20(self):
- '''
+ def CASE20( self ):
+ """
Exit from mininet cli
reinstall ONOS
- '''
- cell_name = main.params['ENV']['cellName']
- ONOS1_ip = main.params['CTRL']['ip1']
- ONOS1_port = main.params['CTRL']['port1']
-
- main.log.report("This testcase exits the mininet cli and reinstalls ONOS to switch over to Packet Optical topology")
- main.log.report("_____________________________________________")
- main.case("Disconnecting mininet and restarting ONOS")
- main.step("Disconnecting mininet and restarting ONOS")
+ """
+ cell_name = main.params[ 'ENV' ][ 'cellName' ]
+ ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+ ONOS1_port = main.params[ 'CTRL' ][ 'port1' ]
+
+ main.log.report(
+ "This testcase exits the mininet cli and reinstalls ONOS to switch over to Packet Optical topology" )
+ main.log.report( "_____________________________________________" )
+ main.case( "Disconnecting mininet and restarting ONOS" )
+ main.step( "Disconnecting mininet and restarting ONOS" )
mininet_disconnect = main.Mininet1.disconnect()
- main.step("Removing raft logs before a clen installation of ONOS")
+ main.step( "Removing raft logs before a clen installation of ONOS" )
main.ONOSbench.onos_remove_raft_logs()
- main.step("Applying cell variable to environment")
- cell_result = main.ONOSbench.set_cell(cell_name)
+ main.step( "Applying cell variable to environment" )
+ cell_result = main.ONOSbench.set_cell( cell_name )
verify_result = main.ONOSbench.verify_cell()
onos_install_result = main.ONOSbench.onos_install()
if onos_install_result == main.TRUE:
- main.log.report("Installing ONOS package successful")
+ main.log.report( "Installing ONOS package successful" )
else:
- main.log.report("Installing ONOS package failed")
+ main.log.report( "Installing ONOS package failed" )
onos1_isup = main.ONOSbench.isup()
if onos1_isup == main.TRUE:
- main.log.report("ONOS instance is up and ready")
+ main.log.report( "ONOS instance is up and ready" )
else:
- main.log.report("ONOS instance may not be up")
+ main.log.report( "ONOS instance may not be up" )
- main.step("Starting ONOS service")
- start_result = main.ONOSbench.onos_start(ONOS1_ip)
-
- main.ONOS2.start_onos_cli(ONOS_ip=main.params['CTRL']['ip1'])
+ main.step( "Starting ONOS service" )
+ start_result = main.ONOSbench.onos_start( ONOS1_ip )
+
+ main.ONOS2.start_onos_cli( ONOS_ip=main.params[ 'CTRL' ][ 'ip1' ] )
print "mininet_disconnect =", mininet_disconnect
print "onos_install_result =", onos_install_result
print "onos1_isup =", onos1_isup
print "start_result =", start_result
-
- case20_result = mininet_disconnect and cell_result and onos_install_result and onos1_isup and start_result
- utilities.assert_equals(expect=main.TRUE, actual=case20_result,
- onpass="Exiting functionality mininet topology and reinstalling ONOS successful",
- onfail="Exiting functionality mininet topology and reinstalling ONOS failed")
- def CASE21(self, main):
+ case20_result = mininet_disconnect and cell_result and onos_install_result and onos1_isup and start_result
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case20_result,
+ onpass="Exiting functionality mininet topology and reinstalling ONOS successful",
+ onfail="Exiting functionality mininet topology and reinstalling ONOS failed" )
+
+ def CASE21( self, main ):
import time
- '''
+ """
On ONOS bench, run this command: ./~/ONOS/tools/test/bin/onos-topo-cfg
which starts the rest and copies the links json file to the onos instance
- Note that in case of Packet Optical, the links are not learnt from the topology, instead the links are learnt
+ Note that in case of Packet Optical, the links are not learnt from the topology, instead the links are learnt
from the json config file
- '''
- main.log.report("This testcase starts the packet layer topology and REST")
- main.log.report("_____________________________________________")
- main.case("Starting LINC-OE and other components")
- main.step("Starting LINC-OE and other components")
+ """
+ main.log.report(
+ "This testcase starts the packet layer topology and REST" )
+ main.log.report( "_____________________________________________" )
+ main.case( "Starting LINC-OE and other components" )
+ main.step( "Starting LINC-OE and other components" )
start_console_result = main.LincOE1.start_console()
optical_mn_script = main.LincOE2.run_optical_mn_script()
- onos_topo_cfg_result = main.ONOSbench.run_onos_topo_cfg(instance_name = main.params['CTRL']['ip1'], json_file = main.params['OPTICAL']['jsonfile'])
-
- print "start_console_result =",start_console_result
- print "optical_mn_script = ",optical_mn_script
- print "onos_topo_cfg_result =",onos_topo_cfg_result
+ onos_topo_cfg_result = main.ONOSbench.run_onos_topo_cfg(
+ instance_name=main.params[ 'CTRL' ][ 'ip1' ],
+ json_file=main.params[ 'OPTICAL' ][ 'jsonfile' ] )
+
+ print "start_console_result =", start_console_result
+ print "optical_mn_script = ", optical_mn_script
+ print "onos_topo_cfg_result =", onos_topo_cfg_result
case21_result = start_console_result and optical_mn_script and onos_topo_cfg_result
- utilities.assert_equals(expect=main.TRUE, actual=case21_result,
- onpass="Packet optical topology spawned successsfully",
- onfail="Packet optical topology spawning failed")
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case21_result,
+ onpass="Packet optical topology spawned successsfully",
+ onfail="Packet optical topology spawning failed" )
-
- def CASE22(self, main):
- '''
+ def CASE22( self, main ):
+ """
Curretly we use, 4 linear switch optical topology and 2 packet layer mininet switches each with one host.
Therefore, the roadmCount variable = 4, packetLayerSWCount variable = 2, hostCount =2
and this is hardcoded in the testcase. If the topology changes, these hardcoded values need to be changed
- '''
-
- main.log.report("This testcase compares the optical+packet topology against what is expected")
- main.case("Topology comparision")
- main.step("Topology comparision")
- main.ONOS3.start_onos_cli(ONOS_ip=main.params['CTRL']['ip1'])
- devices_result = main.ONOS3.devices(json_format = False)
+ """
+ main.log.report(
+ "This testcase compares the optical+packet topology against what is expected" )
+ main.case( "Topology comparision" )
+ main.step( "Topology comparision" )
+ main.ONOS3.start_onos_cli( ONOS_ip=main.params[ 'CTRL' ][ 'ip1' ] )
+ devices_result = main.ONOS3.devices( json_format=False )
print "devices_result = ", devices_result
- devices_linewise = devices_result.split("\n")
- devices_linewise = devices_linewise[1:-1]
+ devices_linewise = devices_result.split( "\n" )
+ devices_linewise = devices_linewise[ 1:-1 ]
roadmCount = 0
packetLayerSWCount = 0
for line in devices_linewise:
- components = line.split(",")
- availability = components[1].split("=")[1]
- type = components[3].split("=")[1]
+ components = line.split( "," )
+ availability = components[ 1 ].split( "=" )[ 1 ]
+ type = components[ 3 ].split( "=" )[ 1 ]
if availability == 'true' and type == 'ROADM':
roadmCount += 1
- elif availability == 'true' and type =='SWITCH':
+ elif availability == 'true' and type == 'SWITCH':
packetLayerSWCount += 1
if roadmCount == 4:
- print "Number of Optical Switches = %d and is correctly detected" %roadmCount
- main.log.info ("Number of Optical Switches = " +str(roadmCount) +" and is correctly detected")
+ print "Number of Optical Switches = %d and is correctly detected" % roadmCount
+ main.log.info(
+ "Number of Optical Switches = " +
+ str( roadmCount ) +
+ " and is correctly detected" )
opticalSW_result = main.TRUE
else:
- print "Number of Optical Switches = %d and is wrong" %roadCount
- main.log.info ("Number of Optical Switches = " +str(roadmCount) +" and is wrong")
+ print "Number of Optical Switches = %d and is wrong" % roadCount
+ main.log.info(
+ "Number of Optical Switches = " +
+ str( roadmCount ) +
+ " and is wrong" )
opticalSW_result = main.FALSE
if packetLayerSWCount == 2:
- print "Number of Packet layer or mininet Switches = %d and is correctly detected" %packetLayerSWCount
- main.log.info("Number of Packet layer or mininet Switches = " +str(packetLayerSWCount) + " and is correctly detected")
+ print "Number of Packet layer or mininet Switches = %d and is correctly detected" % packetLayerSWCount
+ main.log.info(
+ "Number of Packet layer or mininet Switches = " +
+ str( packetLayerSWCount ) +
+ " and is correctly detected" )
packetSW_result = main.TRUE
else:
- print "Number of Packet layer or mininet Switches = %d and is wrong" %packetLayerSWCount
- main.log.info("Number of Packet layer or mininet Switches = " +str(packetLayerSWCount) + " and is wrong")
+ print "Number of Packet layer or mininet Switches = %d and is wrong" % packetLayerSWCount
+ main.log.info(
+ "Number of Packet layer or mininet Switches = " +
+ str( packetLayerSWCount ) +
+ " and is wrong" )
packetSW_result = main.FALSE
print "_________________________________"
-
- links_result = main.ONOS3.links(json_format = False)
+
+ links_result = main.ONOS3.links( json_format=False )
print "links_result = ", links_result
print "_________________________________"
-
- #NOTE:Since only point intents are added, there is no requirement to discover the hosts
- #Therfore, the below portion of the code is commented.
- '''
+
+ # NOTE:Since only point intents are added, there is no requirement to discover the hosts
+ # Therfore, the below portion of the code is commented.
+ """
#Discover hosts using pingall
- pingall_result = main.LincOE2.pingall()
-
- hosts_result = main.ONOS3.hosts(json_format = False)
- main.log.info("hosts_result = "+hosts_result)
- main.log.info("_________________________________")
- hosts_linewise = hosts_result.split("\n")
- hosts_linewise = hosts_linewise[1:-1]
+ pingall_result = main.LincOE2.pingall()
+
+ hosts_result = main.ONOS3.hosts( json_format=False )
+ main.log.info( "hosts_result = "+hosts_result )
+ main.log.info( "_________________________________" )
+ hosts_linewise = hosts_result.split( "\n" )
+ hosts_linewise = hosts_linewise[ 1:-1 ]
hostCount = 0
for line in hosts_linewise:
- hostid = line.split(",")[0].split("=")[1]
+ hostid = line.split( "," )[ 0 ].split( "=" )[ 1 ]
hostCount +=1
if hostCount ==2:
print "Number of hosts = %d and is correctly detected" %hostCount
- main.log.info("Number of hosts = " + str(hostCount) +" and is correctly detected")
+ main.log.info( "Number of hosts = " + str( hostCount ) +" and is correctly detected" )
hostDiscovery = main.TRUE
else:
print "Number of hosts = %d and is wrong" %hostCount
- main.log.info("Number of hosts = " + str(hostCount) +" and is wrong")
+ main.log.info( "Number of hosts = " + str( hostCount ) +" and is wrong" )
hostDiscovery = main.FALSE
- '''
-
+ """
case22_result = opticalSW_result and packetSW_result
- utilities.assert_equals(expect=main.TRUE, actual=case22_result,
- onpass="Packet optical topology discovery successful",
- onfail="Packet optical topology discovery failed")
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case22_result,
+ onpass="Packet optical topology discovery successful",
+ onfail="Packet optical topology discovery failed" )
- def CASE23(self, main):
+ def CASE23( self, main ):
import time
- '''
- Add bidirectional point intents between 2 packet layer(mininet) devices and
+ """
+ Add bidirectional point intents between 2 packet layer( mininet ) devices and
ping mininet hosts
- '''
- main.log.report("This testcase adds bidirectional point intents between 2 packet layer(mininet) devices and ping mininet hosts")
- main.case("Topology comparision")
- main.step("Adding point intents")
- ptp_intent_result = main.ONOS3.add_point_intent("of:0000ffffffff0001/1", "of:0000ffffffff0002/1")
+ """
+ main.log.report(
+ "This testcase adds bidirectional point intents between 2 packet layer(mininet) devices and ping mininet hosts" )
+ main.case( "Topology comparision" )
+ main.step( "Adding point intents" )
+ ptp_intent_result = main.ONOS3.add_point_intent(
+ "of:0000ffffffff0001/1",
+ "of:0000ffffffff0002/1" )
if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS3.intents(json_format = False)
- main.log.info("Point to point intent install successful")
+ get_intent_result = main.ONOS3.intents( json_format=False )
+ main.log.info( "Point to point intent install successful" )
- ptp_intent_result = main.ONOS3.add_point_intent("of:0000ffffffff0002/1", "of:0000ffffffff0001/1")
+ ptp_intent_result = main.ONOS3.add_point_intent(
+ "of:0000ffffffff0002/1",
+ "of:0000ffffffff0001/1" )
if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS3.intents(json_format = False)
- main.log.info("Point to point intent install successful")
+ get_intent_result = main.ONOS3.intents( json_format=False )
+ main.log.info( "Point to point intent install successful" )
- time.sleep(10)
+ time.sleep( 10 )
flowHandle = main.ONOS3.flows()
- main.log.info("flows :" + flowHandle)
+ main.log.info( "flows :" + flowHandle )
# Sleep for 30 seconds to provide time for the intent state to change
- time.sleep(30)
- intentHandle = main.ONOS3.intents(json_format = False)
- main.log.info("intents :" + intentHandle)
-
+ time.sleep( 30 )
+ intentHandle = main.ONOS3.intents( json_format=False )
+ main.log.info( "intents :" + intentHandle )
+
Ping_Result = main.TRUE
count = 1
- main.log.info("\n\nh1 is Pinging h2")
- ping = main.LincOE2.pingHostOptical(src="h1", target="h2")
+ main.log.info( "\n\nh1 is Pinging h2" )
+ ping = main.LincOE2.pingHostOptical( src="h1", target="h2" )
#ping = main.LincOE2.pinghost()
- if ping == main.FALSE and count<5:
- count+=1
+ if ping == main.FALSE and count < 5:
+ count += 1
Ping_Result = main.FALSE
- main.log.info("Ping between h1 and h2 failed. Making attempt number "+str(count) + " in 2 seconds")
- time.sleep(2)
- elif ping==main.FALSE:
- main.log.info("All ping attempts between h1 and h2 have failed")
+ main.log.info(
+ "Ping between h1 and h2 failed. Making attempt number " +
+ str( count ) +
+ " in 2 seconds" )
+ time.sleep( 2 )
+ elif ping == main.FALSE:
+ main.log.info( "All ping attempts between h1 and h2 have failed" )
Ping_Result = main.FALSE
- elif ping==main.TRUE:
- main.log.info("Ping test between h1 and h2 passed!")
+ elif ping == main.TRUE:
+ main.log.info( "Ping test between h1 and h2 passed!" )
Ping_Result = main.TRUE
else:
- main.log.info("Unknown error")
+ main.log.info( "Unknown error" )
Ping_Result = main.ERROR
-
- if Ping_Result==main.FALSE:
- main.log.report("Point intents for packet optical have not ben installed correctly. Cleaning up")
- if Ping_Result==main.TRUE:
- main.log.report("Point Intents for packet optical have been installed correctly")
+
+ if Ping_Result == main.FALSE:
+ main.log.report(
+ "Point intents for packet optical have not ben installed correctly. Cleaning up" )
+ if Ping_Result == main.TRUE:
+ main.log.report(
+ "Point Intents for packet optical have been installed correctly" )
case23_result = Ping_Result
- utilities.assert_equals(expect=main.TRUE, actual=case23_result,
- onpass="Point intents addition for packet optical and Pingall Test successful",
- onfail="Point intents addition for packet optical and Pingall Test NOT successful")
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case23_result,
+ onpass="Point intents addition for packet optical and Pingall Test successful",
+ onfail="Point intents addition for packet optical and Pingall Test NOT successful" )
-
-
- def CASE24(self, main):
+ def CASE24( self, main ):
import time
import json
- '''
- Test Rerouting of Packet Optical by bringing a port down (port 22) of a switch(switchID=1), so that link (between switch1 port22 - switch4-port30) is inactive
+ """
+ Test Rerouting of Packet Optical by bringing a port down ( port 22 ) of a switch( switchID=1 ), so that link ( between switch1 port22 - switch4-port30 ) is inactive
and do a ping test. If rerouting is successful, ping should pass. also check the flows
- '''
- main.log.report("This testcase tests rerouting and pings mininet hosts")
- main.case("Test rerouting and pings mininet hosts")
- main.step("Bring a port down and verify the link state")
- main.LincOE1.port_down(sw_id="1", pt_id="22")
- links_nonjson = main.ONOS3.links(json_format = False)
- main.log.info("links = " +links_nonjson)
+ """
+ main.log.report(
+ "This testcase tests rerouting and pings mininet hosts" )
+ main.case( "Test rerouting and pings mininet hosts" )
+ main.step( "Bring a port down and verify the link state" )
+ main.LincOE1.port_down( sw_id="1", pt_id="22" )
+ links_nonjson = main.ONOS3.links( json_format=False )
+ main.log.info( "links = " + links_nonjson )
links = main.ONOS3.links()
- main.log.info("links = " +links)
-
- links_result = json.loads(links)
+ main.log.info( "links = " + links )
+
+ links_result = json.loads( links )
links_state_result = main.FALSE
for item in links_result:
- if item['src']['device'] == "of:0000ffffffffff01" and item['src']['port'] == "22":
- if item['dst']['device'] == "of:0000ffffffffff04" and item['dst']['port'] == "30":
- links_state = item['state']
+ if item[ 'src' ][ 'device' ] == "of:0000ffffffffff01" and item[
+ 'src' ][ 'port' ] == "22":
+ if item[ 'dst' ][ 'device' ] == "of:0000ffffffffff04" and item[
+ 'dst' ][ 'port' ] == "30":
+ links_state = item[ 'state' ]
if links_state == "INACTIVE":
- main.log.info("Links state is inactive as expected due to one of the ports being down")
- main.log.report("Links state is inactive as expected due to one of the ports being down")
+ main.log.info(
+ "Links state is inactive as expected due to one of the ports being down" )
+ main.log.report(
+ "Links state is inactive as expected due to one of the ports being down" )
links_state_result = main.TRUE
break
else:
- main.log.info("Links state is not inactive as expected")
- main.log.report("Links state is not inactive as expected")
+ main.log.info(
+ "Links state is not inactive as expected" )
+ main.log.report(
+ "Links state is not inactive as expected" )
links_state_result = main.FALSE
print "links_state_result = ", links_state_result
- time.sleep(10)
+ time.sleep( 10 )
flowHandle = main.ONOS3.flows()
- main.log.info("flows :" + flowHandle)
+ main.log.info( "flows :" + flowHandle )
- main.step("Verify Rerouting by a ping test")
+ main.step( "Verify Rerouting by a ping test" )
Ping_Result = main.TRUE
- count = 1
- main.log.info("\n\nh1 is Pinging h2")
- ping = main.LincOE2.pingHostOptical(src="h1", target="h2")
+ count = 1
+ main.log.info( "\n\nh1 is Pinging h2" )
+ ping = main.LincOE2.pingHostOptical( src="h1", target="h2" )
#ping = main.LincOE2.pinghost()
- if ping == main.FALSE and count<5:
- count+=1
+ if ping == main.FALSE and count < 5:
+ count += 1
Ping_Result = main.FALSE
- main.log.info("Ping between h1 and h2 failed. Making attempt number "+str(count) + " in 2 seconds")
- time.sleep(2)
- elif ping==main.FALSE:
- main.log.info("All ping attempts between h1 and h2 have failed")
+ main.log.info(
+ "Ping between h1 and h2 failed. Making attempt number " +
+ str( count ) +
+ " in 2 seconds" )
+ time.sleep( 2 )
+ elif ping == main.FALSE:
+ main.log.info( "All ping attempts between h1 and h2 have failed" )
Ping_Result = main.FALSE
- elif ping==main.TRUE:
- main.log.info("Ping test between h1 and h2 passed!")
+ elif ping == main.TRUE:
+ main.log.info( "Ping test between h1 and h2 passed!" )
Ping_Result = main.TRUE
else:
- main.log.info("Unknown error")
+ main.log.info( "Unknown error" )
Ping_Result = main.ERROR
- if Ping_Result==main.TRUE:
- main.log.report("Ping test successful ")
- if Ping_Result==main.FALSE:
- main.log.report("Ping test failed")
+ if Ping_Result == main.TRUE:
+ main.log.report( "Ping test successful " )
+ if Ping_Result == main.FALSE:
+ main.log.report( "Ping test failed" )
case24_result = Ping_Result and links_state_result
- utilities.assert_equals(expect=main.TRUE, actual=case24_result,
- onpass="Packet optical rerouting successful",
- onfail="Packet optical rerouting failed")
+ utilities.assert_equals( expect=main.TRUE, actual=case24_result,
+ onpass="Packet optical rerouting successful",
+ onfail="Packet optical rerouting failed" )
- def CASE4(self, main):
+ def CASE4( self, main ):
import re
import time
- main.log.report("This testcase is testing the assignment of all the switches to all the controllers and discovering the hosts in reactive mode")
- main.log.report("__________________________________")
- main.case("Pingall Test")
- main.step("Assigning switches to controllers")
- for i in range(1,29):
- if i ==1:
- main.Mininet1.assign_sw_controller(sw=str(i),ip1=ONOS1_ip,port1=ONOS1_port)
- elif i>=2 and i<5:
- main.Mininet1.assign_sw_controller(sw=str(i),ip1=ONOS1_ip,port1=ONOS1_port)
- elif i>=5 and i<8:
- main.Mininet1.assign_sw_controller(sw=str(i),ip1=ONOS1_ip,port1=ONOS1_port)
- elif i>=8 and i<18:
- main.Mininet1.assign_sw_controller(sw=str(i),ip1=ONOS1_ip,port1=ONOS1_port)
- elif i>=18 and i<28:
- main.Mininet1.assign_sw_controller(sw=str(i),ip1=ONOS1_ip,port1=ONOS1_port)
+ main.log.report(
+ "This testcase is testing the assignment of all the switches to all the controllers and discovering the hosts in reactive mode" )
+ main.log.report( "__________________________________" )
+ main.case( "Pingall Test" )
+ main.step( "Assigning switches to controllers" )
+ for i in range( 1, 29 ):
+ if i == 1:
+ main.Mininet1.assign_sw_controller(
+ sw=str( i ),
+ ip1=ONOS1_ip,
+ port1=ONOS1_port )
+ elif i >= 2 and i < 5:
+ main.Mininet1.assign_sw_controller(
+ sw=str( i ),
+ ip1=ONOS1_ip,
+ port1=ONOS1_port )
+ elif i >= 5 and i < 8:
+ main.Mininet1.assign_sw_controller(
+ sw=str( i ),
+ ip1=ONOS1_ip,
+ port1=ONOS1_port )
+ elif i >= 8 and i < 18:
+ main.Mininet1.assign_sw_controller(
+ sw=str( i ),
+ ip1=ONOS1_ip,
+ port1=ONOS1_port )
+ elif i >= 18 and i < 28:
+ main.Mininet1.assign_sw_controller(
+ sw=str( i ),
+ ip1=ONOS1_ip,
+ port1=ONOS1_port )
else:
- main.Mininet1.assign_sw_controller(sw=str(i),ip1=ONOS1_ip,port1=ONOS1_port)
+ main.Mininet1.assign_sw_controller(
+ sw=str( i ),
+ ip1=ONOS1_ip,
+ port1=ONOS1_port )
Switch_Mastership = main.TRUE
- for i in range (1,29):
- if i==1:
- response = main.Mininet1.get_sw_controller("s"+str(i))
- print("Response is " + str(response))
- if re.search("tcp:"+ONOS1_ip,response):
+ for i in range( 1, 29 ):
+ if i == 1:
+ response = main.Mininet1.get_sw_controller( "s" + str( i ) )
+ print( "Response is " + str( response ) )
+ if re.search( "tcp:" + ONOS1_ip, response ):
Switch_Mastership = Switch_Mastership and main.TRUE
else:
Switch_Mastership = main.FALSE
- elif i>=2 and i<5:
- response = main.Mininet1.get_sw_controller("s"+str(i))
- print("Response is " + str(response))
- if re.search("tcp:"+ONOS1_ip,response):
+ elif i >= 2 and i < 5:
+ response = main.Mininet1.get_sw_controller( "s" + str( i ) )
+ print( "Response is " + str( response ) )
+ if re.search( "tcp:" + ONOS1_ip, response ):
Switch_Mastership = Switch_Mastership and main.TRUE
else:
Switch_Mastership = main.FALSE
- elif i>=5 and i<8:
- response = main.Mininet1.get_sw_controller("s"+str(i))
- print("Response is " + str(response))
- if re.search("tcp:"+ONOS1_ip,response):
+ elif i >= 5 and i < 8:
+ response = main.Mininet1.get_sw_controller( "s" + str( i ) )
+ print( "Response is " + str( response ) )
+ if re.search( "tcp:" + ONOS1_ip, response ):
Switch_Mastership = Switch_Mastership and main.TRUE
else:
Switch_Mastership = main.FALSE
- elif i>=8 and i<18:
- response = main.Mininet1.get_sw_controller("s"+str(i))
- print("Response is " + str(response))
- if re.search("tcp:"+ONOS1_ip,response):
+ elif i >= 8 and i < 18:
+ response = main.Mininet1.get_sw_controller( "s" + str( i ) )
+ print( "Response is " + str( response ) )
+ if re.search( "tcp:" + ONOS1_ip, response ):
Switch_Mastership = Switch_Mastership and main.TRUE
else:
Switch_Mastership = main.FALSE
- elif i>=18 and i<28:
- response = main.Mininet1.get_sw_controller("s"+str(i))
- print("Response is " + str(response))
- if re.search("tcp:"+ONOS1_ip,response):
+ elif i >= 18 and i < 28:
+ response = main.Mininet1.get_sw_controller( "s" + str( i ) )
+ print( "Response is " + str( response ) )
+ if re.search( "tcp:" + ONOS1_ip, response ):
Switch_Mastership = Switch_Mastership and main.TRUE
else:
Switch_Mastership = main.FALSE
else:
- response = main.Mininet1.get_sw_controller("s"+str(i))
- print("Response is" + str(response))
- if re.search("tcp:" +ONOS1_ip,response):
+ response = main.Mininet1.get_sw_controller( "s" + str( i ) )
+ print( "Response is" + str( response ) )
+ if re.search( "tcp:" + ONOS1_ip, response ):
Switch_Mastership = Switch_Mastership and main.TRUE
else:
Switch_Mastership = main.FALSE
if Switch_Mastership == main.TRUE:
- main.log.report("Controller assignmnet successful")
+ main.log.report( "Controller assignmnet successful" )
else:
- main.log.report("Controller assignmnet failed")
- utilities.assert_equals(expect = main.TRUE,actual=Switch_Mastership,
- onpass="MasterControllers assigned correctly")
- '''
- for i in range (1,29):
- main.Mininet1.assign_sw_controller(sw=str(i),count=5,
+ main.log.report( "Controller assignmnet failed" )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=Switch_Mastership,
+ onpass="MasterControllers assigned correctly" )
+ """
+ for i in range ( 1,29 ):
+ main.Mininet1.assign_sw_controller( sw=str( i ),count=5,
ip1=ONOS1_ip,port1=ONOS1_port,
ip2=ONOS2_ip,port2=ONOS2_port,
ip3=ONOS3_ip,port3=ONOS3_port,
ip4=ONOS4_ip,port4=ONOS4_port,
- ip5=ONOS5_ip,port5=ONOS5_port)
- '''
- #REACTIVE FWD test
+ ip5=ONOS5_ip,port5=ONOS5_port )
+ """
+ # REACTIVE FWD test
- main.step("Get list of hosts from Mininet")
+ main.step( "Get list of hosts from Mininet" )
host_list = main.Mininet1.get_hosts()
- main.log.info(host_list)
+ main.log.info( host_list )
- main.step("Get host list in ONOS format")
- host_onos_list = main.ONOS2.get_hosts_id(host_list)
- main.log.info(host_onos_list)
- #time.sleep(5)
-
- main.step("Pingall")
+ main.step( "Get host list in ONOS format" )
+ host_onos_list = main.ONOS2.get_hosts_id( host_list )
+ main.log.info( host_onos_list )
+ # time.sleep( 5 )
+
+ main.step( "Pingall" )
ping_result = main.FALSE
while ping_result == main.FALSE:
time1 = time.time()
ping_result = main.Mininet1.pingall()
time2 = time.time()
- print "Time for pingall: %2f seconds" % (time2 - time1)
-
- #Start onos cli again because u might have dropped out of onos prompt to the shell prompt
- #if there was no activity
- main.ONOS2.start_onos_cli(ONOS_ip=main.params['CTRL']['ip1'])
+ print "Time for pingall: %2f seconds" % ( time2 - time1 )
+
+ # Start onos cli again because u might have dropped out of onos prompt to the shell prompt
+ # if there was no activity
+ main.ONOS2.start_onos_cli( ONOS_ip=main.params[ 'CTRL' ][ 'ip1' ] )
case4_result = Switch_Mastership and ping_result
if ping_result == main.TRUE:
- main.log.report("Pingall Test in reactive mode to discover the hosts successful")
+ main.log.report(
+ "Pingall Test in reactive mode to discover the hosts successful" )
else:
- main.log.report("Pingall Test in reactive mode to discover the hosts failed")
+ main.log.report(
+ "Pingall Test in reactive mode to discover the hosts failed" )
- utilities.assert_equals(expect=main.TRUE, actual=case4_result,onpass="Controller assignment and Pingall Test successful",onfail="Controller assignment and Pingall Test NOT successful")
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case4_result,
+ onpass="Controller assignment and Pingall Test successful",
+ onfail="Controller assignment and Pingall Test NOT successful" )
- def CASE10(self):
- main.log.report("This testcase uninstalls the reactive forwarding app")
- main.log.report("__________________________________")
- main.case("Uninstalling reactive forwarding app")
- #Unistall onos-app-fwd app to disable reactive forwarding
- appUninstall_result = main.ONOS2.feature_uninstall("onos-app-fwd")
- main.log.info("onos-app-fwd uninstalled")
+ def CASE10( self ):
+ main.log.report(
+ "This testcase uninstalls the reactive forwarding app" )
+ main.log.report( "__________________________________" )
+ main.case( "Uninstalling reactive forwarding app" )
+ # Unistall onos-app-fwd app to disable reactive forwarding
+ appUninstall_result = main.ONOS2.feature_uninstall( "onos-app-fwd" )
+ main.log.info( "onos-app-fwd uninstalled" )
- #After reactive forwarding is disabled, the reactive flows on switches timeout in 10-15s
- #So sleep for 15s
- time.sleep(15)
+ # After reactive forwarding is disabled, the reactive flows on switches timeout in 10-15s
+ # So sleep for 15s
+ time.sleep( 15 )
flows = main.ONOS2.flows()
- main.log.info(flows)
+ main.log.info( flows )
case10_result = appUninstall_result
- utilities.assert_equals(expect=main.TRUE, actual=case10_result,onpass="Reactive forwarding app uninstallation successful",onfail="Reactive forwarding app uninstallation failed")
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case10_result,
+ onpass="Reactive forwarding app uninstallation successful",
+ onfail="Reactive forwarding app uninstallation failed" )
-
- def CASE6(self):
- main.log.report("This testcase is testing the addition of host intents and then does pingall")
- main.log.report("__________________________________")
- main.case("Obtaining host id's")
- main.step("Get hosts")
+ def CASE6( self ):
+ main.log.report(
+ "This testcase is testing the addition of host intents and then does pingall" )
+ main.log.report( "__________________________________" )
+ main.case( "Obtaining host id's" )
+ main.step( "Get hosts" )
hosts = main.ONOS2.hosts()
- #main.log.info(hosts)
+ # main.log.info( hosts )
- main.step("Get all devices id")
+ main.step( "Get all devices id" )
devices_id_list = main.ONOS2.get_all_devices_id()
- #main.log.info(devices_id_list)
-
- #ONOS displays the hosts in hex format unlike mininet which does in decimal format
- #So take care while adding intents
- '''
- main.step("Add host-to-host intents for mininet hosts h8 and h18 or ONOS hosts h8 and h12")
- hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1")
- hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1")
- hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0A/-1", "00:00:00:00:00:14/-1")
- hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0B/-1", "00:00:00:00:00:15/-1")
- hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0C/-1", "00:00:00:00:00:16/-1")
- hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0D/-1", "00:00:00:00:00:17/-1")
- hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0E/-1", "00:00:00:00:00:18/-1")
- hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1")
- hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1")
- hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1")
- print "_____________________________________________________________________________________"
- '''
-
- for i in range(8,18):
- main.log.info("Adding host intent between h"+str(i)+" and h"+str(i+10))
- host1 = "00:00:00:00:00:" + str(hex(i)[2:]).zfill(2).upper()
- host2 = "00:00:00:00:00:" + str(hex(i+10)[2:]).zfill(2).upper()
- #NOTE: get host can return None
- #TODO: handle this
- host1_id = main.ONOS2.get_host(host1)['id']
- host2_id = main.ONOS2.get_host(host2)['id']
- tmp_result = main.ONOS2.add_host_intent(host1_id, host2_id )
+ # main.log.info( devices_id_list )
- time.sleep(10)
- h_intents = main.ONOS2.intents(json_format = False)
- main.log.info("intents:" +h_intents)
+ # ONOS displays the hosts in hex format unlike mininet which does in decimal format
+ # So take care while adding intents
+ """
+ main.step( "Add host-to-host intents for mininet hosts h8 and h18 or ONOS hosts h8 and h12" )
+ hth_intent_result = main.ONOS2.add_host_intent( "00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1" )
+ hth_intent_result = main.ONOS2.add_host_intent( "00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1" )
+ hth_intent_result = main.ONOS2.add_host_intent( "00:00:00:00:00:0A/-1", "00:00:00:00:00:14/-1" )
+ hth_intent_result = main.ONOS2.add_host_intent( "00:00:00:00:00:0B/-1", "00:00:00:00:00:15/-1" )
+ hth_intent_result = main.ONOS2.add_host_intent( "00:00:00:00:00:0C/-1", "00:00:00:00:00:16/-1" )
+ hth_intent_result = main.ONOS2.add_host_intent( "00:00:00:00:00:0D/-1", "00:00:00:00:00:17/-1" )
+ hth_intent_result = main.ONOS2.add_host_intent( "00:00:00:00:00:0E/-1", "00:00:00:00:00:18/-1" )
+ hth_intent_result = main.ONOS2.add_host_intent( "00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1" )
+ hth_intent_result = main.ONOS2.add_host_intent( "00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1" )
+ hth_intent_result = main.ONOS2.add_host_intent( "00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1" )
+ print "_____________________________________________________________________________________"
+ """
+ for i in range( 8, 18 ):
+ main.log.info(
+ "Adding host intent between h" + str( i ) + " and h" + str( i + 10 ) )
+ host1 = "00:00:00:00:00:" + \
+ str( hex( i )[ 2: ] ).zfill( 2 ).upper()
+ host2 = "00:00:00:00:00:" + \
+ str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
+ # NOTE: get host can return None
+ # TODO: handle this
+ host1_id = main.ONOS2.get_host( host1 )[ 'id' ]
+ host2_id = main.ONOS2.get_host( host2 )[ 'id' ]
+ tmp_result = main.ONOS2.add_host_intent( host1_id, host2_id )
+
+ time.sleep( 10 )
+ h_intents = main.ONOS2.intents( json_format=False )
+ main.log.info( "intents:" + h_intents )
flowHandle = main.ONOS2.flows()
- #main.log.info("flow:" +flowHandle)
+ #main.log.info( "flow:" +flowHandle )
count = 1
i = 8
Ping_Result = main.TRUE
- #while i<10:
- while i <18 :
- main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10))
- ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
- if ping == main.FALSE and count <5:
- count+=1
+ # while i<10:
+ while i < 18:
+ main.log.info(
+ "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
+ ping = main.Mininet1.pingHost(
+ src="h" + str( i ), target="h" + str( i + 10 ) )
+ if ping == main.FALSE and count < 5:
+ count += 1
#i = 8
Ping_Result = main.FALSE
- main.log.report("Ping between h" + str(i) + " and h" + str(i+10) + " failed. Making attempt number "+str(count) + " in 2 seconds")
- time.sleep(2)
- elif ping==main.FALSE:
- main.log.report("All ping attempts between h" + str(i) + " and h" + str(i+10) +"have failed")
- i=19
+ main.log.report( "Ping between h" +
+ str( i ) +
+ " and h" +
+ str( i +
+ 10 ) +
+ " failed. Making attempt number " +
+ str( count ) +
+ " in 2 seconds" )
+ time.sleep( 2 )
+ elif ping == main.FALSE:
+ main.log.report( "All ping attempts between h" +
+ str( i ) +
+ " and h" +
+ str( i +
+ 10 ) +
+ "have failed" )
+ i = 19
Ping_Result = main.FALSE
- elif ping==main.TRUE:
- main.log.info("Ping test between h" + str(i) + " and h" + str(i+10) + "passed!")
- i+=1
+ elif ping == main.TRUE:
+ main.log.info( "Ping test between h" +
+ str( i ) +
+ " and h" +
+ str( i +
+ 10 ) +
+ "passed!" )
+ i += 1
Ping_Result = main.TRUE
else:
- main.log.info("Unknown error")
+ main.log.info( "Unknown error" )
Ping_Result = main.ERROR
- if Ping_Result==main.FALSE:
- main.log.report("Ping all test after Host intent addition failed. Cleaning up")
- #main.cleanup()
- #main.exit()
- if Ping_Result==main.TRUE:
- main.log.report("Ping all test after Host intent addition successful")
-
+ if Ping_Result == main.FALSE:
+ main.log.report(
+ "Ping all test after Host intent addition failed. Cleaning up" )
+ # main.cleanup()
+ # main.exit()
+ if Ping_Result == main.TRUE:
+ main.log.report(
+ "Ping all test after Host intent addition successful" )
+
case6_result = Ping_Result
- utilities.assert_equals(expect=main.TRUE, actual=case6_result,
- onpass="Pingall Test after Host intents addition successful",
- onfail="Pingall Test after Host intents addition failed")
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case6_result,
+ onpass="Pingall Test after Host intents addition successful",
+ onfail="Pingall Test after Host intents addition failed" )
-
- def CASE5(self,main) :
+ def CASE5( self, main ):
import json
from subprocess import Popen, PIPE
- from sts.topology.teston_topology import TestONTopology # assumes that sts is already in you PYTHONPATH
- #main.ONOS2.start_onos_cli(ONOS_ip=main.params['CTRL']['ip1'])
+ # assumes that sts is already in you PYTHONPATH
+ from sts.topology.teston_topology import TestONTopology
+ # main.ONOS2.start_onos_cli( ONOS_ip=main.params[ 'CTRL' ][ 'ip1' ] )
deviceResult = main.ONOS2.devices()
linksResult = main.ONOS2.links()
#portsResult = main.ONOS2.ports()
print "**************"
- main.log.report("This testcase is testing if all ONOS nodes are in topology sync with mininet")
- main.log.report("__________________________________")
- main.case("Comparing Mininet topology with the topology of ONOS")
- main.step("Start continuous pings")
- main.Mininet2.pingLong(src=main.params['PING']['source1'],
- target=main.params['PING']['target1'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source2'],
- target=main.params['PING']['target2'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source3'],
- target=main.params['PING']['target3'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source4'],
- target=main.params['PING']['target4'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source5'],
- target=main.params['PING']['target5'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source6'],
- target=main.params['PING']['target6'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source7'],
- target=main.params['PING']['target7'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source8'],
- target=main.params['PING']['target8'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source9'],
- target=main.params['PING']['target9'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source10'],
- target=main.params['PING']['target10'],pingTime=500)
+ main.log.report(
+ "This testcase is testing if all ONOS nodes are in topology sync with mininet" )
+ main.log.report( "__________________________________" )
+ main.case( "Comparing Mininet topology with the topology of ONOS" )
+ main.step( "Start continuous pings" )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source1' ],
+ target=main.params[ 'PING' ][ 'target1' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source2' ],
+ target=main.params[ 'PING' ][ 'target2' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source3' ],
+ target=main.params[ 'PING' ][ 'target3' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source4' ],
+ target=main.params[ 'PING' ][ 'target4' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source5' ],
+ target=main.params[ 'PING' ][ 'target5' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source6' ],
+ target=main.params[ 'PING' ][ 'target6' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source7' ],
+ target=main.params[ 'PING' ][ 'target7' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source8' ],
+ target=main.params[ 'PING' ][ 'target8' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source9' ],
+ target=main.params[ 'PING' ][ 'target9' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source10' ],
+ target=main.params[ 'PING' ][ 'target10' ],
+ pingTime=500 )
- main.step("Create TestONTopology object")
+ main.step( "Create TestONTopology object" )
global ctrls
ctrls = []
count = 1
while True:
temp = ()
- if ('ip' + str(count)) in main.params['CTRL']:
- temp = temp + (getattr(main,('ONOS' + str(count))),)
- temp = temp + ("ONOS"+str(count),)
- temp = temp + (main.params['CTRL']['ip'+str(count)],)
- temp = temp + (eval(main.params['CTRL']['port'+str(count)]),)
- ctrls.append(temp)
+ if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]:
+ temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), )
+ temp = temp + ( "ONOS" + str( count ), )
+ temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], )
+ temp = temp + \
+ ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), )
+ ctrls.append( temp )
count = count + 1
else:
break
global MNTopo
- Topo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations
+ Topo = TestONTopology(
+ main.Mininet1,
+ ctrls ) # can also add Intent API info for intent operations
MNTopo = Topo
Topology_Check = main.TRUE
- main.step("Compare ONOS Topology to MN Topology")
+ main.step( "Compare ONOS Topology to MN Topology" )
devices_json = main.ONOS2.devices()
links_json = main.ONOS2.links()
#ports_json = main.ONOS2.ports()
print "devices_json= ", devices_json
-
- result1 = main.Mininet1.compare_switches(MNTopo, json.loads(devices_json))
- result2 = main.Mininet1.compare_links(MNTopo, json.loads(links_json))
- #result3 = main.Mininet1.compare_ports(MNTopo, json.loads(ports_json))
-
+
+ result1 = main.Mininet1.compare_switches(
+ MNTopo,
+ json.loads( devices_json ) )
+ result2 = main.Mininet1.compare_links(
+ MNTopo,
+ json.loads( links_json ) )
+ #result3 = main.Mininet1.compare_ports( MNTopo, json.loads( ports_json ) )
+
#result = result1 and result2 and result3
result = result1 and result2
-
+
print "***********************"
if result == main.TRUE:
- main.log.report("ONOS"+ " Topology matches MN Topology")
+ main.log.report( "ONOS" + " Topology matches MN Topology" )
else:
- main.log.report("ONOS"+ " Topology does not match MN Topology")
+ main.log.report( "ONOS" + " Topology does not match MN Topology" )
- utilities.assert_equals(expect=main.TRUE,actual=result,
- onpass="ONOS" + " Topology matches MN Topology",
- onfail="ONOS" + " Topology does not match MN Topology")
-
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=result,
+ onpass="ONOS" +
+ " Topology matches MN Topology",
+ onfail="ONOS" +
+ " Topology does not match MN Topology" )
+
Topology_Check = Topology_Check and result
- utilities.assert_equals(expect=main.TRUE,actual=Topology_Check,
- onpass="Topology checks passed", onfail="Topology checks failed")
-
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=Topology_Check,
+ onpass="Topology checks passed",
+ onfail="Topology checks failed" )
- def CASE7 (self,main):
-
- ONOS1_ip = main.params['CTRL']['ip1']
+ def CASE7( self, main ):
- link_sleep = int(main.params['timers']['LinkDiscovery'])
+ ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
- main.log.report("This testscase is killing a link to ensure that link discovery is consistent")
- main.log.report("__________________________________")
- main.log.report("Killing a link to ensure that link discovery is consistent")
- main.case("Killing a link to Ensure that Link Discovery is Working Properly")
- '''
- main.step("Start continuous pings")
-
- main.Mininet2.pingLong(src=main.params['PING']['source1'],
- target=main.params['PING']['target1'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source2'],
- target=main.params['PING']['target2'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source3'],
- target=main.params['PING']['target3'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source4'],
- target=main.params['PING']['target4'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source5'],
- target=main.params['PING']['target5'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source6'],
- target=main.params['PING']['target6'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source7'],
- target=main.params['PING']['target7'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source8'],
- target=main.params['PING']['target8'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source9'],
- target=main.params['PING']['target9'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source10'],
- target=main.params['PING']['target10'],pingTime=500)
- '''
+ link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
- main.step("Determine the current number of switches and links")
+ main.log.report(
+ "This testscase is killing a link to ensure that link discovery is consistent" )
+ main.log.report( "__________________________________" )
+ main.log.report(
+ "Killing a link to ensure that link discovery is consistent" )
+ main.case(
+ "Killing a link to Ensure that Link Discovery is Working Properly" )
+ """
+ main.step( "Start continuous pings" )
+
+ main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source1' ],
+ target=main.params[ 'PING' ][ 'target1' ],pingTime=500 )
+ main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source2' ],
+ target=main.params[ 'PING' ][ 'target2' ],pingTime=500 )
+ main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source3' ],
+ target=main.params[ 'PING' ][ 'target3' ],pingTime=500 )
+ main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source4' ],
+ target=main.params[ 'PING' ][ 'target4' ],pingTime=500 )
+ main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source5' ],
+ target=main.params[ 'PING' ][ 'target5' ],pingTime=500 )
+ main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source6' ],
+ target=main.params[ 'PING' ][ 'target6' ],pingTime=500 )
+ main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source7' ],
+ target=main.params[ 'PING' ][ 'target7' ],pingTime=500 )
+ main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source8' ],
+ target=main.params[ 'PING' ][ 'target8' ],pingTime=500 )
+ main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source9' ],
+ target=main.params[ 'PING' ][ 'target9' ],pingTime=500 )
+ main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source10' ],
+ target=main.params[ 'PING' ][ 'target10' ],pingTime=500 )
+ """
+ main.step( "Determine the current number of switches and links" )
topology_output = main.ONOS2.topology()
- topology_result = main.ONOS1.get_topology(topology_output)
- activeSwitches = topology_result['devices']
- links = topology_result['links']
- print "activeSwitches = ", type(activeSwitches)
- print "links = ", type(links)
- main.log.info("Currently there are %s switches and %s links" %(str(activeSwitches), str(links)))
+ topology_result = main.ONOS1.get_topology( topology_output )
+ activeSwitches = topology_result[ 'devices' ]
+ links = topology_result[ 'links' ]
+ print "activeSwitches = ", type( activeSwitches )
+ print "links = ", type( links )
+ main.log.info(
+ "Currently there are %s switches and %s links" %
+ ( str( activeSwitches ), str( links ) ) )
- main.step("Kill Link between s3 and s28")
- main.Mininet1.link(END1="s3",END2="s28",OPTION="down")
- time.sleep(link_sleep)
+ main.step( "Kill Link between s3 and s28" )
+ main.Mininet1.link( END1="s3", END2="s28", OPTION="down" )
+ time.sleep( link_sleep )
topology_output = main.ONOS2.topology()
- Link_Down = main.ONOS1.check_status(topology_output,activeSwitches,str(int(links)-2))
+ Link_Down = main.ONOS1.check_status(
+ topology_output, activeSwitches, str(
+ int( links ) - 2 ) )
if Link_Down == main.TRUE:
- main.log.report("Link Down discovered properly")
- utilities.assert_equals(expect=main.TRUE,actual=Link_Down,
- onpass="Link Down discovered properly",
- onfail="Link down was not discovered in "+ str(link_sleep) + " seconds")
-
- #Check ping result here..add code for it
-
- main.step("Bring link between s3 and s28 back up")
- Link_Up = main.Mininet1.link(END1="s3",END2="s28",OPTION="up")
- time.sleep(link_sleep)
+ main.log.report( "Link Down discovered properly" )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=Link_Down,
+ onpass="Link Down discovered properly",
+ onfail="Link down was not discovered in " +
+ str( link_sleep ) +
+ " seconds" )
+
+ # Check ping result here..add code for it
+
+ main.step( "Bring link between s3 and s28 back up" )
+ Link_Up = main.Mininet1.link( END1="s3", END2="s28", OPTION="up" )
+ time.sleep( link_sleep )
topology_output = main.ONOS2.topology()
- Link_Up = main.ONOS1.check_status(topology_output,activeSwitches,str(links))
+ Link_Up = main.ONOS1.check_status(
+ topology_output,
+ activeSwitches,
+ str( links ) )
if Link_Up == main.TRUE:
- main.log.report("Link up discovered properly")
- utilities.assert_equals(expect=main.TRUE,actual=Link_Up,
- onpass="Link up discovered properly",
- onfail="Link up was not discovered in "+ str(link_sleep) + " seconds")
-
- #NOTE Check ping result here..add code for it
-
-
- main.step("Compare ONOS Topology to MN Topology")
- Topo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations
+ main.log.report( "Link up discovered properly" )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=Link_Up,
+ onpass="Link up discovered properly",
+ onfail="Link up was not discovered in " +
+ str( link_sleep ) +
+ " seconds" )
+
+ # NOTE Check ping result here..add code for it
+
+ main.step( "Compare ONOS Topology to MN Topology" )
+ Topo = TestONTopology(
+ main.Mininet1,
+ ctrls ) # can also add Intent API info for intent operations
MNTopo = Topo
Topology_Check = main.TRUE
-
+
devices_json = main.ONOS2.devices()
links_json = main.ONOS2.links()
ports_json = main.ONOS2.ports()
print "devices_json= ", devices_json
-
- result1 = main.Mininet1.compare_switches(MNTopo, json.loads(devices_json))
- result2 = main.Mininet1.compare_links(MNTopo, json.loads(links_json))
- #result3 = main.Mininet1.compare_ports(MNTopo, json.loads(ports_json))
-
+
+ result1 = main.Mininet1.compare_switches(
+ MNTopo,
+ json.loads( devices_json ) )
+ result2 = main.Mininet1.compare_links(
+ MNTopo,
+ json.loads( links_json ) )
+ #result3 = main.Mininet1.compare_ports( MNTopo, json.loads( ports_json ) )
+
#result = result1 and result2 and result3
result = result1 and result2
print "***********************"
-
+
if result == main.TRUE:
- main.log.report("ONOS"+ " Topology matches MN Topology")
- utilities.assert_equals(expect=main.TRUE,actual=result,
- onpass="ONOS" + " Topology matches MN Topology",
- onfail="ONOS" + " Topology does not match MN Topology")
-
+ main.log.report( "ONOS" + " Topology matches MN Topology" )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=result,
+ onpass="ONOS" +
+ " Topology matches MN Topology",
+ onfail="ONOS" +
+ " Topology does not match MN Topology" )
+
Topology_Check = Topology_Check and result
- utilities.assert_equals(expect=main.TRUE,actual=Topology_Check,
- onpass="Topology checks passed", onfail="Topology checks failed")
-
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=Topology_Check,
+ onpass="Topology checks passed",
+ onfail="Topology checks failed" )
+
result = Link_Down and Link_Up and Topology_Check
- utilities.assert_equals(expect=main.TRUE,actual=result,
- onpass="Link failure is discovered correctly",
- onfail="Link Discovery failed")
+ utilities.assert_equals( expect=main.TRUE, actual=result,
+ onpass="Link failure is discovered correctly",
+ onfail="Link Discovery failed" )
-
- def CASE8(self):
- '''
+ def CASE8( self ):
+ """
Host intents removal
- '''
- main.log.report("This testcase removes any previously added intents before adding the same intents or point intents")
- main.log.report("__________________________________")
- main.log.info("Host intents removal")
- main.case("Removing host intents")
- main.step("Obtain the intent id's")
- intent_result = main.ONOS2.intents(json_format = False)
- main.log.info("intent_result = " +intent_result)
-
- intent_linewise = intent_result.split("\n")
+ """
+ main.log.report(
+ "This testcase removes any previously added intents before adding the same intents or point intents" )
+ main.log.report( "__________________________________" )
+ main.log.info( "Host intents removal" )
+ main.case( "Removing host intents" )
+ main.step( "Obtain the intent id's" )
+ intent_result = main.ONOS2.intents( json_format=False )
+ main.log.info( "intent_result = " + intent_result )
+
+ intent_linewise = intent_result.split( "\n" )
intentList = []
for line in intent_linewise:
- if line.startswith("id="):
- intentList.append(line)
-
+ if line.startswith( "id=" ):
+ intentList.append( line )
+
intentids = []
for line in intentList:
- intentids.append(line.split(",")[0].split("=")[1])
+ intentids.append( line.split( "," )[ 0 ].split( "=" )[ 1 ] )
for id in intentids:
print "id = ", id
-
- main.step("Iterate through the intentids list and remove each intent")
+
+ main.step(
+ "Iterate through the intentids list and remove each intent" )
for id in intentids:
- main.ONOS2.remove_intent(intent_id = id)
-
- intent_result = main.ONOS2.intents(json_format = False)
- main.log.info("intent_result = " +intent_result)
+ main.ONOS2.remove_intent( intent_id=id )
+
+ intent_result = main.ONOS2.intents( json_format=False )
+ main.log.info( "intent_result = " + intent_result )
case8_result = main.TRUE
if case8_result == main.TRUE:
- main.log.report("Intent removal successful")
+ main.log.report( "Intent removal successful" )
else:
- main.log.report("Intent removal failed")
-
+ main.log.report( "Intent removal failed" )
+
Ping_Result = main.TRUE
if case8_result == main.TRUE:
i = 8
- while i <18 :
- main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10))
- ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
- if ping==main.TRUE:
+ while i < 18:
+ main.log.info(
+ "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
+ ping = main.Mininet1.pingHost(
+ src="h" + str( i ), target="h" + str( i + 10 ) )
+ if ping == main.TRUE:
i = 19
Ping_Result = Ping_Result and main.TRUE
- elif ping==main.FALSE:
- i+=1
+ elif ping == main.FALSE:
+ i += 1
Ping_Result = Ping_Result and main.FALSE
else:
- main.log.info("Unknown error")
+ main.log.info( "Unknown error" )
Ping_Result = main.ERROR
- #Note: If the ping result failed, that means the intents have been withdrawn correctly.
- if Ping_Result==main.TRUE:
- main.log.report("Host intents have not been withdrawn correctly")
- #main.cleanup()
- #main.exit()
- if Ping_Result==main.FALSE:
- main.log.report("Host intents have been withdrawn correctly")
+ # Note: If the ping result failed, that means the intents have been
+ # withdrawn correctly.
+ if Ping_Result == main.TRUE:
+ main.log.report( "Host intents have not been withdrawn correctly" )
+ # main.cleanup()
+ # main.exit()
+ if Ping_Result == main.FALSE:
+ main.log.report( "Host intents have been withdrawn correctly" )
case8_result = case8_result and Ping_Result
if case8_result == main.FALSE:
- main.log.report("Intent removal successful")
+ main.log.report( "Intent removal successful" )
else:
- main.log.report("Intent removal failed")
+ main.log.report( "Intent removal failed" )
- utilities.assert_equals(expect=main.FALSE, actual=case8_result,
- onpass="Intent removal test failed",
- onfail="Intent removal test passed")
+ utilities.assert_equals( expect=main.FALSE, actual=case8_result,
+ onpass="Intent removal test failed",
+ onfail="Intent removal test passed" )
+ def CASE9( self ):
+ main.log.report(
+ "This testcase adds point intents and then does pingall" )
+ main.log.report( "__________________________________" )
+ main.log.info( "Adding point intents" )
+ main.case(
+ "Adding bidirectional point for mn hosts(h8-h18,h9-h19,h10-h20,h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)" )
+ main.step(
+ "Add point-to-point intents for mininet hosts h8 and h18 or ONOS hosts h8 and h12" )
+ ptp_intent_result = main.ONOS2.add_point_intent(
+ "of:0000000000003008/1",
+ "of:0000000000006018/1" )
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
- def CASE9(self):
- main.log.report("This testcase adds point intents and then does pingall")
- main.log.report("__________________________________")
- main.log.info("Adding point intents")
- main.case("Adding bidirectional point for mn hosts(h8-h18,h9-h19,h10-h20,h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)")
- main.step("Add point-to-point intents for mininet hosts h8 and h18 or ONOS hosts h8 and h12")
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003008/1", "of:0000000000006018/1")
+ ptp_intent_result = main.ONOS2.add_point_intent(
+ "of:0000000000006018/1",
+ "of:0000000000003008/1" )
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOS2.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006018/1", "of:0000000000003008/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- main.step("Add point-to-point intents for mininet hosts h9 and h19 or ONOS hosts h9 and h13")
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003009/1", "of:0000000000006019/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006019/1", "of:0000000000003009/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- main.step("Add point-to-point intents for mininet hosts h10 and h20 or ONOS hosts hA and h14")
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003010/1", "of:0000000000006020/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006020/1", "of:0000000000003010/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
- main.step("Add point-to-point intents for mininet hosts h11 and h21 or ONOS hosts hB and h15")
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003011/1", "of:0000000000006021/1")
+ main.step(
+ "Add point-to-point intents for mininet hosts h9 and h19 or ONOS hosts h9 and h13" )
+ ptp_intent_result = main.ONOS2.add_point_intent(
+ "of:0000000000003009/1",
+ "of:0000000000006019/1" )
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOS2.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006021/1", "of:0000000000003011/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- main.step("Add point-to-point intents for mininet hosts h12 and h22 or ONOS hosts hC and h16")
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003012/1", "of:0000000000006022/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006022/1", "of:0000000000003012/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- main.step("Add point-to-point intents for mininet hosts h13 and h23 or ONOS hosts hD and h17")
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003013/1", "of:0000000000006023/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006023/1", "of:0000000000003013/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
- main.step("Add point-to-point intents for mininet hosts h14 and h24 or ONOS hosts hE and h18")
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003014/1", "of:0000000000006024/1")
+ ptp_intent_result = main.ONOS2.add_point_intent(
+ "of:0000000000006019/1",
+ "of:0000000000003009/1" )
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOS2.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006024/1", "of:0000000000003014/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- main.step("Add point-to-point intents for mininet hosts h15 and h25 or ONOS hosts hF and h19")
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003015/1", "of:0000000000006025/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006025/1", "of:0000000000003015/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- main.step("Add point-to-point intents for mininet hosts h16 and h26 or ONOS hosts h10 and h1A")
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003016/1", "of:0000000000006026/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006026/1", "of:0000000000003016/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
-
- main.step("Add point-to-point intents for mininet hosts h17 and h27 or ONOS hosts h11 and h1B")
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003017/1", "of:0000000000006027/1")
+ main.step(
+ "Add point-to-point intents for mininet hosts h10 and h20 or ONOS hosts hA and h14" )
+ ptp_intent_result = main.ONOS2.add_point_intent(
+ "of:0000000000003010/1",
+ "of:0000000000006020/1" )
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOS2.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006027/1", "of:0000000000003017/1")
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ ptp_intent_result = main.ONOS2.add_point_intent(
+ "of:0000000000006020/1",
+ "of:0000000000003010/1" )
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOS2.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
- print("_______________________________________________________________________________________")
+ main.step(
+ "Add point-to-point intents for mininet hosts h11 and h21 or ONOS hosts hB and h15" )
+ ptp_intent_result = main.ONOS2.add_point_intent(
+ "of:0000000000003011/1",
+ "of:0000000000006021/1" )
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ ptp_intent_result = main.ONOS2.add_point_intent(
+ "of:0000000000006021/1",
+ "of:0000000000003011/1" )
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ main.step(
+ "Add point-to-point intents for mininet hosts h12 and h22 or ONOS hosts hC and h16" )
+ ptp_intent_result = main.ONOS2.add_point_intent(
+ "of:0000000000003012/1",
+ "of:0000000000006022/1" )
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ ptp_intent_result = main.ONOS2.add_point_intent(
+ "of:0000000000006022/1",
+ "of:0000000000003012/1" )
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ main.step(
+ "Add point-to-point intents for mininet hosts h13 and h23 or ONOS hosts hD and h17" )
+ ptp_intent_result = main.ONOS2.add_point_intent(
+ "of:0000000000003013/1",
+ "of:0000000000006023/1" )
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ ptp_intent_result = main.ONOS2.add_point_intent(
+ "of:0000000000006023/1",
+ "of:0000000000003013/1" )
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ main.step(
+ "Add point-to-point intents for mininet hosts h14 and h24 or ONOS hosts hE and h18" )
+ ptp_intent_result = main.ONOS2.add_point_intent(
+ "of:0000000000003014/1",
+ "of:0000000000006024/1" )
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ ptp_intent_result = main.ONOS2.add_point_intent(
+ "of:0000000000006024/1",
+ "of:0000000000003014/1" )
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ main.step(
+ "Add point-to-point intents for mininet hosts h15 and h25 or ONOS hosts hF and h19" )
+ ptp_intent_result = main.ONOS2.add_point_intent(
+ "of:0000000000003015/1",
+ "of:0000000000006025/1" )
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ ptp_intent_result = main.ONOS2.add_point_intent(
+ "of:0000000000006025/1",
+ "of:0000000000003015/1" )
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ main.step(
+ "Add point-to-point intents for mininet hosts h16 and h26 or ONOS hosts h10 and h1A" )
+ ptp_intent_result = main.ONOS2.add_point_intent(
+ "of:0000000000003016/1",
+ "of:0000000000006026/1" )
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ ptp_intent_result = main.ONOS2.add_point_intent(
+ "of:0000000000006026/1",
+ "of:0000000000003016/1" )
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ main.step(
+ "Add point-to-point intents for mininet hosts h17 and h27 or ONOS hosts h11 and h1B" )
+ ptp_intent_result = main.ONOS2.add_point_intent(
+ "of:0000000000003017/1",
+ "of:0000000000006027/1" )
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ ptp_intent_result = main.ONOS2.add_point_intent(
+ "of:0000000000006027/1",
+ "of:0000000000003017/1" )
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( get_intent_result )
+
+ print(
+ "_______________________________________________________________________________________" )
flowHandle = main.ONOS2.flows()
- #print "flowHandle = ", flowHandle
- main.log.info("flows :" + flowHandle)
+ # print "flowHandle = ", flowHandle
+ main.log.info( "flows :" + flowHandle )
count = 1
i = 8
Ping_Result = main.TRUE
- while i <18 :
- main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10))
- ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
- if ping == main.FALSE and count <5:
- count+=1
+ while i < 18:
+ main.log.info(
+ "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
+ ping = main.Mininet1.pingHost(
+ src="h" + str( i ), target="h" + str( i + 10 ) )
+ if ping == main.FALSE and count < 5:
+ count += 1
#i = 8
Ping_Result = main.FALSE
- main.log.report("Ping between h" + str(i) + " and h" + str(i+10) + " failed. Making attempt number "+str(count) + " in 2 seconds")
- time.sleep(2)
- elif ping==main.FALSE:
- main.log.report("All ping attempts between h" + str(i) + " and h" + str(i+10) +"have failed")
- i=19
+ main.log.report( "Ping between h" +
+ str( i ) +
+ " and h" +
+ str( i +
+ 10 ) +
+ " failed. Making attempt number " +
+ str( count ) +
+ " in 2 seconds" )
+ time.sleep( 2 )
+ elif ping == main.FALSE:
+ main.log.report( "All ping attempts between h" +
+ str( i ) +
+ " and h" +
+ str( i +
+ 10 ) +
+ "have failed" )
+ i = 19
Ping_Result = main.FALSE
- elif ping==main.TRUE:
- main.log.info("Ping test between h" + str(i) + " and h" + str(i+10) + "passed!")
- i+=1
+ elif ping == main.TRUE:
+ main.log.info( "Ping test between h" +
+ str( i ) +
+ " and h" +
+ str( i +
+ 10 ) +
+ "passed!" )
+ i += 1
Ping_Result = main.TRUE
else:
- main.log.info("Unknown error")
+ main.log.info( "Unknown error" )
Ping_Result = main.ERROR
- if Ping_Result==main.FALSE:
- main.log.report("Point intents have not ben installed correctly. Cleaning up")
- #main.cleanup()
- #main.exit()
- if Ping_Result==main.TRUE:
- main.log.report("Point Intents have been installed correctly")
+ if Ping_Result == main.FALSE:
+ main.log.report(
+ "Point intents have not ben installed correctly. Cleaning up" )
+ # main.cleanup()
+ # main.exit()
+ if Ping_Result == main.TRUE:
+ main.log.report( "Point Intents have been installed correctly" )
case9_result = Ping_Result
- utilities.assert_equals(expect=main.TRUE, actual=case9_result,
- onpass="Point intents addition and Pingall Test successful",
- onfail="Point intents addition and Pingall Test NOT successful")
-
-
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case9_result,
+ onpass="Point intents addition and Pingall Test successful",
+ onfail="Point intents addition and Pingall Test NOT successful" )
diff --git a/TestON/tests/SdnIpTest/SdnIpTest.py b/TestON/tests/SdnIpTest/SdnIpTest.py
old mode 100755
new mode 100644
index 4f55c02..081b1ca
--- a/TestON/tests/SdnIpTest/SdnIpTest.py
+++ b/TestON/tests/SdnIpTest/SdnIpTest.py
@@ -2,13 +2,14 @@
# Testing the basic functionality of SDN-IP
+
class SdnIpTest:
- def __init__(self):
+
+ def __init__( self ):
self.default = ''
- def CASE1(self, main):
-
- '''
+ def CASE1( self, main ):
+ """
Test the SDN-IP functionality
allRoutes_expected: all expected routes for all BGP peers
routeIntents_expected: all expected MultiPointToSinglePointIntent intents
@@ -16,230 +17,272 @@
allRoutes_actual: all routes from ONOS LCI
routeIntents_actual: actual MultiPointToSinglePointIntent intents from ONOS CLI
bgpIntents_actual: actual PointToPointIntent intents from ONOS CLI
- '''
+ """
import time
import json
from operator import eq
# from datetime import datetime
from time import localtime, strftime
- main.case("The test case is to help to setup the TestON environment and test new drivers")
+ main.case(
+ "The test case is to help to setup the TestON environment and test new drivers" )
SDNIP_JSON_FILE_PATH = "../tests/SdnIpTest/sdnip.json"
# all expected routes for all BGP peers
allRoutes_expected = []
- main.step("Start to generate routes for all BGP peers")
+ main.step( "Start to generate routes for all BGP peers" )
# bgpPeerHosts = []
- # for i in range(3, 5):
- # bgpPeerHosts.append("host" + str(i))
- # main.log.info("BGP Peer Hosts are:" + bgpPeerHosts)
+ # for i in range( 3, 5 ):
+ # bgpPeerHosts.append( "host" + str( i ) )
+ # main.log.info( "BGP Peer Hosts are:" + bgpPeerHosts )
- # for i in range(3, 5):
- # QuaggaCliHost = "QuaggaCliHost" + str(i)
- # prefixes = main.QuaggaCliHost.generate_prefixes(3, 10)
+ # for i in range( 3, 5 ):
+ # QuaggaCliHost = "QuaggaCliHost" + str( i )
+ # prefixes = main.QuaggaCliHost.generate_prefixes( 3, 10 )
- # main.log.info(prefixes)
- # allRoutes_expected.append(prefixes)
- main.log.info("Generate prefixes for host3")
- prefixes_host3 = main.QuaggaCliHost3.generate_prefixes(3, 10)
- main.log.info(prefixes_host3)
+ # main.log.info( prefixes )
+ # allRoutes_expected.append( prefixes )
+ main.log.info( "Generate prefixes for host3" )
+ prefixes_host3 = main.QuaggaCliHost3.generate_prefixes( 3, 10 )
+ main.log.info( prefixes_host3 )
# generate route with next hop
for prefix in prefixes_host3:
- allRoutes_expected.append(prefix + "/" + "192.168.20.1")
- routeIntents_expected_host3 = main.QuaggaCliHost3.generate_expected_onePeerRouteIntents(prefixes_host3, "192.168.20.1", "00:00:00:00:02:02", SDNIP_JSON_FILE_PATH)
+ allRoutes_expected.append( prefix + "/" + "192.168.20.1" )
+ routeIntents_expected_host3 = main.QuaggaCliHost3.generate_expected_onePeerRouteIntents(
+ prefixes_host3,
+ "192.168.20.1",
+ "00:00:00:00:02:02",
+ SDNIP_JSON_FILE_PATH )
- main.log.info("Generate prefixes for host4")
- prefixes_host4 = main.QuaggaCliHost4.generate_prefixes(4, 10)
- main.log.info(prefixes_host4)
+ main.log.info( "Generate prefixes for host4" )
+ prefixes_host4 = main.QuaggaCliHost4.generate_prefixes( 4, 10 )
+ main.log.info( prefixes_host4 )
# generate route with next hop
for prefix in prefixes_host4:
- allRoutes_expected.append(prefix + "/" + "192.168.30.1")
- routeIntents_expected_host4 = main.QuaggaCliHost4.generate_expected_onePeerRouteIntents(prefixes_host4, "192.168.30.1", "00:00:00:00:03:01", SDNIP_JSON_FILE_PATH)
+ allRoutes_expected.append( prefix + "/" + "192.168.30.1" )
+ routeIntents_expected_host4 = main.QuaggaCliHost4.generate_expected_onePeerRouteIntents(
+ prefixes_host4,
+ "192.168.30.1",
+ "00:00:00:00:03:01",
+ SDNIP_JSON_FILE_PATH )
- routeIntents_expected = routeIntents_expected_host3 + routeIntents_expected_host4
+ routeIntents_expected = routeIntents_expected_host3 + \
+ routeIntents_expected_host4
-
- cell_name = main.params['ENV']['cellName']
- ONOS1_ip = main.params['CTRL']['ip1']
- main.step("Set cell for ONOS-cli environment")
- main.ONOScli.set_cell(cell_name)
+ cell_name = main.params[ 'ENV' ][ 'cellName' ]
+ ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+ main.step( "Set cell for ONOS-cli environment" )
+ main.ONOScli.set_cell( cell_name )
verify_result = main.ONOSbench.verify_cell()
- main.log.report("Removing raft logs")
+ main.log.report( "Removing raft logs" )
main.ONOSbench.onos_remove_raft_logs()
- main.log.report("Uninstalling ONOS")
- main.ONOSbench.onos_uninstall(ONOS1_ip)
- main.step("Creating ONOS package")
+ main.log.report( "Uninstalling ONOS" )
+ main.ONOSbench.onos_uninstall( ONOS1_ip )
+ main.step( "Creating ONOS package" )
package_result = main.ONOSbench.onos_package()
- main.step("Starting ONOS service")
+ main.step( "Starting ONOS service" )
# TODO: start ONOS from Mininet Script
- # start_result = main.ONOSbench.onos_start("127.0.0.1")
- main.step("Installing ONOS package")
- onos1_install_result = main.ONOSbench.onos_install(options="-f", node=ONOS1_ip)
+ # start_result = main.ONOSbench.onos_start( "127.0.0.1" )
+ main.step( "Installing ONOS package" )
+ onos1_install_result = main.ONOSbench.onos_install(
+ options="-f",
+ node=ONOS1_ip )
- main.step("Checking if ONOS is up yet")
- time.sleep(60)
- onos1_isup = main.ONOSbench.isup(ONOS1_ip)
+ main.step( "Checking if ONOS is up yet" )
+ time.sleep( 60 )
+ onos1_isup = main.ONOSbench.isup( ONOS1_ip )
if not onos1_isup:
- main.log.report("ONOS1 didn't start!")
+ main.log.report( "ONOS1 didn't start!" )
- main.step("Start ONOS-cli")
+ main.step( "Start ONOS-cli" )
# TODO: change the hardcode in start_onos_cli method in ONOS CLI driver
- main.ONOScli.start_onos_cli(ONOS1_ip)
+ main.ONOScli.start_onos_cli( ONOS1_ip )
- main.step("Get devices in the network")
- list_result = main.ONOScli.devices(json_format=False)
- main.log.info(list_result)
- time.sleep(10)
- main.log.info("Installing sdn-ip feature")
- main.ONOScli.feature_install("onos-app-sdnip")
- time.sleep(10)
- main.step("Login all BGP peers and add routes into peers")
- main.log.info("Login Quagga CLI on host3")
- main.QuaggaCliHost3.loginQuagga("1.168.30.2")
- main.log.info("Enter configuration model of Quagga CLI on host3")
- main.QuaggaCliHost3.enter_config(64514)
- main.log.info("Add routes to Quagga on host3")
- main.QuaggaCliHost3.add_routes(prefixes_host3, 1)
+ main.step( "Get devices in the network" )
+ list_result = main.ONOScli.devices( json_format=False )
+ main.log.info( list_result )
+ time.sleep( 10 )
+ main.log.info( "Installing sdn-ip feature" )
+ main.ONOScli.feature_install( "onos-app-sdnip" )
+ time.sleep( 10 )
+ main.step( "Login all BGP peers and add routes into peers" )
+ main.log.info( "Login Quagga CLI on host3" )
+ main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
+ main.log.info( "Enter configuration model of Quagga CLI on host3" )
+ main.QuaggaCliHost3.enter_config( 64514 )
+ main.log.info( "Add routes to Quagga on host3" )
+ main.QuaggaCliHost3.add_routes( prefixes_host3, 1 )
- main.log.info("Login Quagga CLI on host4")
- main.QuaggaCliHost4.loginQuagga("1.168.30.3")
- main.log.info("Enter configuration model of Quagga CLI on host4")
- main.QuaggaCliHost4.enter_config(64516)
- main.log.info("Add routes to Quagga on host4")
- main.QuaggaCliHost4.add_routes(prefixes_host4, 1)
- time.sleep(60)
+ main.log.info( "Login Quagga CLI on host4" )
+ main.QuaggaCliHost4.loginQuagga( "1.168.30.3" )
+ main.log.info( "Enter configuration model of Quagga CLI on host4" )
+ main.QuaggaCliHost4.enter_config( 64516 )
+ main.log.info( "Add routes to Quagga on host4" )
+ main.QuaggaCliHost4.add_routes( prefixes_host4, 1 )
+ time.sleep( 60 )
# get all routes inside SDN-IP
- get_routes_result = main.ONOScli.routes(json_format=True)
+ get_routes_result = main.ONOScli.routes( json_format=True )
# parse routes from ONOS CLI
- allRoutes_actual = main.QuaggaCliHost3.extract_actual_routes(get_routes_result)
+ allRoutes_actual = main.QuaggaCliHost3.extract_actual_routes(
+ get_routes_result )
- allRoutes_str_expected = str(sorted(allRoutes_expected))
- allRoutes_str_actual = str(allRoutes_actual).replace('u', "")
- main.step("Check routes installed")
- main.log.info("Routes expected:")
- main.log.info(allRoutes_str_expected)
- main.log.info("Routes get from ONOS CLI:")
- main.log.info(allRoutes_str_actual)
- utilities.assert_equals(expect=allRoutes_str_expected, actual=allRoutes_str_actual,
- onpass="***Routes in SDN-IP are correct!***",
- onfail="***Routes in SDN-IP are wrong!***")
- if(eq(allRoutes_str_expected, allRoutes_str_actual)):
- main.log.report("***Routes in SDN-IP after adding routes are correct!***")
+ allRoutes_str_expected = str( sorted( allRoutes_expected ) )
+ allRoutes_str_actual = str( allRoutes_actual ).replace( 'u', "" )
+ main.step( "Check routes installed" )
+ main.log.info( "Routes expected:" )
+ main.log.info( allRoutes_str_expected )
+ main.log.info( "Routes get from ONOS CLI:" )
+ main.log.info( allRoutes_str_actual )
+ utilities.assert_equals(
+ expect=allRoutes_str_expected,
+ actual=allRoutes_str_actual,
+ onpass="***Routes in SDN-IP are correct!***",
+ onfail="***Routes in SDN-IP are wrong!***" )
+ if( eq( allRoutes_str_expected, allRoutes_str_actual ) ):
+ main.log.report(
+ "***Routes in SDN-IP after adding routes are correct!***" )
else:
- main.log.report("***Routes in SDN-IP after adding routes are wrong!***")
+ main.log.report(
+ "***Routes in SDN-IP after adding routes are wrong!***" )
- time.sleep(20)
- get_intents_result = main.ONOScli.intents(json_format=True)
+ time.sleep( 20 )
+ get_intents_result = main.ONOScli.intents( json_format=True )
-
- main.step("Check MultiPointToSinglePointIntent intents installed")
+ main.step( "Check MultiPointToSinglePointIntent intents installed" )
# route_intents_expected are generated when generating routes
# get rpoute intents from ONOS CLI
- routeIntents_actual = main.QuaggaCliHost3.extract_actual_routeIntents(get_intents_result)
- routeIntents_str_expected = str(sorted(routeIntents_expected))
- routeIntents_str_actual = str(routeIntents_actual).replace('u', "")
- main.log.info("MultiPointToSinglePoint intents expected:")
- main.log.info(routeIntents_str_expected)
- main.log.info("MultiPointToSinglePoint intents get from ONOS CLI:")
- main.log.info(routeIntents_str_actual)
- utilities.assert_equals(expect=True, actual=eq(routeIntents_str_expected, routeIntents_str_actual),
- onpass="***MultiPointToSinglePoint Intents in SDN-IP are correct!***",
- onfail="***MultiPointToSinglePoint Intents in SDN-IP are wrong!***")
+ routeIntents_actual = main.QuaggaCliHost3.extract_actual_routeIntents(
+ get_intents_result )
+ routeIntents_str_expected = str( sorted( routeIntents_expected ) )
+ routeIntents_str_actual = str( routeIntents_actual ).replace( 'u', "" )
+ main.log.info( "MultiPointToSinglePoint intents expected:" )
+ main.log.info( routeIntents_str_expected )
+ main.log.info( "MultiPointToSinglePoint intents get from ONOS CLI:" )
+ main.log.info( routeIntents_str_actual )
+ utilities.assert_equals(
+ expect=True,
+ actual=eq(
+ routeIntents_str_expected,
+ routeIntents_str_actual ),
+ onpass="***MultiPointToSinglePoint Intents in SDN-IP are correct!***",
+ onfail="***MultiPointToSinglePoint Intents in SDN-IP are wrong!***" )
- if(eq(routeIntents_str_expected, routeIntents_str_actual)):
- main.log.report("***MultiPointToSinglePoint Intents before deleting routes correct!***")
+ if( eq( routeIntents_str_expected, routeIntents_str_actual ) ):
+ main.log.report(
+ "***MultiPointToSinglePoint Intents before deleting routes correct!***" )
else:
- main.log.report("***MultiPointToSinglePoint Intents before deleting routes wrong!***")
+ main.log.report(
+ "***MultiPointToSinglePoint Intents before deleting routes wrong!***" )
- main.step("Check BGP PointToPointIntent intents installed")
+ main.step( "Check BGP PointToPointIntent intents installed" )
# bgp intents expected
- bgpIntents_expected = main.QuaggaCliHost3.generate_expected_bgpIntents(SDNIP_JSON_FILE_PATH)
+ bgpIntents_expected = main.QuaggaCliHost3.generate_expected_bgpIntents(
+ SDNIP_JSON_FILE_PATH )
# get BGP intents from ONOS CLI
- bgpIntents_actual = main.QuaggaCliHost3.extract_actual_bgpIntents(get_intents_result)
+ bgpIntents_actual = main.QuaggaCliHost3.extract_actual_bgpIntents(
+ get_intents_result )
- bgpIntents_str_expected = str(bgpIntents_expected).replace('u', "")
- bgpIntents_str_actual = str(bgpIntents_actual)
- main.log.info("PointToPointIntent intents expected:")
- main.log.info(bgpIntents_str_expected)
- main.log.info("PointToPointIntent intents get from ONOS CLI:")
- main.log.info(bgpIntents_str_actual)
+ bgpIntents_str_expected = str( bgpIntents_expected ).replace( 'u', "" )
+ bgpIntents_str_actual = str( bgpIntents_actual )
+ main.log.info( "PointToPointIntent intents expected:" )
+ main.log.info( bgpIntents_str_expected )
+ main.log.info( "PointToPointIntent intents get from ONOS CLI:" )
+ main.log.info( bgpIntents_str_actual )
- utilities.assert_equals(expect=True, actual=eq(bgpIntents_str_expected, bgpIntents_str_actual),
- onpass="***PointToPointIntent Intents in SDN-IP are correct!***",
- onfail="***PointToPointIntent Intents in SDN-IP are wrong!***")
+ utilities.assert_equals(
+ expect=True,
+ actual=eq(
+ bgpIntents_str_expected,
+ bgpIntents_str_actual ),
+ onpass="***PointToPointIntent Intents in SDN-IP are correct!***",
+ onfail="***PointToPointIntent Intents in SDN-IP are wrong!***" )
-
- if (eq(bgpIntents_str_expected, bgpIntents_str_actual)):
- main.log.report("***PointToPointIntent Intents in SDN-IP are correct!***")
+ if ( eq( bgpIntents_str_expected, bgpIntents_str_actual ) ):
+ main.log.report(
+ "***PointToPointIntent Intents in SDN-IP are correct!***" )
else:
- main.log.report("***PointToPointIntent Intents in SDN-IP are wrong!***")
-
-
+ main.log.report(
+ "***PointToPointIntent Intents in SDN-IP are wrong!***" )
#============================= Ping Test ========================
# wait until all MultiPointToSinglePoint
- time.sleep(20)
+ time.sleep( 20 )
ping_test_script = "~/SDNIP/SdnIpIntentDemo/CASE1-ping-as2host.sh"
- ping_test_results_file = "~/SDNIP/SdnIpIntentDemo/log/CASE1-ping-results-before-delete-routes-" + strftime("%Y-%m-%d_%H:%M:%S", localtime()) + ".txt"
- ping_test_results = main.QuaggaCliHost.ping_test("1.168.30.100", ping_test_script, ping_test_results_file)
- main.log.info(ping_test_results)
+ ping_test_results_file = "~/SDNIP/SdnIpIntentDemo/log/CASE1-ping-results-before-delete-routes-" + \
+ strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
+ ping_test_results = main.QuaggaCliHost.ping_test(
+ "1.168.30.100",
+ ping_test_script,
+ ping_test_results_file )
+ main.log.info( ping_test_results )
# ping test
#============================= Deleting Routes ==================
- main.step("Check deleting routes installed")
- main.QuaggaCliHost3.delete_routes(prefixes_host3, 1)
- main.QuaggaCliHost4.delete_routes(prefixes_host4, 1)
+ main.step( "Check deleting routes installed" )
+ main.QuaggaCliHost3.delete_routes( prefixes_host3, 1 )
+ main.QuaggaCliHost4.delete_routes( prefixes_host4, 1 )
- # main.log.info("main.ONOScli.get_routes_num() = " )
- # main.log.info(main.ONOScli.get_routes_num())
- # utilities.assert_equals(expect = "Total SDN-IP routes = 1", actual= main.ONOScli.get_routes_num(),
- get_routes_result = main.ONOScli.routes(json_format=True)
- allRoutes_actual = main.QuaggaCliHost3.extract_actual_routes(get_routes_result)
- main.log.info("allRoutes_actual = ")
- main.log.info(allRoutes_actual)
+ # main.log.info( "main.ONOScli.get_routes_num() = " )
+ # main.log.info( main.ONOScli.get_routes_num() )
+ # utilities.assert_equals( expect="Total SDN-IP routes = 1", actual=
+ # main.ONOScli.get_routes_num(),
+ get_routes_result = main.ONOScli.routes( json_format=True )
+ allRoutes_actual = main.QuaggaCliHost3.extract_actual_routes(
+ get_routes_result )
+ main.log.info( "allRoutes_actual = " )
+ main.log.info( allRoutes_actual )
- utilities.assert_equals(expect="[]", actual=str(allRoutes_actual),
- onpass="***Route number in SDN-IP is 0, correct!***",
- onfail="***Routes number in SDN-IP is not 0, wrong!***")
+ utilities.assert_equals(
+ expect="[]",
+ actual=str( allRoutes_actual ),
+ onpass="***Route number in SDN-IP is 0, correct!***",
+ onfail="***Routes number in SDN-IP is not 0, wrong!***" )
- if(eq(allRoutes_str_expected, allRoutes_str_actual)):
- main.log.report("***Routes in SDN-IP after deleting correct!***")
+ if( eq( allRoutes_str_expected, allRoutes_str_actual ) ):
+ main.log.report( "***Routes in SDN-IP after deleting correct!***" )
else:
- main.log.report("***Routes in SDN-IP after deleting wrong!***")
+ main.log.report( "***Routes in SDN-IP after deleting wrong!***" )
- main.step("Check intents after deleting routes")
- get_intents_result = main.ONOScli.intents(json_format=True)
- routeIntents_actual = main.QuaggaCliHost3.extract_actual_routeIntents(get_intents_result)
- main.log.info("main.ONOScli.intents()= ")
- main.log.info(routeIntents_actual)
- utilities.assert_equals(expect="[]", actual=str(routeIntents_actual),
- onpass="***MultiPointToSinglePoint Intents number in SDN-IP is 0, correct!***",
- onfail="***MultiPointToSinglePoint Intents number in SDN-IP is 0, wrong!***")
+ main.step( "Check intents after deleting routes" )
+ get_intents_result = main.ONOScli.intents( json_format=True )
+ routeIntents_actual = main.QuaggaCliHost3.extract_actual_routeIntents(
+ get_intents_result )
+ main.log.info( "main.ONOScli.intents()= " )
+ main.log.info( routeIntents_actual )
+ utilities.assert_equals(
+ expect="[]",
+ actual=str( routeIntents_actual ),
+ onpass="***MultiPointToSinglePoint Intents number in SDN-IP is 0, correct!***",
+ onfail="***MultiPointToSinglePoint Intents number in SDN-IP is 0, wrong!***" )
- if(eq(routeIntents_str_expected, routeIntents_str_actual)):
- main.log.report("***MultiPointToSinglePoint Intents after deleting routes correct!***")
+ if( eq( routeIntents_str_expected, routeIntents_str_actual ) ):
+ main.log.report(
+ "***MultiPointToSinglePoint Intents after deleting routes correct!***" )
else:
- main.log.report("***MultiPointToSinglePoint Intents after deleting routes wrong!***")
+ main.log.report(
+ "***MultiPointToSinglePoint Intents after deleting routes wrong!***" )
- time.sleep(20)
+ time.sleep( 20 )
ping_test_script = "~/SDNIP/SdnIpIntentDemo/CASE1-ping-as2host.sh"
- ping_test_results_file = "~/SDNIP/SdnIpIntentDemo/log/CASE1-ping-results-after-delete-routes-" + strftime("%Y-%m-%d_%H:%M:%S", localtime()) + ".txt"
- ping_test_results = main.QuaggaCliHost.ping_test("1.168.30.100", ping_test_script, ping_test_results_file)
- main.log.info(ping_test_results)
- time.sleep(30)
+ ping_test_results_file = "~/SDNIP/SdnIpIntentDemo/log/CASE1-ping-results-after-delete-routes-" + \
+ strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
+ ping_test_results = main.QuaggaCliHost.ping_test(
+ "1.168.30.100",
+ ping_test_script,
+ ping_test_results_file )
+ main.log.info( ping_test_results )
+ time.sleep( 30 )
- # main.step("Test whether Mininet is started")
- # main.Mininet2.handle.sendline("xterm host1")
- # main.Mininet2.handle.expect("mininet>")
+ # main.step( "Test whether Mininet is started" )
+ # main.Mininet2.handle.sendline( "xterm host1" )
+ # main.Mininet2.handle.expect( "mininet>" )
-
- def CASE2(self, main):
-
- '''
+ def CASE2( self, main ):
+ """
Test the SDN-IP functionality
allRoutes_expected: all expected routes for all BGP peers
routeIntents_expected: all expected MultiPointToSinglePointIntent intents
@@ -247,217 +290,266 @@
allRoutes_actual: all routes from ONOS LCI
routeIntents_actual: actual MultiPointToSinglePointIntent intents from ONOS CLI
bgpIntents_actual: actual PointToPointIntent intents from ONOS CLI
- '''
+ """
import time
import json
from operator import eq
from time import localtime, strftime
- main.case("The test case is to help to setup the TestON environment and test new drivers")
+ main.case(
+ "The test case is to help to setup the TestON environment and test new drivers" )
SDNIP_JSON_FILE_PATH = "../tests/SdnIpTest/sdnip.json"
# all expected routes for all BGP peers
allRoutes_expected = []
- main.step("Start to generate routes for all BGP peers")
+ main.step( "Start to generate routes for all BGP peers" )
- main.log.info("Generate prefixes for host3")
- prefixes_host3 = main.QuaggaCliHost3.generate_prefixes(3, 10)
- main.log.info(prefixes_host3)
+ main.log.info( "Generate prefixes for host3" )
+ prefixes_host3 = main.QuaggaCliHost3.generate_prefixes( 3, 10 )
+ main.log.info( prefixes_host3 )
# generate route with next hop
for prefix in prefixes_host3:
- allRoutes_expected.append(prefix + "/" + "192.168.20.1")
- routeIntents_expected_host3 = main.QuaggaCliHost3.generate_expected_onePeerRouteIntents(prefixes_host3, "192.168.20.1", "00:00:00:00:02:02", SDNIP_JSON_FILE_PATH)
+ allRoutes_expected.append( prefix + "/" + "192.168.20.1" )
+ routeIntents_expected_host3 = main.QuaggaCliHost3.generate_expected_onePeerRouteIntents(
+ prefixes_host3,
+ "192.168.20.1",
+ "00:00:00:00:02:02",
+ SDNIP_JSON_FILE_PATH )
- main.log.info("Generate prefixes for host4")
- prefixes_host4 = main.QuaggaCliHost4.generate_prefixes(4, 10)
- main.log.info(prefixes_host4)
+ main.log.info( "Generate prefixes for host4" )
+ prefixes_host4 = main.QuaggaCliHost4.generate_prefixes( 4, 10 )
+ main.log.info( prefixes_host4 )
# generate route with next hop
for prefix in prefixes_host4:
- allRoutes_expected.append(prefix + "/" + "192.168.30.1")
- routeIntents_expected_host4 = main.QuaggaCliHost4.generate_expected_onePeerRouteIntents(prefixes_host4, "192.168.30.1", "00:00:00:00:03:01", SDNIP_JSON_FILE_PATH)
+ allRoutes_expected.append( prefix + "/" + "192.168.30.1" )
+ routeIntents_expected_host4 = main.QuaggaCliHost4.generate_expected_onePeerRouteIntents(
+ prefixes_host4,
+ "192.168.30.1",
+ "00:00:00:00:03:01",
+ SDNIP_JSON_FILE_PATH )
- routeIntents_expected = routeIntents_expected_host3 + routeIntents_expected_host4
+ routeIntents_expected = routeIntents_expected_host3 + \
+ routeIntents_expected_host4
- main.log.report("Removing raft logs")
+ main.log.report( "Removing raft logs" )
main.ONOSbench.onos_remove_raft_logs()
- main.log.report("Uninstalling ONOS")
- main.ONOSbench.onos_uninstall(ONOS1_ip)
+ main.log.report( "Uninstalling ONOS" )
+ main.ONOSbench.onos_uninstall( ONOS1_ip )
- cell_name = main.params['ENV']['cellName']
- ONOS1_ip = main.params['CTRL']['ip1']
- main.step("Set cell for ONOS-cli environment")
- main.ONOScli.set_cell(cell_name)
+ cell_name = main.params[ 'ENV' ][ 'cellName' ]
+ ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+ main.step( "Set cell for ONOS-cli environment" )
+ main.ONOScli.set_cell( cell_name )
verify_result = main.ONOSbench.verify_cell()
- #main.log.report("Removing raft logs")
- #main.ONOSbench.onos_remove_raft_logs()
- #main.log.report("Uninstalling ONOS")
- #main.ONOSbench.onos_uninstall(ONOS1_ip)
- main.step("Creating ONOS package")
+ #main.log.report( "Removing raft logs" )
+ # main.ONOSbench.onos_remove_raft_logs()
+ #main.log.report( "Uninstalling ONOS" )
+ # main.ONOSbench.onos_uninstall( ONOS1_ip )
+ main.step( "Creating ONOS package" )
package_result = main.ONOSbench.onos_package()
- main.step("Installing ONOS package")
- onos1_install_result = main.ONOSbench.onos_install(options="-f", node=ONOS1_ip)
+ main.step( "Installing ONOS package" )
+ onos1_install_result = main.ONOSbench.onos_install(
+ options="-f",
+ node=ONOS1_ip )
- main.step("Checking if ONOS is up yet")
- time.sleep(60)
- onos1_isup = main.ONOSbench.isup(ONOS1_ip)
+ main.step( "Checking if ONOS is up yet" )
+ time.sleep( 60 )
+ onos1_isup = main.ONOSbench.isup( ONOS1_ip )
if not onos1_isup:
- main.log.report("ONOS1 didn't start!")
+ main.log.report( "ONOS1 didn't start!" )
- main.step("Start ONOS-cli")
- main.ONOScli.start_onos_cli(ONOS1_ip)
+ main.step( "Start ONOS-cli" )
+ main.ONOScli.start_onos_cli( ONOS1_ip )
- main.step("Get devices in the network")
- list_result = main.ONOScli.devices(json_format=False)
- main.log.info(list_result)
- time.sleep(10)
- main.log.info("Installing sdn-ip feature")
- main.ONOScli.feature_install("onos-app-sdnip")
- time.sleep(10)
+ main.step( "Get devices in the network" )
+ list_result = main.ONOScli.devices( json_format=False )
+ main.log.info( list_result )
+ time.sleep( 10 )
+ main.log.info( "Installing sdn-ip feature" )
+ main.ONOScli.feature_install( "onos-app-sdnip" )
+ time.sleep( 10 )
-
- main.step("Check BGP PointToPointIntent intents installed")
+ main.step( "Check BGP PointToPointIntent intents installed" )
# bgp intents expected
- bgpIntents_expected = main.QuaggaCliHost3.generate_expected_bgpIntents(SDNIP_JSON_FILE_PATH)
+ bgpIntents_expected = main.QuaggaCliHost3.generate_expected_bgpIntents(
+ SDNIP_JSON_FILE_PATH )
# get BGP intents from ONOS CLI
- get_intents_result = main.ONOScli.intents(json_format=True)
- bgpIntents_actual = main.QuaggaCliHost3.extract_actual_bgpIntents(get_intents_result)
+ get_intents_result = main.ONOScli.intents( json_format=True )
+ bgpIntents_actual = main.QuaggaCliHost3.extract_actual_bgpIntents(
+ get_intents_result )
- bgpIntents_str_expected = str(bgpIntents_expected).replace('u', "")
- bgpIntents_str_actual = str(bgpIntents_actual)
- main.log.info("PointToPointIntent intents expected:")
- main.log.info(bgpIntents_str_expected)
- main.log.info("PointToPointIntent intents get from ONOS CLI:")
- main.log.info(bgpIntents_str_actual)
+ bgpIntents_str_expected = str( bgpIntents_expected ).replace( 'u', "" )
+ bgpIntents_str_actual = str( bgpIntents_actual )
+ main.log.info( "PointToPointIntent intents expected:" )
+ main.log.info( bgpIntents_str_expected )
+ main.log.info( "PointToPointIntent intents get from ONOS CLI:" )
+ main.log.info( bgpIntents_str_actual )
- utilities.assert_equals(expect=True, actual=eq(bgpIntents_str_expected, bgpIntents_str_actual),
- onpass="***PointToPointIntent Intents in SDN-IP are correct!***",
- onfail="***PointToPointIntent Intents in SDN-IP are wrong!***")
+ utilities.assert_equals(
+ expect=True,
+ actual=eq(
+ bgpIntents_str_expected,
+ bgpIntents_str_actual ),
+ onpass="***PointToPointIntent Intents in SDN-IP are correct!***",
+ onfail="***PointToPointIntent Intents in SDN-IP are wrong!***" )
- if (eq(bgpIntents_str_expected, bgpIntents_str_actual)):
- main.log.report("***PointToPointIntent Intents in SDN-IP are correct!***")
+ if ( eq( bgpIntents_str_expected, bgpIntents_str_actual ) ):
+ main.log.report(
+ "***PointToPointIntent Intents in SDN-IP are correct!***" )
else:
- main.log.report("***PointToPointIntent Intents in SDN-IP are wrong!***")
+ main.log.report(
+ "***PointToPointIntent Intents in SDN-IP are wrong!***" )
-
- allRoutes_str_expected = str(sorted(allRoutes_expected))
- routeIntents_str_expected = str(sorted(routeIntents_expected))
+ allRoutes_str_expected = str( sorted( allRoutes_expected ) )
+ routeIntents_str_expected = str( sorted( routeIntents_expected ) )
ping_test_script = "~/SDNIP/SdnIpIntentDemo/CASE1-ping-as2host.sh"
# round_num = 0;
- # while(True):
- for round_num in range(1, 6):
+ # while( True ):
+ for round_num in range( 1, 6 ):
# round = round + 1;
- main.log.report("The Round " + str(round_num) + " test starts........................................")
+ main.log.report(
+ "The Round " +
+ str( round_num ) +
+ " test starts........................................" )
- main.step("Login all BGP peers and add routes into peers")
- main.log.info("Login Quagga CLI on host3")
- main.QuaggaCliHost3.loginQuagga("1.168.30.2")
- main.log.info("Enter configuration model of Quagga CLI on host3")
- main.QuaggaCliHost3.enter_config(64514)
- main.log.info("Add routes to Quagga on host3")
- main.QuaggaCliHost3.add_routes(prefixes_host3, 1)
+ main.step( "Login all BGP peers and add routes into peers" )
+ main.log.info( "Login Quagga CLI on host3" )
+ main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
+ main.log.info( "Enter configuration model of Quagga CLI on host3" )
+ main.QuaggaCliHost3.enter_config( 64514 )
+ main.log.info( "Add routes to Quagga on host3" )
+ main.QuaggaCliHost3.add_routes( prefixes_host3, 1 )
- main.log.info("Login Quagga CLI on host4")
- main.QuaggaCliHost4.loginQuagga("1.168.30.3")
- main.log.info("Enter configuration model of Quagga CLI on host4")
- main.QuaggaCliHost4.enter_config(64516)
- main.log.info("Add routes to Quagga on host4")
- main.QuaggaCliHost4.add_routes(prefixes_host4, 1)
- time.sleep(60)
+ main.log.info( "Login Quagga CLI on host4" )
+ main.QuaggaCliHost4.loginQuagga( "1.168.30.3" )
+ main.log.info( "Enter configuration model of Quagga CLI on host4" )
+ main.QuaggaCliHost4.enter_config( 64516 )
+ main.log.info( "Add routes to Quagga on host4" )
+ main.QuaggaCliHost4.add_routes( prefixes_host4, 1 )
+ time.sleep( 60 )
# get all routes inside SDN-IP
- get_routes_result = main.ONOScli.routes(json_format=True)
+ get_routes_result = main.ONOScli.routes( json_format=True )
# parse routes from ONOS CLI
- allRoutes_actual = main.QuaggaCliHost3.extract_actual_routes(get_routes_result)
+ allRoutes_actual = main.QuaggaCliHost3.extract_actual_routes(
+ get_routes_result )
- # allRoutes_str_expected = str(sorted(allRoutes_expected))
- allRoutes_str_actual = str(allRoutes_actual).replace('u', "")
- main.step("Check routes installed")
- main.log.info("Routes expected:")
- main.log.info(allRoutes_str_expected)
- main.log.info("Routes get from ONOS CLI:")
- main.log.info(allRoutes_str_actual)
- utilities.assert_equals(expect=allRoutes_str_expected, actual=allRoutes_str_actual,
- onpass="***Routes in SDN-IP are correct!***",
- onfail="***Routes in SDN-IP are wrong!***")
- if(eq(allRoutes_str_expected, allRoutes_str_actual)):
- main.log.report("***Routes in SDN-IP after adding correct!***")
+ # allRoutes_str_expected = str( sorted( allRoutes_expected ) )
+ allRoutes_str_actual = str( allRoutes_actual ).replace( 'u', "" )
+ main.step( "Check routes installed" )
+ main.log.info( "Routes expected:" )
+ main.log.info( allRoutes_str_expected )
+ main.log.info( "Routes get from ONOS CLI:" )
+ main.log.info( allRoutes_str_actual )
+ utilities.assert_equals(
+ expect=allRoutes_str_expected,
+ actual=allRoutes_str_actual,
+ onpass="***Routes in SDN-IP are correct!***",
+ onfail="***Routes in SDN-IP are wrong!***" )
+ if( eq( allRoutes_str_expected, allRoutes_str_actual ) ):
+ main.log.report(
+ "***Routes in SDN-IP after adding correct!***" )
else:
- main.log.report("***Routes in SDN-IP after adding wrong!***")
+ main.log.report( "***Routes in SDN-IP after adding wrong!***" )
- time.sleep(20)
- get_intents_result = main.ONOScli.intents(json_format=True)
+ time.sleep( 20 )
+ get_intents_result = main.ONOScli.intents( json_format=True )
-
- main.step("Check MultiPointToSinglePointIntent intents installed")
+ main.step(
+ "Check MultiPointToSinglePointIntent intents installed" )
# route_intents_expected are generated when generating routes
# get route intents from ONOS CLI
- routeIntents_actual = main.QuaggaCliHost3.extract_actual_routeIntents(get_intents_result)
- # routeIntents_str_expected = str(sorted(routeIntents_expected))
- routeIntents_str_actual = str(routeIntents_actual).replace('u', "")
- main.log.info("MultiPointToSinglePoint intents expected:")
- main.log.info(routeIntents_str_expected)
- main.log.info("MultiPointToSinglePoint intents get from ONOS CLI:")
- main.log.info(routeIntents_str_actual)
- utilities.assert_equals(expect=True, actual=eq(routeIntents_str_expected, routeIntents_str_actual),
- onpass="***MultiPointToSinglePoint Intents in SDN-IP are correct!***",
- onfail="***MultiPointToSinglePoint Intents in SDN-IP are wrong!***")
+ routeIntents_actual = main.QuaggaCliHost3.extract_actual_routeIntents(
+ get_intents_result )
+ # routeIntents_str_expected = str( sorted( routeIntents_expected ) )
+ routeIntents_str_actual = str(
+ routeIntents_actual ).replace( 'u', "" )
+ main.log.info( "MultiPointToSinglePoint intents expected:" )
+ main.log.info( routeIntents_str_expected )
+ main.log.info(
+ "MultiPointToSinglePoint intents get from ONOS CLI:" )
+ main.log.info( routeIntents_str_actual )
+ utilities.assert_equals(
+ expect=True,
+ actual=eq(
+ routeIntents_str_expected,
+ routeIntents_str_actual ),
+ onpass="***MultiPointToSinglePoint Intents in SDN-IP are correct!***",
+ onfail="***MultiPointToSinglePoint Intents in SDN-IP are wrong!***" )
- if(eq(routeIntents_str_expected, routeIntents_str_actual)):
- main.log.report("***MultiPointToSinglePoint Intents after adding routes correct!***")
+ if( eq( routeIntents_str_expected, routeIntents_str_actual ) ):
+ main.log.report(
+ "***MultiPointToSinglePoint Intents after adding routes correct!***" )
else:
- main.log.report("***MultiPointToSinglePoint Intents after adding routes wrong!***")
+ main.log.report(
+ "***MultiPointToSinglePoint Intents after adding routes wrong!***" )
#============================= Ping Test ========================
# wait until all MultiPointToSinglePoint
- time.sleep(20)
+ time.sleep( 20 )
# ping_test_script = "~/SDNIP/SdnIpIntentDemo/CASE1-ping-as2host.sh"
- ping_test_results_file = "~/SDNIP/SdnIpIntentDemo/log/CASE2-Round" + str(round_num) + "-ping-results-before-delete-routes-" + strftime("%Y-%m-%d_%H:%M:%S", localtime()) + ".txt"
- ping_test_results = main.QuaggaCliHost.ping_test("1.168.30.100", ping_test_script, ping_test_results_file)
- main.log.info(ping_test_results)
+ ping_test_results_file = "~/SDNIP/SdnIpIntentDemo/log/CASE2-Round" + \
+ str( round_num ) + "-ping-results-before-delete-routes-" + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
+ ping_test_results = main.QuaggaCliHost.ping_test(
+ "1.168.30.100",
+ ping_test_script,
+ ping_test_results_file )
+ main.log.info( ping_test_results )
# ping test
#============================= Deleting Routes ==================
- main.step("Check deleting routes installed")
- main.log.info("Delete routes to Quagga on host3")
- main.QuaggaCliHost3.delete_routes(prefixes_host3, 1)
- main.log.info("Delete routes to Quagga on host4")
- main.QuaggaCliHost4.delete_routes(prefixes_host4, 1)
+ main.step( "Check deleting routes installed" )
+ main.log.info( "Delete routes to Quagga on host3" )
+ main.QuaggaCliHost3.delete_routes( prefixes_host3, 1 )
+ main.log.info( "Delete routes to Quagga on host4" )
+ main.QuaggaCliHost4.delete_routes( prefixes_host4, 1 )
- get_routes_result = main.ONOScli.routes(json_format=True)
- allRoutes_actual = main.QuaggaCliHost3.extract_actual_routes(get_routes_result)
- main.log.info("allRoutes_actual = ")
- main.log.info(allRoutes_actual)
+ get_routes_result = main.ONOScli.routes( json_format=True )
+ allRoutes_actual = main.QuaggaCliHost3.extract_actual_routes(
+ get_routes_result )
+ main.log.info( "allRoutes_actual = " )
+ main.log.info( allRoutes_actual )
- utilities.assert_equals(expect="[]", actual=str(allRoutes_actual),
- onpass="***Route number in SDN-IP is 0, correct!***",
- onfail="***Routes number in SDN-IP is not 0, wrong!***")
+ utilities.assert_equals(
+ expect="[]",
+ actual=str( allRoutes_actual ),
+ onpass="***Route number in SDN-IP is 0, correct!***",
+ onfail="***Routes number in SDN-IP is not 0, wrong!***" )
- if(eq(allRoutes_str_expected, allRoutes_str_actual)):
- main.log.report("***Routes in SDN-IP after deleting correct!***")
+ if( eq( allRoutes_str_expected, allRoutes_str_actual ) ):
+ main.log.report(
+ "***Routes in SDN-IP after deleting correct!***" )
else:
- main.log.report("***Routes in SDN-IP after deleting wrong!***")
+ main.log.report(
+ "***Routes in SDN-IP after deleting wrong!***" )
- main.step("Check intents after deleting routes")
- get_intents_result = main.ONOScli.intents(json_format=True)
- routeIntents_actual = main.QuaggaCliHost3.extract_actual_routeIntents(get_intents_result)
- main.log.info("main.ONOScli.intents()= ")
- main.log.info(routeIntents_actual)
- utilities.assert_equals(expect="[]", actual=str(routeIntents_actual),
- onpass="***MultiPointToSinglePoint Intents number in SDN-IP is 0, correct!***",
- onfail="***MultiPointToSinglePoint Intents number in SDN-IP is 0, wrong!***")
+ main.step( "Check intents after deleting routes" )
+ get_intents_result = main.ONOScli.intents( json_format=True )
+ routeIntents_actual = main.QuaggaCliHost3.extract_actual_routeIntents(
+ get_intents_result )
+ main.log.info( "main.ONOScli.intents()= " )
+ main.log.info( routeIntents_actual )
+ utilities.assert_equals(
+ expect="[]",
+ actual=str( routeIntents_actual ),
+ onpass="***MultiPointToSinglePoint Intents number in SDN-IP is 0, correct!***",
+ onfail="***MultiPointToSinglePoint Intents number in SDN-IP is 0, wrong!***" )
- if(eq(routeIntents_str_expected, routeIntents_str_actual)):
- main.log.report("***MultiPointToSinglePoint Intents after deleting routes correct!***")
+ if( eq( routeIntents_str_expected, routeIntents_str_actual ) ):
+ main.log.report(
+ "***MultiPointToSinglePoint Intents after deleting routes correct!***" )
else:
- main.log.report("***MultiPointToSinglePoint Intents after deleting routes wrong!***")
+ main.log.report(
+ "***MultiPointToSinglePoint Intents after deleting routes wrong!***" )
- time.sleep(20)
+ time.sleep( 20 )
# ping_test_script = "~/SDNIP/SdnIpIntentDemo/CASE1-ping-as2host.sh"
- ping_test_results_file = "~/SDNIP/SdnIpIntentDemo/log/CASE2-Round" + str(round_num) + "-ping-results-after-delete-routes-" + strftime("%Y-%m-%d_%H:%M:%S", localtime()) + ".txt"
- ping_test_results = main.QuaggaCliHost.ping_test("1.168.30.100", ping_test_script, ping_test_results_file)
- main.log.info(ping_test_results)
- time.sleep(30)
-
-
-
+ ping_test_results_file = "~/SDNIP/SdnIpIntentDemo/log/CASE2-Round" + \
+ str( round_num ) + "-ping-results-after-delete-routes-" + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
+ ping_test_results = main.QuaggaCliHost.ping_test(
+ "1.168.30.100",
+ ping_test_script,
+ ping_test_results_file )
+ main.log.info( ping_test_results )
+ time.sleep( 30 )
diff --git a/TestON/tests/TopoConvNext/TopoConvNext.py b/TestON/tests/TopoConvNext/TopoConvNext.py
index 68d7b5d..c114e48 100644
--- a/TestON/tests/TopoConvNext/TopoConvNext.py
+++ b/TestON/tests/TopoConvNext/TopoConvNext.py
@@ -1,153 +1,155 @@
-#TopoPerfNext
+# TopoPerfNext
#
-#Topology Convergence scale-out test for ONOS-next
-#NOTE: This test supports up to 7 nodes scale-out scenario
+# Topology Convergence scale-out test for ONOS-next
+# NOTE: This test supports up to 7 nodes scale-out scenario
#
-#NOTE: Ensure that you have 'tablet.json' file
+# NOTE: Ensure that you have 'tablet.json' file
# in the onos/tools/package/config directory
-#NOTE: You must start this test initially with 3 nodes
+# NOTE: You must start this test initially with 3 nodes
#
-#andrew@onlab.us
+# andrew@onlab.us
import time
import sys
import os
import re
+
class TopoConvNext:
- def __init__(self):
+
+ def __init__( self ):
self.default = ''
- def CASE1(self, main):
- '''
+ def CASE1( self, main ):
+ """
ONOS startup sequence
- '''
+ """
import time
#******
- #Global cluster count for scale-out purposes
- global cluster_count
+ # Global cluster count for scale-out purposes
+ global cluster_count
global topo_iteration
topo_iteration = 1
- cluster_count = 1
+ cluster_count = 1
#******
- cell_name = main.params['ENV']['cellName']
+ cell_name = main.params[ 'ENV' ][ 'cellName' ]
- git_pull = main.params['GIT']['autoPull']
- checkout_branch = main.params['GIT']['checkout']
+ git_pull = main.params[ 'GIT' ][ 'autoPull' ]
+ checkout_branch = main.params[ 'GIT' ][ 'checkout' ]
- ONOS1_ip = main.params['CTRL']['ip1']
- ONOS2_ip = main.params['CTRL']['ip2']
- ONOS3_ip = main.params['CTRL']['ip3']
- ONOS4_ip = main.params['CTRL']['ip4']
- ONOS5_ip = main.params['CTRL']['ip5']
- ONOS6_ip = main.params['CTRL']['ip6']
- ONOS7_ip = main.params['CTRL']['ip7']
- MN1_ip = main.params['MN']['ip1']
- BENCH_ip = main.params['BENCH']['ip']
+ ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+ ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
+ ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
+ ONOS4_ip = main.params[ 'CTRL' ][ 'ip4' ]
+ ONOS5_ip = main.params[ 'CTRL' ][ 'ip5' ]
+ ONOS6_ip = main.params[ 'CTRL' ][ 'ip6' ]
+ ONOS7_ip = main.params[ 'CTRL' ][ 'ip7' ]
+ MN1_ip = main.params[ 'MN' ][ 'ip1' ]
+ BENCH_ip = main.params[ 'BENCH' ][ 'ip' ]
- main.case("Setting up test environment")
- main.log.info("copying topology event accumulator config file"+\
- " to ONOS package/etc/ directory")
- topo_config_name = main.params['TEST']['topo_config_name']
+ main.case( "Setting up test environment" )
+ main.log.info( "copying topology event accumulator config file" +
+ " to ONOS package/etc/ directory" )
+ topo_config_name = main.params[ 'TEST' ][ 'topo_config_name' ]
topo_config =\
- main.params['TEST']['topo_accumulator_config']
- main.ONOSbench.handle.sendline("cp ~/"+topo_config+\
- " ~/ONOS/tools/package/etc/"+\
- topo_config_name)
- main.ONOSbench.handle.expect("\$")
+ main.params[ 'TEST' ][ 'topo_accumulator_config' ]
+ main.ONOSbench.handle.sendline( "cp ~/" + topo_config +
+ " ~/ONOS/tools/package/etc/" +
+ topo_config_name )
+ main.ONOSbench.handle.expect( "\$" )
- main.log.info("Uninstalling previous instances")
- #main.ONOSbench.onos_uninstall(node_ip = ONOS1_ip)
- main.ONOSbench.onos_uninstall(node_ip = ONOS2_ip)
- main.ONOSbench.onos_uninstall(node_ip = ONOS3_ip)
- main.ONOSbench.onos_uninstall(node_ip = ONOS4_ip)
- main.ONOSbench.onos_uninstall(node_ip = ONOS5_ip)
- main.ONOSbench.onos_uninstall(node_ip = ONOS6_ip)
- main.ONOSbench.onos_uninstall(node_ip = ONOS7_ip)
-
- main.log.report("Setting up test environment")
+ main.log.info( "Uninstalling previous instances" )
+ #main.ONOSbench.onos_uninstall( node_ip=ONOS1_ip )
+ main.ONOSbench.onos_uninstall( node_ip=ONOS2_ip )
+ main.ONOSbench.onos_uninstall( node_ip=ONOS3_ip )
+ main.ONOSbench.onos_uninstall( node_ip=ONOS4_ip )
+ main.ONOSbench.onos_uninstall( node_ip=ONOS5_ip )
+ main.ONOSbench.onos_uninstall( node_ip=ONOS6_ip )
+ main.ONOSbench.onos_uninstall( node_ip=ONOS7_ip )
- main.step("Creating cell file")
+ main.log.report( "Setting up test environment" )
+
+ main.step( "Creating cell file" )
cell_file_result = main.ONOSbench.create_cell_file(
- BENCH_ip, cell_name, MN1_ip,
- "onos-core,onos-app-metrics",
- #ONOS1_ip, ONOS2_ip, ONOS3_ip)
- ONOS1_ip)
-
- main.step("Applying cell file to environment")
- cell_apply_result = main.ONOSbench.set_cell(cell_name)
- verify_cell_result = main.ONOSbench.verify_cell()
-
- main.step("Removing raft logs")
- main.ONOSbench.onos_remove_raft_logs()
- time.sleep(10)
+ BENCH_ip, cell_name, MN1_ip,
+ "onos-core,onos-app-metrics",
+ # ONOS1_ip, ONOS2_ip, ONOS3_ip )
+ ONOS1_ip )
- main.step("Git checkout and pull "+checkout_branch)
+ main.step( "Applying cell file to environment" )
+ cell_apply_result = main.ONOSbench.set_cell( cell_name )
+ verify_cell_result = main.ONOSbench.verify_cell()
+
+ main.step( "Removing raft logs" )
+ main.ONOSbench.onos_remove_raft_logs()
+ time.sleep( 10 )
+
+ main.step( "Git checkout and pull " + checkout_branch )
if git_pull == 'on':
checkout_result = \
- main.ONOSbench.git_checkout(checkout_branch)
+ main.ONOSbench.git_checkout( checkout_branch )
pull_result = main.ONOSbench.git_pull()
else:
checkout_result = main.TRUE
pull_result = main.TRUE
- main.log.info("Skipped git checkout and pull")
+ main.log.info( "Skipped git checkout and pull" )
- main.log.report("Commit information - ")
+ main.log.report( "Commit information - " )
main.ONOSbench.get_version()
- main.step("Using mvn clean & install")
+ main.step( "Using mvn clean & install" )
#mvn_result = main.ONOSbench.clean_install()
mvn_result = main.TRUE
- main.step("Set cell for ONOS cli env")
- main.ONOS1cli.set_cell(cell_name)
- #main.ONOS2cli.set_cell(cell_name)
- #main.ONOS3cli.set_cell(cell_name)
-
- main.step("Creating ONOS package")
+ main.step( "Set cell for ONOS cli env" )
+ main.ONOS1cli.set_cell( cell_name )
+ # main.ONOS2cli.set_cell( cell_name )
+ # main.ONOS3cli.set_cell( cell_name )
+
+ main.step( "Creating ONOS package" )
package_result = main.ONOSbench.onos_package()
- #Start test with single node only
- main.step("Installing ONOS package")
- install1_result = main.ONOSbench.onos_install(node=ONOS1_ip)
- #install2_result = main.ONOSbench.onos_install(node=ONOS2_ip)
- #install3_result = main.ONOSbench.onos_install(node=ONOS3_ip)
+ # Start test with single node only
+ main.step( "Installing ONOS package" )
+ install1_result = main.ONOSbench.onos_install( node=ONOS1_ip )
+ #install2_result = main.ONOSbench.onos_install( node=ONOS2_ip )
+ #install3_result = main.ONOSbench.onos_install( node=ONOS3_ip )
- time.sleep(10)
+ time.sleep( 10 )
- main.step("Start onos cli")
- cli1 = main.ONOS1cli.start_onos_cli(ONOS1_ip)
- #cli2 = main.ONOS2cli.start_onos_cli(ONOS2_ip)
- #cli3 = main.ONOS3cli.start_onos_cli(ONOS3_ip)
+ main.step( "Start onos cli" )
+ cli1 = main.ONOS1cli.start_onos_cli( ONOS1_ip )
+ #cli2 = main.ONOS2cli.start_onos_cli( ONOS2_ip )
+ #cli3 = main.ONOS3cli.start_onos_cli( ONOS3_ip )
- main.step("Enable metrics feature")
- #main.ONOS1cli.feature_install("onos-app-metrics")
+ main.step( "Enable metrics feature" )
+ # main.ONOS1cli.feature_install( "onos-app-metrics" )
- utilities.assert_equals(expect=main.TRUE,
- actual= cell_file_result and cell_apply_result and\
- verify_cell_result and checkout_result and\
- pull_result and mvn_result and\
- install1_result, #and install2_result and\
- #install3_result,
- onpass="Test Environment setup successful",
- onfail="Failed to setup test environment")
-
- def CASE2(self, main):
- '''
+ utilities.assert_equals( expect=main.TRUE,
+ actual=cell_file_result and cell_apply_result and
+ verify_cell_result and checkout_result and
+ pull_result and mvn_result and
+ install1_result, # and install2_result and
+ # install3_result,
+ onpass="Test Environment setup successful",
+ onfail="Failed to setup test environment" )
+
+ def CASE2( self, main ):
+ """
100 Switch discovery latency
Important:
- This test case can be potentially dangerous if
+ This test case can be potentially dangerous if
your machine has previously set iptables rules.
One of the steps of the test case will flush
all existing iptables rules.
Note:
- You can specify the number of switches in the
+ You can specify the number of switches in the
params file to adjust the switch discovery size
- (and specify the corresponding topology in Mininet1
- .topo file)
- '''
+ ( and specify the corresponding topology in Mininet1
+ .topo file )
+ """
import time
import subprocess
import os
@@ -156,221 +158,241 @@
import numpy
ONOS_ip_list = []
- ONOS_ip_list.append('0')
- ONOS_ip_list.append(main.params['CTRL']['ip1'])
- ONOS_ip_list.append(main.params['CTRL']['ip2'])
- ONOS_ip_list.append(main.params['CTRL']['ip3'])
- ONOS_ip_list.append(main.params['CTRL']['ip4'])
- ONOS_ip_list.append(main.params['CTRL']['ip5'])
- ONOS_ip_list.append(main.params['CTRL']['ip6'])
- ONOS_ip_list.append(main.params['CTRL']['ip7'])
- MN1_ip = main.params['MN']['ip1']
- ONOS_user = main.params['CTRL']['user']
+ ONOS_ip_list.append( '0' )
+ ONOS_ip_list.append( main.params[ 'CTRL' ][ 'ip1' ] )
+ ONOS_ip_list.append( main.params[ 'CTRL' ][ 'ip2' ] )
+ ONOS_ip_list.append( main.params[ 'CTRL' ][ 'ip3' ] )
+ ONOS_ip_list.append( main.params[ 'CTRL' ][ 'ip4' ] )
+ ONOS_ip_list.append( main.params[ 'CTRL' ][ 'ip5' ] )
+ ONOS_ip_list.append( main.params[ 'CTRL' ][ 'ip6' ] )
+ ONOS_ip_list.append( main.params[ 'CTRL' ][ 'ip7' ] )
+ MN1_ip = main.params[ 'MN' ][ 'ip1' ]
+ ONOS_user = main.params[ 'CTRL' ][ 'user' ]
- default_sw_port = main.params['CTRL']['port1']
-
- #Number of iterations of case
- num_iter = main.params['TEST']['numIter']
- iter_ignore = int(main.params['TEST']['iterIgnore'])
+ default_sw_port = main.params[ 'CTRL' ][ 'port1' ]
+
+ # Number of iterations of case
+ num_iter = main.params[ 'TEST' ][ 'numIter' ]
+ iter_ignore = int( main.params[ 'TEST' ][ 'iterIgnore' ] )
#***********
- #Global number of switches that change
- #throughout the test
+ # Global number of switches that change
+ # throughout the test
global num_sw
- global topo_iteration
+ global topo_iteration
global cluster_count
if topo_iteration == 1:
- num_sw = main.params['TEST']['numSwitch1']
+ num_sw = main.params[ 'TEST' ][ 'numSwitch1' ]
elif topo_iteration == 2:
- num_sw = main.params['TEST']['numSwitch2']
+ num_sw = main.params[ 'TEST' ][ 'numSwitch2' ]
elif topo_iteration == 3:
- num_sw = main.params['TEST']['numSwitch3']
+ num_sw = main.params[ 'TEST' ][ 'numSwitch3' ]
elif topo_iteration == 4:
- num_sw = main.params['TEST']['numSwitch4']
+ num_sw = main.params[ 'TEST' ][ 'numSwitch4' ]
#***********
- #Timestamp 'keys' for json metrics output.
- #These are subject to change, hence moved into params
- deviceTimestamp = main.params['JSON']['deviceTimestamp']
- graphTimestamp = main.params['JSON']['graphTimestamp']
-
- #Threshold for this test case
- sw_disc_threshold_str = main.params['TEST']['swDisc100Threshold']
- sw_disc_threshold_obj = sw_disc_threshold_str.split(",")
- sw_disc_threshold_min = int(sw_disc_threshold_obj[0])
- sw_disc_threshold_max = int(sw_disc_threshold_obj[1])
+ # Timestamp 'keys' for json metrics output.
+ # These are subject to change, hence moved into params
+ deviceTimestamp = main.params[ 'JSON' ][ 'deviceTimestamp' ]
+ graphTimestamp = main.params[ 'JSON' ][ 'graphTimestamp' ]
+
+ # Threshold for this test case
+ sw_disc_threshold_str = main.params[ 'TEST' ][ 'swDisc100Threshold' ]
+ sw_disc_threshold_obj = sw_disc_threshold_str.split( "," )
+ sw_disc_threshold_min = int( sw_disc_threshold_obj[ 0 ] )
+ sw_disc_threshold_max = int( sw_disc_threshold_obj[ 1 ] )
assertion = main.TRUE
sw_discovery_lat_list = []
syn_ack_delta_list = []
- main.case(str(num_sw)+" switches distributed across "+
- str(cluster_count)+" nodes convergence latency")
-
- main.log.report("Large topology convergence and scale-out test")
- main.log.report("Currently active ONOS node(s): ")
+ main.case( str( num_sw ) + " switches distributed across " +
+ str( cluster_count ) + " nodes convergence latency" )
+
+ main.log.report( "Large topology convergence and scale-out test" )
+ main.log.report( "Currently active ONOS node(s): " )
report_str = "Node "
- for node in range(1, cluster_count+1):
- report_str += (str(node) + " ")
- main.log.report(report_str)
- main.log.report("Topology size: "+str(num_sw)+" switches")
+ for node in range( 1, cluster_count + 1 ):
+ report_str += ( str( node ) + " " )
+ main.log.report( report_str )
+ main.log.report( "Topology size: " + str( num_sw ) + " switches" )
- main.step("Distributing "+num_sw+" switches to each ONOS")
- index = 1
- for node in range(1, cluster_count+1):
- for i in range(index, (int(num_sw)/cluster_count)+index):
+ main.step( "Distributing " + num_sw + " switches to each ONOS" )
+ index = 1
+ for node in range( 1, cluster_count + 1 ):
+ for i in range( index, ( int( num_sw ) / cluster_count ) + index ):
main.Mininet1.assign_sw_controller(
- sw=str(i),
- ip1=ONOS_ip_list[node],
- port1=default_sw_port)
- index = i+1
- #for i in range(1, int(num_sw)+1):
- #main.Mininet1.assign_sw_controller(
- #sw=str(i),
- #ip1="10.128.174.1",
- # port1="6633")
+ sw=str( i ),
+ ip1=ONOS_ip_list[ node ],
+ port1=default_sw_port )
+ index = i + 1
+ # for i in range( 1, int( num_sw )+1 ):
+ # main.Mininet1.assign_sw_controller(
+ # sw=str( i ),
+ # ip1="10.128.174.1",
+ # port1="6633" )
- main.log.info("Please check ptpd configuration to ensure "+\
- "all nodes' system times are in sync")
+ main.log.info( "Please check ptpd configuration to ensure " +
+ "all nodes' system times are in sync" )
- time.sleep(10)
+ time.sleep( 10 )
- for i in range(0, int(num_iter)):
- main.step("Set iptables rule to block sw connections")
-
- #INPUT rules
+ for i in range( 0, int( num_iter ) ):
+ main.step( "Set iptables rule to block sw connections" )
+
+ # INPUT rules
main.ONOS1.handle.sendline(
- "sudo iptables -A INPUT -p tcp -s "+
- MN1_ip+" --dport "+default_sw_port+" -j DROP")
+ "sudo iptables -A INPUT -p tcp -s " +
+ MN1_ip + " --dport " + default_sw_port + " -j DROP" )
main.ONOS2.handle.sendline(
- "sudo iptables -A INPUT -p tcp -s "+
- MN1_ip+" --dport "+default_sw_port+" -j DROP")
+ "sudo iptables -A INPUT -p tcp -s " +
+ MN1_ip + " --dport " + default_sw_port + " -j DROP" )
main.ONOS3.handle.sendline(
- "sudo iptables -A INPUT -p tcp -s "+
- MN1_ip+" --dport "+default_sw_port+" -j DROP")
+ "sudo iptables -A INPUT -p tcp -s " +
+ MN1_ip + " --dport " + default_sw_port + " -j DROP" )
main.ONOS4.handle.sendline(
- "sudo iptables -A INPUT -p tcp -s "+
- MN1_ip+" --dport "+default_sw_port+" -j DROP")
+ "sudo iptables -A INPUT -p tcp -s " +
+ MN1_ip + " --dport " + default_sw_port + " -j DROP" )
main.ONOS5.handle.sendline(
- "sudo iptables -A INPUT -p tcp -s "+
- MN1_ip+" --dport "+default_sw_port+" -j DROP")
+ "sudo iptables -A INPUT -p tcp -s " +
+ MN1_ip + " --dport " + default_sw_port + " -j DROP" )
main.ONOS6.handle.sendline(
- "sudo iptables -A INPUT -p tcp -s "+
- MN1_ip+" --dport "+default_sw_port+" -j DROP")
+ "sudo iptables -A INPUT -p tcp -s " +
+ MN1_ip + " --dport " + default_sw_port + " -j DROP" )
main.ONOS7.handle.sendline(
- "sudo iptables -A INPUT -p tcp -s "+
- MN1_ip+" --dport "+default_sw_port+" -j DROP")
-
- #OUTPUT rules
+ "sudo iptables -A INPUT -p tcp -s " +
+ MN1_ip + " --dport " + default_sw_port + " -j DROP" )
+
+ # OUTPUT rules
main.ONOS1.handle.sendline(
- "sudo iptables -A OUTPUT -p tcp -s "+
- MN1_ip+" --dport "+default_sw_port+" -j DROP")
+ "sudo iptables -A OUTPUT -p tcp -s " +
+ MN1_ip + " --dport " + default_sw_port + " -j DROP" )
main.ONOS2.handle.sendline(
- "sudo iptables -A OUTPUT -p tcp -s "+
- MN1_ip+" --dport "+default_sw_port+" -j DROP")
+ "sudo iptables -A OUTPUT -p tcp -s " +
+ MN1_ip + " --dport " + default_sw_port + " -j DROP" )
main.ONOS3.handle.sendline(
- "sudo iptables -A OUTPUT -p tcp -s "+
- MN1_ip+" --dport "+default_sw_port+" -j DROP")
+ "sudo iptables -A OUTPUT -p tcp -s " +
+ MN1_ip + " --dport " + default_sw_port + " -j DROP" )
main.ONOS4.handle.sendline(
- "sudo iptables -A OUTPUT -p tcp -s "+
- MN1_ip+" --dport "+default_sw_port+" -j DROP")
+ "sudo iptables -A OUTPUT -p tcp -s " +
+ MN1_ip + " --dport " + default_sw_port + " -j DROP" )
main.ONOS5.handle.sendline(
- "sudo iptables -A OUTPUT -p tcp -s "+
- MN1_ip+" --dport "+default_sw_port+" -j DROP")
+ "sudo iptables -A OUTPUT -p tcp -s " +
+ MN1_ip + " --dport " + default_sw_port + " -j DROP" )
main.ONOS6.handle.sendline(
- "sudo iptables -A OUTPUT -p tcp -s "+
- MN1_ip+" --dport "+default_sw_port+" -j DROP")
+ "sudo iptables -A OUTPUT -p tcp -s " +
+ MN1_ip + " --dport " + default_sw_port + " -j DROP" )
main.ONOS7.handle.sendline(
- "sudo iptables -A OUTPUT -p tcp -s "+
- MN1_ip+" --dport "+default_sw_port+" -j DROP")
+ "sudo iptables -A OUTPUT -p tcp -s " +
+ MN1_ip + " --dport " + default_sw_port + " -j DROP" )
- main.log.info("Please wait for switch connection to timeout")
-
+ main.log.info( "Please wait for switch connection to timeout" )
- #time.sleep(60)
- #if cluster_count >= 3:
- # time.sleep(60)
- #if cluster_count >= 5:
- # time.sleep(30)
- #if cluster_count >= 6:
- # time.sleep(30)
+ # time.sleep( 60 )
+ # if cluster_count >= 3:
+ # time.sleep( 60 )
+ # if cluster_count >= 5:
+ # time.sleep( 30 )
+ # if cluster_count >= 6:
+ # time.sleep( 30 )
if cluster_count >= 3:
- main.ONOS1.handle.sendline("tshark -i eth0 -t e | "+
- "grep 'SYN, ACK' | grep '6633' >"+
- "/tmp/syn_ack_onos1_iter"+str(i)+".txt &")
- main.ONOS2.handle.sendline("tshark -i eth0 -t e | "+
- "grep 'SYN, ACK' | grep '6633' >"+
- "/tmp/syn_ack_onos2_iter"+str(i)+".txt &")
- main.ONOS3.handle.sendline("tshark -i eth0 -t e | "+
- "grep 'SYN, ACK' | grep '6633' >"+
- "/tmp/syn_ack_onos3_iter"+str(i)+".txt &")
+ main.ONOS1.handle.sendline(
+ "tshark -i eth0 -t e | " +
+ "grep 'SYN, ACK' | grep '6633' >" +
+ "/tmp/syn_ack_onos1_iter" +
+ str( i ) +
+ ".txt &" )
+ main.ONOS2.handle.sendline(
+ "tshark -i eth0 -t e | " +
+ "grep 'SYN, ACK' | grep '6633' >" +
+ "/tmp/syn_ack_onos2_iter" +
+ str( i ) +
+ ".txt &" )
+ main.ONOS3.handle.sendline(
+ "tshark -i eth0 -t e | " +
+ "grep 'SYN, ACK' | grep '6633' >" +
+ "/tmp/syn_ack_onos3_iter" +
+ str( i ) +
+ ".txt &" )
if cluster_count >= 4:
- main.ONOS4.handle.sendline("tshark -i eth0 -t e | "+
- "grep 'SYN, ACK' | grep '6633' >"+
- "/tmp/syn_ack_onos4_iter"+str(i)+".txt &")
+ main.ONOS4.handle.sendline(
+ "tshark -i eth0 -t e | " +
+ "grep 'SYN, ACK' | grep '6633' >" +
+ "/tmp/syn_ack_onos4_iter" +
+ str( i ) +
+ ".txt &" )
if cluster_count >= 5:
- main.ONOS5.handle.sendline("tshark -i eth0 -t e | "+
- "grep 'SYN, ACK' | grep '6633' >"+
- "/tmp/syn_ack_onos5_iter"+str(i)+".txt &")
+ main.ONOS5.handle.sendline(
+ "tshark -i eth0 -t e | " +
+ "grep 'SYN, ACK' | grep '6633' >" +
+ "/tmp/syn_ack_onos5_iter" +
+ str( i ) +
+ ".txt &" )
if cluster_count >= 6:
- main.ONOS6.handle.sendline("tshark -i eth0 -t e | "+
- "grep 'SYN, ACK' | grep '6633' >"+
- "/tmp/syn_ack_onos6_iter"+str(i)+".txt &")
+ main.ONOS6.handle.sendline(
+ "tshark -i eth0 -t e | " +
+ "grep 'SYN, ACK' | grep '6633' >" +
+ "/tmp/syn_ack_onos6_iter" +
+ str( i ) +
+ ".txt &" )
if cluster_count == 7:
- main.ONOS7.handle.sendline("tshark -i eth0 -t e | "+
- "grep 'SYN, ACK' | grep '6633' >"+
- "/tmp/syn_ack_onos6_iter"+str(i)+".txt &")
-
- #NOTE:
- # Delay before checking devices to
+ main.ONOS7.handle.sendline(
+ "tshark -i eth0 -t e | " +
+ "grep 'SYN, ACK' | grep '6633' >" +
+ "/tmp/syn_ack_onos6_iter" +
+ str( i ) +
+ ".txt &" )
+
+ # NOTE:
+ # Delay before checking devices to
# help prevent timing out from CLI
- # due to multiple command issuing
- time.sleep(20)
+ # due to multiple command issuing
+ time.sleep( 20 )
loop = True
loop_count = 0
device_count = 0
- while loop_count < 60 and loop:
- main.log.info("Checking devices for device down")
-
+ while loop_count < 60 and loop:
+ main.log.info( "Checking devices for device down" )
+
temp_len = 0
device_str1 = main.ONOS1cli.devices(
- node_ip=ONOS_ip_list[1])
- device_json1 = json.loads(device_str1)
- json_len = len(device_json1)
-
- #NOTE: May want to check the rest of
+ node_ip=ONOS_ip_list[ 1 ] )
+ device_json1 = json.loads( device_str1 )
+ json_len = len( device_json1 )
+
+ # NOTE: May want to check the rest of
# the ONOS instances for device down as well
- for device1 in device_json1:
+ for device1 in device_json1:
temp_len = temp_len + 1
- if device1['available'] == True:
+ if device1[ 'available' ]:
loop = True
break
- #if I'm on the last json object and I still haven't
- #broken out of the loop, it means there were
- #no available devices
- elif temp_len == json_len-1:
- main.log.info("Temp length: "+str(temp_len))
- main.step("Flushing iptables and obtaining t0")
- t0_system = time.time()*1000
-
- main.ONOS1.handle.sendline("sudo iptables -F")
- main.ONOS2.handle.sendline("sudo iptables -F")
- main.ONOS3.handle.sendline("sudo iptables -F")
- main.ONOS4.handle.sendline("sudo iptables -F")
- main.ONOS5.handle.sendline("sudo iptables -F")
- main.ONOS6.handle.sendline("sudo iptables -F")
- main.ONOS7.handle.sendline("sudo iptables -F")
-
+ # if I'm on the last json object and I still haven't
+ # broken out of the loop, it means there were
+ # no available devices
+ elif temp_len == json_len - 1:
+ main.log.info( "Temp length: " + str( temp_len ) )
+ main.step( "Flushing iptables and obtaining t0" )
+ t0_system = time.time() * 1000
+
+ main.ONOS1.handle.sendline( "sudo iptables -F" )
+ main.ONOS2.handle.sendline( "sudo iptables -F" )
+ main.ONOS3.handle.sendline( "sudo iptables -F" )
+ main.ONOS4.handle.sendline( "sudo iptables -F" )
+ main.ONOS5.handle.sendline( "sudo iptables -F" )
+ main.ONOS6.handle.sendline( "sudo iptables -F" )
+ main.ONOS7.handle.sendline( "sudo iptables -F" )
+
loop = False
break
-
- loop_count += 1
- time.sleep(1)
- main.log.info("System time t0: "+str(t0_system))
+ loop_count += 1
+ time.sleep( 1 )
+
+ main.log.info( "System time t0: " + str( t0_system ) )
counter_loop = 0
counter_avail1 = 0
@@ -388,207 +410,213 @@
onos6_dev = False
onos7_dev = False
- #TODO: Think of a more elegant way to check all
+ # TODO: Think of a more elegant way to check all
# switches across all nodes
- #Goodluck debugging this loop
+ # Goodluck debugging this loop
while counter_loop < 60:
- for node in range(1, cluster_count+1):
+ for node in range( 1, cluster_count + 1 ):
if node == 1 and not onos1_dev:
- main.log.info("Checking node 1 for device "+
- "discovery")
+ main.log.info( "Checking node 1 for device " +
+ "discovery" )
device_str_obj1 = main.ONOS1cli.devices(
- node_ip=ONOS_ip_list[1])
- device_json1 = json.loads(device_str_obj1)
+ node_ip=ONOS_ip_list[ 1 ] )
+ device_json1 = json.loads( device_str_obj1 )
for device1 in device_json1:
- if device1['available'] == True:
+ if device1[ 'available' ]:
counter_avail1 += 1
- if counter_avail1 == int(num_sw):
+ if counter_avail1 == int( num_sw ):
onos1_dev = True
- main.log.info("All devices have been"+
- " discovered on ONOS1")
+ main.log.info( "All devices have been" +
+ " discovered on ONOS1" )
else:
counter_avail1 = 0
if node == 2 and not onos2_dev:
- main.log.info("Checking node 2 for device "+
- "discovery")
+ main.log.info( "Checking node 2 for device " +
+ "discovery" )
device_str_obj2 = main.ONOS2cli.devices(
- node_ip=ONOS_ip_list[2])
- device_json2 = json.loads(device_str_obj2)
+ node_ip=ONOS_ip_list[ 2 ] )
+ device_json2 = json.loads( device_str_obj2 )
for device2 in device_json2:
- if device2['available'] == True:
+ if device2[ 'available' ]:
counter_avail2 += 1
- if counter_avail2 == int(num_sw):
+ if counter_avail2 == int( num_sw ):
onos2_dev = True
- main.log.info("All devices have been"+
- " discovered on ONOS2")
+ main.log.info( "All devices have been" +
+ " discovered on ONOS2" )
else:
counter_avail2 = 0
if node == 3 and not onos3_dev:
- main.log.info("Checking node 3 for device "+
- "discovery")
+ main.log.info( "Checking node 3 for device " +
+ "discovery" )
device_str_obj3 = main.ONOS3cli.devices(
- node_ip=ONOS_ip_list[3])
- device_json3 = json.loads(device_str_obj3)
+ node_ip=ONOS_ip_list[ 3 ] )
+ device_json3 = json.loads( device_str_obj3 )
for device3 in device_json3:
- if device3['available'] == True:
+ if device3[ 'available' ]:
counter_avail3 += 1
- if counter_avail3 == int(num_sw):
+ if counter_avail3 == int( num_sw ):
onos3_dev = True
- main.log.info("All devices have been"+
- " discovered on ONOS3")
+ main.log.info( "All devices have been" +
+ " discovered on ONOS3" )
else:
counter_avail3 = 0
if node == 4 and not onos4_dev:
- main.log.info("Checking node 4 for device "+
- "discovery")
+ main.log.info( "Checking node 4 for device " +
+ "discovery" )
device_str_obj4 = main.ONOS4cli.devices(
- node_ip=ONOS_ip_list[4])
- device_json4 = json.loads(device_str_obj4)
+ node_ip=ONOS_ip_list[ 4 ] )
+ device_json4 = json.loads( device_str_obj4 )
for device4 in device_json4:
- if device4['available'] == True:
+ if device4[ 'available' ]:
counter_avail4 += 1
- if counter_avail4 == int(num_sw):
+ if counter_avail4 == int( num_sw ):
onos4_dev = True
- main.log.info("All devices have been"+
- " discovered on ONOS4")
+ main.log.info( "All devices have been" +
+ " discovered on ONOS4" )
else:
counter_avail4 = 0
if node == 5 and not onos5_dev:
- main.log.info("Checking node 5 for device "+
- "discovery")
+ main.log.info( "Checking node 5 for device " +
+ "discovery" )
device_str_obj5 = main.ONOS5cli.devices(
- node_ip=ONOS_ip_list[5])
- device_json5 = json.loads(device_str_obj5)
+ node_ip=ONOS_ip_list[ 5 ] )
+ device_json5 = json.loads( device_str_obj5 )
for device5 in device_json5:
- if device5['available'] == True:
+ if device5[ 'available' ]:
counter_avail5 += 1
- if counter_avail5 == int(num_sw):
+ if counter_avail5 == int( num_sw ):
onos5_dev = True
- main.log.info("All devices have been"+
- " discovered on ONOS5")
+ main.log.info( "All devices have been" +
+ " discovered on ONOS5" )
else:
counter_avail5 = 0
if node == 6 and not onos6_dev:
- main.log.info("Checking node 6 for device "+
- "discovery")
+ main.log.info( "Checking node 6 for device " +
+ "discovery" )
device_str_obj6 = main.ONOS6cli.devices(
- node_ip=ONOS_ip_list[6])
- device_json6 = json.loads(device_str_obj6)
+ node_ip=ONOS_ip_list[ 6 ] )
+ device_json6 = json.loads( device_str_obj6 )
for device6 in device_json6:
- if device6['available'] == True:
+ if device6[ 'available' ]:
counter_avail6 += 1
- if counter_avail6 == int(num_sw):
+ if counter_avail6 == int( num_sw ):
onos6_dev = True
- main.log.info("All devices have been"+
- " discovered on ONOS6")
+ main.log.info( "All devices have been" +
+ " discovered on ONOS6" )
else:
counter_avail6 = 0
if node == 7 and not onos7_dev:
- main.log.info("Checking node 7 for device "+
- "discovery")
+ main.log.info( "Checking node 7 for device " +
+ "discovery" )
device_str_obj7 = main.ONOS7cli.devices(
- node_ip=ONOS_ip_list[7])
- device_json7 = json.loads(device_str_obj7)
+ node_ip=ONOS_ip_list[ 7 ] )
+ device_json7 = json.loads( device_str_obj7 )
for device7 in device_json7:
- if device7['available'] == True:
+ if device7[ 'available' ]:
counter_avail7 += 1
- if counter_avail7 == int(num_sw):
+ if counter_avail7 == int( num_sw ):
onos7_dev = True
- main.log.info("All devices have been"+
- " discovered on ONOS7")
+ main.log.info( "All devices have been" +
+ " discovered on ONOS7" )
else:
counter_avail7 = 0
- #END node loop
-
- #TODO: clean up this mess of an if statements if possible
- #Treat each if as a separate test case with the given
+ # END node loop
+
+ # TODO: clean up this mess of an if statements if possible
+ # Treat each if as a separate test case with the given
# cluster count. Hence when the cluster count changes
# the desired calculations will be made
if cluster_count == 1:
if onos1_dev:
- main.log.info("All devices have been discovered"+
- " on all ONOS instances")
- time.sleep(5)
+ main.log.info( "All devices have been discovered" +
+ " on all ONOS instances" )
+ time.sleep( 5 )
json_str_metrics_1 =\
main.ONOS1cli.topology_events_metrics()
- json_obj_1 = json.loads(json_str_metrics_1)
+ json_obj_1 = json.loads( json_str_metrics_1 )
graph_timestamp_1 =\
- json_obj_1[graphTimestamp]['value']
-
+ json_obj_1[ graphTimestamp ][ 'value' ]
+
graph_lat_1 = \
- int(graph_timestamp_1) - int(t0_system)
-
- main.log.info("Graph Timestamp ONOS1: "+
- str(graph_timestamp_1))
+ int( graph_timestamp_1 ) - int( t0_system )
+
+ main.log.info( "Graph Timestamp ONOS1: " +
+ str( graph_timestamp_1 ) )
if graph_lat_1 > sw_disc_threshold_min\
- and graph_lat_1 < sw_disc_threshold_max\
- and int(i) > iter_ignore:
+ and graph_lat_1 < sw_disc_threshold_max\
+ and int( i ) > iter_ignore:
sw_discovery_lat_list.append(
- graph_lat_1)
- main.log.info("Sw discovery latency of "+
- str(cluster_count)+" node(s): "+
- str(graph_lat_1)+" ms")
+ graph_lat_1 )
+ main.log.info(
+ "Sw discovery latency of " +
+ str( cluster_count ) +
+ " node(s): " +
+ str( graph_lat_1 ) +
+ " ms" )
else:
- main.log.info("Switch discovery latency "+
- "exceeded the threshold.")
- main.log.info(str(graph_lat_1)+" ms")
- #Break while loop
+ main.log.info( "Switch discovery latency " +
+ "exceeded the threshold." )
+ main.log.info( str( graph_lat_1 ) + " ms" )
+ # Break while loop
break
if cluster_count == 2:
if onos1_dev and onos2_dev:
- main.log.info("All devices have been discovered"+
- " on all "+str(cluster_count)+
- " ONOS instances")
- time.sleep(5)
+ main.log.info( "All devices have been discovered" +
+ " on all " + str( cluster_count ) +
+ " ONOS instances" )
+ time.sleep( 5 )
json_str_metrics_1 =\
main.ONOS1cli.topology_events_metrics()
json_str_metrics_2 =\
main.ONOS2cli.topology_events_metrics()
- json_obj_1 = json.loads(json_str_metrics_1)
- json_obj_2 = json.loads(json_str_metrics_2)
+ json_obj_1 = json.loads( json_str_metrics_1 )
+ json_obj_2 = json.loads( json_str_metrics_2 )
graph_timestamp_1 =\
- json_obj_1[graphTimestamp]['value']
+ json_obj_1[ graphTimestamp ][ 'value' ]
graph_timestamp_2 =\
- json_obj_2[graphTimestamp]['value']
-
- graph_lat_1 = \
- int(graph_timestamp_1) - int(t0_system)
- graph_lat_2 = \
- int(graph_timestamp_2) - int(t0_system)
-
- main.log.info("Graph Timestamp ONOS1: "+
- str(graph_timestamp_1))
- main.log.info("Graph Timestamp ONOS2: "+
- str(graph_timestamp_2))
+ json_obj_2[ graphTimestamp ][ 'value' ]
- max_graph_lat = max(graph_lat_1,
- graph_lat_2, graph_lat_3)
+ graph_lat_1 = \
+ int( graph_timestamp_1 ) - int( t0_system )
+ graph_lat_2 = \
+ int( graph_timestamp_2 ) - int( t0_system )
+
+ main.log.info( "Graph Timestamp ONOS1: " +
+ str( graph_timestamp_1 ) )
+ main.log.info( "Graph Timestamp ONOS2: " +
+ str( graph_timestamp_2 ) )
+
+ max_graph_lat = max( graph_lat_1,
+ graph_lat_2, graph_lat_3 )
if max_graph_lat > sw_disc_threshold_min\
- and max_graph_lat < sw_disc_threshold_max\
- and int(i) > iter_ignore:
+ and max_graph_lat < sw_disc_threshold_max\
+ and int( i ) > iter_ignore:
sw_discovery_lat_list.append(
- max_graph_lat)
- main.log.info("Sw discovery latency of "+
- str(cluster_count)+" node(s): "+
- str(max_graph_lat)+" ms")
+ max_graph_lat )
+ main.log.info(
+ "Sw discovery latency of " +
+ str( cluster_count ) +
+ " node(s): " +
+ str( max_graph_lat ) +
+ " ms" )
else:
- main.log.info("Switch discovery latency "+
- "exceeded the threshold.")
- main.log.info(str(max_graph_lat)+" ms")
+ main.log.info( "Switch discovery latency " +
+ "exceeded the threshold." )
+ main.log.info( str( max_graph_lat ) + " ms" )
break
if cluster_count == 3:
if onos1_dev and onos2_dev and onos3_dev:
- main.log.info("All devices have been discovered"+
- " on all "+str(cluster_count)+
- " ONOS instances")
-
- #TODO: Investigate this sleep
- # added to 'pad' the results with
+ main.log.info( "All devices have been discovered" +
+ " on all " + str( cluster_count ) +
+ " ONOS instances" )
+
+ # TODO: Investigate this sleep
+ # added to 'pad' the results with
# plenty of time to 'catch up'
- time.sleep(5)
+ time.sleep( 5 )
json_str_metrics_1 =\
main.ONOS1cli.topology_events_metrics()
@@ -596,53 +624,56 @@
main.ONOS2cli.topology_events_metrics()
json_str_metrics_3 =\
main.ONOS3cli.topology_events_metrics()
- json_obj_1 = json.loads(json_str_metrics_1)
- json_obj_2 = json.loads(json_str_metrics_2)
- json_obj_3 = json.loads(json_str_metrics_3)
+ json_obj_1 = json.loads( json_str_metrics_1 )
+ json_obj_2 = json.loads( json_str_metrics_2 )
+ json_obj_3 = json.loads( json_str_metrics_3 )
graph_timestamp_1 =\
- json_obj_1[graphTimestamp]['value']
+ json_obj_1[ graphTimestamp ][ 'value' ]
graph_timestamp_2 =\
- json_obj_2[graphTimestamp]['value']
+ json_obj_2[ graphTimestamp ][ 'value' ]
graph_timestamp_3 =\
- json_obj_3[graphTimestamp]['value']
-
+ json_obj_3[ graphTimestamp ][ 'value' ]
+
graph_lat_1 = \
- int(graph_timestamp_1) - int(t0_system)
+ int( graph_timestamp_1 ) - int( t0_system )
graph_lat_2 = \
- int(graph_timestamp_2) - int(t0_system)
+ int( graph_timestamp_2 ) - int( t0_system )
graph_lat_3 = \
- int(graph_timestamp_3) - int(t0_system)
+ int( graph_timestamp_3 ) - int( t0_system )
- main.log.info("Graph Timestamp ONOS1: "+
- str(graph_timestamp_1))
- main.log.info("Graph Timestamp ONOS2: "+
- str(graph_timestamp_2))
- main.log.info("Graph Timestamp ONOS3: "+
- str(graph_timestamp_3))
+ main.log.info( "Graph Timestamp ONOS1: " +
+ str( graph_timestamp_1 ) )
+ main.log.info( "Graph Timestamp ONOS2: " +
+ str( graph_timestamp_2 ) )
+ main.log.info( "Graph Timestamp ONOS3: " +
+ str( graph_timestamp_3 ) )
- max_graph_lat = max(graph_lat_1,
- graph_lat_2,
- graph_lat_3)
+ max_graph_lat = max( graph_lat_1,
+ graph_lat_2,
+ graph_lat_3 )
if max_graph_lat > sw_disc_threshold_min\
- and max_graph_lat < sw_disc_threshold_max\
- and int(i) > iter_ignore:
+ and max_graph_lat < sw_disc_threshold_max\
+ and int( i ) > iter_ignore:
sw_discovery_lat_list.append(
- max_graph_lat)
- main.log.info("Sw discovery latency of "+
- str(cluster_count)+" node(s): "+
- str(max_graph_lat)+" ms")
+ max_graph_lat )
+ main.log.info(
+ "Sw discovery latency of " +
+ str( cluster_count ) +
+ " node(s): " +
+ str( max_graph_lat ) +
+ " ms" )
else:
- main.log.info("Switch discovery latency "+
- "exceeded the threshold.")
- main.log.info(str(max_graph_lat)+" ms")
-
+ main.log.info( "Switch discovery latency " +
+ "exceeded the threshold." )
+ main.log.info( str( max_graph_lat ) + " ms" )
+
break
if cluster_count == 4:
if onos1_dev and onos2_dev and onos3_dev and\
onos4_dev:
- main.log.info("All devices have been discovered"+
- " on all ONOS instances")
+ main.log.info( "All devices have been discovered" +
+ " on all ONOS instances" )
json_str_metrics_1 =\
main.ONOS1cli.topology_events_metrics()
json_str_metrics_2 =\
@@ -651,67 +682,70 @@
main.ONOS3cli.topology_events_metrics()
json_str_metrics_4 =\
main.ONOS4cli.topology_events_metrics()
- json_obj_1 = json.loads(json_str_metrics_1)
- json_obj_2 = json.loads(json_str_metrics_2)
- json_obj_3 = json.loads(json_str_metrics_3)
- json_obj_4 = json.loads(json_str_metrics_4)
+ json_obj_1 = json.loads( json_str_metrics_1 )
+ json_obj_2 = json.loads( json_str_metrics_2 )
+ json_obj_3 = json.loads( json_str_metrics_3 )
+ json_obj_4 = json.loads( json_str_metrics_4 )
graph_timestamp_1 =\
- json_obj_1[graphTimestamp]['value']
+ json_obj_1[ graphTimestamp ][ 'value' ]
graph_timestamp_2 =\
- json_obj_2[graphTimestamp]['value']
+ json_obj_2[ graphTimestamp ][ 'value' ]
graph_timestamp_3 =\
- json_obj_3[graphTimestamp]['value']
+ json_obj_3[ graphTimestamp ][ 'value' ]
graph_timestamp_4 =\
- json_obj_4[graphTimestamp]['value']
-
- graph_lat_1 = \
- int(graph_timestamp_1) - int(t0_system)
- graph_lat_2 = \
- int(graph_timestamp_2) - int(t0_system)
- graph_lat_3 = \
- int(graph_timestamp_3) - int(t0_system)
- graph_lat_4 = \
- int(graph_timestamp_4) - int(t0_system)
-
- main.log.info("Graph Timestamp ONOS1: "+
- str(graph_timestamp_1))
- main.log.info("Graph Timestamp ONOS2: "+
- str(graph_timestamp_2))
- main.log.info("Graph Timestamp ONOS3: "+
- str(graph_timestamp_3))
- main.log.info("Graph Timestamp ONOS4: "+
- str(graph_timestamp_4))
+ json_obj_4[ graphTimestamp ][ 'value' ]
- max_graph_lat = max(graph_lat_1,
- graph_lat_2,
- graph_lat_3,
- graph_lat_4)
-
+ graph_lat_1 = \
+ int( graph_timestamp_1 ) - int( t0_system )
+ graph_lat_2 = \
+ int( graph_timestamp_2 ) - int( t0_system )
+ graph_lat_3 = \
+ int( graph_timestamp_3 ) - int( t0_system )
+ graph_lat_4 = \
+ int( graph_timestamp_4 ) - int( t0_system )
+
+ main.log.info( "Graph Timestamp ONOS1: " +
+ str( graph_timestamp_1 ) )
+ main.log.info( "Graph Timestamp ONOS2: " +
+ str( graph_timestamp_2 ) )
+ main.log.info( "Graph Timestamp ONOS3: " +
+ str( graph_timestamp_3 ) )
+ main.log.info( "Graph Timestamp ONOS4: " +
+ str( graph_timestamp_4 ) )
+
+ max_graph_lat = max( graph_lat_1,
+ graph_lat_2,
+ graph_lat_3,
+ graph_lat_4 )
+
if max_graph_lat > sw_disc_threshold_min\
- and max_graph_lat < sw_disc_threshold_max\
- and int(i) > iter_ignore:
+ and max_graph_lat < sw_disc_threshold_max\
+ and int( i ) > iter_ignore:
sw_discovery_lat_list.append(
- max_graph_lat)
- main.log.info("Sw discovery latency of "+
- str(cluster_count)+" node(s): "+
- str(max_graph_lat)+" ms")
+ max_graph_lat )
+ main.log.info(
+ "Sw discovery latency of " +
+ str( cluster_count ) +
+ " node(s): " +
+ str( max_graph_lat ) +
+ " ms" )
else:
- main.log.info("Switch discovery latency "+
- "exceeded the threshold.")
- main.log.info(str(max_graph_lat)+" ms")
-
+ main.log.info( "Switch discovery latency " +
+ "exceeded the threshold." )
+ main.log.info( str( max_graph_lat ) + " ms" )
+
break
if cluster_count == 5:
if onos1_dev and onos2_dev and onos3_dev and\
onos4_dev and onos5_dev:
- main.log.info("All devices have been discovered"+
- " on all ONOS instances")
-
- #TODO: Investigate this sleep
- # added to 'pad' the results with
+ main.log.info( "All devices have been discovered" +
+ " on all ONOS instances" )
+
+ # TODO: Investigate this sleep
+ # added to 'pad' the results with
# plenty of time to 'catch up'
- time.sleep(5)
-
+ time.sleep( 5 )
+
json_str_metrics_1 =\
main.ONOS1cli.topology_events_metrics()
json_str_metrics_2 =\
@@ -722,69 +756,72 @@
main.ONOS4cli.topology_events_metrics()
json_str_metrics_5 =\
main.ONOS5cli.topology_events_metrics()
- json_obj_1 = json.loads(json_str_metrics_1)
- json_obj_2 = json.loads(json_str_metrics_2)
- json_obj_3 = json.loads(json_str_metrics_3)
- json_obj_4 = json.loads(json_str_metrics_4)
- json_obj_5 = json.loads(json_str_metrics_5)
+ json_obj_1 = json.loads( json_str_metrics_1 )
+ json_obj_2 = json.loads( json_str_metrics_2 )
+ json_obj_3 = json.loads( json_str_metrics_3 )
+ json_obj_4 = json.loads( json_str_metrics_4 )
+ json_obj_5 = json.loads( json_str_metrics_5 )
graph_timestamp_1 =\
- json_obj_1[graphTimestamp]['value']
+ json_obj_1[ graphTimestamp ][ 'value' ]
graph_timestamp_2 =\
- json_obj_2[graphTimestamp]['value']
+ json_obj_2[ graphTimestamp ][ 'value' ]
graph_timestamp_3 =\
- json_obj_3[graphTimestamp]['value']
+ json_obj_3[ graphTimestamp ][ 'value' ]
graph_timestamp_4 =\
- json_obj_4[graphTimestamp]['value']
+ json_obj_4[ graphTimestamp ][ 'value' ]
graph_timestamp_5 =\
- json_obj_5[graphTimestamp]['value']
-
- graph_lat_1 = \
- int(graph_timestamp_1) - int(t0_system)
- graph_lat_2 = \
- int(graph_timestamp_2) - int(t0_system)
- graph_lat_3 = \
- int(graph_timestamp_3) - int(t0_system)
- graph_lat_4 = \
- int(graph_timestamp_4) - int(t0_system)
- graph_lat_5 = \
- int(graph_timestamp_5) - int(t0_system)
-
- main.log.info("Graph Timestamp ONOS1: "+
- str(graph_timestamp_1))
- main.log.info("Graph Timestamp ONOS2: "+
- str(graph_timestamp_2))
- main.log.info("Graph Timestamp ONOS3: "+
- str(graph_timestamp_3))
- main.log.info("Graph Timestamp ONOS4: "+
- str(graph_timestamp_4))
- main.log.info("Graph Timestamp ONOS5: "+
- str(graph_timestamp_5))
+ json_obj_5[ graphTimestamp ][ 'value' ]
- max_graph_lat = max(graph_lat_1,
- graph_lat_2,
- graph_lat_3,
- graph_lat_4,
- graph_lat_5)
-
+ graph_lat_1 = \
+ int( graph_timestamp_1 ) - int( t0_system )
+ graph_lat_2 = \
+ int( graph_timestamp_2 ) - int( t0_system )
+ graph_lat_3 = \
+ int( graph_timestamp_3 ) - int( t0_system )
+ graph_lat_4 = \
+ int( graph_timestamp_4 ) - int( t0_system )
+ graph_lat_5 = \
+ int( graph_timestamp_5 ) - int( t0_system )
+
+ main.log.info( "Graph Timestamp ONOS1: " +
+ str( graph_timestamp_1 ) )
+ main.log.info( "Graph Timestamp ONOS2: " +
+ str( graph_timestamp_2 ) )
+ main.log.info( "Graph Timestamp ONOS3: " +
+ str( graph_timestamp_3 ) )
+ main.log.info( "Graph Timestamp ONOS4: " +
+ str( graph_timestamp_4 ) )
+ main.log.info( "Graph Timestamp ONOS5: " +
+ str( graph_timestamp_5 ) )
+
+ max_graph_lat = max( graph_lat_1,
+ graph_lat_2,
+ graph_lat_3,
+ graph_lat_4,
+ graph_lat_5 )
+
if max_graph_lat > sw_disc_threshold_min\
- and max_graph_lat < sw_disc_threshold_max\
- and int(i) > iter_ignore:
+ and max_graph_lat < sw_disc_threshold_max\
+ and int( i ) > iter_ignore:
sw_discovery_lat_list.append(
- max_graph_lat)
- main.log.info("Sw discovery latency of "+
- str(cluster_count)+" node(s): "+
- str(max_graph_lat)+" ms")
+ max_graph_lat )
+ main.log.info(
+ "Sw discovery latency of " +
+ str( cluster_count ) +
+ " node(s): " +
+ str( max_graph_lat ) +
+ " ms" )
else:
- main.log.info("Switch discovery latency "+
- "exceeded the threshold.")
- main.log.info(str(max_graph_lat)+" ms")
-
+ main.log.info( "Switch discovery latency " +
+ "exceeded the threshold." )
+ main.log.info( str( max_graph_lat ) + " ms" )
+
break
if cluster_count == 6:
if onos1_dev and onos2_dev and onos3_dev and\
onos4_dev and onos5_dev and onos6_dev:
- main.log.info("All devices have been discovered"+
- " on all ONOS instances")
+ main.log.info( "All devices have been discovered" +
+ " on all ONOS instances" )
json_str_metrics_1 =\
main.ONOS1cli.topology_events_metrics()
json_str_metrics_2 =\
@@ -797,84 +834,87 @@
main.ONOS5cli.topology_events_metrics()
json_str_metrics_6 =\
main.ONOS6cli.topology_events_metrics()
- json_obj_1 = json.loads(json_str_metrics_1)
- json_obj_2 = json.loads(json_str_metrics_2)
- json_obj_3 = json.loads(json_str_metrics_3)
- json_obj_4 = json.loads(json_str_metrics_4)
- json_obj_5 = json.loads(json_str_metrics_5)
- json_obj_6 = json.loads(json_str_metrics_6)
+ json_obj_1 = json.loads( json_str_metrics_1 )
+ json_obj_2 = json.loads( json_str_metrics_2 )
+ json_obj_3 = json.loads( json_str_metrics_3 )
+ json_obj_4 = json.loads( json_str_metrics_4 )
+ json_obj_5 = json.loads( json_str_metrics_5 )
+ json_obj_6 = json.loads( json_str_metrics_6 )
graph_timestamp_1 =\
- json_obj_1[graphTimestamp]['value']
+ json_obj_1[ graphTimestamp ][ 'value' ]
graph_timestamp_2 =\
- json_obj_2[graphTimestamp]['value']
+ json_obj_2[ graphTimestamp ][ 'value' ]
graph_timestamp_3 =\
- json_obj_3[graphTimestamp]['value']
+ json_obj_3[ graphTimestamp ][ 'value' ]
graph_timestamp_4 =\
- json_obj_4[graphTimestamp]['value']
+ json_obj_4[ graphTimestamp ][ 'value' ]
graph_timestamp_5 =\
- json_obj_5[graphTimestamp]['value']
+ json_obj_5[ graphTimestamp ][ 'value' ]
graph_timestamp_6 =\
- json_obj_6[graphTimestamp]['value']
-
- graph_lat_1 = \
- int(graph_timestamp_1) - int(t0_system)
- graph_lat_2 = \
- int(graph_timestamp_2) - int(t0_system)
- graph_lat_3 = \
- int(graph_timestamp_3) - int(t0_system)
- graph_lat_4 = \
- int(graph_timestamp_4) - int(t0_system)
- graph_lat_5 = \
- int(graph_timestamp_5) - int(t0_system)
- graph_lat_6 = \
- int(graph_timestamp_6) - int(t0_system)
-
- main.log.info("Graph Timestamp ONOS1: "+
- str(graph_timestamp_1))
- main.log.info("Graph Timestamp ONOS2: "+
- str(graph_timestamp_2))
- main.log.info("Graph Timestamp ONOS3: "+
- str(graph_timestamp_3))
- main.log.info("Graph Timestamp ONOS4: "+
- str(graph_timestamp_4))
- main.log.info("Graph Timestamp ONOS5: "+
- str(graph_timestamp_5))
- main.log.info("Graph Timestamp ONOS6: "+
- str(graph_timestamp_6))
+ json_obj_6[ graphTimestamp ][ 'value' ]
- max_graph_lat = max(graph_lat_1,
- graph_lat_2,
- graph_lat_3,
- graph_lat_4,
- graph_lat_5,
- graph_lat_6)
-
+ graph_lat_1 = \
+ int( graph_timestamp_1 ) - int( t0_system )
+ graph_lat_2 = \
+ int( graph_timestamp_2 ) - int( t0_system )
+ graph_lat_3 = \
+ int( graph_timestamp_3 ) - int( t0_system )
+ graph_lat_4 = \
+ int( graph_timestamp_4 ) - int( t0_system )
+ graph_lat_5 = \
+ int( graph_timestamp_5 ) - int( t0_system )
+ graph_lat_6 = \
+ int( graph_timestamp_6 ) - int( t0_system )
+
+ main.log.info( "Graph Timestamp ONOS1: " +
+ str( graph_timestamp_1 ) )
+ main.log.info( "Graph Timestamp ONOS2: " +
+ str( graph_timestamp_2 ) )
+ main.log.info( "Graph Timestamp ONOS3: " +
+ str( graph_timestamp_3 ) )
+ main.log.info( "Graph Timestamp ONOS4: " +
+ str( graph_timestamp_4 ) )
+ main.log.info( "Graph Timestamp ONOS5: " +
+ str( graph_timestamp_5 ) )
+ main.log.info( "Graph Timestamp ONOS6: " +
+ str( graph_timestamp_6 ) )
+
+ max_graph_lat = max( graph_lat_1,
+ graph_lat_2,
+ graph_lat_3,
+ graph_lat_4,
+ graph_lat_5,
+ graph_lat_6 )
+
if max_graph_lat > sw_disc_threshold_min\
- and max_graph_lat < sw_disc_threshold_max\
- and int(i) > iter_ignore:
+ and max_graph_lat < sw_disc_threshold_max\
+ and int( i ) > iter_ignore:
sw_discovery_lat_list.append(
- max_graph_lat)
- main.log.info("Sw discovery latency of "+
- str(cluster_count)+" node(s): "+
- str(max_graph_lat)+" ms")
+ max_graph_lat )
+ main.log.info(
+ "Sw discovery latency of " +
+ str( cluster_count ) +
+ " node(s): " +
+ str( max_graph_lat ) +
+ " ms" )
else:
- main.log.info("Switch discovery latency "+
- "exceeded the threshold.")
- main.log.info(str(max_graph_lat)+" ms")
-
+ main.log.info( "Switch discovery latency " +
+ "exceeded the threshold." )
+ main.log.info( str( max_graph_lat ) + " ms" )
+
break
if cluster_count == 7:
if onos1_dev and onos2_dev and onos3_dev and\
onos4_dev and onos5_dev and onos6_dev and\
onos7_dev:
- main.log.info("All devices have been discovered"+
- " on all ONOS instances")
-
- #TODO: Investigate this sleep
- # added to 'pad' the results with
+ main.log.info( "All devices have been discovered" +
+ " on all ONOS instances" )
+
+ # TODO: Investigate this sleep
+ # added to 'pad' the results with
# plenty of time to 'catch up'
- time.sleep(5)
-
+ time.sleep( 5 )
+
json_str_metrics_1 =\
main.ONOS1cli.topology_events_metrics()
json_str_metrics_2 =\
@@ -889,390 +929,451 @@
main.ONOS6cli.topology_events_metrics()
json_str_metrics_7 =\
main.ONOS7cli.topology_events_metrics()
- json_obj_1 = json.loads(json_str_metrics_1)
- json_obj_2 = json.loads(json_str_metrics_2)
- json_obj_3 = json.loads(json_str_metrics_3)
- json_obj_4 = json.loads(json_str_metrics_4)
- json_obj_5 = json.loads(json_str_metrics_5)
- json_obj_6 = json.loads(json_str_metrics_6)
- json_obj_7 = json.loads(json_str_metrics_7)
+ json_obj_1 = json.loads( json_str_metrics_1 )
+ json_obj_2 = json.loads( json_str_metrics_2 )
+ json_obj_3 = json.loads( json_str_metrics_3 )
+ json_obj_4 = json.loads( json_str_metrics_4 )
+ json_obj_5 = json.loads( json_str_metrics_5 )
+ json_obj_6 = json.loads( json_str_metrics_6 )
+ json_obj_7 = json.loads( json_str_metrics_7 )
graph_timestamp_1 =\
- json_obj_1[graphTimestamp]['value']
+ json_obj_1[ graphTimestamp ][ 'value' ]
graph_timestamp_2 =\
- json_obj_2[graphTimestamp]['value']
+ json_obj_2[ graphTimestamp ][ 'value' ]
graph_timestamp_3 =\
- json_obj_3[graphTimestamp]['value']
+ json_obj_3[ graphTimestamp ][ 'value' ]
graph_timestamp_4 =\
- json_obj_4[graphTimestamp]['value']
+ json_obj_4[ graphTimestamp ][ 'value' ]
graph_timestamp_5 =\
- json_obj_5[graphTimestamp]['value']
+ json_obj_5[ graphTimestamp ][ 'value' ]
graph_timestamp_6 =\
- json_obj_6[graphTimestamp]['value']
+ json_obj_6[ graphTimestamp ][ 'value' ]
graph_timestamp_7 =\
- json_obj_7[graphTimestamp]['value']
-
+ json_obj_7[ graphTimestamp ][ 'value' ]
+
graph_lat_1 = \
- int(graph_timestamp_1) - int(t0_system)
+ int( graph_timestamp_1 ) - int( t0_system )
graph_lat_2 = \
- int(graph_timestamp_2) - int(t0_system)
+ int( graph_timestamp_2 ) - int( t0_system )
graph_lat_3 = \
- int(graph_timestamp_3) - int(t0_system)
+ int( graph_timestamp_3 ) - int( t0_system )
graph_lat_4 = \
- int(graph_timestamp_4) - int(t0_system)
+ int( graph_timestamp_4 ) - int( t0_system )
graph_lat_5 = \
- int(graph_timestamp_5) - int(t0_system)
+ int( graph_timestamp_5 ) - int( t0_system )
graph_lat_6 = \
- int(graph_timestamp_6) - int(t0_system)
+ int( graph_timestamp_6 ) - int( t0_system )
graph_lat_7 = \
- int(graph_timestamp_7) - int(t0_system)
+ int( graph_timestamp_7 ) - int( t0_system )
- main.log.info("Graph Timestamp ONOS1: "+
- str(graph_timestamp_1))
- main.log.info("Graph Timestamp ONOS2: "+
- str(graph_timestamp_2))
- main.log.info("Graph Timestamp ONOS3: "+
- str(graph_timestamp_3))
- main.log.info("Graph Timestamp ONOS4: "+
- str(graph_timestamp_4))
- main.log.info("Graph Timestamp ONOS5: "+
- str(graph_timestamp_5))
- main.log.info("Graph Timestamp ONOS6: "+
- str(graph_timestamp_6))
- main.log.info("Graph Timestamp ONOS7: "+
- str(graph_timestamp_7))
+ main.log.info( "Graph Timestamp ONOS1: " +
+ str( graph_timestamp_1 ) )
+ main.log.info( "Graph Timestamp ONOS2: " +
+ str( graph_timestamp_2 ) )
+ main.log.info( "Graph Timestamp ONOS3: " +
+ str( graph_timestamp_3 ) )
+ main.log.info( "Graph Timestamp ONOS4: " +
+ str( graph_timestamp_4 ) )
+ main.log.info( "Graph Timestamp ONOS5: " +
+ str( graph_timestamp_5 ) )
+ main.log.info( "Graph Timestamp ONOS6: " +
+ str( graph_timestamp_6 ) )
+ main.log.info( "Graph Timestamp ONOS7: " +
+ str( graph_timestamp_7 ) )
- max_graph_lat = max(graph_lat_1,
- graph_lat_2,
- graph_lat_3,
- graph_lat_4,
- graph_lat_5,
- graph_lat_6,
- graph_lat_7)
-
+ max_graph_lat = max( graph_lat_1,
+ graph_lat_2,
+ graph_lat_3,
+ graph_lat_4,
+ graph_lat_5,
+ graph_lat_6,
+ graph_lat_7 )
+
if max_graph_lat > sw_disc_threshold_min\
- and max_graph_lat < sw_disc_threshold_max\
- and int(i) > iter_ignore:
+ and max_graph_lat < sw_disc_threshold_max\
+ and int( i ) > iter_ignore:
sw_discovery_lat_list.append(
- max_graph_lat)
- main.log.info("Sw discovery latency of "+
- str(cluster_count)+" node(s): "+
- str(max_graph_lat)+" ms")
+ max_graph_lat )
+ main.log.info(
+ "Sw discovery latency of " +
+ str( cluster_count ) +
+ " node(s): " +
+ str( max_graph_lat ) +
+ " ms" )
else:
- main.log.info("Switch discovery latency "+
- "exceeded the threshold.")
- main.log.info(str(max_graph_lat)+" ms")
-
+ main.log.info( "Switch discovery latency " +
+ "exceeded the threshold." )
+ main.log.info( str( max_graph_lat ) + " ms" )
+
break
-
+
counter_loop += 1
- time.sleep(3)
- #END WHILE LOOP
-
- #Below is used for reporting SYN / ACK timing
- #of all switches
+ time.sleep( 3 )
+ # END WHILE LOOP
+
+ # Below is used for reporting SYN / ACK timing
+ # of all switches
main.ONOS1.tshark_stop()
syn_ack_timestamp_list = []
if cluster_count < 3:
- #TODO: capture synack on nodes less than 3
- syn_ack_timestamp_list.append(0)
+ # TODO: capture synack on nodes less than 3
+ syn_ack_timestamp_list.append( 0 )
if cluster_count >= 3:
- main.ONOS2.tshark_stop()
+ main.ONOS2.tshark_stop()
main.ONOS3.tshark_stop()
- time.sleep(5)
- os.system("scp "+ONOS_user+"@"+ONOS1_ip+":"+
- "/tmp/syn_ack_onos1_iter"+str(i)+".txt /tmp/")
- os.system("scp "+ONOS_user+"@"+ONOS2_ip+":"+
- "/tmp/syn_ack_onos2_iter"+str(i)+".txt /tmp/")
- os.system("scp "+ONOS_user+"@"+ONOS3_ip+":"+
- "/tmp/syn_ack_onos3_iter"+str(i)+".txt /tmp/")
- time.sleep(5)
- #Read each of the files and append all
- #SYN / ACK timestamps to the list
- with open("/tmp/syn_ack_onos1_iter"+str(i)+".txt") as\
- f_onos1:
+ time.sleep( 5 )
+ os.system(
+ "scp " +
+ ONOS_user +
+ "@" +
+ ONOS1_ip +
+ ":" +
+ "/tmp/syn_ack_onos1_iter" +
+ str( i ) +
+ ".txt /tmp/" )
+ os.system(
+ "scp " +
+ ONOS_user +
+ "@" +
+ ONOS2_ip +
+ ":" +
+ "/tmp/syn_ack_onos2_iter" +
+ str( i ) +
+ ".txt /tmp/" )
+ os.system(
+ "scp " +
+ ONOS_user +
+ "@" +
+ ONOS3_ip +
+ ":" +
+ "/tmp/syn_ack_onos3_iter" +
+ str( i ) +
+ ".txt /tmp/" )
+ time.sleep( 5 )
+ # Read each of the files and append all
+ # SYN / ACK timestamps to the list
+ with open( "/tmp/syn_ack_onos1_iter" + str( i ) + ".txt" ) as\
+ f_onos1:
for line in f_onos1:
- line = line.split(" ")
+ line = line.split( " " )
try:
- float(line[1])
- syn_ack_timestamp_list.append(line[1])
+ float( line[ 1 ] )
+ syn_ack_timestamp_list.append( line[ 1 ] )
except ValueError:
- main.log.info("String cannot be converted")
- with open("/tmp/syn_ack_onos2_iter"+str(i)+".txt") as\
- f_onos2:
+ main.log.info( "String cannot be converted" )
+ with open( "/tmp/syn_ack_onos2_iter" + str( i ) + ".txt" ) as\
+ f_onos2:
for line in f_onos2:
- line = line.split(" ")
+ line = line.split( " " )
try:
- float(line[1])
- syn_ack_timestamp_list.append(line[1])
+ float( line[ 1 ] )
+ syn_ack_timestamp_list.append( line[ 1 ] )
except ValueError:
- main.log.info("String cannot be converted")
- with open("/tmp/syn_ack_onos3_iter"+str(i)+".txt") as\
- f_onos3:
+ main.log.info( "String cannot be converted" )
+ with open( "/tmp/syn_ack_onos3_iter" + str( i ) + ".txt" ) as\
+ f_onos3:
for line in f_onos3:
- line = line.split(" ")
+ line = line.split( " " )
try:
- float(line[1])
- syn_ack_timestamp_list.append(line[1])
+ float( line[ 1 ] )
+ syn_ack_timestamp_list.append( line[ 1 ] )
except ValueError:
- main.log.info("String cannot be converted")
+ main.log.info( "String cannot be converted" )
if cluster_count >= 4:
- main.ONOS4.tshark_stop()
- time.sleep(5)
- os.system("scp "+ONOS_user+"@"+ONOS4_ip+":"+
- "/tmp/syn_ack_onos4_iter"+str(i)+".txt /tmp/")
- time.sleep(5)
- with open("/tmp/syn_ack_onos4_iter"+str(i)+".txt") as\
- f_onos4:
+ main.ONOS4.tshark_stop()
+ time.sleep( 5 )
+ os.system(
+ "scp " +
+ ONOS_user +
+ "@" +
+ ONOS4_ip +
+ ":" +
+ "/tmp/syn_ack_onos4_iter" +
+ str( i ) +
+ ".txt /tmp/" )
+ time.sleep( 5 )
+ with open( "/tmp/syn_ack_onos4_iter" + str( i ) + ".txt" ) as\
+ f_onos4:
for line in f_onos4:
- line = line.split(" ")
+ line = line.split( " " )
try:
- float(line[1])
- syn_ack_timestamp_list.append(line[1])
+ float( line[ 1 ] )
+ syn_ack_timestamp_list.append( line[ 1 ] )
except ValueError:
- main.log.info("String cannot be converted")
+ main.log.info( "String cannot be converted" )
if cluster_count >= 5:
main.ONOS5.tshark_stop()
- time.sleep(5)
- os.system("scp "+ONOS_user+"@"+ONOS5_ip+":"+
- "/tmp/syn_ack_onos5_iter"+str(i)+".txt /tmp/")
- time.sleep(5)
- with open("/tmp/syn_ack_onos5_iter"+str(i)+".txt") as\
- f_onos5:
+ time.sleep( 5 )
+ os.system(
+ "scp " +
+ ONOS_user +
+ "@" +
+ ONOS5_ip +
+ ":" +
+ "/tmp/syn_ack_onos5_iter" +
+ str( i ) +
+ ".txt /tmp/" )
+ time.sleep( 5 )
+ with open( "/tmp/syn_ack_onos5_iter" + str( i ) + ".txt" ) as\
+ f_onos5:
for line in f_onos5:
- line = line.split(" ")
+ line = line.split( " " )
try:
- float(line[1])
- syn_ack_timestamp_list.append(line[1])
+ float( line[ 1 ] )
+ syn_ack_timestamp_list.append( line[ 1 ] )
except ValueError:
- main.log.info("String cannot be converted")
+ main.log.info( "String cannot be converted" )
if cluster_count >= 6:
main.ONOS6.tshark_stop()
- time.sleep(5)
- os.system("scp "+ONOS_user+"@"+ONOS6_ip+":"+
- "/tmp/syn_ack_onos6_iter"+str(i)+".txt /tmp/")
- time.sleep(5)
- with open("/tmp/syn_ack_onos6_iter"+str(i)+".txt") as\
- f_onos6:
+ time.sleep( 5 )
+ os.system(
+ "scp " +
+ ONOS_user +
+ "@" +
+ ONOS6_ip +
+ ":" +
+ "/tmp/syn_ack_onos6_iter" +
+ str( i ) +
+ ".txt /tmp/" )
+ time.sleep( 5 )
+ with open( "/tmp/syn_ack_onos6_iter" + str( i ) + ".txt" ) as\
+ f_onos6:
for line in f_onos6:
- line = line.split(" ")
+ line = line.split( " " )
try:
- float(line[1])
- syn_ack_timestamp_list.append(line[1])
+ float( line[ 1 ] )
+ syn_ack_timestamp_list.append( line[ 1 ] )
except ValueError:
- main.log.info("String cannot be converted")
+ main.log.info( "String cannot be converted" )
if cluster_count == 7:
main.ONOS7.tshark_stop()
- time.sleep(5)
- os.system("scp "+ONOS_user+"@"+ONOS7_ip+":"+
- "/tmp/syn_ack_onos7_iter"+str(i)+".txt /tmp/")
- time.sleep(5)
- with open("/tmp/syn_ack_onos7_iter"+str(i)+".txt") as\
- f_onos7:
+ time.sleep( 5 )
+ os.system(
+ "scp " +
+ ONOS_user +
+ "@" +
+ ONOS7_ip +
+ ":" +
+ "/tmp/syn_ack_onos7_iter" +
+ str( i ) +
+ ".txt /tmp/" )
+ time.sleep( 5 )
+ with open( "/tmp/syn_ack_onos7_iter" + str( i ) + ".txt" ) as\
+ f_onos7:
for line in f_onos7:
- line = line.split(" ")
+ line = line.split( " " )
try:
- float(line[1])
- syn_ack_timestamp_list.append(line[1])
+ float( line[ 1 ] )
+ syn_ack_timestamp_list.append( line[ 1 ] )
except ValueError:
- main.log.info("String cannot be converted")
-
- #Sort the list by timestamp
- syn_ack_timestamp_list = sorted(syn_ack_timestamp_list)
- print "syn_ack_-1 " + str(syn_ack_timestamp_list)
+ main.log.info( "String cannot be converted" )
+
+ # Sort the list by timestamp
+ syn_ack_timestamp_list = sorted( syn_ack_timestamp_list )
+ print "syn_ack_-1 " + str( syn_ack_timestamp_list )
syn_ack_delta =\
- int(float(syn_ack_timestamp_list[-1])*1000) -\
- int(float(syn_ack_timestamp_list[0])*1000)
+ int( float( syn_ack_timestamp_list[ -1 ] ) * 1000 ) -\
+ int( float( syn_ack_timestamp_list[ 0 ] ) * 1000 )
- main.log.info("Switch connection attempt delta iteration "+
- str(i)+": "+str(syn_ack_delta))
- syn_ack_delta_list.append(syn_ack_delta)
- #END ITERATION LOOP
- #REPORT HERE
+ main.log.info( "Switch connection attempt delta iteration " +
+ str( i ) + ": " + str( syn_ack_delta ) )
+ syn_ack_delta_list.append( syn_ack_delta )
+ # END ITERATION LOOP
+ # REPORT HERE
- if len(sw_discovery_lat_list) > 0:
- sw_lat_avg = sum(sw_discovery_lat_list) / \
- len(sw_discovery_lat_list)
- sw_lat_dev = numpy.std(sw_discovery_lat_list)
+ if len( sw_discovery_lat_list ) > 0:
+ sw_lat_avg = sum( sw_discovery_lat_list ) / \
+ len( sw_discovery_lat_list )
+ sw_lat_dev = numpy.std( sw_discovery_lat_list )
else:
sw_lat_avg = 0
sw_lat_dev = 0
assertion = main.FALSE
-
- main.log.report("Switch connection attempt time avg "+
- "(last sw SYN/ACK time - first sw SYN/ACK time) "+
- str(sum(syn_ack_delta_list)/len(syn_ack_delta_list)) +
- " ms")
- main.log.report(str(num_sw)+" Switch discovery lat for "+\
- str(cluster_count)+" instance(s): ")
- main.log.report("Avg: "+str(sw_lat_avg)+" ms "+
- "Std Deviation: "+str(round(sw_lat_dev,1))+" ms")
- utilities.assert_equals(expect=main.TRUE, actual=assertion,
- onpass="Switch discovery convergence latency" +\
- " for "+str(cluster_count)+" nodes successful",
- onfail="Switch discovery convergence latency" +\
- " test failed")
-
- def CASE3(self, main):
- '''
+ main.log.report( "Switch connection attempt time avg " +
+ "(last sw SYN/ACK time - first sw SYN/ACK time) " +
+ str( sum( syn_ack_delta_list ) /
+ len( syn_ack_delta_list ) ) +
+ " ms" )
+ main.log.report( str( num_sw ) + " Switch discovery lat for " +
+ str( cluster_count ) + " instance(s): " )
+ main.log.report( "Avg: " +
+ str( sw_lat_avg ) +
+ " ms " +
+ "Std Deviation: " +
+ str( round( sw_lat_dev, 1 ) ) +
+ " ms" )
+
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=assertion,
+ onpass="Switch discovery convergence latency" +
+ " for " +
+ str( cluster_count ) +
+ " nodes successful",
+ onfail="Switch discovery convergence latency" +
+ " test failed" )
+
+ def CASE3( self, main ):
+ """
Increase number of nodes and initiate CLI
- '''
+ """
import time
import subprocess
import os
import requests
import json
-
- ONOS1_ip = main.params['CTRL']['ip1']
- ONOS2_ip = main.params['CTRL']['ip2']
- ONOS3_ip = main.params['CTRL']['ip3']
- ONOS4_ip = main.params['CTRL']['ip4']
- ONOS5_ip = main.params['CTRL']['ip5']
- ONOS6_ip = main.params['CTRL']['ip6']
- ONOS7_ip = main.params['CTRL']['ip7']
-
- cell_name = main.params['ENV']['cellName']
-
- MN1_ip = main.params['MN']['ip1']
- BENCH_ip = main.params['BENCH']['ip']
- #NOTE:We start with cluster_count at 3. The first
- #case already initialized ONOS1. Increase the
- #cluster count and start from 3.
- #You can optionally change the increment to
- #test steps of node sizes, such as 3,5,7
-
+ ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+ ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
+ ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
+ ONOS4_ip = main.params[ 'CTRL' ][ 'ip4' ]
+ ONOS5_ip = main.params[ 'CTRL' ][ 'ip5' ]
+ ONOS6_ip = main.params[ 'CTRL' ][ 'ip6' ]
+ ONOS7_ip = main.params[ 'CTRL' ][ 'ip7' ]
+
+ cell_name = main.params[ 'ENV' ][ 'cellName' ]
+
+ MN1_ip = main.params[ 'MN' ][ 'ip1' ]
+ BENCH_ip = main.params[ 'BENCH' ][ 'ip' ]
+
+ # NOTE:We start with cluster_count at 3. The first
+ # case already initialized ONOS1. Increase the
+ # cluster count and start from 3.
+ # You can optionally change the increment to
+ # test steps of node sizes, such as 3,5,7
+
global cluster_count
- cluster_count += 2
- main.log.report("Increasing cluster size to "+
- str(cluster_count))
+ cluster_count += 2
+ main.log.report( "Increasing cluster size to " +
+ str( cluster_count ) )
install_result = main.FALSE
- #Supports up to 7 node configuration
- #TODO: Cleanup this ridiculous repetitive code
+ # Supports up to 7 node configuration
+ # TODO: Cleanup this ridiculous repetitive code
if cluster_count == 3:
install_result = \
- main.ONOSbench.onos_install(node=ONOS2_ip)
+ main.ONOSbench.onos_install( node=ONOS2_ip )
install_result = \
- main.ONOSbench.onos_install(node=ONOS3_ip)
- time.sleep(5)
- main.log.info("Starting CLI")
- main.ONOS2cli.start_onos_cli(ONOS2_ip)
- main.ONOS3cli.start_onos_cli(ONOS3_ip)
- main.ONOS1cli.add_node(ONOS2_ip, ONOS2_ip)
- main.ONOS1cli.add_node(ONOS3_ip, ONOS3_ip)
-
+ main.ONOSbench.onos_install( node=ONOS3_ip )
+ time.sleep( 5 )
+ main.log.info( "Starting CLI" )
+ main.ONOS2cli.start_onos_cli( ONOS2_ip )
+ main.ONOS3cli.start_onos_cli( ONOS3_ip )
+ main.ONOS1cli.add_node( ONOS2_ip, ONOS2_ip )
+ main.ONOS1cli.add_node( ONOS3_ip, ONOS3_ip )
+
if cluster_count == 4:
- main.log.info("Installing ONOS on node 4")
+ main.log.info( "Installing ONOS on node 4" )
install_result = \
- main.ONOSbench.onos_install(node=ONOS4_ip)
- time.sleep(5)
- main.log.info("Starting CLI")
- main.ONOS4cli.start_onos_cli(ONOS4_ip)
- main.ONOS1cli.add_node(ONOS4_ip, ONOS4_ip)
-
+ main.ONOSbench.onos_install( node=ONOS4_ip )
+ time.sleep( 5 )
+ main.log.info( "Starting CLI" )
+ main.ONOS4cli.start_onos_cli( ONOS4_ip )
+ main.ONOS1cli.add_node( ONOS4_ip, ONOS4_ip )
+
elif cluster_count == 5:
- main.log.info("Installing ONOS on nodes 4 and 5")
+ main.log.info( "Installing ONOS on nodes 4 and 5" )
install_result2 = \
- main.ONOSbench.onos_install(options="",node=ONOS4_ip)
+ main.ONOSbench.onos_install( options="", node=ONOS4_ip )
install_result3 = \
- main.ONOSbench.onos_install(options="",node=ONOS5_ip)
- time.sleep(5)
- main.log.info("Starting CLI")
- main.ONOS4cli.start_onos_cli(ONOS4_ip)
- main.ONOS5cli.start_onos_cli(ONOS5_ip)
- main.ONOS1cli.add_node(ONOS4_ip, ONOS4_ip)
- main.ONOS1cli.add_node(ONOS5_ip, ONOS5_ip)
+ main.ONOSbench.onos_install( options="", node=ONOS5_ip )
+ time.sleep( 5 )
+ main.log.info( "Starting CLI" )
+ main.ONOS4cli.start_onos_cli( ONOS4_ip )
+ main.ONOS5cli.start_onos_cli( ONOS5_ip )
+ main.ONOS1cli.add_node( ONOS4_ip, ONOS4_ip )
+ main.ONOS1cli.add_node( ONOS5_ip, ONOS5_ip )
install_result = install_result2 and install_result3
elif cluster_count == 6:
- main.log.info("Installing ONOS on nodes 4, 5,and 6")
+ main.log.info( "Installing ONOS on nodes 4, 5,and 6" )
install_result1 = \
- main.ONOSbench.onos_install(options="",node=ONOS4_ip)
+ main.ONOSbench.onos_install( options="", node=ONOS4_ip )
install_result2 = \
- main.ONOSbench.onos_install(options="",node=ONOS5_ip)
+ main.ONOSbench.onos_install( options="", node=ONOS5_ip )
install_result3 = \
- main.ONOSbench.onos_install(node=ONOS6_ip)
- time.sleep(5)
- main.log.info("Starting CLI")
- main.ONOS4cli.start_onos_cli(ONOS4_ip)
- main.ONOS5cli.start_onos_cli(ONOS5_ip)
- main.ONOS6cli.start_onos_cli(ONOS6_ip)
- main.ONOS1cli.add_node(ONOS4_ip, ONOS4_ip)
- main.ONOS1cli.add_node(ONOS5_ip, ONOS5_ip)
- main.ONOS1cli.add_node(ONOS6_ip, ONOS6_ip)
+ main.ONOSbench.onos_install( node=ONOS6_ip )
+ time.sleep( 5 )
+ main.log.info( "Starting CLI" )
+ main.ONOS4cli.start_onos_cli( ONOS4_ip )
+ main.ONOS5cli.start_onos_cli( ONOS5_ip )
+ main.ONOS6cli.start_onos_cli( ONOS6_ip )
+ main.ONOS1cli.add_node( ONOS4_ip, ONOS4_ip )
+ main.ONOS1cli.add_node( ONOS5_ip, ONOS5_ip )
+ main.ONOS1cli.add_node( ONOS6_ip, ONOS6_ip )
install_result = install_result1 and install_result2 and\
- install_result3
+ install_result3
elif cluster_count == 7:
- main.log.info("Installing ONOS on nodes 4, 5, 6,and 7")
+ main.log.info( "Installing ONOS on nodes 4, 5, 6,and 7" )
install_result3 = \
- main.ONOSbench.onos_install(node=ONOS6_ip)
+ main.ONOSbench.onos_install( node=ONOS6_ip )
install_result4 = \
- main.ONOSbench.onos_install(node=ONOS7_ip)
- main.log.info("Starting CLI")
- main.ONOS4cli.start_onos_cli(ONOS4_ip)
- main.ONOS5cli.start_onos_cli(ONOS5_ip)
- main.ONOS6cli.start_onos_cli(ONOS6_ip)
- main.ONOS7cli.start_onos_cli(ONOS7_ip)
- main.ONOS1cli.add_node(ONOS4_ip, ONOS4_ip)
- main.ONOS1cli.add_node(ONOS5_ip, ONOS5_ip)
- main.ONOS1cli.add_node(ONOS6_ip, ONOS6_ip)
- main.ONOS1cli.add_node(ONOS7_ip, ONOS7_ip)
+ main.ONOSbench.onos_install( node=ONOS7_ip )
+ main.log.info( "Starting CLI" )
+ main.ONOS4cli.start_onos_cli( ONOS4_ip )
+ main.ONOS5cli.start_onos_cli( ONOS5_ip )
+ main.ONOS6cli.start_onos_cli( ONOS6_ip )
+ main.ONOS7cli.start_onos_cli( ONOS7_ip )
+ main.ONOS1cli.add_node( ONOS4_ip, ONOS4_ip )
+ main.ONOS1cli.add_node( ONOS5_ip, ONOS5_ip )
+ main.ONOS1cli.add_node( ONOS6_ip, ONOS6_ip )
+ main.ONOS1cli.add_node( ONOS7_ip, ONOS7_ip )
install_result = \
- install_result3 and install_result4
+ install_result3 and install_result4
- time.sleep(5)
+ time.sleep( 5 )
if install_result == main.TRUE:
assertion = main.TRUE
else:
assertion = main.FALSE
-
- utilities.assert_equals(expect=main.TRUE, actual=assertion,
- onpass="Scale out to "+str(cluster_count)+\
- " nodes successful",
- onfail="Scale out to "+str(cluster_count)+\
- " nodes failed")
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=assertion,
+ onpass="Scale out to " +
+ str( cluster_count ) +
+ " nodes successful",
+ onfail="Scale out to " +
+ str( cluster_count ) +
+ " nodes failed" )
- def CASE4(self, main):
- '''
+ def CASE4( self, main ):
+ """
Cleanup ONOS nodes and Increase topology size
- '''
- #TODO: use meaningful assertion
- assertion=main.TRUE
+ """
+ # TODO: use meaningful assertion
+ assertion = main.TRUE
- ONOS1_ip = main.params['CTRL']['ip1']
- ONOS2_ip = main.params['CTRL']['ip2']
- ONOS3_ip = main.params['CTRL']['ip3']
- ONOS4_ip = main.params['CTRL']['ip4']
- ONOS5_ip = main.params['CTRL']['ip5']
- ONOS6_ip = main.params['CTRL']['ip6']
- ONOS7_ip = main.params['CTRL']['ip7']
- MN1_ip = main.params['MN']['ip1']
- BENCH_ip = main.params['BENCH']['ip']
+ ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+ ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
+ ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
+ ONOS4_ip = main.params[ 'CTRL' ][ 'ip4' ]
+ ONOS5_ip = main.params[ 'CTRL' ][ 'ip5' ]
+ ONOS6_ip = main.params[ 'CTRL' ][ 'ip6' ]
+ ONOS7_ip = main.params[ 'CTRL' ][ 'ip7' ]
+ MN1_ip = main.params[ 'MN' ][ 'ip1' ]
+ BENCH_ip = main.params[ 'BENCH' ][ 'ip' ]
- main.log.info("Uninstalling previous instances")
- main.ONOSbench.onos_uninstall(node_ip = ONOS2_ip)
- main.ONOSbench.onos_uninstall(node_ip = ONOS3_ip)
- main.ONOSbench.onos_uninstall(node_ip = ONOS4_ip)
- main.ONOSbench.onos_uninstall(node_ip = ONOS5_ip)
- main.ONOSbench.onos_uninstall(node_ip = ONOS6_ip)
- main.ONOSbench.onos_uninstall(node_ip = ONOS7_ip)
-
+ main.log.info( "Uninstalling previous instances" )
+ main.ONOSbench.onos_uninstall( node_ip=ONOS2_ip )
+ main.ONOSbench.onos_uninstall( node_ip=ONOS3_ip )
+ main.ONOSbench.onos_uninstall( node_ip=ONOS4_ip )
+ main.ONOSbench.onos_uninstall( node_ip=ONOS5_ip )
+ main.ONOSbench.onos_uninstall( node_ip=ONOS6_ip )
+ main.ONOSbench.onos_uninstall( node_ip=ONOS7_ip )
+
global topo_iteration
global cluster_count
- cluster_count = 1
+ cluster_count = 1
topo_iteration += 1
- main.log.report("Increasing topology size")
- utilities.assert_equals(expect=main.TRUE, actual=assertion,
- onpass="Topology size increased successfully",
- onfail="Topology size was not increased")
-
-
-
+ main.log.report( "Increasing topology size" )
+ utilities.assert_equals( expect=main.TRUE, actual=assertion,
+ onpass="Topology size increased successfully",
+ onfail="Topology size was not increased" )
diff --git a/TestON/tests/TopoPerfNext/TopoPerfNext.py b/TestON/tests/TopoPerfNext/TopoPerfNext.py
index 65bc7a9..87d7378 100644
--- a/TestON/tests/TopoPerfNext/TopoPerfNext.py
+++ b/TestON/tests/TopoPerfNext/TopoPerfNext.py
@@ -1,37 +1,39 @@
-#TopoPerfNext
+# TopoPerfNext
#
-#Topology Performance test for ONOS-next
+# Topology Performance test for ONOS-next
#
-#andrew@onlab.us
+# andrew@onlab.us
#
-#If your machine does not come with numpy
-#run the following command:
-#sudo apt-get install python-numpy python-scipy
+# If your machine does not come with numpy
+# run the following command:
+# sudo apt-get install python-numpy python-scipy
import time
import sys
import os
import re
+
class TopoPerfNext:
- def __init__(self):
+
+ def __init__( self ):
self.default = ''
- def CASE1(self, main):
- '''
+ def CASE1( self, main ):
+ """
ONOS startup sequence
- '''
+ """
import time
-
- cell_name = main.params['ENV']['cellName']
- git_pull = main.params['GIT']['autoPull']
- checkout_branch = main.params['GIT']['checkout']
+ cell_name = main.params[ 'ENV' ][ 'cellName' ]
- ONOS1_ip = main.params['CTRL']['ip1']
- ONOS2_ip = main.params['CTRL']['ip2']
- ONOS3_ip = main.params['CTRL']['ip3']
-
+ git_pull = main.params[ 'GIT' ][ 'autoPull' ]
+ checkout_branch = main.params[ 'GIT' ][ 'checkout' ]
+
+ ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+ ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
+ ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
+
#### Hardcoded ONOS nodes particular to my env ####
ONOS4_ip = "10.128.174.4"
ONOS5_ip = "10.128.174.5"
@@ -39,108 +41,108 @@
ONOS7_ip = "10.128.174.7"
#### ####
- MN1_ip = main.params['MN']['ip1']
- BENCH_ip = main.params['BENCH']['ip']
+ MN1_ip = main.params[ 'MN' ][ 'ip1' ]
+ BENCH_ip = main.params[ 'BENCH' ][ 'ip' ]
- topo_cfg_file = main.params['TEST']['topo_config_file']
- topo_cfg_name = main.params['TEST']['topo_config_name']
-
- main.case("Setting up test environment")
- main.log.info("Copying topology event accumulator config"+\
- " to ONOS /package/etc")
- main.ONOSbench.handle.sendline("cp ~/"+\
- topo_cfg_file+\
- " ~/ONOS/tools/package/etc/"+\
- topo_cfg_name)
- main.ONOSbench.handle.expect("\$")
+ topo_cfg_file = main.params[ 'TEST' ][ 'topo_config_file' ]
+ topo_cfg_name = main.params[ 'TEST' ][ 'topo_config_name' ]
- main.log.report("Setting up test environment")
+ main.case( "Setting up test environment" )
+ main.log.info( "Copying topology event accumulator config" +
+ " to ONOS /package/etc" )
+ main.ONOSbench.handle.sendline( "cp ~/" +
+ topo_cfg_file +
+ " ~/ONOS/tools/package/etc/" +
+ topo_cfg_name )
+ main.ONOSbench.handle.expect( "\$" )
- main.step("Cleaning previously installed ONOS if any")
- main.ONOSbench.onos_uninstall(node_ip=ONOS4_ip)
- main.ONOSbench.onos_uninstall(node_ip=ONOS5_ip)
- main.ONOSbench.onos_uninstall(node_ip=ONOS6_ip)
- main.ONOSbench.onos_uninstall(node_ip=ONOS7_ip)
+ main.log.report( "Setting up test environment" )
- main.step("Creating cell file")
+ main.step( "Cleaning previously installed ONOS if any" )
+ main.ONOSbench.onos_uninstall( node_ip=ONOS4_ip )
+ main.ONOSbench.onos_uninstall( node_ip=ONOS5_ip )
+ main.ONOSbench.onos_uninstall( node_ip=ONOS6_ip )
+ main.ONOSbench.onos_uninstall( node_ip=ONOS7_ip )
+
+ main.step( "Creating cell file" )
cell_file_result = main.ONOSbench.create_cell_file(
- BENCH_ip, cell_name, MN1_ip, "onos-core,onos-app-metrics",
- ONOS1_ip, ONOS2_ip, ONOS3_ip)
+ BENCH_ip, cell_name, MN1_ip, "onos-core,onos-app-metrics",
+ ONOS1_ip, ONOS2_ip, ONOS3_ip )
- main.step("Applying cell file to environment")
- cell_apply_result = main.ONOSbench.set_cell(cell_name)
+ main.step( "Applying cell file to environment" )
+ cell_apply_result = main.ONOSbench.set_cell( cell_name )
verify_cell_result = main.ONOSbench.verify_cell()
-
- #NOTE: This step may be removed after proper
- # copy cat log functionality
- main.step("Removing raft/copy-cat logs from ONOS nodes")
- main.ONOSbench.onos_remove_raft_logs()
- time.sleep(30)
- main.step("Git checkout and pull "+checkout_branch)
+ # NOTE: This step may be removed after proper
+ # copy cat log functionality
+ main.step( "Removing raft/copy-cat logs from ONOS nodes" )
+ main.ONOSbench.onos_remove_raft_logs()
+ time.sleep( 30 )
+
+ main.step( "Git checkout and pull " + checkout_branch )
if git_pull == 'on':
checkout_result = \
- main.ONOSbench.git_checkout(checkout_branch)
+ main.ONOSbench.git_checkout( checkout_branch )
pull_result = main.ONOSbench.git_pull()
else:
checkout_result = main.TRUE
pull_result = main.TRUE
- main.log.info("Skipped git checkout and pull")
+ main.log.info( "Skipped git checkout and pull" )
- #TODO: Uncomment when wiki posting works
- #main.log.report("Commit information - ")
- #main.ONOSbench.get_version(report=True)
+ # TODO: Uncomment when wiki posting works
+ #main.log.report( "Commit information - " )
+ # main.ONOSbench.get_version( report=True )
- main.step("Using mvn clean & install")
+ main.step( "Using mvn clean & install" )
#mvn_result = main.ONOSbench.clean_install()
mvn_result = main.TRUE
- main.step("Set cell for ONOS cli env")
- main.ONOS1cli.set_cell(cell_name)
- main.ONOS2cli.set_cell(cell_name)
- main.ONOS3cli.set_cell(cell_name)
+ main.step( "Set cell for ONOS cli env" )
+ main.ONOS1cli.set_cell( cell_name )
+ main.ONOS2cli.set_cell( cell_name )
+ main.ONOS3cli.set_cell( cell_name )
- main.step("Creating ONOS package")
+ main.step( "Creating ONOS package" )
package_result = main.ONOSbench.onos_package()
- main.step("Installing ONOS package")
- install1_result = main.ONOSbench.onos_install(node=ONOS1_ip)
- install2_result = main.ONOSbench.onos_install(node=ONOS2_ip)
- install3_result = main.ONOSbench.onos_install(node=ONOS3_ip)
+ main.step( "Installing ONOS package" )
+ install1_result = main.ONOSbench.onos_install( node=ONOS1_ip )
+ install2_result = main.ONOSbench.onos_install( node=ONOS2_ip )
+ install3_result = main.ONOSbench.onos_install( node=ONOS3_ip )
- time.sleep(10)
+ time.sleep( 10 )
- main.step("Start onos cli")
- cli1 = main.ONOS1cli.start_onos_cli(ONOS1_ip)
- cli2 = main.ONOS2cli.start_onos_cli(ONOS2_ip)
- cli3 = main.ONOS3cli.start_onos_cli(ONOS3_ip)
+ main.step( "Start onos cli" )
+ cli1 = main.ONOS1cli.start_onos_cli( ONOS1_ip )
+ cli2 = main.ONOS2cli.start_onos_cli( ONOS2_ip )
+ cli3 = main.ONOS3cli.start_onos_cli( ONOS3_ip )
- utilities.assert_equals(expect=main.TRUE,
- actual= cell_file_result and cell_apply_result and\
- verify_cell_result and checkout_result and\
- pull_result and mvn_result and\
- install1_result and install2_result and\
- install3_result,
- onpass="Test Environment setup successful",
- onfail="Failed to setup test environment")
+ utilities.assert_equals( expect=main.TRUE,
+ actual=cell_file_result and cell_apply_result and
+ verify_cell_result and checkout_result and
+ pull_result and mvn_result and
+ install1_result and install2_result and
+ install3_result,
+ onpass="Test Environment setup successful",
+ onfail="Failed to setup test environment" )
- def CASE2(self, main):
- '''
+ def CASE2( self, main ):
+ """
Assign s1 to ONOS1 and measure latency
-
+
There are 4 levels of latency measurements to this test:
- 1) End-to-end measurement: Complete end-to-end measurement
- from TCP (SYN/ACK) handshake to Graph change
- 2) OFP-to-graph measurement: 'ONOS processing' snippet of
+ 1 ) End-to-end measurement: Complete end-to-end measurement
+ from TCP ( SYN/ACK ) handshake to Graph change
+ 2 ) OFP-to-graph measurement: 'ONOS processing' snippet of
measurement from OFP Vendor message to Graph change
- 3) OFP-to-device measurement: 'ONOS processing without
+ 3 ) OFP-to-device measurement: 'ONOS processing without
graph change' snippet of measurement from OFP vendor
message to Device change timestamp
- 4) T0-to-device measurement: Measurement that includes
- the switch handshake to devices timestamp without
- the graph view change. (TCP handshake -> Device
- change)
- '''
+ 4 ) T0-to-device measurement: Measurement that includes
+ the switch handshake to devices timestamp without
+ the graph view change. ( TCP handshake -> Device
+ change )
+ """
import time
import subprocess
import json
@@ -148,414 +150,436 @@
import os
import numpy
- ONOS1_ip = main.params['CTRL']['ip1']
- ONOS2_ip = main.params['CTRL']['ip2']
- ONOS3_ip = main.params['CTRL']['ip3']
- ONOS_user = main.params['CTRL']['user']
+ ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+ ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
+ ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
+ ONOS_user = main.params[ 'CTRL' ][ 'user' ]
- default_sw_port = main.params['CTRL']['port1']
-
- #Number of iterations of case
- num_iter = main.params['TEST']['numIter']
- #Number of first 'x' iterations to ignore:
- iter_ignore = int(main.params['TEST']['iterIgnore'])
+ default_sw_port = main.params[ 'CTRL' ][ 'port1' ]
- #Timestamp 'keys' for json metrics output.
- #These are subject to change, hence moved into params
- deviceTimestamp = main.params['JSON']['deviceTimestamp']
- graphTimestamp = main.params['JSON']['graphTimestamp']
+ # Number of iterations of case
+ num_iter = main.params[ 'TEST' ][ 'numIter' ]
+ # Number of first 'x' iterations to ignore:
+ iter_ignore = int( main.params[ 'TEST' ][ 'iterIgnore' ] )
- debug_mode = main.params['TEST']['debugMode']
- onos_log = main.params['TEST']['onosLogFile']
+ # Timestamp 'keys' for json metrics output.
+ # These are subject to change, hence moved into params
+ deviceTimestamp = main.params[ 'JSON' ][ 'deviceTimestamp' ]
+ graphTimestamp = main.params[ 'JSON' ][ 'graphTimestamp' ]
- #Threshold for the test
- threshold_str = main.params['TEST']['singleSwThreshold']
- threshold_obj = threshold_str.split(",")
- threshold_min = int(threshold_obj[0])
- threshold_max = int(threshold_obj[1])
+ debug_mode = main.params[ 'TEST' ][ 'debugMode' ]
+ onos_log = main.params[ 'TEST' ][ 'onosLogFile' ]
- #List of switch add latency collected from
- #all iterations
+ # Threshold for the test
+ threshold_str = main.params[ 'TEST' ][ 'singleSwThreshold' ]
+ threshold_obj = threshold_str.split( "," )
+ threshold_min = int( threshold_obj[ 0 ] )
+ threshold_max = int( threshold_obj[ 1 ] )
+
+ # List of switch add latency collected from
+ # all iterations
latency_end_to_end_list = []
latency_ofp_to_graph_list = []
latency_ofp_to_device_list = []
latency_t0_to_device_list = []
latency_tcp_to_ofp_list = []
- #Directory/file to store tshark results
+ # Directory/file to store tshark results
tshark_of_output = "/tmp/tshark_of_topo.txt"
tshark_tcp_output = "/tmp/tshark_tcp_topo.txt"
- #String to grep in tshark output
- tshark_tcp_string = "TCP 74 "+default_sw_port
+ # String to grep in tshark output
+ tshark_tcp_string = "TCP 74 " + default_sw_port
tshark_of_string = "OFP 86 Vendor"
-
- #Initialize assertion to TRUE
+
+ # Initialize assertion to TRUE
assertion = main.TRUE
-
- local_time = time.strftime('%x %X')
- local_time = local_time.replace("/","")
- local_time = local_time.replace(" ","_")
- local_time = local_time.replace(":","")
+
+ local_time = time.strftime( '%x %X' )
+ local_time = local_time.replace( "/", "" )
+ local_time = local_time.replace( " ", "_" )
+ local_time = local_time.replace( ":", "" )
if debug_mode == 'on':
- main.ONOS1.tshark_pcap("eth0",
- "/tmp/single_sw_lat_pcap_"+local_time)
+ main.ONOS1.tshark_pcap( "eth0",
+ "/tmp/single_sw_lat_pcap_" + local_time )
- main.log.info("TEST")
+ main.log.info( "TEST" )
- main.log.report("Latency of adding one switch to controller")
- main.log.report("First "+str(iter_ignore)+" iterations ignored"+
- " for jvm warmup time")
- main.log.report("Total iterations of test: "+str(num_iter))
+ main.log.report( "Latency of adding one switch to controller" )
+ main.log.report(
+ "First " +
+ str( iter_ignore ) +
+ " iterations ignored" +
+ " for jvm warmup time" )
+ main.log.report( "Total iterations of test: " + str( num_iter ) )
- for i in range(0, int(num_iter)):
- main.log.info("Starting tshark capture")
+ for i in range( 0, int( num_iter ) ):
+ main.log.info( "Starting tshark capture" )
- #* TCP [ACK, SYN] is used as t0_a, the
- # very first "exchange" between ONOS and
+ #* TCP [ ACK, SYN ] is used as t0_a, the
+ # very first "exchange" between ONOS and
# the switch for end-to-end measurement
- #* OFP [Stats Reply] is used for t0_b
+ #* OFP [ Stats Reply ] is used for t0_b
# the very last OFP message between ONOS
# and the switch for ONOS measurement
- main.ONOS1.tshark_grep(tshark_tcp_string,
- tshark_tcp_output)
- main.ONOS1.tshark_grep(tshark_of_string,
- tshark_of_output)
+ main.ONOS1.tshark_grep( tshark_tcp_string,
+ tshark_tcp_output )
+ main.ONOS1.tshark_grep( tshark_of_string,
+ tshark_of_output )
- #Wait and ensure tshark is started and
- #capturing
- time.sleep(10)
+ # Wait and ensure tshark is started and
+ # capturing
+ time.sleep( 10 )
- main.log.info("Assigning s1 to controller")
+ main.log.info( "Assigning s1 to controller" )
- main.Mininet1.assign_sw_controller(sw="1",
- ip1=ONOS1_ip, port1=default_sw_port)
+ main.Mininet1.assign_sw_controller(
+ sw="1",
+ ip1=ONOS1_ip,
+ port1=default_sw_port )
- #Wait and ensure switch is assigned
- #before stopping tshark
- time.sleep(30)
-
- main.log.info("Stopping all Tshark processes")
+ # Wait and ensure switch is assigned
+ # before stopping tshark
+ time.sleep( 30 )
+
+ main.log.info( "Stopping all Tshark processes" )
main.ONOS1.stop_tshark()
- #tshark output is saved in ONOS. Use subprocess
- #to copy over files to TestON for parsing
- main.log.info("Copying over tshark files")
-
- #TCP CAPTURE ****
- #Copy the tshark output from ONOS machine to
- #TestON machine in tshark_tcp_output directory>file
- os.system("scp "+ONOS_user+"@"+ONOS1_ip+":"+
- tshark_tcp_output+" /tmp/")
- tcp_file = open(tshark_tcp_output, 'r')
- temp_text = tcp_file.readline()
- temp_text = temp_text.split(" ")
+ # tshark output is saved in ONOS. Use subprocess
+ # to copy over files to TestON for parsing
+ main.log.info( "Copying over tshark files" )
- main.log.info("Object read in from TCP capture: "+
- str(temp_text))
- if len(temp_text) > 1:
- t0_tcp = float(temp_text[1])*1000.0
+ # TCP CAPTURE ****
+ # Copy the tshark output from ONOS machine to
+ # TestON machine in tshark_tcp_output directory>file
+ os.system( "scp " + ONOS_user + "@" + ONOS1_ip + ":" +
+ tshark_tcp_output + " /tmp/" )
+ tcp_file = open( tshark_tcp_output, 'r' )
+ temp_text = tcp_file.readline()
+ temp_text = temp_text.split( " " )
+
+ main.log.info( "Object read in from TCP capture: " +
+ str( temp_text ) )
+ if len( temp_text ) > 1:
+ t0_tcp = float( temp_text[ 1 ] ) * 1000.0
else:
- main.log.error("Tshark output file for TCP"+
- " returned unexpected results")
+ main.log.error( "Tshark output file for TCP" +
+ " returned unexpected results" )
t0_tcp = 0
assertion = main.FALSE
-
+
tcp_file.close()
#****************
- #OF CAPTURE ****
- os.system("scp "+ONOS_user+"@"+ONOS1_ip+":"+
- tshark_of_output+" /tmp/")
- of_file = open(tshark_of_output, 'r')
-
+ # OF CAPTURE ****
+ os.system( "scp " + ONOS_user + "@" + ONOS1_ip + ":" +
+ tshark_of_output + " /tmp/" )
+ of_file = open( tshark_of_output, 'r' )
+
line_ofp = ""
- #Read until last line of file
+ # Read until last line of file
while True:
temp_text = of_file.readline()
- if temp_text !='':
+ if temp_text != '':
line_ofp = temp_text
else:
- break
- obj = line_ofp.split(" ")
-
- main.log.info("Object read in from OFP capture: "+
- str(line_ofp))
-
- if len(line_ofp) > 1:
- t0_ofp = float(obj[1])*1000.0
+ break
+ obj = line_ofp.split( " " )
+
+ main.log.info( "Object read in from OFP capture: " +
+ str( line_ofp ) )
+
+ if len( line_ofp ) > 1:
+ t0_ofp = float( obj[ 1 ] ) * 1000.0
else:
- main.log.error("Tshark output file for OFP"+
- " returned unexpected results")
+ main.log.error( "Tshark output file for OFP" +
+ " returned unexpected results" )
t0_ofp = 0
assertion = main.FALSE
-
+
of_file.close()
#****************
-
+
json_str_1 = main.ONOS1cli.topology_events_metrics()
json_str_2 = main.ONOS2cli.topology_events_metrics()
json_str_3 = main.ONOS3cli.topology_events_metrics()
- json_obj_1 = json.loads(json_str_1)
- json_obj_2 = json.loads(json_str_2)
- json_obj_3 = json.loads(json_str_3)
+ json_obj_1 = json.loads( json_str_1 )
+ json_obj_2 = json.loads( json_str_2 )
+ json_obj_3 = json.loads( json_str_3 )
- #Obtain graph timestamp. This timestsamp captures
- #the epoch time at which the topology graph was updated.
+ # Obtain graph timestamp. This timestsamp captures
+ # the epoch time at which the topology graph was updated.
graph_timestamp_1 = \
- json_obj_1[graphTimestamp]['value']
+ json_obj_1[ graphTimestamp ][ 'value' ]
graph_timestamp_2 = \
- json_obj_2[graphTimestamp]['value']
+ json_obj_2[ graphTimestamp ][ 'value' ]
graph_timestamp_3 = \
- json_obj_3[graphTimestamp]['value']
+ json_obj_3[ graphTimestamp ][ 'value' ]
- #Obtain device timestamp. This timestamp captures
- #the epoch time at which the device event happened
+ # Obtain device timestamp. This timestamp captures
+ # the epoch time at which the device event happened
device_timestamp_1 = \
- json_obj_1[deviceTimestamp]['value']
+ json_obj_1[ deviceTimestamp ][ 'value' ]
device_timestamp_2 = \
- json_obj_2[deviceTimestamp]['value']
+ json_obj_2[ deviceTimestamp ][ 'value' ]
device_timestamp_3 = \
- json_obj_3[deviceTimestamp]['value']
+ json_obj_3[ deviceTimestamp ][ 'value' ]
- #t0 to device processing latency
- delta_device_1 = int(device_timestamp_1) - int(t0_tcp)
- delta_device_2 = int(device_timestamp_2) - int(t0_tcp)
- delta_device_3 = int(device_timestamp_3) - int(t0_tcp)
-
- #Get average of delta from all instances
+ # t0 to device processing latency
+ delta_device_1 = int( device_timestamp_1 ) - int( t0_tcp )
+ delta_device_2 = int( device_timestamp_2 ) - int( t0_tcp )
+ delta_device_3 = int( device_timestamp_3 ) - int( t0_tcp )
+
+ # Get average of delta from all instances
avg_delta_device = \
- (int(delta_device_1)+\
- int(delta_device_2)+\
- int(delta_device_3)) / 3
+ ( int( delta_device_1 ) +
+ int( delta_device_2 ) +
+ int( delta_device_3 ) ) / 3
- #Ensure avg delta meets the threshold before appending
+ # Ensure avg delta meets the threshold before appending
if avg_delta_device > 0.0 and avg_delta_device < 10000\
- and int(i) > iter_ignore:
- latency_t0_to_device_list.append(avg_delta_device)
+ and int( i ) > iter_ignore:
+ latency_t0_to_device_list.append( avg_delta_device )
else:
- main.log.info("Results for t0-to-device ignored"+\
- "due to excess in threshold / warmup iteration.")
+ main.log.info(
+ "Results for t0-to-device ignored" +
+ "due to excess in threshold / warmup iteration." )
- #t0 to graph processing latency (end-to-end)
- delta_graph_1 = int(graph_timestamp_1) - int(t0_tcp)
- delta_graph_2 = int(graph_timestamp_2) - int(t0_tcp)
- delta_graph_3 = int(graph_timestamp_3) - int(t0_tcp)
-
- #Get average of delta from all instances
+ # t0 to graph processing latency ( end-to-end )
+ delta_graph_1 = int( graph_timestamp_1 ) - int( t0_tcp )
+ delta_graph_2 = int( graph_timestamp_2 ) - int( t0_tcp )
+ delta_graph_3 = int( graph_timestamp_3 ) - int( t0_tcp )
+
+ # Get average of delta from all instances
avg_delta_graph = \
- (int(delta_graph_1)+\
- int(delta_graph_2)+\
- int(delta_graph_3)) / 3
+ ( int( delta_graph_1 ) +
+ int( delta_graph_2 ) +
+ int( delta_graph_3 ) ) / 3
- #Ensure avg delta meets the threshold before appending
+ # Ensure avg delta meets the threshold before appending
if avg_delta_graph > 0.0 and avg_delta_graph < 10000\
- and int(i) > iter_ignore:
- latency_end_to_end_list.append(avg_delta_graph)
+ and int( i ) > iter_ignore:
+ latency_end_to_end_list.append( avg_delta_graph )
else:
- main.log.info("Results for end-to-end ignored"+\
- "due to excess in threshold")
+ main.log.info( "Results for end-to-end ignored" +
+ "due to excess in threshold" )
- #ofp to graph processing latency (ONOS processing)
- delta_ofp_graph_1 = int(graph_timestamp_1) - int(t0_ofp)
- delta_ofp_graph_2 = int(graph_timestamp_2) - int(t0_ofp)
- delta_ofp_graph_3 = int(graph_timestamp_3) - int(t0_ofp)
-
+ # ofp to graph processing latency ( ONOS processing )
+ delta_ofp_graph_1 = int( graph_timestamp_1 ) - int( t0_ofp )
+ delta_ofp_graph_2 = int( graph_timestamp_2 ) - int( t0_ofp )
+ delta_ofp_graph_3 = int( graph_timestamp_3 ) - int( t0_ofp )
+
avg_delta_ofp_graph = \
- (int(delta_ofp_graph_1)+\
- int(delta_ofp_graph_2)+\
- int(delta_ofp_graph_3)) / 3
-
+ ( int( delta_ofp_graph_1 ) +
+ int( delta_ofp_graph_2 ) +
+ int( delta_ofp_graph_3 ) ) / 3
+
if avg_delta_ofp_graph > threshold_min \
and avg_delta_ofp_graph < threshold_max\
- and int(i) > iter_ignore:
- latency_ofp_to_graph_list.append(avg_delta_ofp_graph)
- elif avg_delta_ofp_graph > (-10) and \
+ and int( i ) > iter_ignore:
+ latency_ofp_to_graph_list.append( avg_delta_ofp_graph )
+ elif avg_delta_ofp_graph > ( -10 ) and \
avg_delta_ofp_graph < 0.0 and\
- int(i) > iter_ignore:
- main.log.info("Sub-millisecond result likely; "+
- "negative result was rounded to 0")
- #NOTE: Current metrics framework does not
- #support sub-millisecond accuracy. Therefore,
- #if the result is negative, we can reasonably
- #conclude sub-millisecond results and just
- #append the best rounded effort - 0 ms.
- latency_ofp_to_graph_list.append(0)
+ int( i ) > iter_ignore:
+ main.log.info( "Sub-millisecond result likely; " +
+ "negative result was rounded to 0" )
+ # NOTE: Current metrics framework does not
+ # support sub-millisecond accuracy. Therefore,
+ # if the result is negative, we can reasonably
+ # conclude sub-millisecond results and just
+ # append the best rounded effort - 0 ms.
+ latency_ofp_to_graph_list.append( 0 )
else:
- main.log.info("Results for ofp-to-graph "+\
- "ignored due to excess in threshold")
+ main.log.info( "Results for ofp-to-graph " +
+ "ignored due to excess in threshold" )
- #ofp to device processing latency (ONOS processing)
- delta_ofp_device_1 = float(device_timestamp_1) - float(t0_ofp)
- delta_ofp_device_2 = float(device_timestamp_2) - float(t0_ofp)
- delta_ofp_device_3 = float(device_timestamp_3) - float(t0_ofp)
-
+ # ofp to device processing latency ( ONOS processing )
+ delta_ofp_device_1 = float( device_timestamp_1 ) - float( t0_ofp )
+ delta_ofp_device_2 = float( device_timestamp_2 ) - float( t0_ofp )
+ delta_ofp_device_3 = float( device_timestamp_3 ) - float( t0_ofp )
+
avg_delta_ofp_device = \
- (float(delta_ofp_device_1)+\
- float(delta_ofp_device_2)+\
- float(delta_ofp_device_3)) / 3
-
- #NOTE: ofp - delta measurements are occasionally negative
- # due to system time misalignment.
- latency_ofp_to_device_list.append(avg_delta_ofp_device)
+ ( float( delta_ofp_device_1 ) +
+ float( delta_ofp_device_2 ) +
+ float( delta_ofp_device_3 ) ) / 3
- delta_ofp_tcp = int(t0_ofp) - int(t0_tcp)
+ # NOTE: ofp - delta measurements are occasionally negative
+ # due to system time misalignment.
+ latency_ofp_to_device_list.append( avg_delta_ofp_device )
+
+ delta_ofp_tcp = int( t0_ofp ) - int( t0_tcp )
if delta_ofp_tcp > threshold_min \
and delta_ofp_tcp < threshold_max and\
- int(i) > iter_ignore:
- latency_tcp_to_ofp_list.append(delta_ofp_tcp)
+ int( i ) > iter_ignore:
+ latency_tcp_to_ofp_list.append( delta_ofp_tcp )
else:
- main.log.info("Results fo tcp-to-ofp "+\
- "ignored due to excess in threshold")
+ main.log.info( "Results fo tcp-to-ofp " +
+ "ignored due to excess in threshold" )
- #TODO:
- #Fetch logs upon threshold excess
+ # TODO:
+ # Fetch logs upon threshold excess
- main.log.info("ONOS1 delta end-to-end: "+
- str(delta_graph_1) + " ms")
- main.log.info("ONOS2 delta end-to-end: "+
- str(delta_graph_2) + " ms")
- main.log.info("ONOS3 delta end-to-end: "+
- str(delta_graph_3) + " ms")
+ main.log.info( "ONOS1 delta end-to-end: " +
+ str( delta_graph_1 ) + " ms" )
+ main.log.info( "ONOS2 delta end-to-end: " +
+ str( delta_graph_2 ) + " ms" )
+ main.log.info( "ONOS3 delta end-to-end: " +
+ str( delta_graph_3 ) + " ms" )
- main.log.info("ONOS1 delta OFP - graph: "+
- str(delta_ofp_graph_1) + " ms")
- main.log.info("ONOS2 delta OFP - graph: "+
- str(delta_ofp_graph_2) + " ms")
- main.log.info("ONOS3 delta OFP - graph: "+
- str(delta_ofp_graph_3) + " ms")
-
- main.log.info("ONOS1 delta device - t0: "+
- str(delta_device_1) + " ms")
- main.log.info("ONOS2 delta device - t0: "+
- str(delta_device_2) + " ms")
- main.log.info("ONOS3 delta device - t0: "+
- str(delta_device_3) + " ms")
-
- main.log.info("TCP to OFP delta: "+
- str(delta_ofp_tcp) + " ms")
- #main.log.info("ONOS1 delta OFP - device: "+
- # str(delta_ofp_device_1) + " ms")
- #main.log.info("ONOS2 delta OFP - device: "+
- # str(delta_ofp_device_2) + " ms")
- #main.log.info("ONOS3 delta OFP - device: "+
- # str(delta_ofp_device_3) + " ms")
+ main.log.info( "ONOS1 delta OFP - graph: " +
+ str( delta_ofp_graph_1 ) + " ms" )
+ main.log.info( "ONOS2 delta OFP - graph: " +
+ str( delta_ofp_graph_2 ) + " ms" )
+ main.log.info( "ONOS3 delta OFP - graph: " +
+ str( delta_ofp_graph_3 ) + " ms" )
- main.step("Remove switch from controller")
- main.Mininet1.delete_sw_controller("s1")
+ main.log.info( "ONOS1 delta device - t0: " +
+ str( delta_device_1 ) + " ms" )
+ main.log.info( "ONOS2 delta device - t0: " +
+ str( delta_device_2 ) + " ms" )
+ main.log.info( "ONOS3 delta device - t0: " +
+ str( delta_device_3 ) + " ms" )
- time.sleep(5)
+ main.log.info( "TCP to OFP delta: " +
+ str( delta_ofp_tcp ) + " ms" )
+ # main.log.info( "ONOS1 delta OFP - device: "+
+ # str( delta_ofp_device_1 ) + " ms" )
+ # main.log.info( "ONOS2 delta OFP - device: "+
+ # str( delta_ofp_device_2 ) + " ms" )
+ # main.log.info( "ONOS3 delta OFP - device: "+
+ # str( delta_ofp_device_3 ) + " ms" )
- #END of for loop iteration
+ main.step( "Remove switch from controller" )
+ main.Mininet1.delete_sw_controller( "s1" )
- #If there is at least 1 element in each list,
- #pass the test case
- if len(latency_end_to_end_list) > 0 and\
- len(latency_ofp_to_graph_list) > 0 and\
- len(latency_ofp_to_device_list) > 0 and\
- len(latency_t0_to_device_list) > 0 and\
- len(latency_tcp_to_ofp_list) > 0:
+ time.sleep( 5 )
+
+ # END of for loop iteration
+
+ # If there is at least 1 element in each list,
+ # pass the test case
+ if len( latency_end_to_end_list ) > 0 and\
+ len( latency_ofp_to_graph_list ) > 0 and\
+ len( latency_ofp_to_device_list ) > 0 and\
+ len( latency_t0_to_device_list ) > 0 and\
+ len( latency_tcp_to_ofp_list ) > 0:
assertion = main.TRUE
- elif len(latency_end_to_end_list) == 0:
- #The appending of 0 here is to prevent
- #the min,max,sum functions from failing
- #below
- latency_end_to_end_list.append(0)
+ elif len( latency_end_to_end_list ) == 0:
+ # The appending of 0 here is to prevent
+ # the min,max,sum functions from failing
+ # below
+ latency_end_to_end_list.append( 0 )
assertion = main.FALSE
- elif len(latency_ofp_to_graph_list) == 0:
- latency_ofp_to_graph_list.append(0)
+ elif len( latency_ofp_to_graph_list ) == 0:
+ latency_ofp_to_graph_list.append( 0 )
assertion = main.FALSE
- elif len(latency_ofp_to_device_list) == 0:
- latency_ofp_to_device_list.append(0)
+ elif len( latency_ofp_to_device_list ) == 0:
+ latency_ofp_to_device_list.append( 0 )
assertion = main.FALSE
- elif len(latency_t0_to_device_list) == 0:
- latency_t0_to_device_list.append(0)
+ elif len( latency_t0_to_device_list ) == 0:
+ latency_t0_to_device_list.append( 0 )
assertion = main.FALSE
- elif len(latency_tcp_to_ofp_list) == 0:
- latency_tcp_to_ofp_list.append(0)
+ elif len( latency_tcp_to_ofp_list ) == 0:
+ latency_tcp_to_ofp_list.append( 0 )
assertion = main.FALSE
- #Calculate min, max, avg of latency lists
+ # Calculate min, max, avg of latency lists
latency_end_to_end_max = \
- int(max(latency_end_to_end_list))
+ int( max( latency_end_to_end_list ) )
latency_end_to_end_min = \
- int(min(latency_end_to_end_list))
+ int( min( latency_end_to_end_list ) )
latency_end_to_end_avg = \
- (int(sum(latency_end_to_end_list)) / \
- len(latency_end_to_end_list))
+ ( int( sum( latency_end_to_end_list ) ) /
+ len( latency_end_to_end_list ) )
latency_end_to_end_std_dev = \
- str(round(numpy.std(latency_end_to_end_list),1))
+ str( round( numpy.std( latency_end_to_end_list ), 1 ) )
latency_ofp_to_graph_max = \
- int(max(latency_ofp_to_graph_list))
+ int( max( latency_ofp_to_graph_list ) )
latency_ofp_to_graph_min = \
- int(min(latency_ofp_to_graph_list))
+ int( min( latency_ofp_to_graph_list ) )
latency_ofp_to_graph_avg = \
- (int(sum(latency_ofp_to_graph_list)) / \
- len(latency_ofp_to_graph_list))
+ ( int( sum( latency_ofp_to_graph_list ) ) /
+ len( latency_ofp_to_graph_list ) )
latency_ofp_to_graph_std_dev = \
- str(round(numpy.std(latency_ofp_to_graph_list),1))
+ str( round( numpy.std( latency_ofp_to_graph_list ), 1 ) )
latency_ofp_to_device_max = \
- int(max(latency_ofp_to_device_list))
+ int( max( latency_ofp_to_device_list ) )
latency_ofp_to_device_min = \
- int(min(latency_ofp_to_device_list))
+ int( min( latency_ofp_to_device_list ) )
latency_ofp_to_device_avg = \
- (int(sum(latency_ofp_to_device_list)) / \
- len(latency_ofp_to_device_list))
+ ( int( sum( latency_ofp_to_device_list ) ) /
+ len( latency_ofp_to_device_list ) )
latency_ofp_to_device_std_dev = \
- str(round(numpy.std(latency_ofp_to_device_list),1))
+ str( round( numpy.std( latency_ofp_to_device_list ), 1 ) )
latency_t0_to_device_max = \
- int(max(latency_t0_to_device_list))
+ int( max( latency_t0_to_device_list ) )
latency_t0_to_device_min = \
- int(min(latency_t0_to_device_list))
+ int( min( latency_t0_to_device_list ) )
latency_t0_to_device_avg = \
- (int(sum(latency_t0_to_device_list)) / \
- len(latency_t0_to_device_list))
+ ( int( sum( latency_t0_to_device_list ) ) /
+ len( latency_t0_to_device_list ) )
latency_ofp_to_device_std_dev = \
- str(round(numpy.std(latency_t0_to_device_list),1))
+ str( round( numpy.std( latency_t0_to_device_list ), 1 ) )
latency_tcp_to_ofp_max = \
- int(max(latency_tcp_to_ofp_list))
+ int( max( latency_tcp_to_ofp_list ) )
latency_tcp_to_ofp_min = \
- int(min(latency_tcp_to_ofp_list))
+ int( min( latency_tcp_to_ofp_list ) )
latency_tcp_to_ofp_avg = \
- (int(sum(latency_tcp_to_ofp_list)) / \
- len(latency_tcp_to_ofp_list))
+ ( int( sum( latency_tcp_to_ofp_list ) ) /
+ len( latency_tcp_to_ofp_list ) )
latency_tcp_to_ofp_std_dev = \
- str(round(numpy.std(latency_tcp_to_ofp_list),1))
+ str( round( numpy.std( latency_tcp_to_ofp_list ), 1 ) )
- main.log.report("Switch add - End-to-end latency: "+\
- "Avg: "+str(latency_end_to_end_avg)+" ms "+
- "Std Deviation: "+latency_end_to_end_std_dev+" ms")
- main.log.report("Switch add - OFP-to-Graph latency: "+\
- "Note: results are not accurate to sub-millisecond. "+
- "Any sub-millisecond results are rounded to 0 ms. ")
- main.log.report("Avg: "+str(latency_ofp_to_graph_avg)+" ms "+
- "Std Deviation: "+latency_ofp_to_graph_std_dev+" ms")
- main.log.report("Switch add - TCP-to-OFP latency: "+\
- "Avg: "+str(latency_tcp_to_ofp_avg)+" ms "+
- "Std Deviation: "+latency_tcp_to_ofp_std_dev+" ms")
+ main.log.report(
+ "Switch add - End-to-end latency: " +
+ "Avg: " +
+ str( latency_end_to_end_avg ) +
+ " ms " +
+ "Std Deviation: " +
+ latency_end_to_end_std_dev +
+ " ms" )
+ main.log.report(
+ "Switch add - OFP-to-Graph latency: " +
+ "Note: results are not accurate to sub-millisecond. " +
+ "Any sub-millisecond results are rounded to 0 ms. " )
+ main.log.report(
+ "Avg: " +
+ str( latency_ofp_to_graph_avg ) +
+ " ms " +
+ "Std Deviation: " +
+ latency_ofp_to_graph_std_dev +
+ " ms" )
+ main.log.report(
+ "Switch add - TCP-to-OFP latency: " +
+ "Avg: " +
+ str( latency_tcp_to_ofp_avg ) +
+ " ms " +
+ "Std Deviation: " +
+ latency_tcp_to_ofp_std_dev +
+ " ms" )
if debug_mode == 'on':
- main.ONOS1.cp_logs_to_dir("/opt/onos/log/karaf.log",
- "/tmp/", copy_file_name="sw_lat_karaf")
+ main.ONOS1.cp_logs_to_dir( "/opt/onos/log/karaf.log",
+ "/tmp/", copy_file_name="sw_lat_karaf" )
- utilities.assert_equals(expect=main.TRUE, actual=assertion,
- onpass="Switch latency test successful",
- onfail="Switch latency test failed")
+ utilities.assert_equals( expect=main.TRUE, actual=assertion,
+ onpass="Switch latency test successful",
+ onfail="Switch latency test failed" )
- def CASE3(self, main):
- '''
+ def CASE3( self, main ):
+ """
Bring port up / down and measure latency.
Port enable / disable is simulated by ifconfig up / down
-
- In ONOS-next, we must ensure that the port we are
+
+ In ONOS-next, we must ensure that the port we are
manipulating is connected to another switch with a valid
connection. Otherwise, graph view will not be updated.
- '''
+ """
import time
import subprocess
import os
@@ -563,925 +587,961 @@
import json
import numpy
- ONOS1_ip = main.params['CTRL']['ip1']
- ONOS2_ip = main.params['CTRL']['ip2']
- ONOS3_ip = main.params['CTRL']['ip3']
- ONOS_user = main.params['CTRL']['user']
+ ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+ ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
+ ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
+ ONOS_user = main.params[ 'CTRL' ][ 'user' ]
- default_sw_port = main.params['CTRL']['port1']
-
+ default_sw_port = main.params[ 'CTRL' ][ 'port1' ]
+
assertion = main.TRUE
- #Number of iterations of case
- num_iter = main.params['TEST']['numIter']
-
- #Timestamp 'keys' for json metrics output.
- #These are subject to change, hence moved into params
- deviceTimestamp = main.params['JSON']['deviceTimestamp']
- graphTimestamp = main.params['JSON']['graphTimestamp']
-
- debug_mode = main.params['TEST']['debugMode']
+ # Number of iterations of case
+ num_iter = main.params[ 'TEST' ][ 'numIter' ]
- local_time = time.strftime('%x %X')
- local_time = local_time.replace("/","")
- local_time = local_time.replace(" ","_")
- local_time = local_time.replace(":","")
+ # Timestamp 'keys' for json metrics output.
+ # These are subject to change, hence moved into params
+ deviceTimestamp = main.params[ 'JSON' ][ 'deviceTimestamp' ]
+ graphTimestamp = main.params[ 'JSON' ][ 'graphTimestamp' ]
+
+ debug_mode = main.params[ 'TEST' ][ 'debugMode' ]
+
+ local_time = time.strftime( '%x %X' )
+ local_time = local_time.replace( "/", "" )
+ local_time = local_time.replace( " ", "_" )
+ local_time = local_time.replace( ":", "" )
if debug_mode == 'on':
- main.ONOS1.tshark_pcap("eth0",
- "/tmp/port_lat_pcap_"+local_time)
+ main.ONOS1.tshark_pcap( "eth0",
+ "/tmp/port_lat_pcap_" + local_time )
- #Threshold for this test case
- up_threshold_str = main.params['TEST']['portUpThreshold']
- down_threshold_str = main.params['TEST']['portDownThreshold']
-
- up_threshold_obj = up_threshold_str.split(",")
- down_threshold_obj = down_threshold_str.split(",")
+ # Threshold for this test case
+ up_threshold_str = main.params[ 'TEST' ][ 'portUpThreshold' ]
+ down_threshold_str = main.params[ 'TEST' ][ 'portDownThreshold' ]
- up_threshold_min = int(up_threshold_obj[0])
- up_threshold_max = int(up_threshold_obj[1])
+ up_threshold_obj = up_threshold_str.split( "," )
+ down_threshold_obj = down_threshold_str.split( "," )
- down_threshold_min = int(down_threshold_obj[0])
- down_threshold_max = int(down_threshold_obj[1])
+ up_threshold_min = int( up_threshold_obj[ 0 ] )
+ up_threshold_max = int( up_threshold_obj[ 1 ] )
- #NOTE: Some hardcoded variables you may need to configure
+ down_threshold_min = int( down_threshold_obj[ 0 ] )
+ down_threshold_max = int( down_threshold_obj[ 1 ] )
+
+ # NOTE: Some hardcoded variables you may need to configure
# besides the params
-
+
tshark_port_status = "OFP 130 Port Status"
tshark_port_up = "/tmp/tshark_port_up.txt"
tshark_port_down = "/tmp/tshark_port_down.txt"
interface_config = "s1-eth1"
- main.log.report("Port enable / disable latency")
- main.log.report("Simulated by ifconfig up / down")
- main.log.report("Total iterations of test: "+str(num_iter))
+ main.log.report( "Port enable / disable latency" )
+ main.log.report( "Simulated by ifconfig up / down" )
+ main.log.report( "Total iterations of test: " + str( num_iter ) )
- main.step("Assign switches s1 and s2 to controller 1")
- main.Mininet1.assign_sw_controller(sw="1",ip1=ONOS1_ip,
- port1=default_sw_port)
- main.Mininet1.assign_sw_controller(sw="2",ip1=ONOS1_ip,
- port1=default_sw_port)
+ main.step( "Assign switches s1 and s2 to controller 1" )
+ main.Mininet1.assign_sw_controller( sw="1", ip1=ONOS1_ip,
+ port1=default_sw_port )
+ main.Mininet1.assign_sw_controller( sw="2", ip1=ONOS1_ip,
+ port1=default_sw_port )
- #Give enough time for metrics to propagate the
- #assign controller event. Otherwise, these events may
- #carry over to our measurements
- time.sleep(15)
+ # Give enough time for metrics to propagate the
+ # assign controller event. Otherwise, these events may
+ # carry over to our measurements
+ time.sleep( 15 )
port_up_device_to_ofp_list = []
port_up_graph_to_ofp_list = []
port_down_device_to_ofp_list = []
port_down_graph_to_ofp_list = []
- for i in range(0, int(num_iter)):
- main.step("Starting wireshark capture for port status down")
- main.ONOS1.tshark_grep(tshark_port_status,
- tshark_port_down)
-
- time.sleep(5)
+ for i in range( 0, int( num_iter ) ):
+ main.step( "Starting wireshark capture for port status down" )
+ main.ONOS1.tshark_grep( tshark_port_status,
+ tshark_port_down )
- #Disable interface that is connected to switch 2
- main.step("Disable port: "+interface_config)
- main.Mininet1.handle.sendline("sh ifconfig "+
- interface_config+" down")
- main.Mininet1.handle.expect("mininet>")
+ time.sleep( 5 )
- time.sleep(3)
+ # Disable interface that is connected to switch 2
+ main.step( "Disable port: " + interface_config )
+ main.Mininet1.handle.sendline( "sh ifconfig " +
+ interface_config + " down" )
+ main.Mininet1.handle.expect( "mininet>" )
+
+ time.sleep( 3 )
main.ONOS1.tshark_stop()
-
- main.step("Obtain t1 by metrics call")
+
+ main.step( "Obtain t1 by metrics call" )
json_str_up_1 = main.ONOS1cli.topology_events_metrics()
json_str_up_2 = main.ONOS2cli.topology_events_metrics()
json_str_up_3 = main.ONOS3cli.topology_events_metrics()
- json_obj_1 = json.loads(json_str_up_1)
- json_obj_2 = json.loads(json_str_up_2)
- json_obj_3 = json.loads(json_str_up_3)
-
- #Copy tshark output file from ONOS to TestON instance
- #/tmp directory
- os.system("scp "+ONOS_user+"@"+ONOS1_ip+":"+
- tshark_port_down+" /tmp/")
+ json_obj_1 = json.loads( json_str_up_1 )
+ json_obj_2 = json.loads( json_str_up_2 )
+ json_obj_3 = json.loads( json_str_up_3 )
- f_port_down = open(tshark_port_down, 'r')
- #Get first line of port down event from tshark
+ # Copy tshark output file from ONOS to TestON instance
+ #/tmp directory
+ os.system( "scp " + ONOS_user + "@" + ONOS1_ip + ":" +
+ tshark_port_down + " /tmp/" )
+
+ f_port_down = open( tshark_port_down, 'r' )
+ # Get first line of port down event from tshark
f_line = f_port_down.readline()
- obj_down = f_line.split(" ")
- if len(f_line) > 0:
- timestamp_begin_pt_down = int(float(obj_down[1])*1000)
- main.log.info("Port down begin timestamp: "+
- str(timestamp_begin_pt_down))
+ obj_down = f_line.split( " " )
+ if len( f_line ) > 0:
+ timestamp_begin_pt_down = int( float( obj_down[ 1 ] ) * 1000 )
+ main.log.info( "Port down begin timestamp: " +
+ str( timestamp_begin_pt_down ) )
else:
- main.log.info("Tshark output file returned unexpected"+
- " results: "+str(obj_down))
+ main.log.info( "Tshark output file returned unexpected" +
+ " results: " + str( obj_down ) )
timestamp_begin_pt_down = 0
-
+
f_port_down.close()
- main.log.info("TEST tshark obj: "+str(obj_down))
+ main.log.info( "TEST tshark obj: " + str( obj_down ) )
- time.sleep(3)
+ time.sleep( 3 )
- #Obtain graph timestamp. This timestsamp captures
- #the epoch time at which the topology graph was updated.
+ # Obtain graph timestamp. This timestsamp captures
+ # the epoch time at which the topology graph was updated.
graph_timestamp_1 = \
- json_obj_1[graphTimestamp]['value']
+ json_obj_1[ graphTimestamp ][ 'value' ]
graph_timestamp_2 = \
- json_obj_2[graphTimestamp]['value']
+ json_obj_2[ graphTimestamp ][ 'value' ]
graph_timestamp_3 = \
- json_obj_3[graphTimestamp]['value']
+ json_obj_3[ graphTimestamp ][ 'value' ]
- main.log.info("TEST graph timestamp ONOS1: "+
- str(graph_timestamp_1))
+ main.log.info( "TEST graph timestamp ONOS1: " +
+ str( graph_timestamp_1 ) )
- #Obtain device timestamp. This timestamp captures
- #the epoch time at which the device event happened
+ # Obtain device timestamp. This timestamp captures
+ # the epoch time at which the device event happened
device_timestamp_1 = \
- json_obj_1[deviceTimestamp]['value']
+ json_obj_1[ deviceTimestamp ][ 'value' ]
device_timestamp_2 = \
- json_obj_2[deviceTimestamp]['value']
+ json_obj_2[ deviceTimestamp ][ 'value' ]
device_timestamp_3 = \
- json_obj_3[deviceTimestamp]['value']
+ json_obj_3[ deviceTimestamp ][ 'value' ]
- #Get delta between graph event and OFP
- pt_down_graph_to_ofp_1 = int(graph_timestamp_1) -\
- int(timestamp_begin_pt_down)
- pt_down_graph_to_ofp_2 = int(graph_timestamp_2) -\
- int(timestamp_begin_pt_down)
- pt_down_graph_to_ofp_3 = int(graph_timestamp_3) -\
- int(timestamp_begin_pt_down)
+ # Get delta between graph event and OFP
+ pt_down_graph_to_ofp_1 = int( graph_timestamp_1 ) -\
+ int( timestamp_begin_pt_down )
+ pt_down_graph_to_ofp_2 = int( graph_timestamp_2 ) -\
+ int( timestamp_begin_pt_down )
+ pt_down_graph_to_ofp_3 = int( graph_timestamp_3 ) -\
+ int( timestamp_begin_pt_down )
- #Get delta between device event and OFP
- pt_down_device_to_ofp_1 = int(device_timestamp_1) -\
- int(timestamp_begin_pt_down)
- pt_down_device_to_ofp_2 = int(device_timestamp_2) -\
- int(timestamp_begin_pt_down)
- pt_down_device_to_ofp_3 = int(device_timestamp_3) -\
- int(timestamp_begin_pt_down)
-
- #Caluclate average across clusters
+ # Get delta between device event and OFP
+ pt_down_device_to_ofp_1 = int( device_timestamp_1 ) -\
+ int( timestamp_begin_pt_down )
+ pt_down_device_to_ofp_2 = int( device_timestamp_2 ) -\
+ int( timestamp_begin_pt_down )
+ pt_down_device_to_ofp_3 = int( device_timestamp_3 ) -\
+ int( timestamp_begin_pt_down )
+
+ # Caluclate average across clusters
pt_down_graph_to_ofp_avg =\
- (int(pt_down_graph_to_ofp_1) +
- int(pt_down_graph_to_ofp_2) +
- int(pt_down_graph_to_ofp_3)) / 3
+ ( int( pt_down_graph_to_ofp_1 ) +
+ int( pt_down_graph_to_ofp_2 ) +
+ int( pt_down_graph_to_ofp_3 ) ) / 3
pt_down_device_to_ofp_avg = \
- (int(pt_down_device_to_ofp_1) +
- int(pt_down_device_to_ofp_2) +
- int(pt_down_device_to_ofp_3)) / 3
+ ( int( pt_down_device_to_ofp_1 ) +
+ int( pt_down_device_to_ofp_2 ) +
+ int( pt_down_device_to_ofp_3 ) ) / 3
if pt_down_graph_to_ofp_avg > down_threshold_min and \
pt_down_graph_to_ofp_avg < down_threshold_max:
port_down_graph_to_ofp_list.append(
- pt_down_graph_to_ofp_avg)
- main.log.info("Port down: graph to ofp avg: "+
- str(pt_down_graph_to_ofp_avg) + " ms")
+ pt_down_graph_to_ofp_avg )
+ main.log.info( "Port down: graph to ofp avg: " +
+ str( pt_down_graph_to_ofp_avg ) + " ms" )
else:
- main.log.info("Average port down graph-to-ofp result" +
- " exceeded the threshold: "+
- str(pt_down_graph_to_ofp_avg))
+ main.log.info( "Average port down graph-to-ofp result" +
+ " exceeded the threshold: " +
+ str( pt_down_graph_to_ofp_avg ) )
if pt_down_device_to_ofp_avg > 0 and \
pt_down_device_to_ofp_avg < 1000:
port_down_device_to_ofp_list.append(
- pt_down_device_to_ofp_avg)
- main.log.info("Port down: device to ofp avg: "+
- str(pt_down_device_to_ofp_avg) + " ms")
+ pt_down_device_to_ofp_avg )
+ main.log.info( "Port down: device to ofp avg: " +
+ str( pt_down_device_to_ofp_avg ) + " ms" )
else:
- main.log.info("Average port down device-to-ofp result" +
- " exceeded the threshold: "+
- str(pt_down_device_to_ofp_avg))
+ main.log.info( "Average port down device-to-ofp result" +
+ " exceeded the threshold: " +
+ str( pt_down_device_to_ofp_avg ) )
- #Port up events
- main.step("Enable port and obtain timestamp")
- main.step("Starting wireshark capture for port status up")
- main.ONOS1.tshark_grep(tshark_port_status, tshark_port_up)
- time.sleep(5)
+ # Port up events
+ main.step( "Enable port and obtain timestamp" )
+ main.step( "Starting wireshark capture for port status up" )
+ main.ONOS1.tshark_grep( tshark_port_status, tshark_port_up )
+ time.sleep( 5 )
- main.Mininet1.handle.sendline("sh ifconfig "+
- interface_config+" up")
- main.Mininet1.handle.expect("mininet>")
-
- #Allow time for tshark to capture event
- time.sleep(3)
+ main.Mininet1.handle.sendline( "sh ifconfig " +
+ interface_config + " up" )
+ main.Mininet1.handle.expect( "mininet>" )
+
+ # Allow time for tshark to capture event
+ time.sleep( 3 )
main.ONOS1.tshark_stop()
- #Obtain metrics shortly afterwards
- #This timestsamp captures
- #the epoch time at which the topology graph was updated.
- main.step("Obtain t1 by REST call")
+ # Obtain metrics shortly afterwards
+ # This timestsamp captures
+ # the epoch time at which the topology graph was updated.
+ main.step( "Obtain t1 by REST call" )
json_str_up_1 = main.ONOS1cli.topology_events_metrics()
json_str_up_2 = main.ONOS2cli.topology_events_metrics()
json_str_up_3 = main.ONOS3cli.topology_events_metrics()
-
- json_obj_1 = json.loads(json_str_up_1)
- json_obj_2 = json.loads(json_str_up_2)
- json_obj_3 = json.loads(json_str_up_3)
- os.system("scp "+ONOS_user+"@"+ONOS1_ip+":"+
- tshark_port_up+" /tmp/")
+ json_obj_1 = json.loads( json_str_up_1 )
+ json_obj_2 = json.loads( json_str_up_2 )
+ json_obj_3 = json.loads( json_str_up_3 )
- f_port_up = open(tshark_port_up, 'r')
+ os.system( "scp " + ONOS_user + "@" + ONOS1_ip + ":" +
+ tshark_port_up + " /tmp/" )
+
+ f_port_up = open( tshark_port_up, 'r' )
f_line = f_port_up.readline()
- obj_up = f_line.split(" ")
- if len(f_line) > 0:
- timestamp_begin_pt_up = int(float(obj_up[1])*1000)
- main.log.info("Port up begin timestamp: "+
- str(timestamp_begin_pt_up))
+ obj_up = f_line.split( " " )
+ if len( f_line ) > 0:
+ timestamp_begin_pt_up = int( float( obj_up[ 1 ] ) * 1000 )
+ main.log.info( "Port up begin timestamp: " +
+ str( timestamp_begin_pt_up ) )
else:
- main.log.info("Tshark output file returned unexpected"+
- " results.")
+ main.log.info( "Tshark output file returned unexpected" +
+ " results." )
timestamp_begin_pt_up = 0
-
+
f_port_up.close()
graph_timestamp_1 = \
- json_obj_1[graphTimestamp]['value']
+ json_obj_1[ graphTimestamp ][ 'value' ]
graph_timestamp_2 = \
- json_obj_2[graphTimestamp]['value']
+ json_obj_2[ graphTimestamp ][ 'value' ]
graph_timestamp_3 = \
- json_obj_3[graphTimestamp]['value']
+ json_obj_3[ graphTimestamp ][ 'value' ]
- #Obtain device timestamp. This timestamp captures
- #the epoch time at which the device event happened
+ # Obtain device timestamp. This timestamp captures
+ # the epoch time at which the device event happened
device_timestamp_1 = \
- json_obj_1[deviceTimestamp]['value']
+ json_obj_1[ deviceTimestamp ][ 'value' ]
device_timestamp_2 = \
- json_obj_2[deviceTimestamp]['value']
+ json_obj_2[ deviceTimestamp ][ 'value' ]
device_timestamp_3 = \
- json_obj_3[deviceTimestamp]['value']
+ json_obj_3[ deviceTimestamp ][ 'value' ]
- #Get delta between graph event and OFP
- pt_up_graph_to_ofp_1 = int(graph_timestamp_1) -\
- int(timestamp_begin_pt_up)
- pt_up_graph_to_ofp_2 = int(graph_timestamp_2) -\
- int(timestamp_begin_pt_up)
- pt_up_graph_to_ofp_3 = int(graph_timestamp_3) -\
- int(timestamp_begin_pt_up)
+ # Get delta between graph event and OFP
+ pt_up_graph_to_ofp_1 = int( graph_timestamp_1 ) -\
+ int( timestamp_begin_pt_up )
+ pt_up_graph_to_ofp_2 = int( graph_timestamp_2 ) -\
+ int( timestamp_begin_pt_up )
+ pt_up_graph_to_ofp_3 = int( graph_timestamp_3 ) -\
+ int( timestamp_begin_pt_up )
- #Get delta between device event and OFP
- pt_up_device_to_ofp_1 = int(device_timestamp_1) -\
- int(timestamp_begin_pt_up)
- pt_up_device_to_ofp_2 = int(device_timestamp_2) -\
- int(timestamp_begin_pt_up)
- pt_up_device_to_ofp_3 = int(device_timestamp_3) -\
- int(timestamp_begin_pt_up)
+ # Get delta between device event and OFP
+ pt_up_device_to_ofp_1 = int( device_timestamp_1 ) -\
+ int( timestamp_begin_pt_up )
+ pt_up_device_to_ofp_2 = int( device_timestamp_2 ) -\
+ int( timestamp_begin_pt_up )
+ pt_up_device_to_ofp_3 = int( device_timestamp_3 ) -\
+ int( timestamp_begin_pt_up )
- main.log.info("ONOS1 delta G2O: "+str(pt_up_graph_to_ofp_1))
- main.log.info("ONOS2 delta G2O: "+str(pt_up_graph_to_ofp_2))
- main.log.info("ONOS3 delta G2O: "+str(pt_up_graph_to_ofp_3))
+ main.log.info( "ONOS1 delta G2O: " + str( pt_up_graph_to_ofp_1 ) )
+ main.log.info( "ONOS2 delta G2O: " + str( pt_up_graph_to_ofp_2 ) )
+ main.log.info( "ONOS3 delta G2O: " + str( pt_up_graph_to_ofp_3 ) )
- main.log.info("ONOS1 delta D2O: "+str(pt_up_device_to_ofp_1))
- main.log.info("ONOS2 delta D2O: "+str(pt_up_device_to_ofp_2))
- main.log.info("ONOS3 delta D2O: "+str(pt_up_device_to_ofp_3))
+ main.log.info( "ONOS1 delta D2O: " + str( pt_up_device_to_ofp_1 ) )
+ main.log.info( "ONOS2 delta D2O: " + str( pt_up_device_to_ofp_2 ) )
+ main.log.info( "ONOS3 delta D2O: " + str( pt_up_device_to_ofp_3 ) )
pt_up_graph_to_ofp_avg = \
- (int(pt_up_graph_to_ofp_1) +
- int(pt_up_graph_to_ofp_2) +
- int(pt_up_graph_to_ofp_3)) / 3
+ ( int( pt_up_graph_to_ofp_1 ) +
+ int( pt_up_graph_to_ofp_2 ) +
+ int( pt_up_graph_to_ofp_3 ) ) / 3
pt_up_device_to_ofp_avg = \
- (int(pt_up_device_to_ofp_1) +
- int(pt_up_device_to_ofp_2) +
- int(pt_up_device_to_ofp_3)) / 3
+ ( int( pt_up_device_to_ofp_1 ) +
+ int( pt_up_device_to_ofp_2 ) +
+ int( pt_up_device_to_ofp_3 ) ) / 3
if pt_up_graph_to_ofp_avg > up_threshold_min and \
- pt_up_graph_to_ofp_avg < up_threshold_max:
+ pt_up_graph_to_ofp_avg < up_threshold_max:
port_up_graph_to_ofp_list.append(
- pt_up_graph_to_ofp_avg)
- main.log.info("Port down: graph to ofp avg: "+
- str(pt_up_graph_to_ofp_avg) + " ms")
+ pt_up_graph_to_ofp_avg )
+ main.log.info( "Port down: graph to ofp avg: " +
+ str( pt_up_graph_to_ofp_avg ) + " ms" )
else:
- main.log.info("Average port up graph-to-ofp result"+
- " exceeded the threshold: "+
- str(pt_up_graph_to_ofp_avg))
-
+ main.log.info( "Average port up graph-to-ofp result" +
+ " exceeded the threshold: " +
+ str( pt_up_graph_to_ofp_avg ) )
+
if pt_up_device_to_ofp_avg > up_threshold_min and \
pt_up_device_to_ofp_avg < up_threshold_max:
port_up_device_to_ofp_list.append(
- pt_up_device_to_ofp_avg)
- main.log.info("Port up: device to ofp avg: "+
- str(pt_up_device_to_ofp_avg) + " ms")
+ pt_up_device_to_ofp_avg )
+ main.log.info( "Port up: device to ofp avg: " +
+ str( pt_up_device_to_ofp_avg ) + " ms" )
else:
- main.log.info("Average port up device-to-ofp result"+
- " exceeded the threshold: "+
- str(pt_up_device_to_ofp_avg))
-
- #END ITERATION FOR LOOP
-
- #Check all list for latency existence and set assertion
- if (port_down_graph_to_ofp_list and port_down_device_to_ofp_list\
- and port_up_graph_to_ofp_list and port_up_device_to_ofp_list):
+ main.log.info( "Average port up device-to-ofp result" +
+ " exceeded the threshold: " +
+ str( pt_up_device_to_ofp_avg ) )
+
+ # END ITERATION FOR LOOP
+
+ # Check all list for latency existence and set assertion
+ if ( port_down_graph_to_ofp_list and port_down_device_to_ofp_list
+ and port_up_graph_to_ofp_list and port_up_device_to_ofp_list ):
assertion = main.TRUE
- #Calculate and report latency measurements
- port_down_graph_to_ofp_min = min(port_down_graph_to_ofp_list)
- port_down_graph_to_ofp_max = max(port_down_graph_to_ofp_list)
+ # Calculate and report latency measurements
+ port_down_graph_to_ofp_min = min( port_down_graph_to_ofp_list )
+ port_down_graph_to_ofp_max = max( port_down_graph_to_ofp_list )
port_down_graph_to_ofp_avg = \
- (sum(port_down_graph_to_ofp_list) /
- len(port_down_graph_to_ofp_list))
+ ( sum( port_down_graph_to_ofp_list ) /
+ len( port_down_graph_to_ofp_list ) )
port_down_graph_to_ofp_std_dev = \
- str(round(numpy.std(port_down_graph_to_ofp_list),1))
-
- main.log.report("Port down graph-to-ofp "+
- "Avg: "+str(port_down_graph_to_ofp_avg)+" ms "+
- "Std Deviation: "+port_down_graph_to_ofp_std_dev+" ms")
-
- port_down_device_to_ofp_min = min(port_down_device_to_ofp_list)
- port_down_device_to_ofp_max = max(port_down_device_to_ofp_list)
+ str( round( numpy.std( port_down_graph_to_ofp_list ), 1 ) )
+
+ main.log.report(
+ "Port down graph-to-ofp " +
+ "Avg: " +
+ str( port_down_graph_to_ofp_avg ) +
+ " ms " +
+ "Std Deviation: " +
+ port_down_graph_to_ofp_std_dev +
+ " ms" )
+
+ port_down_device_to_ofp_min = min( port_down_device_to_ofp_list )
+ port_down_device_to_ofp_max = max( port_down_device_to_ofp_list )
port_down_device_to_ofp_avg = \
- (sum(port_down_device_to_ofp_list) /\
- len(port_down_device_to_ofp_list))
+ ( sum( port_down_device_to_ofp_list ) /
+ len( port_down_device_to_ofp_list ) )
port_down_device_to_ofp_std_dev = \
- str(round(numpy.std(port_down_device_to_ofp_list),1))
-
- main.log.report("Port down device-to-ofp "+
- "Avg: "+str(port_down_device_to_ofp_avg)+" ms "+
- "Std Deviation: "+port_down_device_to_ofp_std_dev+" ms")
-
- port_up_graph_to_ofp_min = min(port_up_graph_to_ofp_list)
- port_up_graph_to_ofp_max = max(port_up_graph_to_ofp_list)
+ str( round( numpy.std( port_down_device_to_ofp_list ), 1 ) )
+
+ main.log.report(
+ "Port down device-to-ofp " +
+ "Avg: " +
+ str( port_down_device_to_ofp_avg ) +
+ " ms " +
+ "Std Deviation: " +
+ port_down_device_to_ofp_std_dev +
+ " ms" )
+
+ port_up_graph_to_ofp_min = min( port_up_graph_to_ofp_list )
+ port_up_graph_to_ofp_max = max( port_up_graph_to_ofp_list )
port_up_graph_to_ofp_avg = \
- (sum(port_up_graph_to_ofp_list) /\
- len(port_up_graph_to_ofp_list))
+ ( sum( port_up_graph_to_ofp_list ) /
+ len( port_up_graph_to_ofp_list ) )
port_up_graph_to_ofp_std_dev = \
- str(round(numpy.std(port_up_graph_to_ofp_list),1))
-
- main.log.report("Port up graph-to-ofp "+
- "Avg: "+str(port_up_graph_to_ofp_avg)+" ms "+
- "Std Deviation: "+port_up_graph_to_ofp_std_dev+" ms")
-
- port_up_device_to_ofp_min = min(port_up_device_to_ofp_list)
- port_up_device_to_ofp_max = max(port_up_device_to_ofp_list)
+ str( round( numpy.std( port_up_graph_to_ofp_list ), 1 ) )
+
+ main.log.report(
+ "Port up graph-to-ofp " +
+ "Avg: " +
+ str( port_up_graph_to_ofp_avg ) +
+ " ms " +
+ "Std Deviation: " +
+ port_up_graph_to_ofp_std_dev +
+ " ms" )
+
+ port_up_device_to_ofp_min = min( port_up_device_to_ofp_list )
+ port_up_device_to_ofp_max = max( port_up_device_to_ofp_list )
port_up_device_to_ofp_avg = \
- (sum(port_up_device_to_ofp_list) /\
- len(port_up_device_to_ofp_list))
+ ( sum( port_up_device_to_ofp_list ) /
+ len( port_up_device_to_ofp_list ) )
port_up_device_to_ofp_std_dev = \
- str(round(numpy.std(port_up_device_to_ofp_list),1))
-
- main.log.report("Port up device-to-ofp "+
- "Avg: "+str(port_up_device_to_ofp_avg)+" ms "+
- "Std Deviation: "+port_up_device_to_ofp_std_dev+" ms")
+ str( round( numpy.std( port_up_device_to_ofp_list ), 1 ) )
- utilities.assert_equals(expect=main.TRUE, actual=assertion,
- onpass="Port discovery latency calculation successful",
- onfail="Port discovery test failed")
+ main.log.report(
+ "Port up device-to-ofp " +
+ "Avg: " +
+ str( port_up_device_to_ofp_avg ) +
+ " ms " +
+ "Std Deviation: " +
+ port_up_device_to_ofp_std_dev +
+ " ms" )
- def CASE4(self, main):
- '''
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=assertion,
+ onpass="Port discovery latency calculation successful",
+ onfail="Port discovery test failed" )
+
+ def CASE4( self, main ):
+ """
Link down event using loss rate 100%
-
+
Important:
Use a simple 2 switch topology with 1 link between
- the two switches. Ensure that mac addresses of the
+ the two switches. Ensure that mac addresses of the
switches are 1 / 2 respectively
- '''
+ """
import time
import subprocess
import os
import requests
import json
- import numpy
-
- ONOS1_ip = main.params['CTRL']['ip1']
- ONOS2_ip = main.params['CTRL']['ip2']
- ONOS3_ip = main.params['CTRL']['ip3']
- ONOS_user = main.params['CTRL']['user']
+ import numpy
- default_sw_port = main.params['CTRL']['port1']
-
- #Number of iterations of case
- num_iter = main.params['TEST']['numIter']
-
- #Timestamp 'keys' for json metrics output.
- #These are subject to change, hence moved into params
- deviceTimestamp = main.params['JSON']['deviceTimestamp']
- linkTimestamp = main.params['JSON']['linkTimestamp']
- graphTimestamp = main.params['JSON']['graphTimestamp']
-
- debug_mode = main.params['TEST']['debugMode']
+ ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+ ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
+ ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
+ ONOS_user = main.params[ 'CTRL' ][ 'user' ]
- local_time = time.strftime('%x %X')
- local_time = local_time.replace("/","")
- local_time = local_time.replace(" ","_")
- local_time = local_time.replace(":","")
+ default_sw_port = main.params[ 'CTRL' ][ 'port1' ]
+
+ # Number of iterations of case
+ num_iter = main.params[ 'TEST' ][ 'numIter' ]
+
+ # Timestamp 'keys' for json metrics output.
+ # These are subject to change, hence moved into params
+ deviceTimestamp = main.params[ 'JSON' ][ 'deviceTimestamp' ]
+ linkTimestamp = main.params[ 'JSON' ][ 'linkTimestamp' ]
+ graphTimestamp = main.params[ 'JSON' ][ 'graphTimestamp' ]
+
+ debug_mode = main.params[ 'TEST' ][ 'debugMode' ]
+
+ local_time = time.strftime( '%x %X' )
+ local_time = local_time.replace( "/", "" )
+ local_time = local_time.replace( " ", "_" )
+ local_time = local_time.replace( ":", "" )
if debug_mode == 'on':
- main.ONOS1.tshark_pcap("eth0",
- "/tmp/link_lat_pcap_"+local_time)
+ main.ONOS1.tshark_pcap( "eth0",
+ "/tmp/link_lat_pcap_" + local_time )
- #Threshold for this test case
- up_threshold_str = main.params['TEST']['linkUpThreshold']
- down_threshold_str = main.params['TEST']['linkDownThreshold']
+ # Threshold for this test case
+ up_threshold_str = main.params[ 'TEST' ][ 'linkUpThreshold' ]
+ down_threshold_str = main.params[ 'TEST' ][ 'linkDownThreshold' ]
- up_threshold_obj = up_threshold_str.split(",")
- down_threshold_obj = down_threshold_str.split(",")
+ up_threshold_obj = up_threshold_str.split( "," )
+ down_threshold_obj = down_threshold_str.split( "," )
- up_threshold_min = int(up_threshold_obj[0])
- up_threshold_max = int(up_threshold_obj[1])
+ up_threshold_min = int( up_threshold_obj[ 0 ] )
+ up_threshold_max = int( up_threshold_obj[ 1 ] )
- down_threshold_min = int(down_threshold_obj[0])
- down_threshold_max = int(down_threshold_obj[1])
+ down_threshold_min = int( down_threshold_obj[ 0 ] )
+ down_threshold_max = int( down_threshold_obj[ 1 ] )
assertion = main.TRUE
- #Link event timestamp to system time list
+ # Link event timestamp to system time list
link_down_link_to_system_list = []
link_up_link_to_system_list = []
- #Graph event timestamp to system time list
+ # Graph event timestamp to system time list
link_down_graph_to_system_list = []
- link_up_graph_to_system_list = []
+ link_up_graph_to_system_list = []
- main.log.report("Link up / down discovery latency between "+
- "two switches")
- main.log.report("Simulated by setting loss-rate 100%")
- main.log.report("'tc qdisc add dev <intfs> root netem loss 100%'")
- main.log.report("Total iterations of test: "+str(num_iter))
+ main.log.report( "Link up / down discovery latency between " +
+ "two switches" )
+ main.log.report( "Simulated by setting loss-rate 100%" )
+ main.log.report( "'tc qdisc add dev <intfs> root netem loss 100%'" )
+ main.log.report( "Total iterations of test: " + str( num_iter ) )
- main.step("Assign all switches")
- main.Mininet1.assign_sw_controller(sw="1",
- ip1=ONOS1_ip, port1=default_sw_port)
- main.Mininet1.assign_sw_controller(sw="2",
- ip1=ONOS1_ip, port1=default_sw_port)
+ main.step( "Assign all switches" )
+ main.Mininet1.assign_sw_controller(
+ sw="1",
+ ip1=ONOS1_ip,
+ port1=default_sw_port )
+ main.Mininet1.assign_sw_controller(
+ sw="2",
+ ip1=ONOS1_ip,
+ port1=default_sw_port )
- main.step("Verifying switch assignment")
- result_s1 = main.Mininet1.get_sw_controller(sw="s1")
- result_s2 = main.Mininet1.get_sw_controller(sw="s2")
-
- #Allow time for events to finish before taking measurements
- time.sleep(10)
+ main.step( "Verifying switch assignment" )
+ result_s1 = main.Mininet1.get_sw_controller( sw="s1" )
+ result_s2 = main.Mininet1.get_sw_controller( sw="s2" )
+
+ # Allow time for events to finish before taking measurements
+ time.sleep( 10 )
link_down1 = False
link_down2 = False
link_down3 = False
- #Start iteration of link event test
- for i in range(0, int(num_iter)):
- main.step("Getting initial system time as t0")
-
- timestamp_link_down_t0 = time.time() * 1000
- #Link down is simulated by 100% loss rate using traffic
- #control command
- main.Mininet1.handle.sendline(
- "sh tc qdisc add dev s1-eth1 root netem loss 100%")
+ # Start iteration of link event test
+ for i in range( 0, int( num_iter ) ):
+ main.step( "Getting initial system time as t0" )
- #TODO: Iterate through 'links' command to verify that
- # link s1 -> s2 went down (loop timeout 30 seconds)
+ timestamp_link_down_t0 = time.time() * 1000
+ # Link down is simulated by 100% loss rate using traffic
+ # control command
+ main.Mininet1.handle.sendline(
+ "sh tc qdisc add dev s1-eth1 root netem loss 100%" )
+
+ # TODO: Iterate through 'links' command to verify that
+ # link s1 -> s2 went down ( loop timeout 30 seconds )
# on all 3 ONOS instances
- main.log.info("Checking ONOS for link update")
+ main.log.info( "Checking ONOS for link update" )
loop_count = 0
- while( not (link_down1 and link_down2 and link_down3)\
+ while( not ( link_down1 and link_down2 and link_down3 )
and loop_count < 30 ):
json_str1 = main.ONOS1cli.links()
json_str2 = main.ONOS2cli.links()
json_str3 = main.ONOS3cli.links()
-
- if not (json_str1 and json_str2 and json_str3):
- main.log.error("CLI command returned error ")
+
+ if not ( json_str1 and json_str2 and json_str3 ):
+ main.log.error( "CLI command returned error " )
break
else:
- json_obj1 = json.loads(json_str1)
- json_obj2 = json.loads(json_str2)
- json_obj3 = json.loads(json_str3)
+ json_obj1 = json.loads( json_str1 )
+ json_obj2 = json.loads( json_str2 )
+ json_obj3 = json.loads( json_str3 )
for obj1 in json_obj1:
- if '01' not in obj1['src']['device']:
+ if '01' not in obj1[ 'src' ][ 'device' ]:
link_down1 = True
- main.log.info("Link down from "+
- "s1 -> s2 on ONOS1 detected")
+ main.log.info( "Link down from " +
+ "s1 -> s2 on ONOS1 detected" )
for obj2 in json_obj2:
- if '01' not in obj2['src']['device']:
+ if '01' not in obj2[ 'src' ][ 'device' ]:
link_down2 = True
- main.log.info("Link down from "+
- "s1 -> s2 on ONOS2 detected")
+ main.log.info( "Link down from " +
+ "s1 -> s2 on ONOS2 detected" )
for obj3 in json_obj3:
- if '01' not in obj3['src']['device']:
+ if '01' not in obj3[ 'src' ][ 'device' ]:
link_down3 = True
- main.log.info("Link down from "+
- "s1 -> s2 on ONOS3 detected")
-
+ main.log.info( "Link down from " +
+ "s1 -> s2 on ONOS3 detected" )
+
loop_count += 1
- #If CLI doesn't like the continuous requests
- #and exits in this loop, increase the sleep here.
- #Consequently, while loop timeout will increase
- time.sleep(1)
-
- #Give time for metrics measurement to catch up
- #NOTE: May need to be configured more accurately
- time.sleep(10)
- #If we exited the while loop and link down 1,2,3 are still
- #false, then ONOS has failed to discover link down event
- if not (link_down1 and link_down2 and link_down3):
- main.log.info("Link down discovery failed")
-
+ # If CLI doesn't like the continuous requests
+ # and exits in this loop, increase the sleep here.
+ # Consequently, while loop timeout will increase
+ time.sleep( 1 )
+
+ # Give time for metrics measurement to catch up
+ # NOTE: May need to be configured more accurately
+ time.sleep( 10 )
+ # If we exited the while loop and link down 1,2,3 are still
+ # false, then ONOS has failed to discover link down event
+ if not ( link_down1 and link_down2 and link_down3 ):
+ main.log.info( "Link down discovery failed" )
+
link_down_lat_graph1 = 0
link_down_lat_graph2 = 0
link_down_lat_graph3 = 0
link_down_lat_device1 = 0
link_down_lat_device2 = 0
link_down_lat_device3 = 0
-
+
assertion = main.FALSE
else:
json_topo_metrics_1 =\
- main.ONOS1cli.topology_events_metrics()
+ main.ONOS1cli.topology_events_metrics()
json_topo_metrics_2 =\
- main.ONOS2cli.topology_events_metrics()
+ main.ONOS2cli.topology_events_metrics()
json_topo_metrics_3 =\
- main.ONOS3cli.topology_events_metrics()
- json_topo_metrics_1 = json.loads(json_topo_metrics_1)
- json_topo_metrics_2 = json.loads(json_topo_metrics_2)
- json_topo_metrics_3 = json.loads(json_topo_metrics_3)
+ main.ONOS3cli.topology_events_metrics()
+ json_topo_metrics_1 = json.loads( json_topo_metrics_1 )
+ json_topo_metrics_2 = json.loads( json_topo_metrics_2 )
+ json_topo_metrics_3 = json.loads( json_topo_metrics_3 )
- main.log.info("Obtaining graph and device timestamp")
+ main.log.info( "Obtaining graph and device timestamp" )
graph_timestamp_1 = \
- json_topo_metrics_1[graphTimestamp]['value']
+ json_topo_metrics_1[ graphTimestamp ][ 'value' ]
graph_timestamp_2 = \
- json_topo_metrics_2[graphTimestamp]['value']
+ json_topo_metrics_2[ graphTimestamp ][ 'value' ]
graph_timestamp_3 = \
- json_topo_metrics_3[graphTimestamp]['value']
+ json_topo_metrics_3[ graphTimestamp ][ 'value' ]
link_timestamp_1 = \
- json_topo_metrics_1[linkTimestamp]['value']
+ json_topo_metrics_1[ linkTimestamp ][ 'value' ]
link_timestamp_2 = \
- json_topo_metrics_2[linkTimestamp]['value']
+ json_topo_metrics_2[ linkTimestamp ][ 'value' ]
link_timestamp_3 = \
- json_topo_metrics_3[linkTimestamp]['value']
+ json_topo_metrics_3[ linkTimestamp ][ 'value' ]
if graph_timestamp_1 and graph_timestamp_2 and\
graph_timestamp_3 and link_timestamp_1 and\
link_timestamp_2 and link_timestamp_3:
- link_down_lat_graph1 = int(graph_timestamp_1) -\
- int(timestamp_link_down_t0)
- link_down_lat_graph2 = int(graph_timestamp_2) -\
- int(timestamp_link_down_t0)
- link_down_lat_graph3 = int(graph_timestamp_3) -\
- int(timestamp_link_down_t0)
-
- link_down_lat_link1 = int(link_timestamp_1) -\
- int(timestamp_link_down_t0)
- link_down_lat_link2 = int(link_timestamp_2) -\
- int(timestamp_link_down_t0)
- link_down_lat_link3 = int(link_timestamp_3) -\
- int(timestamp_link_down_t0)
+ link_down_lat_graph1 = int( graph_timestamp_1 ) -\
+ int( timestamp_link_down_t0 )
+ link_down_lat_graph2 = int( graph_timestamp_2 ) -\
+ int( timestamp_link_down_t0 )
+ link_down_lat_graph3 = int( graph_timestamp_3 ) -\
+ int( timestamp_link_down_t0 )
+
+ link_down_lat_link1 = int( link_timestamp_1 ) -\
+ int( timestamp_link_down_t0 )
+ link_down_lat_link2 = int( link_timestamp_2 ) -\
+ int( timestamp_link_down_t0 )
+ link_down_lat_link3 = int( link_timestamp_3 ) -\
+ int( timestamp_link_down_t0 )
else:
- main.log.error("There was an error calculating"+
- " the delta for link down event")
+ main.log.error( "There was an error calculating" +
+ " the delta for link down event" )
link_down_lat_graph1 = 0
link_down_lat_graph2 = 0
link_down_lat_graph3 = 0
-
+
link_down_lat_device1 = 0
link_down_lat_device2 = 0
link_down_lat_device3 = 0
-
- main.log.info("Link down latency ONOS1 iteration "+
- str(i)+" (end-to-end): "+
- str(link_down_lat_graph1)+" ms")
- main.log.info("Link down latency ONOS2 iteration "+
- str(i)+" (end-to-end): "+
- str(link_down_lat_graph2)+" ms")
- main.log.info("Link down latency ONOS3 iteration "+
- str(i)+" (end-to-end): "+
- str(link_down_lat_graph3)+" ms")
-
- main.log.info("Link down latency ONOS1 iteration "+
- str(i)+" (link-event-to-system-timestamp): "+
- str(link_down_lat_link1)+" ms")
- main.log.info("Link down latency ONOS2 iteration "+
- str(i)+" (link-event-to-system-timestamp): "+
- str(link_down_lat_link2)+" ms")
- main.log.info("Link down latency ONOS3 iteration "+
- str(i)+" (link-event-to-system-timestamp): "+
- str(link_down_lat_link3))
-
- #Calculate avg of node calculations
- link_down_lat_graph_avg =\
- (link_down_lat_graph1 +
- link_down_lat_graph2 +
- link_down_lat_graph3) / 3
- link_down_lat_link_avg =\
- (link_down_lat_link1 +
- link_down_lat_link2 +
- link_down_lat_link3) / 3
- #Set threshold and append latency to list
+ main.log.info( "Link down latency ONOS1 iteration " +
+ str( i ) + " (end-to-end): " +
+ str( link_down_lat_graph1 ) + " ms" )
+ main.log.info( "Link down latency ONOS2 iteration " +
+ str( i ) + " (end-to-end): " +
+ str( link_down_lat_graph2 ) + " ms" )
+ main.log.info( "Link down latency ONOS3 iteration " +
+ str( i ) + " (end-to-end): " +
+ str( link_down_lat_graph3 ) + " ms" )
+
+ main.log.info( "Link down latency ONOS1 iteration " +
+ str( i ) + " (link-event-to-system-timestamp): " +
+ str( link_down_lat_link1 ) + " ms" )
+ main.log.info( "Link down latency ONOS2 iteration " +
+ str( i ) + " (link-event-to-system-timestamp): " +
+ str( link_down_lat_link2 ) + " ms" )
+ main.log.info( "Link down latency ONOS3 iteration " +
+ str( i ) + " (link-event-to-system-timestamp): " +
+ str( link_down_lat_link3 ) )
+
+ # Calculate avg of node calculations
+ link_down_lat_graph_avg =\
+ ( link_down_lat_graph1 +
+ link_down_lat_graph2 +
+ link_down_lat_graph3 ) / 3
+ link_down_lat_link_avg =\
+ ( link_down_lat_link1 +
+ link_down_lat_link2 +
+ link_down_lat_link3 ) / 3
+
+ # Set threshold and append latency to list
if link_down_lat_graph_avg > down_threshold_min and\
link_down_lat_graph_avg < down_threshold_max:
link_down_graph_to_system_list.append(
- link_down_lat_graph_avg)
+ link_down_lat_graph_avg )
else:
- main.log.info("Link down latency exceeded threshold")
- main.log.info("Results for iteration "+str(i)+
- "have been omitted")
+ main.log.info( "Link down latency exceeded threshold" )
+ main.log.info( "Results for iteration " + str( i ) +
+ "have been omitted" )
if link_down_lat_link_avg > down_threshold_min and\
link_down_lat_link_avg < down_threshold_max:
link_down_link_to_system_list.append(
- link_down_lat_link_avg)
+ link_down_lat_link_avg )
else:
- main.log.info("Link down latency exceeded threshold")
- main.log.info("Results for iteration "+str(i)+
- "have been omitted")
+ main.log.info( "Link down latency exceeded threshold" )
+ main.log.info( "Results for iteration " + str( i ) +
+ "have been omitted" )
- #NOTE: To remove loss rate and measure latency:
+ # NOTE: To remove loss rate and measure latency:
# 'sh tc qdisc del dev s1-eth1 root'
timestamp_link_up_t0 = time.time() * 1000
- main.Mininet1.handle.sendline("sh tc qdisc del dev "+
- "s1-eth1 root")
- main.Mininet1.handle.expect("mininet>")
-
- main.log.info("Checking ONOS for link update")
-
+ main.Mininet1.handle.sendline( "sh tc qdisc del dev " +
+ "s1-eth1 root" )
+ main.Mininet1.handle.expect( "mininet>" )
+
+ main.log.info( "Checking ONOS for link update" )
+
link_down1 = True
link_down2 = True
link_down3 = True
loop_count = 0
- while( (link_down1 and link_down2 and link_down3)\
+ while( ( link_down1 and link_down2 and link_down3 )
and loop_count < 30 ):
json_str1 = main.ONOS1cli.links()
json_str2 = main.ONOS2cli.links()
json_str3 = main.ONOS3cli.links()
- if not (json_str1 and json_str2 and json_str3):
- main.log.error("CLI command returned error ")
+ if not ( json_str1 and json_str2 and json_str3 ):
+ main.log.error( "CLI command returned error " )
break
else:
- json_obj1 = json.loads(json_str1)
- json_obj2 = json.loads(json_str2)
- json_obj3 = json.loads(json_str3)
-
+ json_obj1 = json.loads( json_str1 )
+ json_obj2 = json.loads( json_str2 )
+ json_obj3 = json.loads( json_str3 )
+
for obj1 in json_obj1:
- if '01' in obj1['src']['device']:
- link_down1 = False
- main.log.info("Link up from "+
- "s1 -> s2 on ONOS1 detected")
+ if '01' in obj1[ 'src' ][ 'device' ]:
+ link_down1 = False
+ main.log.info( "Link up from " +
+ "s1 -> s2 on ONOS1 detected" )
for obj2 in json_obj2:
- if '01' in obj2['src']['device']:
- link_down2 = False
- main.log.info("Link up from "+
- "s1 -> s2 on ONOS2 detected")
+ if '01' in obj2[ 'src' ][ 'device' ]:
+ link_down2 = False
+ main.log.info( "Link up from " +
+ "s1 -> s2 on ONOS2 detected" )
for obj3 in json_obj3:
- if '01' in obj3['src']['device']:
- link_down3 = False
- main.log.info("Link up from "+
- "s1 -> s2 on ONOS3 detected")
-
+ if '01' in obj3[ 'src' ][ 'device' ]:
+ link_down3 = False
+ main.log.info( "Link up from " +
+ "s1 -> s2 on ONOS3 detected" )
+
loop_count += 1
- time.sleep(1)
-
- if (link_down1 and link_down2 and link_down3):
- main.log.info("Link up discovery failed")
-
+ time.sleep( 1 )
+
+ if ( link_down1 and link_down2 and link_down3 ):
+ main.log.info( "Link up discovery failed" )
+
link_up_lat_graph1 = 0
link_up_lat_graph2 = 0
link_up_lat_graph3 = 0
link_up_lat_device1 = 0
link_up_lat_device2 = 0
link_up_lat_device3 = 0
-
+
assertion = main.FALSE
else:
json_topo_metrics_1 =\
- main.ONOS1cli.topology_events_metrics()
+ main.ONOS1cli.topology_events_metrics()
json_topo_metrics_2 =\
- main.ONOS2cli.topology_events_metrics()
+ main.ONOS2cli.topology_events_metrics()
json_topo_metrics_3 =\
- main.ONOS3cli.topology_events_metrics()
- json_topo_metrics_1 = json.loads(json_topo_metrics_1)
- json_topo_metrics_2 = json.loads(json_topo_metrics_2)
- json_topo_metrics_3 = json.loads(json_topo_metrics_3)
+ main.ONOS3cli.topology_events_metrics()
+ json_topo_metrics_1 = json.loads( json_topo_metrics_1 )
+ json_topo_metrics_2 = json.loads( json_topo_metrics_2 )
+ json_topo_metrics_3 = json.loads( json_topo_metrics_3 )
- main.log.info("Obtaining graph and device timestamp")
+ main.log.info( "Obtaining graph and device timestamp" )
graph_timestamp_1 = \
- json_topo_metrics_1[graphTimestamp]['value']
+ json_topo_metrics_1[ graphTimestamp ][ 'value' ]
graph_timestamp_2 = \
- json_topo_metrics_2[graphTimestamp]['value']
+ json_topo_metrics_2[ graphTimestamp ][ 'value' ]
graph_timestamp_3 = \
- json_topo_metrics_3[graphTimestamp]['value']
+ json_topo_metrics_3[ graphTimestamp ][ 'value' ]
link_timestamp_1 = \
- json_topo_metrics_1[linkTimestamp]['value']
+ json_topo_metrics_1[ linkTimestamp ][ 'value' ]
link_timestamp_2 = \
- json_topo_metrics_2[linkTimestamp]['value']
+ json_topo_metrics_2[ linkTimestamp ][ 'value' ]
link_timestamp_3 = \
- json_topo_metrics_3[linkTimestamp]['value']
+ json_topo_metrics_3[ linkTimestamp ][ 'value' ]
if graph_timestamp_1 and graph_timestamp_2 and\
graph_timestamp_3 and link_timestamp_1 and\
link_timestamp_2 and link_timestamp_3:
- link_up_lat_graph1 = int(graph_timestamp_1) -\
- int(timestamp_link_up_t0)
- link_up_lat_graph2 = int(graph_timestamp_2) -\
- int(timestamp_link_up_t0)
- link_up_lat_graph3 = int(graph_timestamp_3) -\
- int(timestamp_link_up_t0)
-
- link_up_lat_link1 = int(link_timestamp_1) -\
- int(timestamp_link_up_t0)
- link_up_lat_link2 = int(link_timestamp_2) -\
- int(timestamp_link_up_t0)
- link_up_lat_link3 = int(link_timestamp_3) -\
- int(timestamp_link_up_t0)
+ link_up_lat_graph1 = int( graph_timestamp_1 ) -\
+ int( timestamp_link_up_t0 )
+ link_up_lat_graph2 = int( graph_timestamp_2 ) -\
+ int( timestamp_link_up_t0 )
+ link_up_lat_graph3 = int( graph_timestamp_3 ) -\
+ int( timestamp_link_up_t0 )
+
+ link_up_lat_link1 = int( link_timestamp_1 ) -\
+ int( timestamp_link_up_t0 )
+ link_up_lat_link2 = int( link_timestamp_2 ) -\
+ int( timestamp_link_up_t0 )
+ link_up_lat_link3 = int( link_timestamp_3 ) -\
+ int( timestamp_link_up_t0 )
else:
- main.log.error("There was an error calculating"+
- " the delta for link down event")
+ main.log.error( "There was an error calculating" +
+ " the delta for link down event" )
link_up_lat_graph1 = 0
link_up_lat_graph2 = 0
link_up_lat_graph3 = 0
-
+
link_up_lat_device1 = 0
link_up_lat_device2 = 0
link_up_lat_device3 = 0
-
- if debug_mode == 'on':
- main.log.info("Link up latency ONOS1 iteration "+
- str(i)+" (end-to-end): "+
- str(link_up_lat_graph1)+" ms")
- main.log.info("Link up latency ONOS2 iteration "+
- str(i)+" (end-to-end): "+
- str(link_up_lat_graph2)+" ms")
- main.log.info("Link up latency ONOS3 iteration "+
- str(i)+" (end-to-end): "+
- str(link_up_lat_graph3)+" ms")
-
- main.log.info("Link up latency ONOS1 iteration "+
- str(i)+" (link-event-to-system-timestamp): "+
- str(link_up_lat_link1)+" ms")
- main.log.info("Link up latency ONOS2 iteration "+
- str(i)+" (link-event-to-system-timestamp): "+
- str(link_up_lat_link2)+" ms")
- main.log.info("Link up latency ONOS3 iteration "+
- str(i)+" (link-event-to-system-timestamp): "+
- str(link_up_lat_link3))
-
- #Calculate avg of node calculations
- link_up_lat_graph_avg =\
- (link_up_lat_graph1 +
- link_up_lat_graph2 +
- link_up_lat_graph3) / 3
- link_up_lat_link_avg =\
- (link_up_lat_link1 +
- link_up_lat_link2 +
- link_up_lat_link3) / 3
- #Set threshold and append latency to list
+ if debug_mode == 'on':
+ main.log.info( "Link up latency ONOS1 iteration " +
+ str( i ) + " (end-to-end): " +
+ str( link_up_lat_graph1 ) + " ms" )
+ main.log.info( "Link up latency ONOS2 iteration " +
+ str( i ) + " (end-to-end): " +
+ str( link_up_lat_graph2 ) + " ms" )
+ main.log.info( "Link up latency ONOS3 iteration " +
+ str( i ) + " (end-to-end): " +
+ str( link_up_lat_graph3 ) + " ms" )
+
+ main.log.info(
+ "Link up latency ONOS1 iteration " +
+ str( i ) +
+ " (link-event-to-system-timestamp): " +
+ str( link_up_lat_link1 ) +
+ " ms" )
+ main.log.info(
+ "Link up latency ONOS2 iteration " +
+ str( i ) +
+ " (link-event-to-system-timestamp): " +
+ str( link_up_lat_link2 ) +
+ " ms" )
+ main.log.info(
+ "Link up latency ONOS3 iteration " +
+ str( i ) +
+ " (link-event-to-system-timestamp): " +
+ str( link_up_lat_link3 ) )
+
+ # Calculate avg of node calculations
+ link_up_lat_graph_avg =\
+ ( link_up_lat_graph1 +
+ link_up_lat_graph2 +
+ link_up_lat_graph3 ) / 3
+ link_up_lat_link_avg =\
+ ( link_up_lat_link1 +
+ link_up_lat_link2 +
+ link_up_lat_link3 ) / 3
+
+ # Set threshold and append latency to list
if link_up_lat_graph_avg > up_threshold_min and\
link_up_lat_graph_avg < up_threshold_max:
link_up_graph_to_system_list.append(
- link_up_lat_graph_avg)
+ link_up_lat_graph_avg )
else:
- main.log.info("Link up latency exceeded threshold")
- main.log.info("Results for iteration "+str(i)+
- "have been omitted")
+ main.log.info( "Link up latency exceeded threshold" )
+ main.log.info( "Results for iteration " + str( i ) +
+ "have been omitted" )
if link_up_lat_link_avg > up_threshold_min and\
link_up_lat_link_avg < up_threshold_max:
link_up_link_to_system_list.append(
- link_up_lat_link_avg)
+ link_up_lat_link_avg )
else:
- main.log.info("Link up latency exceeded threshold")
- main.log.info("Results for iteration "+str(i)+
- "have been omitted")
+ main.log.info( "Link up latency exceeded threshold" )
+ main.log.info( "Results for iteration " + str( i ) +
+ "have been omitted" )
- #Calculate min, max, avg of list and report
- link_down_min = min(link_down_graph_to_system_list)
- link_down_max = max(link_down_graph_to_system_list)
- link_down_avg = sum(link_down_graph_to_system_list) / \
- len(link_down_graph_to_system_list)
- link_up_min = min(link_up_graph_to_system_list)
- link_up_max = max(link_up_graph_to_system_list)
- link_up_avg = sum(link_up_graph_to_system_list) / \
- len(link_up_graph_to_system_list)
+ # Calculate min, max, avg of list and report
+ link_down_min = min( link_down_graph_to_system_list )
+ link_down_max = max( link_down_graph_to_system_list )
+ link_down_avg = sum( link_down_graph_to_system_list ) / \
+ len( link_down_graph_to_system_list )
+ link_up_min = min( link_up_graph_to_system_list )
+ link_up_max = max( link_up_graph_to_system_list )
+ link_up_avg = sum( link_up_graph_to_system_list ) / \
+ len( link_up_graph_to_system_list )
link_down_std_dev = \
- str(round(numpy.std(link_down_graph_to_system_list),1))
+ str( round( numpy.std( link_down_graph_to_system_list ), 1 ) )
link_up_std_dev = \
- str(round(numpy.std(link_up_graph_to_system_list),1))
+ str( round( numpy.std( link_up_graph_to_system_list ), 1 ) )
- main.log.report("Link down latency " +
- "Avg: "+str(link_down_avg)+" ms "+
- "Std Deviation: "+link_down_std_dev+" ms")
- main.log.report("Link up latency "+
- "Avg: "+str(link_up_avg)+" ms "+
- "Std Deviation: "+link_up_std_dev+" ms")
+ main.log.report( "Link down latency " +
+ "Avg: " + str( link_down_avg ) + " ms " +
+ "Std Deviation: " + link_down_std_dev + " ms" )
+ main.log.report( "Link up latency " +
+ "Avg: " + str( link_up_avg ) + " ms " +
+ "Std Deviation: " + link_up_std_dev + " ms" )
- utilities.assert_equals(expect=main.TRUE, actual=assertion,
- onpass="Link discovery latency calculation successful",
- onfail="Link discovery latency case failed")
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=assertion,
+ onpass="Link discovery latency calculation successful",
+ onfail="Link discovery latency case failed" )
- def CASE5(self, main):
- '''
+ def CASE5( self, main ):
+ """
100 Switch discovery latency
Important:
- This test case can be potentially dangerous if
+ This test case can be potentially dangerous if
your machine has previously set iptables rules.
One of the steps of the test case will flush
all existing iptables rules.
Note:
- You can specify the number of switches in the
+ You can specify the number of switches in the
params file to adjust the switch discovery size
- (and specify the corresponding topology in Mininet1
- .topo file)
- '''
+ ( and specify the corresponding topology in Mininet1
+ .topo file )
+ """
import time
import subprocess
import os
import requests
import json
- ONOS1_ip = main.params['CTRL']['ip1']
- ONOS2_ip = main.params['CTRL']['ip2']
- ONOS3_ip = main.params['CTRL']['ip3']
- MN1_ip = main.params['MN']['ip1']
- ONOS_user = main.params['CTRL']['user']
+ ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+ ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
+ ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
+ MN1_ip = main.params[ 'MN' ][ 'ip1' ]
+ ONOS_user = main.params[ 'CTRL' ][ 'user' ]
- default_sw_port = main.params['CTRL']['port1']
-
- #Number of iterations of case
- num_iter = main.params['TEST']['numIter']
- num_sw = main.params['TEST']['numSwitch']
+ default_sw_port = main.params[ 'CTRL' ][ 'port1' ]
- #Timestamp 'keys' for json metrics output.
- #These are subject to change, hence moved into params
- deviceTimestamp = main.params['JSON']['deviceTimestamp']
- graphTimestamp = main.params['JSON']['graphTimestamp']
-
- debug_mode = main.params['TEST']['debugMode']
+ # Number of iterations of case
+ num_iter = main.params[ 'TEST' ][ 'numIter' ]
+ num_sw = main.params[ 'TEST' ][ 'numSwitch' ]
- local_time = time.strftime('%X')
- local_time = local_time.replace("/","")
- local_time = local_time.replace(" ","_")
- local_time = local_time.replace(":","")
+ # Timestamp 'keys' for json metrics output.
+ # These are subject to change, hence moved into params
+ deviceTimestamp = main.params[ 'JSON' ][ 'deviceTimestamp' ]
+ graphTimestamp = main.params[ 'JSON' ][ 'graphTimestamp' ]
+
+ debug_mode = main.params[ 'TEST' ][ 'debugMode' ]
+
+ local_time = time.strftime( '%X' )
+ local_time = local_time.replace( "/", "" )
+ local_time = local_time.replace( " ", "_" )
+ local_time = local_time.replace( ":", "" )
if debug_mode == 'on':
- main.ONOS1.tshark_pcap("eth0",
- "/tmp/100_sw_lat_pcap_"+local_time)
-
- #Threshold for this test case
- sw_disc_threshold_str = main.params['TEST']['swDisc100Threshold']
- sw_disc_threshold_obj = sw_disc_threshold_str.split(",")
- sw_disc_threshold_min = int(sw_disc_threshold_obj[0])
- sw_disc_threshold_max = int(sw_disc_threshold_obj[1])
+ main.ONOS1.tshark_pcap( "eth0",
+ "/tmp/100_sw_lat_pcap_" + local_time )
- tshark_ofp_output = "/tmp/tshark_ofp_"+num_sw+"sw.txt"
- tshark_tcp_output = "/tmp/tshark_tcp_"+num_sw+"sw.txt"
+ # Threshold for this test case
+ sw_disc_threshold_str = main.params[ 'TEST' ][ 'swDisc100Threshold' ]
+ sw_disc_threshold_obj = sw_disc_threshold_str.split( "," )
+ sw_disc_threshold_min = int( sw_disc_threshold_obj[ 0 ] )
+ sw_disc_threshold_max = int( sw_disc_threshold_obj[ 1 ] )
+
+ tshark_ofp_output = "/tmp/tshark_ofp_" + num_sw + "sw.txt"
+ tshark_tcp_output = "/tmp/tshark_tcp_" + num_sw + "sw.txt"
tshark_ofp_result_list = []
tshark_tcp_result_list = []
sw_discovery_lat_list = []
- main.case(num_sw+" Switch discovery latency")
- main.step("Assigning all switches to ONOS1")
- for i in range(1, int(num_sw)+1):
+ main.case( num_sw + " Switch discovery latency" )
+ main.step( "Assigning all switches to ONOS1" )
+ for i in range( 1, int( num_sw ) + 1 ):
main.Mininet1.assign_sw_controller(
- sw=str(i),
- ip1=ONOS1_ip,
- port1=default_sw_port)
-
- #Ensure that nodes are configured with ptpd
- #Just a warning message
- main.log.info("Please check ptpd configuration to ensure"+\
- " All nodes' system times are in sync")
- time.sleep(5)
+ sw=str( i ),
+ ip1=ONOS1_ip,
+ port1=default_sw_port )
- for i in range(0, int(num_iter)):
-
- main.step("Set iptables rule to block incoming sw connections")
- #Set iptables rule to block incoming switch connections
- #The rule description is as follows:
+ # Ensure that nodes are configured with ptpd
+ # Just a warning message
+ main.log.info( "Please check ptpd configuration to ensure" +
+ " All nodes' system times are in sync" )
+ time.sleep( 5 )
+
+ for i in range( 0, int( num_iter ) ):
+
+ main.step( "Set iptables rule to block incoming sw connections" )
+ # Set iptables rule to block incoming switch connections
+ # The rule description is as follows:
# Append to INPUT rule,
# behavior DROP that matches following:
# * packet type: tcp
# * source IP: MN1_ip
# * destination PORT: 6633
main.ONOS1.handle.sendline(
- "sudo iptables -A INPUT -p tcp -s "+MN1_ip+
- " --dport "+default_sw_port+" -j DROP")
- main.ONOS1.handle.expect("\$")
- # Append to OUTPUT rule,
+ "sudo iptables -A INPUT -p tcp -s " + MN1_ip +
+ " --dport " + default_sw_port + " -j DROP" )
+ main.ONOS1.handle.expect( "\$" )
+ # Append to OUTPUT rule,
# behavior DROP that matches following:
# * packet type: tcp
# * source IP: MN1_ip
# * destination PORT: 6633
main.ONOS1.handle.sendline(
- "sudo iptables -A OUTPUT -p tcp -s "+MN1_ip+
- " --dport "+default_sw_port+" -j DROP")
- main.ONOS1.handle.expect("\$")
- #Give time to allow rule to take effect
- #NOTE: Sleep period may need to be configured
+ "sudo iptables -A OUTPUT -p tcp -s " + MN1_ip +
+ " --dport " + default_sw_port + " -j DROP" )
+ main.ONOS1.handle.expect( "\$" )
+ # Give time to allow rule to take effect
+ # NOTE: Sleep period may need to be configured
# based on the number of switches in the topology
- main.log.info("Please wait for switch connection to "+
- "time out")
- time.sleep(60)
-
- #Gather vendor OFP with tshark
- main.ONOS1.tshark_grep("OFP 86 Vendor",
- tshark_ofp_output)
- main.ONOS1.tshark_grep("TCP 74 ",
- tshark_tcp_output)
+ main.log.info( "Please wait for switch connection to " +
+ "time out" )
+ time.sleep( 60 )
- #NOTE: Remove all iptables rule quickly (flush)
- # Before removal, obtain TestON timestamp at which
+ # Gather vendor OFP with tshark
+ main.ONOS1.tshark_grep( "OFP 86 Vendor",
+ tshark_ofp_output )
+ main.ONOS1.tshark_grep( "TCP 74 ",
+ tshark_tcp_output )
+
+ # NOTE: Remove all iptables rule quickly ( flush )
+ # Before removal, obtain TestON timestamp at which
# removal took place
- # (ensuring nodes are configured via ptp)
+ # ( ensuring nodes are configured via ptp )
# sudo iptables -F
-
+
t0_system = time.time() * 1000
main.ONOS1.handle.sendline(
- "sudo iptables -F")
+ "sudo iptables -F" )
- #Counter to track loop count
+ # Counter to track loop count
counter_loop = 0
counter_avail1 = 0
counter_avail2 = 0
@@ -1490,126 +1550,124 @@
onos2_dev = False
onos3_dev = False
while counter_loop < 60:
- #Continue to check devices for all device
- #availability. When all devices in all 3
- #ONOS instances indicate that devices are available
- #obtain graph event timestamp for t1.
+ # Continue to check devices for all device
+ # availability. When all devices in all 3
+ # ONOS instances indicate that devices are available
+ # obtain graph event timestamp for t1.
device_str_obj1 = main.ONOS1cli.devices()
device_str_obj2 = main.ONOS2cli.devices()
device_str_obj3 = main.ONOS3cli.devices()
- device_json1 = json.loads(device_str_obj1)
- device_json2 = json.loads(device_str_obj2)
- device_json3 = json.loads(device_str_obj3)
-
+ device_json1 = json.loads( device_str_obj1 )
+ device_json2 = json.loads( device_str_obj2 )
+ device_json3 = json.loads( device_str_obj3 )
+
for device1 in device_json1:
- if device1['available'] == True:
+ if device1[ 'available' ]:
counter_avail1 += 1
- if counter_avail1 == int(num_sw):
+ if counter_avail1 == int( num_sw ):
onos1_dev = True
- main.log.info("All devices have been "+
- "discovered on ONOS1")
+ main.log.info( "All devices have been " +
+ "discovered on ONOS1" )
else:
counter_avail1 = 0
for device2 in device_json2:
- if device2['available'] == True:
+ if device2[ 'available' ]:
counter_avail2 += 1
- if counter_avail2 == int(num_sw):
+ if counter_avail2 == int( num_sw ):
onos2_dev = True
- main.log.info("All devices have been "+
- "discovered on ONOS2")
+ main.log.info( "All devices have been " +
+ "discovered on ONOS2" )
else:
counter_avail2 = 0
for device3 in device_json3:
- if device3['available'] == True:
+ if device3[ 'available' ]:
counter_avail3 += 1
- if counter_avail3 == int(num_sw):
+ if counter_avail3 == int( num_sw ):
onos3_dev = True
- main.log.info("All devices have been "+
- "discovered on ONOS3")
+ main.log.info( "All devices have been " +
+ "discovered on ONOS3" )
else:
counter_avail3 = 0
if onos1_dev and onos2_dev and onos3_dev:
- main.log.info("All devices have been discovered "+
- "on all ONOS instances")
+ main.log.info( "All devices have been discovered " +
+ "on all ONOS instances" )
json_str_topology_metrics_1 =\
main.ONOS1cli.topology_events_metrics()
json_str_topology_metrics_2 =\
main.ONOS2cli.topology_events_metrics()
json_str_topology_metrics_3 =\
main.ONOS3cli.topology_events_metrics()
-
- #Exit while loop if all devices discovered
- break
-
+
+ # Exit while loop if all devices discovered
+ break
+
counter_loop += 1
- #Give some time in between CLI calls
- #(will not affect measurement)
- time.sleep(3)
+ # Give some time in between CLI calls
+ #( will not affect measurement )
+ time.sleep( 3 )
main.ONOS1.tshark_stop()
-
- os.system("scp "+ONOS_user+"@"+ONOS1_ip+":"+
- tshark_ofp_output+" /tmp/")
- os.system("scp "+ONOS_user+"@"+ONOS1_ip+":"+
- tshark_tcp_output+" /tmp/")
- #TODO: Automate OFP output analysis
- #Debug mode - print out packets captured at runtime
- if debug_mode == 'on':
- ofp_file = open(tshark_ofp_output, 'r')
- main.log.info("Tshark OFP Vendor output: ")
+ os.system( "scp " + ONOS_user + "@" + ONOS1_ip + ":" +
+ tshark_ofp_output + " /tmp/" )
+ os.system( "scp " + ONOS_user + "@" + ONOS1_ip + ":" +
+ tshark_tcp_output + " /tmp/" )
+
+ # TODO: Automate OFP output analysis
+ # Debug mode - print out packets captured at runtime
+ if debug_mode == 'on':
+ ofp_file = open( tshark_ofp_output, 'r' )
+ main.log.info( "Tshark OFP Vendor output: " )
for line in ofp_file:
- tshark_ofp_result_list.append(line)
- main.log.info(line)
+ tshark_ofp_result_list.append( line )
+ main.log.info( line )
ofp_file.close()
- tcp_file = open(tshark_tcp_output, 'r')
- main.log.info("Tshark TCP 74 output: ")
+ tcp_file = open( tshark_tcp_output, 'r' )
+ main.log.info( "Tshark TCP 74 output: " )
for line in tcp_file:
- tshark_tcp_result_list.append(line)
- main.log.info(line)
+ tshark_tcp_result_list.append( line )
+ main.log.info( line )
tcp_file.close()
- json_obj_1 = json.loads(json_str_topology_metrics_1)
- json_obj_2 = json.loads(json_str_topology_metrics_2)
- json_obj_3 = json.loads(json_str_topology_metrics_3)
+ json_obj_1 = json.loads( json_str_topology_metrics_1 )
+ json_obj_2 = json.loads( json_str_topology_metrics_2 )
+ json_obj_3 = json.loads( json_str_topology_metrics_3 )
graph_timestamp_1 = \
- json_obj_1[graphTimestamp]['value']
+ json_obj_1[ graphTimestamp ][ 'value' ]
graph_timestamp_2 = \
- json_obj_2[graphTimestamp]['value']
+ json_obj_2[ graphTimestamp ][ 'value' ]
graph_timestamp_3 = \
- json_obj_3[graphTimestamp]['value']
+ json_obj_3[ graphTimestamp ][ 'value' ]
- graph_lat_1 = int(graph_timestamp_1) - int(t0_system)
- graph_lat_2 = int(graph_timestamp_2) - int(t0_system)
- graph_lat_3 = int(graph_timestamp_3) - int(t0_system)
+ graph_lat_1 = int( graph_timestamp_1 ) - int( t0_system )
+ graph_lat_2 = int( graph_timestamp_2 ) - int( t0_system )
+ graph_lat_3 = int( graph_timestamp_3 ) - int( t0_system )
avg_graph_lat = \
- (int(graph_lat_1) +\
- int(graph_lat_2) +\
- int(graph_lat_3)) / 3
-
+ ( int( graph_lat_1 ) +
+ int( graph_lat_2 ) +
+ int( graph_lat_3 ) ) / 3
+
if avg_graph_lat > sw_disc_threshold_min \
and avg_graph_lat < sw_disc_threshold_max:
sw_discovery_lat_list.append(
- avg_graph_lat)
+ avg_graph_lat )
else:
- main.log.info("100 Switch discovery latency "+
- "exceeded the threshold.")
-
- #END ITERATION FOR LOOP
+ main.log.info( "100 Switch discovery latency " +
+ "exceeded the threshold." )
- sw_lat_min = min(sw_discovery_lat_list)
- sw_lat_max = max(sw_discovery_lat_list)
- sw_lat_avg = sum(sw_discovery_lat_list) /\
- len(sw_discovery_lat_list)
+ # END ITERATION FOR LOOP
- main.log.report("100 Switch discovery lat "+\
- "Min: "+str(sw_lat_min)+" ms"+\
- "Max: "+str(sw_lat_max)+" ms"+\
- "Avg: "+str(sw_lat_avg)+" ms")
+ sw_lat_min = min( sw_discovery_lat_list )
+ sw_lat_max = max( sw_discovery_lat_list )
+ sw_lat_avg = sum( sw_discovery_lat_list ) /\
+ len( sw_discovery_lat_list )
-
+ main.log.report( "100 Switch discovery lat " +
+ "Min: " + str( sw_lat_min ) + " ms" +
+ "Max: " + str( sw_lat_max ) + " ms" +
+ "Avg: " + str( sw_lat_avg ) + " ms" )
diff --git a/TestON/tests/TopoPerfNextSingleNode/TopoPerfNextSingleNode.py b/TestON/tests/TopoPerfNextSingleNode/TopoPerfNextSingleNode.py
index d10c0ee..e81d905 100644
--- a/TestON/tests/TopoPerfNextSingleNode/TopoPerfNextSingleNode.py
+++ b/TestON/tests/TopoPerfNextSingleNode/TopoPerfNextSingleNode.py
@@ -1,1108 +1,1113 @@
-#TopoPerfNext
+# TopoPerfNext
#
-#Topology Performance test for ONOS-next
+# Topology Performance test for ONOS-next
#*** Revised for single node operation ***
#
-#andrew@onlab.us
+# andrew@onlab.us
import time
import sys
import os
import re
+
class TopoPerfNextSingleNode:
- def __init__(self):
+
+ def __init__( self ):
self.default = ''
- def CASE1(self, main):
- '''
+ def CASE1( self, main ):
+ """
ONOS startup sequence
- '''
+ """
import time
-
- cell_name = main.params['ENV']['cellName']
- git_pull = main.params['GIT']['autoPull']
- checkout_branch = main.params['GIT']['checkout']
+ cell_name = main.params[ 'ENV' ][ 'cellName' ]
- ONOS1_ip = main.params['CTRL']['ip1']
- MN1_ip = main.params['MN']['ip1']
- BENCH_ip = main.params['BENCH']['ip']
+ git_pull = main.params[ 'GIT' ][ 'autoPull' ]
+ checkout_branch = main.params[ 'GIT' ][ 'checkout' ]
- main.case("Setting up test environment")
+ ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+ MN1_ip = main.params[ 'MN' ][ 'ip1' ]
+ BENCH_ip = main.params[ 'BENCH' ][ 'ip' ]
- main.step("Creating cell file")
+ main.case( "Setting up test environment" )
+
+ main.step( "Creating cell file" )
cell_file_result = main.ONOSbench.create_cell_file(
- BENCH_ip, cell_name, MN1_ip, "onos-core",
- ONOS1_ip)
+ BENCH_ip, cell_name, MN1_ip, "onos-core",
+ ONOS1_ip )
- main.step("Applying cell file to environment")
- cell_apply_result = main.ONOSbench.set_cell(cell_name)
+ main.step( "Applying cell file to environment" )
+ cell_apply_result = main.ONOSbench.set_cell( cell_name )
verify_cell_result = main.ONOSbench.verify_cell()
-
- main.step("Git checkout and pull "+checkout_branch)
+
+ main.step( "Git checkout and pull " + checkout_branch )
if git_pull == 'on':
checkout_result = \
- main.ONOSbench.git_checkout(checkout_branch)
+ main.ONOSbench.git_checkout( checkout_branch )
pull_result = main.ONOSbench.git_pull()
else:
checkout_result = main.TRUE
pull_result = main.TRUE
- main.log.info("Skipped git checkout and pull")
+ main.log.info( "Skipped git checkout and pull" )
- main.step("Using mvn clean & install")
+ main.step( "Using mvn clean & install" )
#mvn_result = main.ONOSbench.clean_install()
mvn_result = main.TRUE
- main.step("Creating ONOS package")
+ main.step( "Creating ONOS package" )
package_result = main.ONOSbench.onos_package()
- main.step("Installing ONOS package")
- install1_result = main.ONOSbench.onos_install(node=ONOS1_ip)
+ main.step( "Installing ONOS package" )
+ install1_result = main.ONOSbench.onos_install( node=ONOS1_ip )
- #NOTE: This step may be unnecessary
- #main.step("Starting ONOS service")
- #start_result = main.ONOSbench.onos_start(ONOS1_ip)
+ # NOTE: This step may be unnecessary
+ #main.step( "Starting ONOS service" )
+ #start_result = main.ONOSbench.onos_start( ONOS1_ip )
- main.step("Set cell for ONOS cli env")
- main.ONOS1cli.set_cell(cell_name)
+ main.step( "Set cell for ONOS cli env" )
+ main.ONOS1cli.set_cell( cell_name )
- time.sleep(10)
+ time.sleep( 10 )
- main.step("Start onos cli")
- cli1 = main.ONOS1cli.start_onos_cli(ONOS1_ip)
+ main.step( "Start onos cli" )
+ cli1 = main.ONOS1cli.start_onos_cli( ONOS1_ip )
- main.step("Enable metrics feature")
- main.ONOS1cli.feature_install("onos-app-metrics")
+ main.step( "Enable metrics feature" )
+ main.ONOS1cli.feature_install( "onos-app-metrics" )
- utilities.assert_equals(expect=main.TRUE,
- actual= cell_file_result and cell_apply_result and\
- verify_cell_result and checkout_result and\
- pull_result and mvn_result and\
- install1_result,
- onpass="ONOS started successfully",
- onfail="Failed to start ONOS")
+ utilities.assert_equals( expect=main.TRUE,
+ actual=cell_file_result and cell_apply_result and
+ verify_cell_result and checkout_result and
+ pull_result and mvn_result and
+ install1_result,
+ onpass="ONOS started successfully",
+ onfail="Failed to start ONOS" )
- def CASE2(self, main):
- '''
+ def CASE2( self, main ):
+ """
Assign s1 to ONOS1 and measure latency
-
+
There are 4 levels of latency measurements to this test:
- 1) End-to-end measurement: Complete end-to-end measurement
- from TCP (SYN/ACK) handshake to Graph change
- 2) OFP-to-graph measurement: 'ONOS processing' snippet of
+ 1 ) End-to-end measurement: Complete end-to-end measurement
+ from TCP ( SYN/ACK ) handshake to Graph change
+ 2 ) OFP-to-graph measurement: 'ONOS processing' snippet of
measurement from OFP Vendor message to Graph change
- 3) OFP-to-device measurement: 'ONOS processing without
+ 3 ) OFP-to-device measurement: 'ONOS processing without
graph change' snippet of measurement from OFP vendor
message to Device change timestamp
- 4) T0-to-device measurement: Measurement that includes
- the switch handshake to devices timestamp without
- the graph view change. (TCP handshake -> Device
- change)
- '''
+ 4 ) T0-to-device measurement: Measurement that includes
+ the switch handshake to devices timestamp without
+ the graph view change. ( TCP handshake -> Device
+ change )
+ """
import time
import subprocess
import json
import requests
import os
- ONOS1_ip = main.params['CTRL']['ip1']
- ONOS_user = main.params['CTRL']['user']
+ ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+ ONOS_user = main.params[ 'CTRL' ][ 'user' ]
- default_sw_port = main.params['CTRL']['port1']
-
- #Number of iterations of case
- num_iter = main.params['TEST']['numIter']
-
- #Timestamp 'keys' for json metrics output.
- #These are subject to change, hence moved into params
- deviceTimestamp = main.params['JSON']['deviceTimestamp']
- graphTimestamp = main.params['JSON']['graphTimestamp']
+ default_sw_port = main.params[ 'CTRL' ][ 'port1' ]
- #List of switch add latency collected from
- #all iterations
+ # Number of iterations of case
+ num_iter = main.params[ 'TEST' ][ 'numIter' ]
+
+ # Timestamp 'keys' for json metrics output.
+ # These are subject to change, hence moved into params
+ deviceTimestamp = main.params[ 'JSON' ][ 'deviceTimestamp' ]
+ graphTimestamp = main.params[ 'JSON' ][ 'graphTimestamp' ]
+
+ # List of switch add latency collected from
+ # all iterations
latency_end_to_end_list = []
latency_ofp_to_graph_list = []
latency_ofp_to_device_list = []
latency_t0_to_device_list = []
- #Directory/file to store tshark results
+ # Directory/file to store tshark results
tshark_of_output = "/tmp/tshark_of_topo.txt"
tshark_tcp_output = "/tmp/tshark_tcp_topo.txt"
- #String to grep in tshark output
- tshark_tcp_string = "TCP 74 "+default_sw_port
+ # String to grep in tshark output
+ tshark_tcp_string = "TCP 74 " + default_sw_port
tshark_of_string = "OFP 86 Vendor"
-
- #Initialize assertion to TRUE
+
+ # Initialize assertion to TRUE
assertion = main.TRUE
-
- main.log.report("Latency of adding one switch")
- for i in range(0, int(num_iter)):
- main.log.info("Starting tshark capture")
+ main.log.report( "Latency of adding one switch" )
- #* TCP [ACK, SYN] is used as t0_a, the
- # very first "exchange" between ONOS and
+ for i in range( 0, int( num_iter ) ):
+ main.log.info( "Starting tshark capture" )
+
+ #* TCP [ ACK, SYN ] is used as t0_a, the
+ # very first "exchange" between ONOS and
# the switch for end-to-end measurement
- #* OFP [Stats Reply] is used for t0_b
+ #* OFP [ Stats Reply ] is used for t0_b
# the very last OFP message between ONOS
# and the switch for ONOS measurement
- main.ONOS1.tshark_grep(tshark_tcp_string,
- tshark_tcp_output)
- main.ONOS1.tshark_grep(tshark_of_string,
- tshark_of_output)
+ main.ONOS1.tshark_grep( tshark_tcp_string,
+ tshark_tcp_output )
+ main.ONOS1.tshark_grep( tshark_of_string,
+ tshark_of_output )
- #Wait and ensure tshark is started and
- #capturing
- time.sleep(10)
+ # Wait and ensure tshark is started and
+ # capturing
+ time.sleep( 10 )
- main.log.info("Assigning s1 to controller")
+ main.log.info( "Assigning s1 to controller" )
- main.Mininet1.assign_sw_controller(sw="1",
- ip1=ONOS1_ip, port1=default_sw_port)
+ main.Mininet1.assign_sw_controller(
+ sw="1",
+ ip1=ONOS1_ip,
+ port1=default_sw_port )
- #Wait and ensure switch is assigned
- #before stopping tshark
- time.sleep(30)
-
- main.log.info("Stopping all Tshark processes")
+ # Wait and ensure switch is assigned
+ # before stopping tshark
+ time.sleep( 30 )
+
+ main.log.info( "Stopping all Tshark processes" )
main.ONOS1.stop_tshark()
- #tshark output is saved in ONOS. Use subprocess
- #to copy over files to TestON for parsing
- main.log.info("Copying over tshark files")
-
- #TCP CAPTURE ****
- #Copy the tshark output from ONOS machine to
- #TestON machine in tshark_tcp_output directory>file
- os.system("scp "+ONOS_user+"@"+ONOS1_ip+":"+
- tshark_tcp_output+" /tmp/")
- tcp_file = open(tshark_tcp_output, 'r')
- temp_text = tcp_file.readline()
- temp_text = temp_text.split(" ")
+ # tshark output is saved in ONOS. Use subprocess
+ # to copy over files to TestON for parsing
+ main.log.info( "Copying over tshark files" )
- main.log.info("Object read in from TCP capture: "+
- str(temp_text))
- if len(temp_text) > 1:
- t0_tcp = float(temp_text[1])*1000.0
+ # TCP CAPTURE ****
+ # Copy the tshark output from ONOS machine to
+ # TestON machine in tshark_tcp_output directory>file
+ os.system( "scp " + ONOS_user + "@" + ONOS1_ip + ":" +
+ tshark_tcp_output + " /tmp/" )
+ tcp_file = open( tshark_tcp_output, 'r' )
+ temp_text = tcp_file.readline()
+ temp_text = temp_text.split( " " )
+
+ main.log.info( "Object read in from TCP capture: " +
+ str( temp_text ) )
+ if len( temp_text ) > 1:
+ t0_tcp = float( temp_text[ 1 ] ) * 1000.0
else:
- main.log.error("Tshark output file for TCP"+
- " returned unexpected results")
+ main.log.error( "Tshark output file for TCP" +
+ " returned unexpected results" )
t0_tcp = 0
assertion = main.FALSE
-
+
tcp_file.close()
#****************
- #OF CAPTURE ****
- os.system("scp "+ONOS_user+"@"+ONOS1_ip+":"+
- tshark_of_output+" /tmp/")
- of_file = open(tshark_of_output, 'r')
-
+ # OF CAPTURE ****
+ os.system( "scp " + ONOS_user + "@" + ONOS1_ip + ":" +
+ tshark_of_output + " /tmp/" )
+ of_file = open( tshark_of_output, 'r' )
+
line_ofp = ""
- #Read until last line of file
+ # Read until last line of file
while True:
temp_text = of_file.readline()
- if temp_text !='':
+ if temp_text != '':
line_ofp = temp_text
else:
- break
- obj = line_ofp.split(" ")
-
- main.log.info("Object read in from OFP capture: "+
- str(line_ofp))
-
- if len(line_ofp) > 1:
- t0_ofp = float(obj[1])*1000.0
+ break
+ obj = line_ofp.split( " " )
+
+ main.log.info( "Object read in from OFP capture: " +
+ str( line_ofp ) )
+
+ if len( line_ofp ) > 1:
+ t0_ofp = float( obj[ 1 ] ) * 1000.0
else:
- main.log.error("Tshark output file for OFP"+
- " returned unexpected results")
+ main.log.error( "Tshark output file for OFP" +
+ " returned unexpected results" )
t0_ofp = 0
assertion = main.FALSE
-
+
of_file.close()
#****************
-
+
json_str_1 = main.ONOS1cli.topology_events_metrics()
- json_obj_1 = json.loads(json_str_1)
+ json_obj_1 = json.loads( json_str_1 )
- #Obtain graph timestamp. This timestsamp captures
- #the epoch time at which the topology graph was updated.
+ # Obtain graph timestamp. This timestsamp captures
+ # the epoch time at which the topology graph was updated.
graph_timestamp_1 = \
- json_obj_1[graphTimestamp]['value']
+ json_obj_1[ graphTimestamp ][ 'value' ]
- #Obtain device timestamp. This timestamp captures
- #the epoch time at which the device event happened
+ # Obtain device timestamp. This timestamp captures
+ # the epoch time at which the device event happened
device_timestamp_1 = \
- json_obj_1[deviceTimestamp]['value']
-
- #t0 to device processing latency
- delta_device_1 = int(device_timestamp_1) - int(t0_tcp)
-
- #Get average of delta from all instances
- avg_delta_device = (int(delta_device_1))
+ json_obj_1[ deviceTimestamp ][ 'value' ]
- #Ensure avg delta meets the threshold before appending
+ # t0 to device processing latency
+ delta_device_1 = int( device_timestamp_1 ) - int( t0_tcp )
+
+ # Get average of delta from all instances
+ avg_delta_device = ( int( delta_device_1 ) )
+
+ # Ensure avg delta meets the threshold before appending
if avg_delta_device > 0.0 and avg_delta_device < 10000:
- latency_t0_to_device_list.append(avg_delta_device)
+ latency_t0_to_device_list.append( avg_delta_device )
else:
- main.log.info("Results for t0-to-device ignored"+\
- "due to excess in threshold")
+ main.log.info( "Results for t0-to-device ignored" +
+ "due to excess in threshold" )
- #t0 to graph processing latency (end-to-end)
- delta_graph_1 = int(graph_timestamp_1) - int(t0_tcp)
-
- #Get average of delta from all instances
- avg_delta_graph = int(delta_graph_1)
+ # t0 to graph processing latency ( end-to-end )
+ delta_graph_1 = int( graph_timestamp_1 ) - int( t0_tcp )
- #Ensure avg delta meets the threshold before appending
+ # Get average of delta from all instances
+ avg_delta_graph = int( delta_graph_1 )
+
+ # Ensure avg delta meets the threshold before appending
if avg_delta_graph > 0.0 and avg_delta_graph < 10000:
- latency_end_to_end_list.append(avg_delta_graph)
+ latency_end_to_end_list.append( avg_delta_graph )
else:
- main.log.info("Results for end-to-end ignored"+\
- "due to excess in threshold")
+ main.log.info( "Results for end-to-end ignored" +
+ "due to excess in threshold" )
- #ofp to graph processing latency (ONOS processing)
- delta_ofp_graph_1 = int(graph_timestamp_1) - int(t0_ofp)
-
- avg_delta_ofp_graph = int(delta_ofp_graph_1)
-
+ # ofp to graph processing latency ( ONOS processing )
+ delta_ofp_graph_1 = int( graph_timestamp_1 ) - int( t0_ofp )
+
+ avg_delta_ofp_graph = int( delta_ofp_graph_1 )
+
if avg_delta_ofp_graph > 0.0 and avg_delta_ofp_graph < 10000:
- latency_ofp_to_graph_list.append(avg_delta_ofp_graph)
+ latency_ofp_to_graph_list.append( avg_delta_ofp_graph )
else:
- main.log.info("Results for ofp-to-graph "+\
- "ignored due to excess in threshold")
+ main.log.info( "Results for ofp-to-graph " +
+ "ignored due to excess in threshold" )
- #ofp to device processing latency (ONOS processing)
- delta_ofp_device_1 = float(device_timestamp_1) - float(t0_ofp)
-
- avg_delta_ofp_device = float(delta_ofp_device_1)
-
- #NOTE: ofp - delta measurements are occasionally negative
+ # ofp to device processing latency ( ONOS processing )
+ delta_ofp_device_1 = float( device_timestamp_1 ) - float( t0_ofp )
+
+ avg_delta_ofp_device = float( delta_ofp_device_1 )
+
+ # NOTE: ofp - delta measurements are occasionally negative
# due to system time misalignment.
- latency_ofp_to_device_list.append(avg_delta_ofp_device)
+ latency_ofp_to_device_list.append( avg_delta_ofp_device )
- #TODO:
- #Fetch logs upon threshold excess
+ # TODO:
+ # Fetch logs upon threshold excess
- main.log.info("ONOS1 delta end-to-end: "+
- str(delta_graph_1) + " ms")
+ main.log.info( "ONOS1 delta end-to-end: " +
+ str( delta_graph_1 ) + " ms" )
- main.log.info("ONOS1 delta OFP - graph: "+
- str(delta_ofp_graph_1) + " ms")
-
- main.log.info("ONOS1 delta device - t0: "+
- str(delta_device_1) + " ms")
-
- main.step("Remove switch from controller")
- main.Mininet1.delete_sw_controller("s1")
+ main.log.info( "ONOS1 delta OFP - graph: " +
+ str( delta_ofp_graph_1 ) + " ms" )
- time.sleep(5)
+ main.log.info( "ONOS1 delta device - t0: " +
+ str( delta_device_1 ) + " ms" )
- #END of for loop iteration
+ main.step( "Remove switch from controller" )
+ main.Mininet1.delete_sw_controller( "s1" )
- #If there is at least 1 element in each list,
- #pass the test case
- if len(latency_end_to_end_list) > 0 and\
- len(latency_ofp_to_graph_list) > 0 and\
- len(latency_ofp_to_device_list) > 0 and\
- len(latency_t0_to_device_list) > 0:
+ time.sleep( 5 )
+
+ # END of for loop iteration
+
+ # If there is at least 1 element in each list,
+ # pass the test case
+ if len( latency_end_to_end_list ) > 0 and\
+ len( latency_ofp_to_graph_list ) > 0 and\
+ len( latency_ofp_to_device_list ) > 0 and\
+ len( latency_t0_to_device_list ) > 0:
assertion = main.TRUE
- elif len(latency_end_to_end_list) == 0:
- #The appending of 0 here is to prevent
- #the min,max,sum functions from failing
- #below
- latency_end_to_end_list.append(0)
+ elif len( latency_end_to_end_list ) == 0:
+ # The appending of 0 here is to prevent
+ # the min,max,sum functions from failing
+ # below
+ latency_end_to_end_list.append( 0 )
assertion = main.FALSE
- elif len(latency_ofp_to_graph_list) == 0:
- latency_ofp_to_graph_list.append(0)
+ elif len( latency_ofp_to_graph_list ) == 0:
+ latency_ofp_to_graph_list.append( 0 )
assertion = main.FALSE
- elif len(latency_ofp_to_device_list) == 0:
- latency_ofp_to_device_list.append(0)
+ elif len( latency_ofp_to_device_list ) == 0:
+ latency_ofp_to_device_list.append( 0 )
assertion = main.FALSE
- elif len(latency_t0_to_device_list) == 0:
- latency_t0_to_device_list.append(0)
+ elif len( latency_t0_to_device_list ) == 0:
+ latency_t0_to_device_list.append( 0 )
assertion = main.FALSE
- #Calculate min, max, avg of latency lists
+ # Calculate min, max, avg of latency lists
latency_end_to_end_max = \
- int(max(latency_end_to_end_list))
+ int( max( latency_end_to_end_list ) )
latency_end_to_end_min = \
- int(min(latency_end_to_end_list))
+ int( min( latency_end_to_end_list ) )
latency_end_to_end_avg = \
- (int(sum(latency_end_to_end_list)) / \
- len(latency_end_to_end_list))
-
+ ( int( sum( latency_end_to_end_list ) ) /
+ len( latency_end_to_end_list ) )
+
latency_ofp_to_graph_max = \
- int(max(latency_ofp_to_graph_list))
+ int( max( latency_ofp_to_graph_list ) )
latency_ofp_to_graph_min = \
- int(min(latency_ofp_to_graph_list))
+ int( min( latency_ofp_to_graph_list ) )
latency_ofp_to_graph_avg = \
- (int(sum(latency_ofp_to_graph_list)) / \
- len(latency_ofp_to_graph_list))
+ ( int( sum( latency_ofp_to_graph_list ) ) /
+ len( latency_ofp_to_graph_list ) )
latency_ofp_to_device_max = \
- int(max(latency_ofp_to_device_list))
+ int( max( latency_ofp_to_device_list ) )
latency_ofp_to_device_min = \
- int(min(latency_ofp_to_device_list))
+ int( min( latency_ofp_to_device_list ) )
latency_ofp_to_device_avg = \
- (int(sum(latency_ofp_to_device_list)) / \
- len(latency_ofp_to_device_list))
+ ( int( sum( latency_ofp_to_device_list ) ) /
+ len( latency_ofp_to_device_list ) )
latency_t0_to_device_max = \
- float(max(latency_t0_to_device_list))
+ float( max( latency_t0_to_device_list ) )
latency_t0_to_device_min = \
- float(min(latency_t0_to_device_list))
+ float( min( latency_t0_to_device_list ) )
latency_t0_to_device_avg = \
- (float(sum(latency_t0_to_device_list)) / \
- len(latency_ofp_to_device_list))
+ ( float( sum( latency_t0_to_device_list ) ) /
+ len( latency_ofp_to_device_list ) )
- main.log.report("Switch add - End-to-end latency: \n"+\
- "Min: "+str(latency_end_to_end_min)+"\n"+\
- "Max: "+str(latency_end_to_end_max)+"\n"+\
- "Avg: "+str(latency_end_to_end_avg))
- main.log.report("Switch add - OFP-to-Graph latency: \n"+\
- "Min: "+str(latency_ofp_to_graph_min)+"\n"+\
- "Max: "+str(latency_ofp_to_graph_max)+"\n"+\
- "Avg: "+str(latency_ofp_to_graph_avg))
- main.log.report("Switch add - t0-to-Device latency: \n"+\
- "Min: "+str(latency_t0_to_device_min)+"\n"+\
- "Max: "+str(latency_t0_to_device_max)+"\n"+\
- "Avg: "+str(latency_t0_to_device_avg))
+ main.log.report( "Switch add - End-to-end latency: \n" +
+ "Min: " + str( latency_end_to_end_min ) + "\n" +
+ "Max: " + str( latency_end_to_end_max ) + "\n" +
+ "Avg: " + str( latency_end_to_end_avg ) )
+ main.log.report( "Switch add - OFP-to-Graph latency: \n" +
+ "Min: " + str( latency_ofp_to_graph_min ) + "\n" +
+ "Max: " + str( latency_ofp_to_graph_max ) + "\n" +
+ "Avg: " + str( latency_ofp_to_graph_avg ) )
+ main.log.report( "Switch add - t0-to-Device latency: \n" +
+ "Min: " + str( latency_t0_to_device_min ) + "\n" +
+ "Max: " + str( latency_t0_to_device_max ) + "\n" +
+ "Avg: " + str( latency_t0_to_device_avg ) )
- utilities.assert_equals(expect=main.TRUE, actual=assertion,
- onpass="Switch latency test successful",
- onfail="Switch latency test failed")
+ utilities.assert_equals( expect=main.TRUE, actual=assertion,
+ onpass="Switch latency test successful",
+ onfail="Switch latency test failed" )
- def CASE3(self, main):
- '''
+ def CASE3( self, main ):
+ """
Bring port up / down and measure latency.
Port enable / disable is simulated by ifconfig up / down
-
- In ONOS-next, we must ensure that the port we are
+
+ In ONOS-next, we must ensure that the port we are
manipulating is connected to another switch with a valid
connection. Otherwise, graph view will not be updated.
- '''
+ """
import time
import subprocess
import os
import requests
import json
- ONOS1_ip = main.params['CTRL']['ip1']
- ONOS_user = main.params['CTRL']['user']
+ ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+ ONOS_user = main.params[ 'CTRL' ][ 'user' ]
- default_sw_port = main.params['CTRL']['port1']
-
+ default_sw_port = main.params[ 'CTRL' ][ 'port1' ]
+
assertion = main.TRUE
- #Number of iterations of case
- num_iter = main.params['TEST']['numIter']
-
- #Timestamp 'keys' for json metrics output.
- #These are subject to change, hence moved into params
- deviceTimestamp = main.params['JSON']['deviceTimestamp']
- graphTimestamp = main.params['JSON']['graphTimestamp']
+ # Number of iterations of case
+ num_iter = main.params[ 'TEST' ][ 'numIter' ]
- #NOTE: Some hardcoded variables you may need to configure
+ # Timestamp 'keys' for json metrics output.
+ # These are subject to change, hence moved into params
+ deviceTimestamp = main.params[ 'JSON' ][ 'deviceTimestamp' ]
+ graphTimestamp = main.params[ 'JSON' ][ 'graphTimestamp' ]
+
+ # NOTE: Some hardcoded variables you may need to configure
# besides the params
-
+
tshark_port_status = "OFP 130 Port Status"
tshark_port_up = "/tmp/tshark_port_up.txt"
tshark_port_down = "/tmp/tshark_port_down.txt"
interface_config = "s1-eth1"
- main.log.report("Port enable / disable latency")
+ main.log.report( "Port enable / disable latency" )
- main.step("Assign switches s1 and s2 to controller 1")
- main.Mininet1.assign_sw_controller(sw="1",ip1=ONOS1_ip,
- port1=default_sw_port)
- main.Mininet1.assign_sw_controller(sw="2",ip1=ONOS1_ip,
- port1=default_sw_port)
+ main.step( "Assign switches s1 and s2 to controller 1" )
+ main.Mininet1.assign_sw_controller( sw="1", ip1=ONOS1_ip,
+ port1=default_sw_port )
+ main.Mininet1.assign_sw_controller( sw="2", ip1=ONOS1_ip,
+ port1=default_sw_port )
- #Give enough time for metrics to propagate the
- #assign controller event. Otherwise, these events may
- #carry over to our measurements
- time.sleep(10)
+ # Give enough time for metrics to propagate the
+ # assign controller event. Otherwise, these events may
+ # carry over to our measurements
+ time.sleep( 10 )
- main.step("Verify switch is assigned correctly")
- result_s1 = main.Mininet1.get_sw_controller(sw="s1")
- result_s2 = main.Mininet1.get_sw_controller(sw="s2")
+ main.step( "Verify switch is assigned correctly" )
+ result_s1 = main.Mininet1.get_sw_controller( sw="s1" )
+ result_s2 = main.Mininet1.get_sw_controller( sw="s2" )
if result_s1 == main.FALSE or result_s2 == main.FALSE:
- main.log.info("Switch s1 was not assigned correctly")
+ main.log.info( "Switch s1 was not assigned correctly" )
assertion = main.FALSE
else:
- main.log.info("Switch s1 was assigned correctly")
+ main.log.info( "Switch s1 was assigned correctly" )
port_up_device_to_ofp_list = []
port_up_graph_to_ofp_list = []
port_down_device_to_ofp_list = []
port_down_graph_to_ofp_list = []
- for i in range(0, int(num_iter)):
- main.step("Starting wireshark capture for port status down")
- main.ONOS1.tshark_grep(tshark_port_status,
- tshark_port_down)
-
- time.sleep(10)
+ for i in range( 0, int( num_iter ) ):
+ main.step( "Starting wireshark capture for port status down" )
+ main.ONOS1.tshark_grep( tshark_port_status,
+ tshark_port_down )
- #Disable interface that is connected to switch 2
- main.step("Disable port: "+interface_config)
- main.Mininet2.handle.sendline("sudo ifconfig "+
- interface_config+" down")
- main.Mininet2.handle.expect("\$")
- time.sleep(10)
+ time.sleep( 10 )
+
+ # Disable interface that is connected to switch 2
+ main.step( "Disable port: " + interface_config )
+ main.Mininet2.handle.sendline( "sudo ifconfig " +
+ interface_config + " down" )
+ main.Mininet2.handle.expect( "\$" )
+ time.sleep( 10 )
main.ONOS1.tshark_stop()
- time.sleep(5)
-
- #Copy tshark output file from ONOS to TestON instance
- #/tmp directory
- os.system("scp "+ONOS_user+"@"+ONOS1_ip+":"+
- tshark_port_down+" /tmp/")
+ time.sleep( 5 )
- f_port_down = open(tshark_port_down, 'r')
- #Get first line of port down event from tshark
+ # Copy tshark output file from ONOS to TestON instance
+ #/tmp directory
+ os.system( "scp " + ONOS_user + "@" + ONOS1_ip + ":" +
+ tshark_port_down + " /tmp/" )
+
+ f_port_down = open( tshark_port_down, 'r' )
+ # Get first line of port down event from tshark
f_line = f_port_down.readline()
- obj_down = f_line.split(" ")
- if len(f_line) > 0:
- timestamp_begin_pt_down = int(float(obj_down[1]))*1000
- main.log.info("Port down begin timestamp: "+
- str(timestamp_begin_pt_down))
+ obj_down = f_line.split( " " )
+ if len( f_line ) > 0:
+ timestamp_begin_pt_down = int( float( obj_down[ 1 ] ) ) * 1000
+ main.log.info( "Port down begin timestamp: " +
+ str( timestamp_begin_pt_down ) )
else:
- main.log.info("Tshark output file returned unexpected"+
- " results: "+str(obj_down))
+ main.log.info( "Tshark output file returned unexpected" +
+ " results: " + str( obj_down ) )
timestamp_begin_pt_down = 0
-
+
f_port_down.close()
- main.log.info("TEST tshark obj: "+str(obj_down))
+ main.log.info( "TEST tshark obj: " + str( obj_down ) )
- main.step("Obtain t1 by REST call")
+ main.step( "Obtain t1 by REST call" )
json_str_1 = main.ONOS1cli.topology_events_metrics()
- main.log.info("TEST json_str 1: "+str(json_str_1))
+ main.log.info( "TEST json_str 1: " + str( json_str_1 ) )
- json_obj_1 = json.loads(json_str_1)
-
- time.sleep(5)
+ json_obj_1 = json.loads( json_str_1 )
- #Obtain graph timestamp. This timestsamp captures
- #the epoch time at which the topology graph was updated.
+ time.sleep( 5 )
+
+ # Obtain graph timestamp. This timestsamp captures
+ # the epoch time at which the topology graph was updated.
graph_timestamp_1 = \
- json_obj_1[graphTimestamp]['value']
+ json_obj_1[ graphTimestamp ][ 'value' ]
- #Obtain device timestamp. This timestamp captures
- #the epoch time at which the device event happened
+ # Obtain device timestamp. This timestamp captures
+ # the epoch time at which the device event happened
device_timestamp_1 = \
- json_obj_1[deviceTimestamp]['value']
+ json_obj_1[ deviceTimestamp ][ 'value' ]
- #Get delta between graph event and OFP
- pt_down_graph_to_ofp_1 = int(graph_timestamp_1) -\
- int(timestamp_begin_pt_down)
+ # Get delta between graph event and OFP
+ pt_down_graph_to_ofp_1 = int( graph_timestamp_1 ) -\
+ int( timestamp_begin_pt_down )
- #Get delta between device event and OFP
- pt_down_device_to_ofp_1 = int(device_timestamp_1) -\
- int(timestamp_begin_pt_down)
-
- #Caluclate average across clusters
- pt_down_graph_to_ofp_avg = int(pt_down_graph_to_ofp_1)
- pt_down_device_to_ofp_avg = int(pt_down_device_to_ofp_1)
+ # Get delta between device event and OFP
+ pt_down_device_to_ofp_1 = int( device_timestamp_1 ) -\
+ int( timestamp_begin_pt_down )
+
+ # Caluclate average across clusters
+ pt_down_graph_to_ofp_avg = int( pt_down_graph_to_ofp_1 )
+ pt_down_device_to_ofp_avg = int( pt_down_device_to_ofp_1 )
if pt_down_graph_to_ofp_avg > 0.0 and \
pt_down_graph_to_ofp_avg < 1000:
port_down_graph_to_ofp_list.append(
- pt_down_graph_to_ofp_avg)
- main.log.info("Port down: graph to ofp avg: "+
- str(pt_down_graph_to_ofp_avg) + " ms")
+ pt_down_graph_to_ofp_avg )
+ main.log.info( "Port down: graph to ofp avg: " +
+ str( pt_down_graph_to_ofp_avg ) + " ms" )
else:
- main.log.info("Average port down graph-to-ofp result" +
- " exceeded the threshold: "+
- str(pt_down_graph_to_ofp_avg))
+ main.log.info( "Average port down graph-to-ofp result" +
+ " exceeded the threshold: " +
+ str( pt_down_graph_to_ofp_avg ) )
if pt_down_device_to_ofp_avg > 0 and \
pt_down_device_to_ofp_avg < 1000:
port_down_device_to_ofp_list.append(
- pt_down_device_to_ofp_avg)
- main.log.info("Port down: device to ofp avg: "+
- str(pt_down_device_to_ofp_avg) + " ms")
+ pt_down_device_to_ofp_avg )
+ main.log.info( "Port down: device to ofp avg: " +
+ str( pt_down_device_to_ofp_avg ) + " ms" )
else:
- main.log.info("Average port down device-to-ofp result" +
- " exceeded the threshold: "+
- str(pt_down_device_to_ofp_avg))
+ main.log.info( "Average port down device-to-ofp result" +
+ " exceeded the threshold: " +
+ str( pt_down_device_to_ofp_avg ) )
- #Port up events
- main.step("Enable port and obtain timestamp")
- main.step("Starting wireshark capture for port status up")
- main.ONOS1.tshark_grep("OFP 130 Port Status", tshark_port_up)
- time.sleep(5)
+ # Port up events
+ main.step( "Enable port and obtain timestamp" )
+ main.step( "Starting wireshark capture for port status up" )
+ main.ONOS1.tshark_grep( "OFP 130 Port Status", tshark_port_up )
+ time.sleep( 5 )
- main.Mininet2.handle.sendline("sudo ifconfig "+
- interface_config+" up")
- main.Mininet2.handle.expect("\$")
- time.sleep(10)
-
+ main.Mininet2.handle.sendline( "sudo ifconfig " +
+ interface_config + " up" )
+ main.Mininet2.handle.expect( "\$" )
+ time.sleep( 10 )
+
main.ONOS1.tshark_stop()
- os.system("scp "+ONOS_user+"@"+ONOS1_ip+":"+
- tshark_port_up+" /tmp/")
+ os.system( "scp " + ONOS_user + "@" + ONOS1_ip + ":" +
+ tshark_port_up + " /tmp/" )
- f_port_up = open(tshark_port_up, 'r')
+ f_port_up = open( tshark_port_up, 'r' )
f_line = f_port_up.readline()
- obj_up = f_line.split(" ")
- if len(f_line) > 0:
- timestamp_begin_pt_up = int(float(obj_up[1]))*1000
- main.log.info("Port up begin timestamp: "+
- str(timestamp_begin_pt_up))
+ obj_up = f_line.split( " " )
+ if len( f_line ) > 0:
+ timestamp_begin_pt_up = int( float( obj_up[ 1 ] ) ) * 1000
+ main.log.info( "Port up begin timestamp: " +
+ str( timestamp_begin_pt_up ) )
else:
- main.log.info("Tshark output file returned unexpected"+
- " results.")
+ main.log.info( "Tshark output file returned unexpected" +
+ " results." )
timestamp_begin_pt_up = 0
-
+
f_port_up.close()
- main.step("Obtain t1 by REST call")
+ main.step( "Obtain t1 by REST call" )
json_str_1 = main.ONOS1cli.topology_events_metrics()
- json_obj_1 = json.loads(json_str_1)
+ json_obj_1 = json.loads( json_str_1 )
- #Obtain graph timestamp. This timestsamp captures
- #the epoch time at which the topology graph was updated.
+ # Obtain graph timestamp. This timestsamp captures
+ # the epoch time at which the topology graph was updated.
graph_timestamp_1 = \
- json_obj_1[graphTimestamp]['value']
+ json_obj_1[ graphTimestamp ][ 'value' ]
- #Obtain device timestamp. This timestamp captures
- #the epoch time at which the device event happened
+ # Obtain device timestamp. This timestamp captures
+ # the epoch time at which the device event happened
device_timestamp_1 = \
- json_obj_1[deviceTimestamp]['value']
-
- #Get delta between graph event and OFP
- pt_up_graph_to_ofp_1 = int(graph_timestamp_1) -\
- int(timestamp_begin_pt_up)
+ json_obj_1[ deviceTimestamp ][ 'value' ]
- #Get delta between device event and OFP
- pt_up_device_to_ofp_1 = int(device_timestamp_1) -\
- int(timestamp_begin_pt_up)
+ # Get delta between graph event and OFP
+ pt_up_graph_to_ofp_1 = int( graph_timestamp_1 ) -\
+ int( timestamp_begin_pt_up )
- pt_up_graph_to_ofp_avg = float(pt_up_graph_to_ofp_1)
+ # Get delta between device event and OFP
+ pt_up_device_to_ofp_1 = int( device_timestamp_1 ) -\
+ int( timestamp_begin_pt_up )
- pt_up_device_to_ofp_avg = float(pt_up_device_to_ofp_1)
+ pt_up_graph_to_ofp_avg = float( pt_up_graph_to_ofp_1 )
+
+ pt_up_device_to_ofp_avg = float( pt_up_device_to_ofp_1 )
if pt_up_graph_to_ofp_avg > 0 and \
pt_up_graph_to_ofp_avg < 1000:
port_up_graph_to_ofp_list.append(
- pt_up_graph_to_ofp_avg)
- main.log.info("Port down: graph to ofp avg: "+
- str(pt_up_graph_to_ofp_avg) + " ms")
+ pt_up_graph_to_ofp_avg )
+ main.log.info( "Port down: graph to ofp avg: " +
+ str( pt_up_graph_to_ofp_avg ) + " ms" )
else:
- main.log.info("Average port up graph-to-ofp result"+
- " exceeded the threshold: "+
- str(pt_up_graph_to_ofp_avg))
-
+ main.log.info( "Average port up graph-to-ofp result" +
+ " exceeded the threshold: " +
+ str( pt_up_graph_to_ofp_avg ) )
+
if pt_up_device_to_ofp_avg > 0 and \
pt_up_device_to_ofp_avg < 1000:
port_up_device_to_ofp_list.append(
- pt_up_device_to_ofp_avg)
- main.log.info("Port up: device to ofp avg: "+
- str(pt_up_device_to_ofp_avg) + " ms")
+ pt_up_device_to_ofp_avg )
+ main.log.info( "Port up: device to ofp avg: " +
+ str( pt_up_device_to_ofp_avg ) + " ms" )
else:
- main.log.info("Average port up device-to-ofp result"+
- " exceeded the threshold: "+
- str(pt_up_device_to_ofp_avg))
-
- #END ITERATION FOR LOOP
-
- #Check all list for latency existence and set assertion
- if (port_down_graph_to_ofp_list and port_down_device_to_ofp_list\
- and port_up_graph_to_ofp_list and port_up_device_to_ofp_list):
+ main.log.info( "Average port up device-to-ofp result" +
+ " exceeded the threshold: " +
+ str( pt_up_device_to_ofp_avg ) )
+
+ # END ITERATION FOR LOOP
+
+ # Check all list for latency existence and set assertion
+ if ( port_down_graph_to_ofp_list and port_down_device_to_ofp_list
+ and port_up_graph_to_ofp_list and port_up_device_to_ofp_list ):
assertion = main.TRUE
- #Calculate and report latency measurements
- port_down_graph_to_ofp_min = min(port_down_graph_to_ofp_list)
- port_down_graph_to_ofp_max = max(port_down_graph_to_ofp_list)
+ # Calculate and report latency measurements
+ port_down_graph_to_ofp_min = min( port_down_graph_to_ofp_list )
+ port_down_graph_to_ofp_max = max( port_down_graph_to_ofp_list )
port_down_graph_to_ofp_avg = \
- (sum(port_down_graph_to_ofp_list) /
- len(port_down_graph_to_ofp_list))
-
- main.log.report("Port down graph-to-ofp Min: "+
- str(port_down_graph_to_ofp_min)+" ms Max: "+
- str(port_down_graph_to_ofp_max)+" ms Avg: "+
- str(port_down_graph_to_ofp_avg))
-
- port_down_device_to_ofp_min = min(port_down_device_to_ofp_list)
- port_down_device_to_ofp_max = max(port_down_device_to_ofp_list)
+ ( sum( port_down_graph_to_ofp_list ) /
+ len( port_down_graph_to_ofp_list ) )
+
+ main.log.report( "Port down graph-to-ofp Min: " +
+ str( port_down_graph_to_ofp_min ) + " ms Max: " +
+ str( port_down_graph_to_ofp_max ) + " ms Avg: " +
+ str( port_down_graph_to_ofp_avg ) )
+
+ port_down_device_to_ofp_min = min( port_down_device_to_ofp_list )
+ port_down_device_to_ofp_max = max( port_down_device_to_ofp_list )
port_down_device_to_ofp_avg = \
- (sum(port_down_device_to_ofp_list) /\
- len(port_down_device_to_ofp_list))
-
- main.log.report("Port down device-to-ofp Min: "+
- str(port_down_device_to_ofp_min)+" ms Max: "+
- str(port_down_device_to_ofp_max)+" ms Avg: "+
- str(port_down_device_to_ofp_avg))
-
- port_up_graph_to_ofp_min = min(port_up_graph_to_ofp_list)
- port_up_graph_to_ofp_max = max(port_up_graph_to_ofp_list)
+ ( sum( port_down_device_to_ofp_list ) /
+ len( port_down_device_to_ofp_list ) )
+
+ main.log.report( "Port down device-to-ofp Min: " +
+ str( port_down_device_to_ofp_min ) + " ms Max: " +
+ str( port_down_device_to_ofp_max ) + " ms Avg: " +
+ str( port_down_device_to_ofp_avg ) )
+
+ port_up_graph_to_ofp_min = min( port_up_graph_to_ofp_list )
+ port_up_graph_to_ofp_max = max( port_up_graph_to_ofp_list )
port_up_graph_to_ofp_avg = \
- (sum(port_up_graph_to_ofp_list) /\
- len(port_up_graph_to_ofp_list))
-
- main.log.report("Port up graph-to-ofp Min: "+
- str(port_up_graph_to_ofp_min)+" ms Max: "+
- str(port_up_graph_to_ofp_max)+" ms Avg: "+
- str(port_up_graph_to_ofp_avg))
-
- port_up_device_to_ofp_min = min(port_up_device_to_ofp_list)
- port_up_device_to_ofp_max = max(port_up_device_to_ofp_list)
+ ( sum( port_up_graph_to_ofp_list ) /
+ len( port_up_graph_to_ofp_list ) )
+
+ main.log.report( "Port up graph-to-ofp Min: " +
+ str( port_up_graph_to_ofp_min ) + " ms Max: " +
+ str( port_up_graph_to_ofp_max ) + " ms Avg: " +
+ str( port_up_graph_to_ofp_avg ) )
+
+ port_up_device_to_ofp_min = min( port_up_device_to_ofp_list )
+ port_up_device_to_ofp_max = max( port_up_device_to_ofp_list )
port_up_device_to_ofp_avg = \
- (sum(port_up_device_to_ofp_list) /\
- len(port_up_device_to_ofp_list))
-
- main.log.report("Port up device-to-ofp Min: "+
- str(port_up_device_to_ofp_min)+" ms Max: "+
- str(port_up_device_to_ofp_max)+" ms Avg: "+
- str(port_up_device_to_ofp_avg))
+ ( sum( port_up_device_to_ofp_list ) /
+ len( port_up_device_to_ofp_list ) )
- utilities.assert_equals(expect=main.TRUE, actual=assertion,
- onpass="Port discovery latency calculation successful",
- onfail="Port discovery test failed")
+ main.log.report( "Port up device-to-ofp Min: " +
+ str( port_up_device_to_ofp_min ) + " ms Max: " +
+ str( port_up_device_to_ofp_max ) + " ms Avg: " +
+ str( port_up_device_to_ofp_avg ) )
- def CASE4(self, main):
- '''
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=assertion,
+ onpass="Port discovery latency calculation successful",
+ onfail="Port discovery test failed" )
+
+ def CASE4( self, main ):
+ """
Link down event using loss rate 100%
-
+
Important:
Use a simple 2 switch topology with 1 link between
- the two switches. Ensure that mac addresses of the
+ the two switches. Ensure that mac addresses of the
switches are 1 / 2 respectively
- '''
+ """
import time
import subprocess
import os
import requests
import json
- ONOS1_ip = main.params['CTRL']['ip1']
- ONOS_user = main.params['CTRL']['user']
+ ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+ ONOS_user = main.params[ 'CTRL' ][ 'user' ]
- default_sw_port = main.params['CTRL']['port1']
-
- #Number of iterations of case
- num_iter = main.params['TEST']['numIter']
-
- #Timestamp 'keys' for json metrics output.
- #These are subject to change, hence moved into params
- deviceTimestamp = main.params['JSON']['deviceTimestamp']
- linkTimestamp = main.params['JSON']['linkTimestamp']
- graphTimestamp = main.params['JSON']['graphTimestamp']
+ default_sw_port = main.params[ 'CTRL' ][ 'port1' ]
+
+ # Number of iterations of case
+ num_iter = main.params[ 'TEST' ][ 'numIter' ]
+
+ # Timestamp 'keys' for json metrics output.
+ # These are subject to change, hence moved into params
+ deviceTimestamp = main.params[ 'JSON' ][ 'deviceTimestamp' ]
+ linkTimestamp = main.params[ 'JSON' ][ 'linkTimestamp' ]
+ graphTimestamp = main.params[ 'JSON' ][ 'graphTimestamp' ]
assertion = main.TRUE
- #Link event timestamp to system time list
+ # Link event timestamp to system time list
link_down_link_to_system_list = []
link_up_link_to_system_list = []
- #Graph event timestamp to system time list
+ # Graph event timestamp to system time list
link_down_graph_to_system_list = []
- link_up_graph_to_system_list = []
+ link_up_graph_to_system_list = []
- main.log.report("Add / remove link latency between "+
- "two switches")
+ main.log.report( "Add / remove link latency between " +
+ "two switches" )
- main.step("Assign all switches")
- main.Mininet1.assign_sw_controller(sw="1",
- ip1=ONOS1_ip, port1=default_sw_port)
- main.Mininet1.assign_sw_controller(sw="2",
- ip1=ONOS1_ip, port1=default_sw_port)
+ main.step( "Assign all switches" )
+ main.Mininet1.assign_sw_controller(
+ sw="1",
+ ip1=ONOS1_ip,
+ port1=default_sw_port )
+ main.Mininet1.assign_sw_controller(
+ sw="2",
+ ip1=ONOS1_ip,
+ port1=default_sw_port )
- main.step("Verifying switch assignment")
- result_s1 = main.Mininet1.get_sw_controller(sw="s1")
- result_s2 = main.Mininet1.get_sw_controller(sw="s2")
-
- #Allow time for events to finish before taking measurements
- time.sleep(10)
+ main.step( "Verifying switch assignment" )
+ result_s1 = main.Mininet1.get_sw_controller( sw="s1" )
+ result_s2 = main.Mininet1.get_sw_controller( sw="s2" )
+
+ # Allow time for events to finish before taking measurements
+ time.sleep( 10 )
link_down = False
- #Start iteration of link event test
- for i in range(0, int(num_iter)):
- main.step("Getting initial system time as t0")
-
- timestamp_link_down_t0 = time.time() * 1000
- #Link down is simulated by 100% loss rate using traffic
- #control command
- main.Mininet1.handle.sendline(
- "sh tc qdisc add dev s1-eth1 root netem loss 100%")
+ # Start iteration of link event test
+ for i in range( 0, int( num_iter ) ):
+ main.step( "Getting initial system time as t0" )
- #TODO: Iterate through 'links' command to verify that
- # link s1 -> s2 went down (loop timeout 30 seconds)
+ timestamp_link_down_t0 = time.time() * 1000
+ # Link down is simulated by 100% loss rate using traffic
+ # control command
+ main.Mininet1.handle.sendline(
+ "sh tc qdisc add dev s1-eth1 root netem loss 100%" )
+
+ # TODO: Iterate through 'links' command to verify that
+ # link s1 -> s2 went down ( loop timeout 30 seconds )
# on all 3 ONOS instances
- main.log.info("Checking ONOS for link update")
+ main.log.info( "Checking ONOS for link update" )
loop_count = 0
while( not link_down and loop_count < 30 ):
json_str = main.ONOS1cli.links()
-
+
if not json_str:
- main.log.error("CLI command returned error ")
+ main.log.error( "CLI command returned error " )
break
else:
- json_obj = json.loads(json_str)
+ json_obj = json.loads( json_str )
for obj in json_obj:
- if '01' not in obj['src']['device']:
+ if '01' not in obj[ 'src' ][ 'device' ]:
link_down = True
- main.log.report("Link down from "+
- "s1 -> s2 on ONOS1 detected")
+ main.log.report( "Link down from " +
+ "s1 -> s2 on ONOS1 detected" )
loop_count += 1
- #If CLI doesn't like the continuous requests
- #and exits in this loop, increase the sleep here.
- #Consequently, while loop timeout will increase
- time.sleep(1)
-
- #Give time for metrics measurement to catch up
- #NOTE: May need to be configured more accurately
- time.sleep(10)
- #If we exited the while loop and link down 1,2,3 are still
- #false, then ONOS has failed to discover link down event
+ # If CLI doesn't like the continuous requests
+ # and exits in this loop, increase the sleep here.
+ # Consequently, while loop timeout will increase
+ time.sleep( 1 )
+
+ # Give time for metrics measurement to catch up
+ # NOTE: May need to be configured more accurately
+ time.sleep( 10 )
+ # If we exited the while loop and link down 1,2,3 are still
+ # false, then ONOS has failed to discover link down event
if not link_down:
- main.log.info("Link down discovery failed")
-
+ main.log.info( "Link down discovery failed" )
+
link_down_lat_graph1 = 0
link_down_lat_device1 = 0
assertion = main.FALSE
else:
json_topo_metrics_1 =\
- main.ONOS1cli.topology_events_metrics()
- json_topo_metrics_1 = json.loads(json_topo_metrics_1)
-
- main.log.info("Obtaining graph and device timestamp")
+ main.ONOS1cli.topology_events_metrics()
+ json_topo_metrics_1 = json.loads( json_topo_metrics_1 )
+
+ main.log.info( "Obtaining graph and device timestamp" )
graph_timestamp_1 = \
- json_topo_metrics_1[graphTimestamp]['value']
+ json_topo_metrics_1[ graphTimestamp ][ 'value' ]
link_timestamp_1 = \
- json_topo_metrics_1[linkTimestamp]['value']
+ json_topo_metrics_1[ linkTimestamp ][ 'value' ]
if graph_timestamp_1 and link_timestamp_1:
- link_down_lat_graph1 = int(graph_timestamp_1) -\
- timestamp_link_down_t0
-
- link_down_lat_link1 = int(link_timestamp_1) -\
- timestamp_link_down_t0
+ link_down_lat_graph1 = int( graph_timestamp_1 ) -\
+ timestamp_link_down_t0
+
+ link_down_lat_link1 = int( link_timestamp_1 ) -\
+ timestamp_link_down_t0
else:
- main.log.error("There was an error calculating"+
- " the delta for link down event")
+ main.log.error( "There was an error calculating" +
+ " the delta for link down event" )
link_down_lat_graph1 = 0
-
+
link_down_lat_device1 = 0
-
- main.log.report("Link down latency ONOS1 iteration "+
- str(i)+" (end-to-end): "+
- str(link_down_lat_graph1)+" ms")
-
- main.log.report("Link down latency ONOS1 iteration "+
- str(i)+" (link-event-to-system-timestamp): "+
- str(link_down_lat_link1)+" ms")
-
- #Calculate avg of node calculations
+
+ main.log.report( "Link down latency ONOS1 iteration " +
+ str( i ) + " (end-to-end): " +
+ str( link_down_lat_graph1 ) + " ms" )
+
+ main.log.report( "Link down latency ONOS1 iteration " +
+ str( i ) + " (link-event-to-system-timestamp): " +
+ str( link_down_lat_link1 ) + " ms" )
+
+ # Calculate avg of node calculations
link_down_lat_graph_avg = link_down_lat_graph1
link_down_lat_link_avg = link_down_lat_link1
- #Set threshold and append latency to list
+ # Set threshold and append latency to list
if link_down_lat_graph_avg > 0.0 and\
link_down_lat_graph_avg < 30000:
link_down_graph_to_system_list.append(
- link_down_lat_graph_avg)
+ link_down_lat_graph_avg )
else:
- main.log.info("Link down latency exceeded threshold")
- main.log.info("Results for iteration "+str(i)+
- "have been omitted")
+ main.log.info( "Link down latency exceeded threshold" )
+ main.log.info( "Results for iteration " + str( i ) +
+ "have been omitted" )
if link_down_lat_link_avg > 0.0 and\
link_down_lat_link_avg < 30000:
link_down_link_to_system_list.append(
- link_down_lat_link_avg)
+ link_down_lat_link_avg )
else:
- main.log.info("Link down latency exceeded threshold")
- main.log.info("Results for iteration "+str(i)+
- "have been omitted")
+ main.log.info( "Link down latency exceeded threshold" )
+ main.log.info( "Results for iteration " + str( i ) +
+ "have been omitted" )
- #NOTE: To remove loss rate and measure latency:
+ # NOTE: To remove loss rate and measure latency:
# 'sh tc qdisc del dev s1-eth1 root'
timestamp_link_up_t0 = time.time() * 1000
- main.Mininet1.handle.sendline("sh tc qdisc del dev "+
- "s1-eth1 root")
- main.Mininet1.handle.expect("mininet>")
-
- main.log.info("Checking ONOS for link update")
-
+ main.Mininet1.handle.sendline( "sh tc qdisc del dev " +
+ "s1-eth1 root" )
+ main.Mininet1.handle.expect( "mininet>" )
+
+ main.log.info( "Checking ONOS for link update" )
+
link_down1 = True
loop_count = 0
while( link_down1 and loop_count < 30 ):
json_str1 = main.ONOS1cli.links()
if not json_str1:
- main.log.error("CLI command returned error ")
+ main.log.error( "CLI command returned error " )
break
else:
- json_obj1 = json.loads(json_str1)
-
+ json_obj1 = json.loads( json_str1 )
+
for obj1 in json_obj1:
- if '01' in obj1['src']['device']:
- link_down1 = False
- main.log.report("Link up from "+
- "s1 -> s2 on ONOS1 detected")
+ if '01' in obj1[ 'src' ][ 'device' ]:
+ link_down1 = False
+ main.log.report( "Link up from " +
+ "s1 -> s2 on ONOS1 detected" )
loop_count += 1
- time.sleep(1)
-
+ time.sleep( 1 )
+
if link_down1:
- main.log.info("Link up discovery failed")
+ main.log.info( "Link up discovery failed" )
link_up_lat_graph1 = 0
link_up_lat_device1 = 0
assertion = main.FALSE
else:
json_topo_metrics_1 =\
- main.ONOS1cli.topology_events_metrics()
- json_topo_metrics_1 = json.loads(json_topo_metrics_1)
+ main.ONOS1cli.topology_events_metrics()
+ json_topo_metrics_1 = json.loads( json_topo_metrics_1 )
- main.log.info("Obtaining graph and device timestamp")
+ main.log.info( "Obtaining graph and device timestamp" )
graph_timestamp_1 = \
- json_topo_metrics_1[graphTimestamp]['value']
-
+ json_topo_metrics_1[ graphTimestamp ][ 'value' ]
+
link_timestamp_1 = \
- json_topo_metrics_1[linkTimestamp]['value']
+ json_topo_metrics_1[ linkTimestamp ][ 'value' ]
if graph_timestamp_1 and link_timestamp_1:
- link_up_lat_graph1 = int(graph_timestamp_1) -\
- timestamp_link_up_t0
- link_up_lat_link1 = int(link_timestamp_1) -\
- timestamp_link_up_t0
+ link_up_lat_graph1 = int( graph_timestamp_1 ) -\
+ timestamp_link_up_t0
+ link_up_lat_link1 = int( link_timestamp_1 ) -\
+ timestamp_link_up_t0
else:
- main.log.error("There was an error calculating"+
- " the delta for link down event")
+ main.log.error( "There was an error calculating" +
+ " the delta for link down event" )
link_up_lat_graph1 = 0
link_up_lat_device1 = 0
-
- main.log.info("Link up latency ONOS1 iteration "+
- str(i)+" (end-to-end): "+
- str(link_up_lat_graph1)+" ms")
-
- main.log.info("Link up latency ONOS1 iteration "+
- str(i)+" (link-event-to-system-timestamp): "+
- str(link_up_lat_link1)+" ms")
-
- #Calculate avg of node calculations
+
+ main.log.info( "Link up latency ONOS1 iteration " +
+ str( i ) + " (end-to-end): " +
+ str( link_up_lat_graph1 ) + " ms" )
+
+ main.log.info( "Link up latency ONOS1 iteration " +
+ str( i ) + " (link-event-to-system-timestamp): " +
+ str( link_up_lat_link1 ) + " ms" )
+
+ # Calculate avg of node calculations
link_up_lat_graph_avg = link_up_lat_graph1
link_up_lat_link_avg = link_up_lat_link1
- #Set threshold and append latency to list
+ # Set threshold and append latency to list
if link_up_lat_graph_avg > 0.0 and\
link_up_lat_graph_avg < 30000:
link_up_graph_to_system_list.append(
- link_up_lat_graph_avg)
+ link_up_lat_graph_avg )
else:
- main.log.info("Link up latency exceeded threshold")
- main.log.info("Results for iteration "+str(i)+
- "have been omitted")
+ main.log.info( "Link up latency exceeded threshold" )
+ main.log.info( "Results for iteration " + str( i ) +
+ "have been omitted" )
if link_up_lat_link_avg > 0.0 and\
link_up_lat_link_avg < 30000:
link_up_link_to_system_list.append(
- link_up_lat_link_avg)
+ link_up_lat_link_avg )
else:
- main.log.info("Link up latency exceeded threshold")
- main.log.info("Results for iteration "+str(i)+
- "have been omitted")
+ main.log.info( "Link up latency exceeded threshold" )
+ main.log.info( "Results for iteration " + str( i ) +
+ "have been omitted" )
- #Calculate min, max, avg of list and report
- link_down_min = min(link_down_graph_to_system_list)
- link_down_max = max(link_down_graph_to_system_list)
- link_down_avg = sum(link_down_graph_to_system_list) / \
- len(link_down_graph_to_system_list)
- link_up_min = min(link_up_graph_to_system_list)
- link_up_max = max(link_up_graph_to_system_list)
- link_up_avg = sum(link_up_graph_to_system_list) / \
- len(link_up_graph_to_system_list)
+ # Calculate min, max, avg of list and report
+ link_down_min = min( link_down_graph_to_system_list )
+ link_down_max = max( link_down_graph_to_system_list )
+ link_down_avg = sum( link_down_graph_to_system_list ) / \
+ len( link_down_graph_to_system_list )
+ link_up_min = min( link_up_graph_to_system_list )
+ link_up_max = max( link_up_graph_to_system_list )
+ link_up_avg = sum( link_up_graph_to_system_list ) / \
+ len( link_up_graph_to_system_list )
- main.log.report("Link down latency - Min: "+
- str(link_down_min)+"ms Max: "+
- str(link_down_max)+"ms Avg: "+
- str(link_down_avg)+"ms")
- main.log.report("Link up latency - Min: "+
- str(link_up_min)+"ms Max: "+
- str(link_up_max)+"ms Avg: "+
- str(link_up_avg)+"ms")
+ main.log.report( "Link down latency - Min: " +
+ str( link_down_min ) + "ms Max: " +
+ str( link_down_max ) + "ms Avg: " +
+ str( link_down_avg ) + "ms" )
+ main.log.report( "Link up latency - Min: " +
+ str( link_up_min ) + "ms Max: " +
+ str( link_up_max ) + "ms Avg: " +
+ str( link_up_avg ) + "ms" )
- utilities.assert_equals(expect=main.TRUE, actual=assertion,
- onpass="Link discovery latency calculation successful",
- onfail="Link discovery latency case failed")
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=assertion,
+ onpass="Link discovery latency calculation successful",
+ onfail="Link discovery latency case failed" )
- def CASE5(self, main):
- '''
+ def CASE5( self, main ):
+ """
100 Switch discovery latency
Important:
- This test case can be potentially dangerous if
+ This test case can be potentially dangerous if
your machine has previously set iptables rules.
One of the steps of the test case will flush
all existing iptables rules.
Note:
- You can specify the number of switches in the
+ You can specify the number of switches in the
params file to adjust the switch discovery size
- (and specify the corresponding topology in Mininet1
- .topo file)
- '''
+ ( and specify the corresponding topology in Mininet1
+ .topo file )
+ """
import time
import subprocess
import os
import requests
import json
- ONOS1_ip = main.params['CTRL']['ip1']
- MN1_ip = main.params['MN']['ip1']
- ONOS_user = main.params['CTRL']['user']
+ ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+ MN1_ip = main.params[ 'MN' ][ 'ip1' ]
+ ONOS_user = main.params[ 'CTRL' ][ 'user' ]
- default_sw_port = main.params['CTRL']['port1']
-
- #Number of iterations of case
- num_iter = main.params['TEST']['numIter']
- num_sw = main.params['TEST']['numSwitch']
+ default_sw_port = main.params[ 'CTRL' ][ 'port1' ]
- #Timestamp 'keys' for json metrics output.
- #These are subject to change, hence moved into params
- deviceTimestamp = main.params['JSON']['deviceTimestamp']
- graphTimestamp = main.params['JSON']['graphTimestamp']
-
- tshark_ofp_output = "/tmp/tshark_ofp_"+num_sw+"sw.txt"
- tshark_tcp_output = "/tmp/tshark_tcp_"+num_sw+"sw.txt"
+ # Number of iterations of case
+ num_iter = main.params[ 'TEST' ][ 'numIter' ]
+ num_sw = main.params[ 'TEST' ][ 'numSwitch' ]
+
+ # Timestamp 'keys' for json metrics output.
+ # These are subject to change, hence moved into params
+ deviceTimestamp = main.params[ 'JSON' ][ 'deviceTimestamp' ]
+ graphTimestamp = main.params[ 'JSON' ][ 'graphTimestamp' ]
+
+ tshark_ofp_output = "/tmp/tshark_ofp_" + num_sw + "sw.txt"
+ tshark_tcp_output = "/tmp/tshark_tcp_" + num_sw + "sw.txt"
tshark_ofp_result_list = []
tshark_tcp_result_list = []
- main.case(num_sw+" Switch discovery latency")
- main.step("Assigning all switches to ONOS1")
- for i in range(1, int(num_sw)+1):
+ main.case( num_sw + " Switch discovery latency" )
+ main.step( "Assigning all switches to ONOS1" )
+ for i in range( 1, int( num_sw ) + 1 ):
main.Mininet1.assign_sw_controller(
- sw=str(i),
- ip1=ONOS1_ip,
- port1=default_sw_port)
-
- #Ensure that nodes are configured with ptpd
- #Just a warning message
- main.log.info("Please check ptpd configuration to ensure"+\
- " All nodes' system times are in sync")
- time.sleep(5)
+ sw=str( i ),
+ ip1=ONOS1_ip,
+ port1=default_sw_port )
- for i in range(0, int(num_iter)):
-
- main.step("Set iptables rule to block incoming sw connections")
- #Set iptables rule to block incoming switch connections
- #The rule description is as follows:
+ # Ensure that nodes are configured with ptpd
+ # Just a warning message
+ main.log.info( "Please check ptpd configuration to ensure" +
+ " All nodes' system times are in sync" )
+ time.sleep( 5 )
+
+ for i in range( 0, int( num_iter ) ):
+
+ main.step( "Set iptables rule to block incoming sw connections" )
+ # Set iptables rule to block incoming switch connections
+ # The rule description is as follows:
# Append to INPUT rule,
# behavior DROP that matches following:
# * packet type: tcp
# * source IP: MN1_ip
# * destination PORT: 6633
main.ONOS1.handle.sendline(
- "sudo iptables -A INPUT -p tcp -s "+MN1_ip+
- " --dport "+default_sw_port+" -j DROP")
- main.ONOS1.handle.expect("\$")
- # Append to OUTPUT rule,
+ "sudo iptables -A INPUT -p tcp -s " + MN1_ip +
+ " --dport " + default_sw_port + " -j DROP" )
+ main.ONOS1.handle.expect( "\$" )
+ # Append to OUTPUT rule,
# behavior DROP that matches following:
# * packet type: tcp
# * source IP: MN1_ip
# * destination PORT: 6633
main.ONOS1.handle.sendline(
- "sudo iptables -A OUTPUT -p tcp -s "+MN1_ip+
- " --dport "+default_sw_port+" -j DROP")
- main.ONOS1.handle.expect("\$")
- #Give time to allow rule to take effect
- #NOTE: Sleep period may need to be configured
+ "sudo iptables -A OUTPUT -p tcp -s " + MN1_ip +
+ " --dport " + default_sw_port + " -j DROP" )
+ main.ONOS1.handle.expect( "\$" )
+ # Give time to allow rule to take effect
+ # NOTE: Sleep period may need to be configured
# based on the number of switches in the topology
- main.log.info("Please wait for switch connection to "+
- "time out")
- time.sleep(60)
-
- #Gather vendor OFP with tshark
- main.ONOS1.tshark_grep("OFP 86 Vendor",
- tshark_ofp_output)
- main.ONOS1.tshark_grep("TCP 74 ",
- tshark_tcp_output)
+ main.log.info( "Please wait for switch connection to " +
+ "time out" )
+ time.sleep( 60 )
- #NOTE: Remove all iptables rule quickly (flush)
- # Before removal, obtain TestON timestamp at which
+ # Gather vendor OFP with tshark
+ main.ONOS1.tshark_grep( "OFP 86 Vendor",
+ tshark_ofp_output )
+ main.ONOS1.tshark_grep( "TCP 74 ",
+ tshark_tcp_output )
+
+ # NOTE: Remove all iptables rule quickly ( flush )
+ # Before removal, obtain TestON timestamp at which
# removal took place
- # (ensuring nodes are configured via ptp)
+ # ( ensuring nodes are configured via ptp )
# sudo iptables -F
-
+
t0_system = time.time() * 1000
main.ONOS1.handle.sendline(
- "sudo iptables -F")
+ "sudo iptables -F" )
- #Counter to track loop count
+ # Counter to track loop count
counter_loop = 0
counter_avail1 = 0
onos1_dev = False
while counter_loop < 60:
- #Continue to check devices for all device
- #availability. When all devices in all 3
- #ONOS instances indicate that devices are available
- #obtain graph event timestamp for t1.
+ # Continue to check devices for all device
+ # availability. When all devices in all 3
+ # ONOS instances indicate that devices are available
+ # obtain graph event timestamp for t1.
device_str_obj1 = main.ONOS1cli.devices()
- device_json1 = json.loads(device_str_obj1)
-
+ device_json1 = json.loads( device_str_obj1 )
+
for device1 in device_json1:
- if device1['available'] == True:
+ if device1[ 'available' ]:
counter_avail1 += 1
- if counter_avail1 == int(num_sw):
+ if counter_avail1 == int( num_sw ):
onos1_dev = True
- main.log.info("All devices have been "+
- "discovered on ONOS1")
+ main.log.info( "All devices have been " +
+ "discovered on ONOS1" )
else:
counter_avail1 = 0
- if onos1_dev:
- main.log.info("All devices have been discovered "+
- "on all ONOS instances")
+ if onos1_dev:
+ main.log.info( "All devices have been discovered " +
+ "on all ONOS instances" )
json_str_topology_metrics_1 =\
main.ONOS1cli.topology_events_metrics()
- #Exit while loop if all devices discovered
- break
-
+ # Exit while loop if all devices discovered
+ break
+
counter_loop += 1
- #Give some time in between CLI calls
- #(will not affect measurement)
- time.sleep(3)
+ # Give some time in between CLI calls
+ #( will not affect measurement )
+ time.sleep( 3 )
main.ONOS1.tshark_stop()
-
- os.system("scp "+ONOS_user+"@"+ONOS1_ip+":"+
- tshark_ofp_output+" /tmp/")
- os.system("scp "+ONOS_user+"@"+ONOS1_ip+":"+
- tshark_tcp_output+" /tmp/")
- ofp_file = open(tshark_ofp_output, 'r')
- #The following is for information purpose only.
- #TODO: Automate OFP output analysis
- main.log.info("Tshark OFP Vendor output: ")
+ os.system( "scp " + ONOS_user + "@" + ONOS1_ip + ":" +
+ tshark_ofp_output + " /tmp/" )
+ os.system( "scp " + ONOS_user + "@" + ONOS1_ip + ":" +
+ tshark_tcp_output + " /tmp/" )
+ ofp_file = open( tshark_ofp_output, 'r' )
+
+ # The following is for information purpose only.
+ # TODO: Automate OFP output analysis
+ main.log.info( "Tshark OFP Vendor output: " )
for line in ofp_file:
- tshark_ofp_result_list.append(line)
- main.log.info(line)
+ tshark_ofp_result_list.append( line )
+ main.log.info( line )
ofp_file.close()
- tcp_file = open(tshark_tcp_output, 'r')
- main.log.info("Tshark TCP 74 output: ")
+ tcp_file = open( tshark_tcp_output, 'r' )
+ main.log.info( "Tshark TCP 74 output: " )
for line in tcp_file:
- tshark_tcp_result_list.append(line)
- main.log.info(line)
+ tshark_tcp_result_list.append( line )
+ main.log.info( line )
tcp_file.close()
- json_obj_1 = json.loads(json_str_topology_metrics_1)
+ json_obj_1 = json.loads( json_str_topology_metrics_1 )
graph_timestamp_1 = \
- json_obj_1[graphTimestamp]['value']
+ json_obj_1[ graphTimestamp ][ 'value' ]
main.log.info(
- int(graph_timestamp_1) - int(t0_system))
-
-
-
-
-
-
-
+ int( graph_timestamp_1 ) - int( t0_system ) )