Creating subfolders for test suites
allow teston to look in subfolders
create subfolders for current test suites
move tests into sub folders
create HA suite dependencies folder and moved all common files there
minor driver and test updates
standardize on the name dependencies for the directory
change from admin to sdn users
Conflicts:
TestON/tests/FUNC/FUNCipv6Intent/FUNCipv6Intent.topo
Change-Id: I849e45ab67da8b285c36c5fdf43b34323876e741
diff --git a/TestON/tests/FUNC/FUNCintent/FUNCintent.params b/TestON/tests/FUNC/FUNCintent/FUNCintent.params
new file mode 100644
index 0000000..d0fcfa8
--- /dev/null
+++ b/TestON/tests/FUNC/FUNCintent/FUNCintent.params
@@ -0,0 +1,71 @@
+<PARAMS>
+ # CASE - Description
+ # 1 - Variable initialization and optional pull and build ONOS package
+ # 2 - Install ONOS
+ # 8 - Compare Topology
+ # 9 - Report logs
+ # 10 - Start Mininet with Openflow 1.0
+ # 11 - Start Mininet with Openflow 1.3
+ # 12 - Assign switch to controller
+ # 13 - Create Scapy Components
+ # 14 - Discover hosts with Mininet Pingall
+ # 15 - Discover hosts with Scapy arping ( only discovers scapy hosts )
+ # 16 - Balance ownership of switches
+ # 17 - Activate Flow Objectives
+ # 18 - Stop Mininet
+ # 1000 - Test host intents
+ # 2000 - Test point intents
+ # 3000 - Test single to multi point intents
+ # 4000 - Test multi to single point intents
+ # 5000 - Test host mobility
+ # 6000 - Test Multi Point intent End Point Failure
+
+ <testcases>1,[2,10,12,13,15,16,1000,2000,3000,4000,5000,6000,18]*2,[2,10,12,13,15,16,17,1000,2000,3000,4000,5000,6000,18]*2,[2,11,12,13,15,16,1000,2000,3000,4000,5000,6000,18]*2,[2,11,12,13,15,16,17,1000,2000,3000,4000,5000,6000,18]*2</testcases>
+
+ <SCALE>
+ <size>1,3,1,3,1,3,1,3</size>
+ </SCALE>
+
+ <DEPENDENCY>
+ <path>/tests/FUNC/FUNCintent/dependencies/</path>
+ <wrapper1>startUp</wrapper1>
+ <wrapper2>FuncIntentFunction</wrapper2>
+ <wrapper3>topo</wrapper3>
+ <topology>newFuncTopo.py</topology>
+ </DEPENDENCY>
+
+ <ENV>
+ <cellApps>drivers,openflow,proxyarp,mobility</cellApps>
+ </ENV>
+ <GIT>
+ <pull>False</pull>
+ <branch>master</branch>
+ </GIT>
+
+ <SLEEP>
+ <startup>15</startup>
+ <reroute>5</reroute>
+ <removeintent>10</removeintent>
+ <checkintent>5</checkintent>
+ <fwd>10</fwd>
+ <topoAttempts>3</topoAttempts>
+ </SLEEP>
+
+ <MININET>
+ <switch>7</switch>
+ <links>20</links>
+ </MININET>
+
+ <SCAPY>
+ <HOSTNAMES>h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11,h12,h13,h14,h15,h16,h17,h18,h19,h20,h21,h22,h23,h24</HOSTNAMES>
+ </SCAPY>
+
+ # Intent tests params
+ <SDNIP>
+ <tcpProto>6</tcpProto>
+ <ipPrototype>6</ipPrototype>
+ <srcPort>5001</srcPort>
+ <dstPort>5001</dstPort>
+ </SDNIP>
+
+</PARAMS>
diff --git a/TestON/tests/FUNC/FUNCintent/FUNCintent.py b/TestON/tests/FUNC/FUNCintent/FUNCintent.py
new file mode 100644
index 0000000..0855dc1
--- /dev/null
+++ b/TestON/tests/FUNC/FUNCintent/FUNCintent.py
@@ -0,0 +1,2057 @@
+# Testing the basic intent functionality of ONOS
+
+class FUNCintent:
+
+ def __init__( self ):
+ self.default = ''
+
+ def CASE1( self, main ):
+ import time
+ import imp
+ import re
+
+ """
+ - Construct tests variables
+ - GIT ( optional )
+ - Checkout ONOS master branch
+ - Pull latest ONOS code
+ - Building ONOS ( optional )
+ - Install ONOS package
+ - Build ONOS package
+ """
+
+ main.case( "Constructing test variables and building ONOS package" )
+ main.step( "Constructing test variables" )
+ main.caseExplanation = "This test case is mainly for loading " +\
+ "from params file, and pull and build the " +\
+ " latest ONOS package"
+ stepResult = main.FALSE
+
+ # Test variables
+ try:
+ main.testOnDirectory = re.sub( "(/tests)$", "", main.testDir )
+ main.apps = main.params[ 'ENV' ][ 'cellApps' ]
+ gitBranch = main.params[ 'GIT' ][ 'branch' ]
+ main.dependencyPath = main.testOnDirectory + \
+ main.params[ 'DEPENDENCY' ][ 'path' ]
+ main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ]
+ main.scale = ( main.params[ 'SCALE' ][ 'size' ] ).split( "," )
+ if main.ONOSbench.maxNodes:
+ main.maxNodes = int( main.ONOSbench.maxNodes )
+ else:
+ main.maxNodes = 0
+ wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
+ wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ]
+ wrapperFile3 = main.params[ 'DEPENDENCY' ][ 'wrapper3' ]
+ main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
+ main.checkIntentSleep = int( main.params[ 'SLEEP' ][ 'checkintent' ] )
+ main.removeIntentSleep = int( main.params[ 'SLEEP' ][ 'removeintent' ] )
+ main.rerouteSleep = int( main.params[ 'SLEEP' ][ 'reroute' ] )
+ main.fwdSleep = int( main.params[ 'SLEEP' ][ 'fwd' ] )
+ main.checkTopoAttempts = int( main.params[ 'SLEEP' ][ 'topoAttempts' ] )
+ gitPull = main.params[ 'GIT' ][ 'pull' ]
+ main.numSwitch = int( main.params[ 'MININET' ][ 'switch' ] )
+ main.numLinks = int( main.params[ 'MININET' ][ 'links' ] )
+ main.cellData = {} # for creating cell file
+ main.hostsData = {}
+ main.CLIs = []
+ main.ONOSip = []
+ main.scapyHostNames = main.params[ 'SCAPY' ][ 'HOSTNAMES' ].split( ',' )
+ main.scapyHosts = [] # List of scapy hosts for iterating
+ main.assertReturnString = '' # Assembled assert return string
+
+ main.ONOSip = main.ONOSbench.getOnosIps()
+ print main.ONOSip
+
+ # Assigning ONOS cli handles to a list
+ for i in range( 1, main.maxNodes + 1 ):
+ main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
+
+ # -- INIT SECTION, ONLY RUNS ONCE -- #
+ main.startUp = imp.load_source( wrapperFile1,
+ main.dependencyPath +
+ wrapperFile1 +
+ ".py" )
+
+ main.intentFunction = imp.load_source( wrapperFile2,
+ main.dependencyPath +
+ wrapperFile2 +
+ ".py" )
+
+ main.topo = imp.load_source( wrapperFile3,
+ main.dependencyPath +
+ wrapperFile3 +
+ ".py" )
+
+ copyResult1 = main.ONOSbench.scp( main.Mininet1,
+ main.dependencyPath +
+ main.topology,
+ main.Mininet1.home + "custom/",
+ direction="to" )
+ if main.CLIs:
+ stepResult = main.TRUE
+ else:
+ main.log.error( "Did not properly created list of ONOS CLI handle" )
+ stepResult = main.FALSE
+ except Exception as e:
+ main.log.exception(e)
+ main.cleanup()
+ main.exit()
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully construct " +
+ "test variables ",
+ onfail="Failed to construct test variables" )
+
+ if gitPull == 'True':
+ main.step( "Building ONOS in " + gitBranch + " branch" )
+ onosBuildResult = main.startUp.onosBuild( main, gitBranch )
+ stepResult = onosBuildResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully compiled " +
+ "latest ONOS",
+ onfail="Failed to compile " +
+ "latest ONOS" )
+ else:
+ main.log.warn( "Did not pull new code so skipping mvn " +
+ "clean install" )
+ main.ONOSbench.getVersion( report=True )
+
+ def CASE2( self, main ):
+ """
+ - Set up cell
+ - Create cell file
+ - Set cell file
+ - Verify cell file
+ - Kill ONOS process
+ - Uninstall ONOS cluster
+ - Verify ONOS start up
+ - Install ONOS cluster
+ - Connect to cli
+ """
+
+ # main.scale[ 0 ] determines the current number of ONOS controller
+ main.numCtrls = int( main.scale[ 0 ] )
+ main.flowCompiler = "Flow Rules"
+
+ main.case( "Starting up " + str( main.numCtrls ) +
+ " node(s) ONOS cluster" )
+ main.caseExplanation = "Set up ONOS with " + str( main.numCtrls ) +\
+ " node(s) ONOS cluster"
+
+ #kill off all onos processes
+ main.log.info( "Safety check, killing all ONOS processes" +
+ " before initiating environment setup" )
+
+ time.sleep( main.startUpSleep )
+ main.step( "Uninstalling ONOS package" )
+ onosUninstallResult = main.TRUE
+ for ip in main.ONOSip:
+ onosUninstallResult = onosUninstallResult and \
+ main.ONOSbench.onosUninstall( nodeIp=ip )
+ stepResult = onosUninstallResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully uninstalled ONOS package",
+ onfail="Failed to uninstall ONOS package" )
+ time.sleep( main.startUpSleep )
+
+ for i in range( main.maxNodes ):
+ main.ONOSbench.onosDie( main.ONOSip[ i ] )
+
+ print "NODE COUNT = ", main.numCtrls
+
+ tempOnosIp = []
+ for i in range( main.numCtrls ):
+ tempOnosIp.append( main.ONOSip[i] )
+
+ main.ONOSbench.createCellFile( main.ONOSbench.ip_address,
+ "temp", main.Mininet1.ip_address,
+ main.apps, tempOnosIp )
+
+ main.step( "Apply cell to environment" )
+ cellResult = main.ONOSbench.setCell( "temp" )
+ verifyResult = main.ONOSbench.verifyCell()
+ stepResult = cellResult and verifyResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully applied cell to " + \
+ "environment",
+ onfail="Failed to apply cell to environment " )
+
+ main.step( "Creating ONOS package" )
+ packageResult = main.ONOSbench.onosPackage()
+ stepResult = packageResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully created ONOS package",
+ onfail="Failed to create ONOS package" )
+
+ time.sleep( main.startUpSleep )
+ main.step( "Installing ONOS package" )
+ onosInstallResult = main.TRUE
+ for i in range( main.numCtrls ):
+ onosInstallResult = onosInstallResult and \
+ main.ONOSbench.onosInstall( node=main.ONOSip[ i ] )
+ stepResult = onosInstallResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully installed ONOS package",
+ onfail="Failed to install ONOS package" )
+
+ time.sleep( main.startUpSleep )
+ main.step( "Starting ONOS service" )
+ stopResult = main.TRUE
+ startResult = main.TRUE
+ onosIsUp = main.TRUE
+
+ for i in range( main.numCtrls ):
+ onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
+ if onosIsUp == main.TRUE:
+ main.log.report( "ONOS instance is up and ready" )
+ else:
+ main.log.report( "ONOS instance may not be up, stop and " +
+ "start ONOS again " )
+
+ for i in range( main.numCtrls ):
+ stopResult = stopResult and \
+ main.ONOSbench.onosStop( main.ONOSip[ i ] )
+ for i in range( main.numCtrls ):
+ startResult = startResult and \
+ main.ONOSbench.onosStart( main.ONOSip[ i ] )
+ stepResult = onosIsUp and stopResult and startResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="ONOS service is ready",
+ onfail="ONOS service did not start properly" )
+
+ main.step( "Start ONOS cli" )
+ cliResult = main.TRUE
+ for i in range( main.numCtrls ):
+ cliResult = cliResult and \
+ main.CLIs[ i ].startOnosCli( main.ONOSip[ i ] )
+ stepResult = cliResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully start ONOS cli",
+ onfail="Failed to start ONOS cli" )
+
+ # Remove the first element in main.scale list
+ main.scale.remove( main.scale[ 0 ] )
+
+ main.intentFunction.report( main )
+
+ def CASE8( self, main ):
+ """
+ Compare ONOS Topology to Mininet Topology
+ """
+ import json
+
+ main.case( "Compare ONOS Topology view to Mininet topology" )
+ main.caseExplanation = "Compare topology elements between Mininet" +\
+ " and ONOS"
+
+ main.log.info( "Gathering topology information from Mininet" )
+ devicesResults = main.FALSE # Overall Boolean for device correctness
+ linksResults = main.FALSE # Overall Boolean for link correctness
+ hostsResults = main.FALSE # Overall Boolean for host correctness
+ deviceFails = [] # Nodes where devices are incorrect
+ linkFails = [] # Nodes where links are incorrect
+ hostFails = [] # Nodes where hosts are incorrect
+ attempts = main.checkTopoAttempts # Remaining Attempts
+
+ mnSwitches = main.Mininet1.getSwitches()
+ mnLinks = main.Mininet1.getLinks()
+ mnHosts = main.Mininet1.getHosts()
+
+ main.step( "Comparing Mininet topology to ONOS topology" )
+
+ while ( attempts >= 0 ) and\
+ ( not devicesResults or not linksResults or not hostsResults ):
+ time.sleep( 2 )
+ if not devicesResults:
+ devices = main.topo.getAllDevices( main )
+ ports = main.topo.getAllPorts( main )
+ devicesResults = main.TRUE
+ deviceFails = [] # Reset for each failed attempt
+ if not linksResults:
+ links = main.topo.getAllLinks( main )
+ linksResults = main.TRUE
+ linkFails = [] # Reset for each failed attempt
+ if not hostsResults:
+ hosts = main.topo.getAllHosts( main )
+ hostsResults = main.TRUE
+ hostFails = [] # Reset for each failed attempt
+
+ # Check for matching topology on each node
+ for controller in range( main.numCtrls ):
+ controllerStr = str( controller + 1 ) # ONOS node number
+ # Compare Devices
+ if devices[ controller ] and ports[ controller ] and\
+ "Error" not in devices[ controller ] and\
+ "Error" not in ports[ controller ]:
+
+ try:
+ deviceData = json.loads( devices[ controller ] )
+ portData = json.loads( ports[ controller ] )
+ except (TypeError,ValueError):
+ main.log.error( "Could not load json: {0} or {1}".format( str( devices[ controller ] ), str( ports[ controller ] ) ) )
+ currentDevicesResult = main.FALSE
+ else:
+ currentDevicesResult = main.Mininet1.compareSwitches(
+ mnSwitches,deviceData,portData )
+ else:
+ currentDevicesResult = main.FALSE
+ if not currentDevicesResult:
+ deviceFails.append( controllerStr )
+ devicesResults = devicesResults and currentDevicesResult
+ # Compare Links
+ if links[ controller ] and "Error" not in links[ controller ]:
+ try:
+ linkData = json.loads( links[ controller ] )
+ except (TypeError,ValueError):
+ main.log.error("Could not load json:" + str( links[ controller ] ) )
+ currentLinksResult = main.FALSE
+ else:
+ currentLinksResult = main.Mininet1.compareLinks(
+ mnSwitches, mnLinks,linkData )
+ else:
+ currentLinksResult = main.FALSE
+ if not currentLinksResult:
+ linkFails.append( controllerStr )
+ linksResults = linksResults and currentLinksResult
+ # Compare Hosts
+ if hosts[ controller ] and "Error" not in hosts[ controller ]:
+ try:
+ hostData = json.loads( hosts[ controller ] )
+ except (TypeError,ValueError):
+ main.log.error("Could not load json:" + str( hosts[ controller ] ) )
+ currentHostsResult = main.FALSE
+ else:
+ currentHostsResult = main.Mininet1.compareHosts(
+ mnHosts,hostData )
+ else:
+ currentHostsResult = main.FALSE
+ if not currentHostsResult:
+ hostFails.append( controllerStr )
+ hostsResults = hostsResults and currentHostsResult
+ # Decrement Attempts Remaining
+ attempts -= 1
+
+
+ utilities.assert_equals( expect=[],
+ actual=deviceFails,
+ onpass="ONOS correctly discovered all devices",
+ onfail="ONOS incorrectly discovered devices on nodes: " +
+ str( deviceFails ) )
+ utilities.assert_equals( expect=[],
+ actual=linkFails,
+ onpass="ONOS correctly discovered all links",
+ onfail="ONOS incorrectly discovered links on nodes: " +
+ str( linkFails ) )
+ utilities.assert_equals( expect=[],
+ actual=hostFails,
+ onpass="ONOS correctly discovered all hosts",
+ onfail="ONOS incorrectly discovered hosts on nodes: " +
+ str( hostFails ) )
+ topoResults = hostsResults and linksResults and devicesResults
+ utilities.assert_equals( expect=main.TRUE,
+ actual=topoResults,
+ onpass="ONOS correctly discovered the topology",
+ onfail="ONOS incorrectly discovered the topology" )
+
+ def CASE10( self, main ):
+ """
+ Start Mininet topology with OF 1.0 switches
+ """
+ main.OFProtocol = "1.0"
+ main.log.report( "Start Mininet topology with OF 1.0 switches" )
+ main.case( "Start Mininet topology with OF 1.0 switches" )
+ main.caseExplanation = "Start mininet topology with OF 1.0 " +\
+ "switches to test intents, exits out if " +\
+ "topology did not start correctly"
+
+ main.step( "Starting Mininet topology with OF 1.0 switches" )
+ args = "--switch ovs,protocols=OpenFlow10"
+ topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
+ main.topology,
+ args=args )
+ stepResult = topoResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully loaded topology",
+ onfail="Failed to load topology" )
+ # Exit if topology did not load properly
+ if not topoResult:
+ main.cleanup()
+ main.exit()
+
+ def CASE11( self, main ):
+ """
+ Start Mininet topology with OF 1.3 switches
+ """
+ main.OFProtocol = "1.3"
+ main.log.report( "Start Mininet topology with OF 1.3 switches" )
+ main.case( "Start Mininet topology with OF 1.3 switches" )
+ main.caseExplanation = "Start mininet topology with OF 1.3 " +\
+ "switches to test intents, exits out if " +\
+ "topology did not start correctly"
+
+ main.step( "Starting Mininet topology with OF 1.3 switches" )
+ args = "--switch ovs,protocols=OpenFlow13"
+ topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
+ main.topology,
+ args=args )
+ stepResult = topoResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully loaded topology",
+ onfail="Failed to load topology" )
+ # Exit if topology did not load properly
+ if not topoResult:
+ main.cleanup()
+ main.exit()
+
+ def CASE12( self, main ):
+ """
+ Assign mastership to controllers
+ """
+ import re
+
+ main.case( "Assign switches to controllers" )
+ main.step( "Assigning switches to controllers" )
+ main.caseExplanation = "Assign OF " + main.OFProtocol +\
+ " switches to ONOS nodes"
+
+ assignResult = main.TRUE
+ switchList = []
+
+ # Creates a list switch name, use getSwitch() function later...
+ for i in range( 1, ( main.numSwitch + 1 ) ):
+ switchList.append( 's' + str( i ) )
+
+ tempONOSip = []
+ for i in range( main.numCtrls ):
+ tempONOSip.append( main.ONOSip[ i ] )
+
+ assignResult = main.Mininet1.assignSwController( sw=switchList,
+ ip=tempONOSip,
+ port='6653' )
+ if not assignResult:
+ main.cleanup()
+ main.exit()
+
+ for i in range( 1, ( main.numSwitch + 1 ) ):
+ response = main.Mininet1.getSwController( "s" + str( i ) )
+ print( "Response is " + str( response ) )
+ if re.search( "tcp:" + main.ONOSip[ 0 ], response ):
+ assignResult = assignResult and main.TRUE
+ else:
+ assignResult = main.FALSE
+ stepResult = assignResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully assigned switches" +
+ "to controller",
+ onfail="Failed to assign switches to " +
+ "controller" )
+
+ def CASE13( self,main ):
+ """
+ Create Scapy components
+ """
+ main.case( "Create scapy components" )
+ main.step( "Create scapy components" )
+ import json
+ scapyResult = main.TRUE
+ for hostName in main.scapyHostNames:
+ main.Scapy1.createHostComponent( hostName )
+ main.scapyHosts.append( getattr( main, hostName ) )
+
+ main.step( "Start scapy components" )
+ for host in main.scapyHosts:
+ host.startHostCli()
+ host.startScapy()
+ host.updateSelf()
+ main.log.debug( host.name )
+ main.log.debug( host.hostIp )
+ main.log.debug( host.hostMac )
+
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=scapyResult,
+ onpass="Successfully created Scapy Components",
+ onfail="Failed to discover Scapy Components" )
+
+ def CASE14( self, main ):
+ """
+ Discover all hosts with fwd and pingall and store its data in a dictionary
+ """
+ main.case( "Discover all hosts" )
+ main.step( "Pingall hosts and confirm ONOS discovery" )
+ utilities.retry( f=main.intentFunction.fwdPingall, retValue=main.FALSE, args=[ main ] )
+
+ utilities.retry( f=main.intentFunction.confirmHostDiscovery, retValue=main.FALSE,
+ args=[ main ], attempts=main.checkTopoAttempts, sleep=2 )
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully discovered hosts",
+ onfail="Failed to discover hosts" )
+
+ main.step( "Populate hostsData" )
+ stepResult = main.intentFunction.populateHostData( main )
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully populated hostsData",
+ onfail="Failed to populate hostsData" )
+
+ def CASE15( self, main ):
+ """
+ Discover all hosts with scapy arp packets and store its data to a dictionary
+ """
+ main.case( "Discover all hosts using scapy" )
+ main.step( "Send packets from each host to the first host and confirm onos discovery" )
+
+ import collections
+ if len( main.scapyHosts ) < 1:
+ main.log.error( "No scapy hosts have been created" )
+ main.skipCase()
+
+ # Send ARP packets from each scapy host component
+ main.intentFunction.sendDiscoveryArp( main, main.scapyHosts )
+
+ stepResult = utilities.retry( f=main.intentFunction.confirmHostDiscovery,
+ retValue=main.FALSE, args=[ main ],
+ attempts=main.checkTopoAttempts, sleep=2 )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="ONOS correctly discovered all hosts",
+ onfail="ONOS incorrectly discovered hosts" )
+
+ main.step( "Populate hostsData" )
+ stepResult = main.intentFunction.populateHostData( main )
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully populated hostsData",
+ onfail="Failed to populate hostsData" )
+
+ def CASE16( self, main ):
+ """
+ Balance Masters
+ """
+ main.case( "Balance mastership of switches" )
+ main.step( "Balancing mastership of switches" )
+
+ balanceResult = main.FALSE
+ balanceResult = utilities.retry( f=main.CLIs[ 0 ].balanceMasters, retValue=main.FALSE, args=[] )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=balanceResult,
+ onpass="Successfully balanced mastership of switches",
+ onfail="Failed to balance mastership of switches" )
+
+ def CASE17( self, main ):
+ """
+ Use Flow Objectives
+ """
+ main.case( "Enable intent compilation using Flow Objectives" )
+ main.step( "Enabling Flow Objectives" )
+
+ main.flowCompiler = "Flow Objectives"
+
+ cmd = "org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator"
+
+ stepResult = main.CLIs[ 0 ].setCfg( component=cmd,
+ propName="useFlowObjectives", value="true" )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully activated Flow Objectives",
+ onfail="Failed to activate Flow Objectives" )
+
+ def CASE18( self, main ):
+ """
+ Stop mininet and remove scapy host
+ """
+ main.log.report( "Stop Mininet and Scapy" )
+ main.case( "Stop Mininet and Scapy" )
+ main.caseExplanation = "Stopping the current mininet topology " +\
+ "to start up fresh"
+ main.step( "Stopping and Removing Scapy Host Components" )
+ scapyResult = main.TRUE
+ for host in main.scapyHosts:
+ scapyResult = scapyResult and host.stopScapy()
+ main.log.info( "Stopped Scapy Host: {0}".format( host.name ) )
+
+ for host in main.scapyHosts:
+ scapyResult = scapyResult and main.Scapy1.removeHostComponent( host.name )
+ main.log.info( "Removed Scapy Host Component: {0}".format( host.name ) )
+
+ main.scapyHosts = []
+ main.scapyHostIPs = []
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=scapyResult,
+ onpass="Successfully stopped scapy and removed host components",
+ onfail="Failed to stop mininet and scapy" )
+
+ main.step( "Stopping Mininet Topology" )
+ mininetResult = main.Mininet1.stopNet( )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=mininetResult,
+ onpass="Successfully stopped mininet and scapy",
+ onfail="Failed to stop mininet and scapy" )
+ # Exit if topology did not load properly
+ if not ( mininetResult and scapyResult ):
+ main.cleanup()
+ main.exit()
+
+ def CASE1000( self, main ):
+ """
+ Add host intents between 2 host:
+ - Discover hosts
+ - Add host intents
+ - Check intents
+ - Verify flows
+ - Ping hosts
+ - Reroute
+ - Link down
+ - Verify flows
+ - Check topology
+ - Ping hosts
+ - Link up
+ - Verify flows
+ - Check topology
+ - Ping hosts
+ - Remove intents
+ """
+ import time
+ import json
+ import re
+
+ # Assert variables - These variable's name|format must be followed
+ # if you want to use the wrapper function
+ assert main, "There is no main"
+ assert main.CLIs, "There is no main.CLIs"
+ assert main.Mininet1, "Mininet handle should be named Mininet1"
+ assert main.numSwitch, "Placed the total number of switch topology in \
+ main.numSwitch"
+
+ # Save leader candidates
+ intentLeadersOld = main.CLIs[ 0 ].leaderCandidates()
+
+ main.testName = "Host Intents"
+ main.case( main.testName + " Test - " + str( main.numCtrls ) +
+ " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
+ main.caseExplanation = "This test case tests Host intents using " +\
+ str( main.numCtrls ) + " node(s) cluster;\n" +\
+ "Different type of hosts will be tested in " +\
+ "each step such as IPV4, Dual stack, VLAN " +\
+ "etc;\nThe test will use OF " + main.OFProtocol +\
+ " OVS running in Mininet and compile intents" +\
+ " using " + main.flowCompiler
+
+ main.step( "IPV4: Add host intents between h1 and h9" )
+ main.assertReturnString = "Assertion Result for IPV4 host intent with mac addresses\n"
+ host1 = { "name":"h1","id":"00:00:00:00:00:01/-1" }
+ host2 = { "name":"h9","id":"00:00:00:00:00:09/-1" }
+ testResult = main.FALSE
+ installResult = main.FALSE
+ installResult = main.intentFunction.installHostIntent( main,
+ name='IPV4',
+ onosNode='0',
+ host1=host1,
+ host2=host2)
+ if installResult:
+ testResult = main.intentFunction.testHostIntent( main,
+ name='IPV4',
+ intentId = installResult,
+ onosNode='0',
+ host1=host1,
+ host2=host2,
+ sw1='s5',
+ sw2='s2',
+ expectedLink = 18)
+ else:
+ main.CLIs[ 0 ].removeAllIntents( purge=True )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=testResult,
+ onpass=main.assertReturnString,
+ onfail=main.assertReturnString)
+
+ main.step( "DUALSTACK1: Add host intents between h3 and h11" )
+ main.assertReturnString = "Assertion Result for dualstack IPV4 with MAC addresses\n"
+ host1 = { "name":"h3","id":"00:00:00:00:00:03/-1" }
+ host2 = { "name":"h11","id":"00:00:00:00:00:0B/-1 "}
+ testResult = main.FALSE
+ installResult = main.FALSE
+ installResult = main.intentFunction.installHostIntent( main,
+ name='DUALSTACK',
+ onosNode='0',
+ host1=host1,
+ host2=host2)
+
+ if installResult:
+ testResult = main.intentFunction.testHostIntent( main,
+ name='DUALSTACK',
+ intentId = installResult,
+ onosNode='0',
+ host1=host1,
+ host2=host2,
+ sw1='s5',
+ sw2='s2',
+ expectedLink = 18)
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=testResult,
+ onpass=main.assertReturnString,
+ onfail=main.assertReturnString)
+
+ main.step( "DUALSTACK2: Add host intents between h1 and h11" )
+ main.assertReturnString = "Assertion Result for dualstack2 host intent\n"
+ host1 = { "name":"h1" }
+ host2 = { "name":"h11" }
+ testResult = main.FALSE
+ installResult = main.FALSE
+ installResult = main.intentFunction.installHostIntent( main,
+ name='DUALSTACK2',
+ onosNode='0',
+ host1=host1,
+ host2=host2)
+
+ if installResult:
+ testResult = main.intentFunction.testHostIntent( main,
+ name='DUALSTACK2',
+ intentId = installResult,
+ onosNode='0',
+ host1=host1,
+ host2=host2,
+ sw1='s5',
+ sw2='s2',
+ expectedLink = 18)
+ else:
+ main.CLIs[ 0 ].removeAllIntents( purge=True )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=testResult,
+ onpass=main.assertReturnString,
+ onfail=main.assertReturnString)
+
+ main.step( "1HOP: Add host intents between h1 and h3" )
+ main.assertReturnString = "Assertion Result for 1HOP for IPV4 same switch\n"
+ host1 = { "name":"h1" }
+ host2 = { "name":"h3" }
+ testResult = main.FALSE
+ installResult = main.FALSE
+ installResult = main.intentFunction.installHostIntent( main,
+ name='1HOP',
+ onosNode='0',
+ host1=host1,
+ host2=host2)
+
+ if installResult:
+ testResult = main.intentFunction.testHostIntent( main,
+ name='1HOP',
+ intentId = installResult,
+ onosNode='0',
+ host1=host1,
+ host2=host2,
+ sw1='s5',
+ sw2='s2',
+ expectedLink = 18)
+ else:
+ main.CLIs[ 0 ].removeAllIntents( purge=True )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=testResult,
+ onpass=main.assertReturnString,
+ onfail=main.assertReturnString)
+
+ main.step( "VLAN1: Add vlan host intents between h4 and h12" )
+ main.assertReturnString = "Assertion Result vlan IPV4\n"
+ host1 = { "name":"h4","id":"00:00:00:00:00:04/100" }
+ host2 = { "name":"h12","id":"00:00:00:00:00:0C/100 "}
+ testResult = main.FALSE
+ installResult = main.FALSE
+ installResult = main.intentFunction.installHostIntent( main,
+ name='VLAN1',
+ onosNode='0',
+ host1=host1,
+ host2=host2)
+
+ if installResult:
+ testResult = main.intentFunction.testHostIntent( main,
+ name='VLAN1',
+ intentId = installResult,
+ onosNode='0',
+ host1=host1,
+ host2=host2,
+ sw1='s5',
+ sw2='s2',
+ expectedLink = 18)
+ else:
+ main.CLIs[ 0 ].removeAllIntents( purge=True )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=testResult,
+ onpass=main.assertReturnString,
+ onfail=main.assertReturnString)
+
+ main.step( "VLAN2: Add inter vlan host intents between h13 and h20" )
+ main.assertReturnString = "Assertion Result different VLAN negative test\n"
+ host1 = { "name":"h13" }
+ host2 = { "name":"h20" }
+ testResult = main.FALSE
+ installResult = main.FALSE
+ installResult = main.intentFunction.installHostIntent( main,
+ name='VLAN2',
+ onosNode='0',
+ host1=host1,
+ host2=host2)
+
+ if installResult:
+ testResult = main.intentFunction.testHostIntent( main,
+ name='VLAN2',
+ intentId = installResult,
+ onosNode='0',
+ host1=host1,
+ host2=host2,
+ sw1='s5',
+ sw2='s2',
+ expectedLink = 18)
+ else:
+ main.CLIs[ 0 ].removeAllIntents( purge=True )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=testResult,
+ onpass=main.assertReturnString,
+ onfail=main.assertReturnString)
+
+ main.step( "Confirm that ONOS leadership is unchanged")
+ intentLeadersNew = main.CLIs[ 0 ].leaderCandidates()
+ main.intentFunction.checkLeaderChange( intentLeadersOld,
+ intentLeadersNew )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=testResult,
+ onpass="ONOS Leaders Unchanged",
+ onfail="ONOS Leader Mismatch")
+
+ main.intentFunction.report( main )
+
+ def CASE2000( self, main ):
+ """
+ Add point intents between 2 hosts:
+ - Get device ids | ports
+ - Add point intents
+ - Check intents
+ - Verify flows
+ - Ping hosts
+ - Reroute
+ - Link down
+ - Verify flows
+ - Check topology
+ - Ping hosts
+ - Link up
+ - Verify flows
+ - Check topology
+ - Ping hosts
+ - Remove intents
+ """
+ import time
+ import json
+ import re
+
+ # Assert variables - These variable's name|format must be followed
+ # if you want to use the wrapper function
+ assert main, "There is no main"
+ assert main.CLIs, "There is no main.CLIs"
+ assert main.Mininet1, "Mininet handle should be named Mininet1"
+ assert main.numSwitch, "Placed the total number of switch topology in \
+ main.numSwitch"
+
+ main.testName = "Point Intents"
+ main.case( main.testName + " Test - " + str( main.numCtrls ) +
+ " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
+ main.caseExplanation = "This test case will test point to point" +\
+ " intents using " + str( main.numCtrls ) +\
+ " node(s) cluster;\n" +\
+ "Different type of hosts will be tested in " +\
+ "each step such as IPV4, Dual stack, VLAN etc" +\
+ ";\nThe test will use OF " + main.OFProtocol +\
+ " OVS running in Mininet and compile intents" +\
+ " using " + main.flowCompiler
+
+ # No option point intents
+ main.step( "NOOPTION: Add point intents between h1 and h9" )
+ main.assertReturnString = "Assertion Result for NOOPTION point intent\n"
+ senders = [
+ { "name":"h1","device":"of:0000000000000005/1" }
+ ]
+ recipients = [
+ { "name":"h9","device":"of:0000000000000006/1" }
+ ]
+ testResult = main.FALSE
+ installResult = main.FALSE
+ installResult = main.intentFunction.installPointIntent(
+ main,
+ name="NOOPTION",
+ senders=senders,
+ recipients=recipients )
+
+ if installResult:
+ testResult = main.intentFunction.testPointIntent(
+ main,
+ intentId=installResult,
+ name="NOOPTION",
+ senders=senders,
+ recipients=recipients,
+ sw1="s5",
+ sw2="s2",
+ expectedLink=18)
+ else:
+ main.CLIs[ 0 ].removeAllIntents( purge=True )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=testResult,
+ onpass=main.assertReturnString,
+ onfail=main.assertReturnString )
+
+ stepResult = main.TRUE
+ main.step( "IPV4: Add point intents between h1 and h9" )
+ main.assertReturnString = "Assertion Result for IPV4 point intent\n"
+ senders = [
+ { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01" }
+ ]
+ recipients = [
+ { "name":"h9","device":"of:0000000000000006/1","mac":"00:00:00:00:00:09" }
+ ]
+ testResult = main.FALSE
+ installResult = main.FALSE
+ installResult = main.intentFunction.installPointIntent(
+ main,
+ name="IPV4",
+ senders=senders,
+ recipients=recipients,
+ ethType="IPV4" )
+
+ if installResult:
+ testResult = main.intentFunction.testPointIntent(
+ main,
+ intentId=installResult,
+ name="IPV4",
+ senders=senders,
+ recipients=recipients,
+ sw1="s5",
+ sw2="s2",
+ expectedLink=18)
+ else:
+ main.CLIs[ 0 ].removeAllIntents( purge=True )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=testResult,
+ onpass=main.assertReturnString,
+ onfail=main.assertReturnString )
+ main.step( "IPV4_2: Add point intents between h1 and h9" )
+ main.assertReturnString = "Assertion Result for IPV4 no mac address point intents\n"
+ senders = [
+ { "name":"h1","device":"of:0000000000000005/1" }
+ ]
+ recipients = [
+ { "name":"h9","device":"of:0000000000000006/1" }
+ ]
+ testResult = main.FALSE
+ installResult = main.FALSE
+ installResult = main.intentFunction.installPointIntent(
+ main,
+ name="IPV4_2",
+ senders=senders,
+ recipients=recipients,
+ ethType="IPV4" )
+
+ if installResult:
+ testResult = main.intentFunction.testPointIntent(
+ main,
+ intentId=installResult,
+ name="IPV4_2",
+ senders=senders,
+ recipients=recipients,
+ sw1="s5",
+ sw2="s2",
+ expectedLink=18)
+ else:
+ main.CLIs[ 0 ].removeAllIntents( purge=True )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=testResult,
+ onpass=main.assertReturnString,
+ onfail=main.assertReturnString )
+
+ main.step( "SDNIP-ICMP: Add point intents between h1 and h9" )
+ main.assertReturnString = "Assertion Result for SDNIP-ICMP IPV4 using TCP point intents\n"
+ senders = [
+ { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01",
+ "ip":( main.h1.hostIp + "/24" ) }
+ ]
+ recipients = [
+ { "name":"h9","device":"of:0000000000000006/1","mac":"00:00:00:00:00:09",
+ "ip":( main.h9.hostIp + "/24" ) }
+ ]
+ ipProto = main.params[ 'SDNIP' ][ 'ipPrototype' ]
+ # Uneccessary, not including this in the selectors
+ tcpSrc = main.params[ 'SDNIP' ][ 'srcPort' ]
+ tcpDst = main.params[ 'SDNIP' ][ 'dstPort' ]
+ testResult = main.FALSE
+ installResult = main.FALSE
+ installResult = main.intentFunction.installPointIntent(
+ main,
+ name="SDNIP-ICMP",
+ senders=senders,
+ recipients=recipients,
+ ethType="IPV4",
+ ipProto=ipProto,
+ tcpSrc=tcpSrc,
+ tcpDst=tcpDst )
+
+ if installResult:
+ testResult = main.intentFunction.testPointIntent(
+ main,
+ intentId=installResult,
+ name="SDNIP_ICMP",
+ senders=senders,
+ recipients=recipients,
+ sw1="s5",
+ sw2="s2",
+ expectedLink=18)
+ else:
+ main.CLIs[ 0 ].removeAllIntents( purge=True )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=testResult,
+ onpass=main.assertReturnString,
+ onfail=main.assertReturnString )
+
+ main.step( "SDNIP-TCP: Add point intents between h1 and h9" )
+ main.assertReturnString = "Assertion Result for SDNIP-TCP IPV4 using ICMP point intents\n"
+ mac1 = main.hostsData[ 'h1' ][ 'mac' ]
+ mac2 = main.hostsData[ 'h9' ][ 'mac' ]
+ ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/32"
+ ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/32"
+ ipProto = main.params[ 'SDNIP' ][ 'tcpProto' ]
+ tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
+ tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
+
+ stepResult = main.intentFunction.pointIntentTcp(
+ main,
+ name="SDNIP-TCP",
+ host1="h1",
+ host2="h9",
+ deviceId1="of:0000000000000005/1",
+ deviceId2="of:0000000000000006/1",
+ mac1=mac1,
+ mac2=mac2,
+ ethType="IPV4",
+ ipProto=ipProto,
+ ip1=ip1,
+ ip2=ip2,
+ tcp1=tcp1,
+ tcp2=tcp2 )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass=main.assertReturnString,
+ onfail=main.assertReturnString )
+
+ main.step( "DUALSTACK1: Add point intents between h3 and h11" )
+ main.assertReturnString = "Assertion Result for Dualstack1 IPV4 with mac address point intents\n"
+ senders = [
+ { "name":"h3","device":"of:0000000000000005/3","mac":"00:00:00:00:00:03" }
+ ]
+ recipients = [
+ { "name":"h11","device":"of:0000000000000006/3","mac":"00:00:00:00:00:0B" }
+ ]
+ testResult = main.FALSE
+ installResult = main.FALSE
+ installResult = main.intentFunction.installPointIntent(
+ main,
+ name="DUALSTACK1",
+ senders=senders,
+ recipients=recipients,
+ ethType="IPV4" )
+
+ if installResult:
+ testResult = main.intentFunction.testPointIntent(
+ main,
+ intentId=installResult,
+ name="DUALSTACK1",
+ senders=senders,
+ recipients=recipients,
+ sw1="s5",
+ sw2="s2",
+ expectedLink=18)
+ else:
+ main.CLIs[ 0 ].removeAllIntents( purge=True )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=testResult,
+ onpass=main.assertReturnString,
+ onfail=main.assertReturnString )
+
+ main.step( "VLAN: Add point intents between h5 and h21" )
+ main.assertReturnString = "Assertion Result for VLAN IPV4 with mac address point intents\n"
+ senders = [
+ { "name":"h5","device":"of:0000000000000005/5","mac":"00:00:00:00:00:05" }
+ ]
+ recipients = [
+ { "name":"h21","device":"of:0000000000000007/5","mac":"00:00:00:00:00:15" }
+ ]
+ testResult = main.FALSE
+ installResult = main.FALSE
+ installResult = main.intentFunction.installPointIntent(
+ main,
+ name="DUALSTACK1",
+ senders=senders,
+ recipients=recipients,
+ ethType="IPV4" )
+
+ if installResult:
+ testResult = main.intentFunction.testPointIntent(
+ main,
+ intentId=installResult,
+ name="DUALSTACK1",
+ senders=senders,
+ recipients=recipients,
+ sw1="s5",
+ sw2="s2",
+ expectedLink=18)
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=testResult,
+ onpass=main.assertReturnString,
+ onfail=main.assertReturnString )
+
+ main.step( "1HOP: Add point intents between h1 and h3" )
+ main.assertReturnString = "Assertion Result for 1HOP IPV4 with no mac address point intents\n"
+ senders = [
+ { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01" }
+ ]
+ recipients = [
+ { "name":"h3","device":"of:0000000000000005/3","mac":"00:00:00:00:00:03" }
+ ]
+ testResult = main.FALSE
+ installResult = main.FALSE
+ installResult = main.intentFunction.installPointIntent(
+ main,
+ name="1HOP IPV4",
+ senders=senders,
+ recipients=recipients,
+ ethType="IPV4" )
+
+ if installResult:
+ testResult = main.intentFunction.testPointIntent(
+ main,
+ intentId=installResult,
+ name="1HOP IPV4",
+ senders=senders,
+ recipients=recipients,
+ sw1="s5",
+ sw2="s2",
+ expectedLink=18)
+ else:
+ main.CLIs[ 0 ].removeAllIntents( purge=True )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=testResult,
+ onpass=main.assertReturnString,
+ onfail=main.assertReturnString )
+
+ main.intentFunction.report( main )
+
+ def CASE3000( self, main ):
+ """
+ Add single point to multi point intents
+ - Get device ids
+ - Add single point to multi point intents
+ - Check intents
+ - Verify flows
+ - Ping hosts
+ - Reroute
+ - Link down
+ - Verify flows
+ - Check topology
+ - Ping hosts
+ - Link up
+ - Verify flows
+ - Check topology
+ - Ping hosts
+ - Remove intents
+ """
+ assert main, "There is no main"
+ assert main.CLIs, "There is no main.CLIs"
+ assert main.Mininet1, "Mininet handle should be named Mininet1"
+ assert main.numSwitch, "Placed the total number of switch topology in \
+ main.numSwitch"
+
+ main.testName = "Single to Multi Point Intents"
+ main.case( main.testName + " Test - " + str( main.numCtrls ) +
+ " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
+ main.caseExplanation = "This test case will test single point to" +\
+ " multi point intents using " +\
+ str( main.numCtrls ) + " node(s) cluster;\n" +\
+ "Different type of hosts will be tested in " +\
+ "each step such as IPV4, Dual stack, VLAN etc" +\
+ ";\nThe test will use OF " + main.OFProtocol +\
+ " OVS running in Mininet and compile intents" +\
+ " using " + main.flowCompiler
+
+ main.step( "NOOPTION: Install and test single point to multi point intents" )
+ main.assertReturnString = "Assertion results for IPV4 single to multi point intent with no options set\n"
+ senders = [
+ { "name":"h8", "device":"of:0000000000000005/8" }
+ ]
+ recipients = [
+ { "name":"h16", "device":"of:0000000000000006/8" },
+ { "name":"h24", "device":"of:0000000000000007/8" }
+ ]
+ badSenders=[ { "name":"h9" } ] # Senders that are not in the intent
+ badRecipients=[ { "name":"h17" } ] # Recipients that are not in the intent
+ testResult = main.FALSE
+ installResult = main.FALSE
+ installResult = main.intentFunction.installSingleToMultiIntent(
+ main,
+ name="NOOPTION",
+ senders=senders,
+ recipients=recipients,
+ sw1="s5",
+ sw2="s2")
+
+ if installResult:
+ testResult = main.intentFunction.testPointIntent(
+ main,
+ intentId=installResult,
+ name="NOOPTION",
+ senders=senders,
+ recipients=recipients,
+ badSenders=badSenders,
+ badRecipients=badRecipients,
+ sw1="s5",
+ sw2="s2",
+ expectedLink=18)
+ else:
+ main.CLIs[ 0 ].removeAllIntents( purge=True )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=testResult,
+ onpass=main.assertReturnString,
+ onfail=main.assertReturnString )
+
+ main.step( "IPV4: Install and test single point to multi point intents" )
+ main.assertReturnString = "Assertion results for IPV4 single to multi point intent with IPV4 type and MAC addresses\n"
+ senders = [
+ { "name":"h8", "device":"of:0000000000000005/8","mac":"00:00:00:00:00:08" }
+ ]
+ recipients = [
+ { "name":"h16", "device":"of:0000000000000006/8", "mac":"00:00:00:00:00:10" },
+ { "name":"h24", "device":"of:0000000000000007/8", "mac":"00:00:00:00:00:18" }
+ ]
+ badSenders=[ { "name":"h9" } ] # Senders that are not in the intent
+ badRecipients=[ { "name":"h17" } ] # Recipients that are not in the intent
+ testResult = main.FALSE
+ installResult = main.FALSE
+ installResult = main.intentFunction.installSingleToMultiIntent(
+ main,
+ name="IPV4",
+ senders=senders,
+ recipients=recipients,
+ ethType="IPV4",
+ sw1="s5",
+ sw2="s2")
+
+ if installResult:
+ testResult = main.intentFunction.testPointIntent(
+ main,
+ intentId=installResult,
+ name="IPV4",
+ senders=senders,
+ recipients=recipients,
+ badSenders=badSenders,
+ badRecipients=badRecipients,
+ sw1="s5",
+ sw2="s2",
+ expectedLink=18)
+ else:
+ main.CLIs[ 0 ].removeAllIntents( purge=True )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=testResult,
+ onpass=main.assertReturnString,
+ onfail=main.assertReturnString )
+
+ main.step( "IPV4_2: Add single point to multi point intents" )
+ main.assertReturnString = "Assertion results for IPV4 single to multi point intent with IPV4 type and no MAC addresses\n"
+ senders = [
+ { "name":"h8", "device":"of:0000000000000005/8" }
+ ]
+ recipients = [
+ { "name":"h16", "device":"of:0000000000000006/8" },
+ { "name":"h24", "device":"of:0000000000000007/8" }
+ ]
+ badSenders=[ { "name":"h9" } ] # Senders that are not in the intent
+ badRecipients=[ { "name":"h17" } ] # Recipients that are not in the intent
+ testResult = main.FALSE
+ installResult = main.FALSE
+ installResult = main.intentFunction.installSingleToMultiIntent(
+ main,
+ name="IPV4_2",
+ senders=senders,
+ recipients=recipients,
+ ethType="IPV4",
+ sw1="s5",
+ sw2="s2")
+
+ if installResult:
+ testResult = main.intentFunction.testPointIntent(
+ main,
+ intentId=installResult,
+ name="IPV4_2",
+ senders=senders,
+ recipients=recipients,
+ badSenders=badSenders,
+ badRecipients=badRecipients,
+ sw1="s5",
+ sw2="s2",
+ expectedLink=18)
+ else:
+ main.CLIs[ 0 ].removeAllIntents( purge=True )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=testResult,
+ onpass=main.assertReturnString,
+ onfail=main.assertReturnString )
+
+ main.step( "VLAN: Add single point to multi point intents" )
+ main.assertReturnString = "Assertion results for IPV4 single to multi point intent with IPV4 type and MAC addresses in the same VLAN\n"
+ senders = [
+ { "name":"h4", "device":"of:0000000000000005/4", "mac":"00:00:00:00:00:04" }
+ ]
+ recipients = [
+ { "name":"h12", "device":"of:0000000000000006/4", "mac":"00:00:00:00:00:0C" },
+ { "name":"h20", "device":"of:0000000000000007/4", "mac":"00:00:00:00:00:14" }
+ ]
+ badSenders=[ { "name":"h13" } ] # Senders that are not in the intent
+ badRecipients=[ { "name":"h21" } ] # Recipients that are not in the intent
+ testResult = main.FALSE
+ installResult = main.FALSE
+ installResult = main.intentFunction.installSingleToMultiIntent(
+ main,
+ name="IPV4",
+ senders=senders,
+ recipients=recipients,
+ ethType="IPV4",
+ sw1="s5",
+ sw2="s2")
+
+ if installResult:
+ testResult = main.intentFunction.testPointIntent(
+ main,
+ intentId=installResult,
+ name="IPV4",
+ senders=senders,
+ recipients=recipients,
+ badSenders=badSenders,
+ badRecipients=badRecipients,
+ sw1="s5",
+ sw2="s2",
+ expectedLink=18)
+ else:
+ main.CLIs[ 0 ].removeAllIntents( purge=True )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=testResult,
+ onpass=main.assertReturnString,
+ onfail=main.assertReturnString )
+
+ main.intentFunction.report( main )
+
+ def CASE4000( self, main ):
+ """
+ Add multi point to single point intents
+ - Get device ids
+ - Add multi point to single point intents
+ - Check intents
+ - Verify flows
+ - Ping hosts
+ - Reroute
+ - Link down
+ - Verify flows
+ - Check topology
+ - Ping hosts
+ - Link up
+ - Verify flows
+ - Check topology
+ - Ping hosts
+ - Remove intents
+ """
+ assert main, "There is no main"
+ assert main.CLIs, "There is no main.CLIs"
+ assert main.Mininet1, "Mininet handle should be named Mininet1"
+ assert main.numSwitch, "Placed the total number of switch topology in \
+ main.numSwitch"
+
+ main.testName = "Multi To Single Point Intents"
+ main.case( main.testName + " Test - " + str( main.numCtrls ) +
+ " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
+ main.caseExplanation = "This test case will test single point to" +\
+ " multi point intents using " +\
+ str( main.numCtrls ) + " node(s) cluster;\n" +\
+ "Different type of hosts will be tested in " +\
+ "each step such as IPV4, Dual stack, VLAN etc" +\
+ ";\nThe test will use OF " + main.OFProtocol +\
+ " OVS running in Mininet and compile intents" +\
+ " using " + main.flowCompiler
+
+ main.step( "NOOPTION: Add multi point to single point intents" )
+ main.assertReturnString = "Assertion results for NOOPTION multi to single point intent\n"
+ senders = [
+ { "name":"h16", "device":"of:0000000000000006/8" },
+ { "name":"h24", "device":"of:0000000000000007/8" }
+ ]
+ recipients = [
+ { "name":"h8", "device":"of:0000000000000005/8" }
+ ]
+ badSenders=[ { "name":"h17" } ] # Senders that are not in the intent
+ badRecipients=[ { "name":"h9" } ] # Recipients that are not in the intent
+ testResult = main.FALSE
+ installResult = main.FALSE
+ installResult = main.intentFunction.installMultiToSingleIntent(
+ main,
+ name="NOOPTION",
+ senders=senders,
+ recipients=recipients,
+ sw1="s5",
+ sw2="s2" )
+
+ if installResult:
+ testResult = main.intentFunction.testPointIntent(
+ main,
+ intentId=installResult,
+ name="NOOPTION",
+ senders=senders,
+ recipients=recipients,
+ badSenders=badSenders,
+ badRecipients=badRecipients,
+ sw1="s5",
+ sw2="s2",
+ expectedLink=18 )
+ else:
+ main.CLIs[ 0 ].removeAllIntents( purge=True )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=testResult,
+ onpass=main.assertReturnString,
+ onfail=main.assertReturnString )
+
+ main.step( "IPV4: Add multi point to single point intents" )
+ main.assertReturnString = "Assertion results for IPV4 multi to single point intent with IPV4 type and MAC addresses\n"
+ senders = [
+ { "name":"h16", "device":"of:0000000000000006/8", "mac":"00:00:00:00:00:10" },
+ { "name":"h24", "device":"of:0000000000000007/8", "mac":"00:00:00:00:00:18" }
+ ]
+ recipients = [
+ { "name":"h8", "device":"of:0000000000000005/8", "mac":"00:00:00:00:00:08" }
+ ]
+ badSenders=[ { "name":"h17" } ] # Senders that are not in the intent
+ badRecipients=[ { "name":"h9" } ] # Recipients that are not in the intent
+ testResult = main.FALSE
+ installResult = main.FALSE
+ installResult = main.intentFunction.installMultiToSingleIntent(
+ main,
+ name="IPV4",
+ senders=senders,
+ recipients=recipients,
+ ethType="IPV4",
+ sw1="s5",
+ sw2="s2")
+
+ if installResult:
+ testResult = main.intentFunction.testPointIntent(
+ main,
+ intentId=installResult,
+ name="IPV4",
+ senders=senders,
+ recipients=recipients,
+ badSenders=badSenders,
+ badRecipients=badRecipients,
+ sw1="s5",
+ sw2="s2",
+ expectedLink=18)
+ else:
+ main.CLIs[ 0 ].removeAllIntents( purge=True )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=testResult,
+ onpass=main.assertReturnString,
+ onfail=main.assertReturnString )
+
+ main.step( "IPV4_2: Add multi point to single point intents" )
+ main.assertReturnString = "Assertion results for IPV4 multi to single point intent with IPV4 type and no MAC addresses\n"
+ senders = [
+ { "name":"h16", "device":"of:0000000000000006/8" },
+ { "name":"h24", "device":"of:0000000000000007/8" }
+ ]
+ recipients = [
+ { "name":"h8", "device":"of:0000000000000005/8" }
+ ]
+ badSenders=[ { "name":"h17" } ] # Senders that are not in the intent
+ badRecipients=[ { "name":"h9" } ] # Recipients that are not in the intent
+ testResult = main.FALSE
+ installResult = main.FALSE
+ installResult = main.intentFunction.installMultiToSingleIntent(
+ main,
+ name="IPV4_2",
+ senders=senders,
+ recipients=recipients,
+ ethType="IPV4",
+ sw1="s5",
+ sw2="s2")
+
+ if installResult:
+ testResult = main.intentFunction.testPointIntent(
+ main,
+ intentId=installResult,
+ name="IPV4_2",
+ senders=senders,
+ recipients=recipients,
+ badSenders=badSenders,
+ badRecipients=badRecipients,
+ sw1="s5",
+ sw2="s2",
+ expectedLink=18)
+ else:
+ main.CLIs[ 0 ].removeAllIntents( purge=True )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=testResult,
+ onpass=main.assertReturnString,
+ onfail=main.assertReturnString )
+
+ main.step( "VLAN: Add multi point to single point intents" )
+ main.assertReturnString = "Assertion results for IPV4 multi to single point intent with IPV4 type and no MAC addresses in the same VLAN\n"
+ senders = [
+ { "name":"h13", "device":"of:0000000000000006/5" },
+ { "name":"h21", "device":"of:0000000000000007/5" }
+ ]
+ recipients = [
+ { "name":"h5", "device":"of:0000000000000005/5" }
+ ]
+ badSenders=[ { "name":"h12" } ] # Senders that are not in the intent
+ badRecipients=[ { "name":"h20" } ] # Recipients that are not in the intent
+ testResult = main.FALSE
+ installResult = main.FALSE
+ installResult = main.intentFunction.installMultiToSingleIntent(
+ main,
+ name="VLAN",
+ senders=senders,
+ recipients=recipients,
+ ethType="IPV4",
+ sw1="s5",
+ sw2="s2")
+
+ if installResult:
+ testResult = main.intentFunction.testPointIntent(
+ main,
+ intentId=installResult,
+ name="VLAN",
+ senders=senders,
+ recipients=recipients,
+ badSenders=badSenders,
+ badRecipients=badRecipients,
+ sw1="s5",
+ sw2="s2",
+ expectedLink=18)
+ else:
+ main.CLIs[ 0 ].removeAllIntents( purge=True )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=testResult,
+ onpass=main.assertReturnString,
+ onfail=main.assertReturnString )
+
+ main.intentFunction.report( main )
+
+ def CASE5000( self, main ):
+ """
+ Tests Host Mobility
+ Modifies the topology location of h1
+ """
+ assert main, "There is no main"
+ assert main.CLIs, "There is no main.CLIs"
+ assert main.Mininet1, "Mininet handle should be named Mininet1"
+ assert main.numSwitch, "Placed the total number of switch topology in \
+ main.numSwitch"
+ main.case( "Test host mobility with host intents " )
+ main.step( "Testing host mobility by moving h1 from s5 to s6" )
+ h1PreMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
+
+ main.log.info( "Moving h1 from s5 to s6")
+ main.Mininet1.moveHost( "h1","s5","s6" )
+
+ # Send discovery ping from moved host
+ # Moving the host brings down the default interfaces and creates a new one.
+ # Scapy is restarted on this host to detect the new interface
+ main.h1.stopScapy()
+ main.h1.startScapy()
+
+ # Discover new host location in ONOS and populate host data.
+ # Host 1 IP and MAC should be unchanged
+ main.intentFunction.sendDiscoveryArp( main, [ main.h1 ] )
+ main.intentFunction.populateHostData( main )
+
+ h1PostMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
+
+ utilities.assert_equals( expect="of:0000000000000006",
+ actual=h1PostMove,
+ onpass="Mobility: Successfully moved h1 to s6",
+ onfail="Mobility: Failed to move h1 to s6" +
+ " to single point intents" +
+ " with IPV4 type and MAC addresses" +
+ " in the same VLAN" )
+
+ main.step( "IPV4: Add host intents between h1 and h9" )
+ main.assertReturnString = "Assert result for IPV4 host intent between h1, moved, and h9\n"
+ host1 = { "name":"h1","id":"00:00:00:00:00:01/-1" }
+ host2 = { "name":"h9","id":"00:00:00:00:00:09/-1" }
+ testResult = main.FALSE
+ installResult = main.FALSE
+ installResult = main.intentFunction.installHostIntent( main,
+ name='IPV4 Mobility IPV4',
+ onosNode='0',
+ host1=host1,
+ host2=host2 )
+ if installResult:
+ testResult = main.intentFunction.testHostIntent( main,
+ name='Host Mobility IPV4',
+ intentId = installResult,
+ onosNode='0',
+ host1=host1,
+ host2=host2,
+ sw1="s6",
+ sw2="s2",
+ expectedLink=18 )
+ else:
+ main.CLIs[ 0 ].removeAllIntents( purge=True )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=testResult,
+ onpass=main.assertReturnString,
+ onfail=main.assertReturnString )
+
+ main.intentFunction.report( main )
+
+ def CASE6000( self, main ):
+ """
+ Tests Multi to Single Point Intent and Single to Multi Point Intent End Point Failure
+ """
+ assert main, "There is no main"
+ assert main.CLIs, "There is no main.CLIs"
+ assert main.Mininet1, "Mininet handle should be named Mininet1"
+ assert main.numSwitch, "Placed the total number of switch topology in \
+ main.numSwitch"
+ main.case( "Test Multi to Single End Point Failure" )
+ main.step( "Installing Multi to Single Point intents" )
+
+ main.assertReturnString = "Assertion results for IPV4 multi to single \
+ point intent end point failure with no options set\n"
+ senders = [
+ { "name":"h16", "device":"of:0000000000000006/8" },
+ { "name":"h24", "device":"of:0000000000000007/8" }
+ ]
+ recipients = [
+ { "name":"h8", "device":"of:0000000000000005/8" }
+ ]
+ isolatedSenders = [
+ { "name":"h24"}
+ ]
+ isolatedRecipients = []
+ testResult = main.FALSE
+ installResult = main.FALSE
+ installResult = main.intentFunction.installMultiToSingleIntent(
+ main,
+ name="NOOPTION",
+ senders=senders,
+ recipients=recipients,
+ sw1="s5",
+ sw2="s2" )
+
+ if installResult:
+ testResult = main.intentFunction.testEndPointFail(
+ main,
+ intentId=installResult,
+ name="NOOPTION",
+ senders=senders,
+ recipients=recipients,
+ isolatedSenders=isolatedSenders,
+ isolatedRecipients=isolatedRecipients,
+ sw1="s6",
+ sw2="s2",
+ sw3="s4",
+ sw4="s1",
+ sw5="s3",
+ expectedLink1=16,
+ expectedLink2=14 )
+ else:
+ main.CLIs[ 0 ].removeAllIntents( purge=True )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=testResult,
+ onpass=main.assertReturnString,
+ onfail=main.assertReturnString )
+
+ main.step( "IPV4: Add multi point to single point intents" )
+ main.assertReturnString = "Assertion results for IPV4 multi to single \
+ point intent end point failure with IPV4 type and MAC addresses\n"
+ senders = [
+ { "name":"h16", "device":"of:0000000000000006/8", "mac":"00:00:00:00:00:10" },
+ { "name":"h24", "device":"of:0000000000000007/8", "mac":"00:00:00:00:00:18" }
+ ]
+ recipients = [
+ { "name":"h8", "device":"of:0000000000000005/8", "mac":"00:00:00:00:00:08" }
+ ]
+ isolatedSenders = [
+ { "name":"h24"}
+ ]
+ isolatedRecipients = []
+ testResult = main.FALSE
+ installResult = main.FALSE
+ installResult = main.intentFunction.installMultiToSingleIntent(
+ main,
+ name="IPV4",
+ senders=senders,
+ recipients=recipients,
+ ethType="IPV4",
+ sw1="s5",
+ sw2="s2")
+
+ if installResult:
+ testResult = main.intentFunction.testEndPointFail(
+ main,
+ intentId=installResult,
+ name="IPV4",
+ senders=senders,
+ recipients=recipients,
+ isolatedSenders=isolatedSenders,
+ isolatedRecipients=isolatedRecipients,
+ sw1="s6",
+ sw2="s2",
+ sw3="s4",
+ sw4="s1",
+ sw5="s3",
+ expectedLink1=16,
+ expectedLink2=14 )
+ else:
+ main.CLIs[ 0 ].removeAllIntents( purge=True )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=testResult,
+ onpass=main.assertReturnString,
+ onfail=main.assertReturnString )
+
+ main.step( "IPV4_2: Add multi point to single point intents" )
+ main.assertReturnString = "Assertion results for IPV4 multi to single \
+ point intent end point failure with IPV4 type and no MAC addresses\n"
+ senders = [
+ { "name":"h16", "device":"of:0000000000000006/8" },
+ { "name":"h24", "device":"of:0000000000000007/8" }
+ ]
+ recipients = [
+ { "name":"h8", "device":"of:0000000000000005/8" }
+ ]
+ isolatedSenders = [
+ { "name":"h24"}
+ ]
+ isolatedRecipients = []
+ testResult = main.FALSE
+ installResult = main.FALSE
+ installResult = main.intentFunction.installMultiToSingleIntent(
+ main,
+ name="IPV4_2",
+ senders=senders,
+ recipients=recipients,
+ ethType="IPV4",
+ sw1="s5",
+ sw2="s2")
+
+ if installResult:
+ testResult = main.intentFunction.testEndPointFail(
+ main,
+ intentId=installResult,
+ name="IPV4_2",
+ senders=senders,
+ recipients=recipients,
+ isolatedSenders=isolatedSenders,
+ isolatedRecipients=isolatedRecipients,
+ sw1="s6",
+ sw2="s2",
+ sw3="s4",
+ sw4="s1",
+ sw5="s3",
+ expectedLink1=16,
+ expectedLink2=14 )
+ else:
+ main.CLIs[ 0 ].removeAllIntents( purge=True )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=testResult,
+ onpass=main.assertReturnString,
+ onfail=main.assertReturnString )
+
+ main.step( "VLAN: Add multi point to single point intents" )
+ main.assertReturnString = "Assertion results for IPV4 multi to single \
+ point intent end point failure with IPV4 type and no MAC addresses in the same VLAN\n"
+ senders = [
+ { "name":"h13", "device":"of:0000000000000006/5" },
+ { "name":"h21", "device":"of:0000000000000007/5" }
+ ]
+ recipients = [
+ { "name":"h5", "device":"of:0000000000000005/5" }
+ ]
+ isolatedSenders = [
+ { "name":"h21"}
+ ]
+ isolatedRecipients = []
+ testResult = main.FALSE
+ installResult = main.FALSE
+ installResult = main.intentFunction.installMultiToSingleIntent(
+ main,
+ name="VLAN",
+ senders=senders,
+ recipients=recipients,
+ ethType="IPV4",
+ sw1="s5",
+ sw2="s2")
+
+ if installResult:
+ testResult = main.intentFunction.testEndPointFail(
+ main,
+ intentId=installResult,
+ name="VLAN",
+ senders=senders,
+ recipients=recipients,
+ isolatedSenders=isolatedSenders,
+ isolatedRecipients=isolatedRecipients,
+ sw1="s6",
+ sw2="s2",
+ sw3="s4",
+ sw4="s1",
+ sw5="s3",
+ expectedLink1=16,
+ expectedLink2=14 )
+ else:
+ main.CLIs[ 0 ].removeAllIntents( purge=True )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=testResult,
+ onpass=main.assertReturnString,
+ onfail=main.assertReturnString )
+
+ main.step( "NOOPTION: Install and test single point to multi point intents" )
+ main.assertReturnString = "Assertion results for IPV4 single to multi \
+ point intent end point failure with no options set\n"
+ senders = [
+ { "name":"h8", "device":"of:0000000000000005/8" }
+ ]
+ recipients = [
+ { "name":"h16", "device":"of:0000000000000006/8" },
+ { "name":"h24", "device":"of:0000000000000007/8" }
+ ]
+ isolatedSenders = []
+ isolatedRecipients = [
+ { "name":"h24" }
+ ]
+ testResult = main.FALSE
+ installResult = main.FALSE
+ installResult = main.intentFunction.installSingleToMultiIntent(
+ main,
+ name="NOOPTION",
+ senders=senders,
+ recipients=recipients,
+ sw1="s5",
+ sw2="s2")
+
+ if installResult:
+ testResult = main.intentFunction.testEndPointFail(
+ main,
+ intentId=installResult,
+ name="NOOPTION",
+ senders=senders,
+ recipients=recipients,
+ isolatedSenders=isolatedSenders,
+ isolatedRecipients=isolatedRecipients,
+ sw1="s6",
+ sw2="s2",
+ sw3="s4",
+ sw4="s1",
+ sw5="s3",
+ expectedLink1=16,
+ expectedLink2=14 )
+ else:
+ main.CLIs[ 0 ].removeAllIntents( purge=True )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=testResult,
+ onpass=main.assertReturnString,
+ onfail=main.assertReturnString )
+
+ main.step( "IPV4: Install and test single point to multi point intents" )
+ main.assertReturnString = "Assertion results for IPV4 single to multi \
+ point intent end point failure with IPV4 type and no MAC addresses\n"
+ senders = [
+ { "name":"h8", "device":"of:0000000000000005/8","mac":"00:00:00:00:00:08" }
+ ]
+ recipients = [
+ { "name":"h16", "device":"of:0000000000000006/8", "mac":"00:00:00:00:00:10" },
+ { "name":"h24", "device":"of:0000000000000007/8", "mac":"00:00:00:00:00:18" }
+ ]
+ isolatedSenders = []
+ isolatedRecipients = [
+ { "name":"h24" }
+ ]
+ testResult = main.FALSE
+ installResult = main.FALSE
+ installResult = main.intentFunction.installSingleToMultiIntent(
+ main,
+ name="IPV4",
+ senders=senders,
+ recipients=recipients,
+ ethType="IPV4",
+ sw1="s5",
+ sw2="s2")
+
+ if installResult:
+ testResult = main.intentFunction.testEndPointFail(
+ main,
+ intentId=installResult,
+ name="IPV4",
+ senders=senders,
+ recipients=recipients,
+ isolatedSenders=isolatedSenders,
+ isolatedRecipients=isolatedRecipients,
+ sw1="s6",
+ sw2="s2",
+ sw3="s4",
+ sw4="s1",
+ sw5="s3",
+ expectedLink1=16,
+ expectedLink2=14 )
+ else:
+ main.CLIs[ 0 ].removeAllIntents( purge=True )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=testResult,
+ onpass=main.assertReturnString,
+ onfail=main.assertReturnString )
+
+ main.step( "IPV4_2: Add single point to multi point intents" )
+ main.assertReturnString = "Assertion results for IPV4 single to multi\
+ point intent endpoint failure with IPV4 type and no MAC addresses\n"
+ senders = [
+ { "name":"h8", "device":"of:0000000000000005/8" }
+ ]
+ recipients = [
+ { "name":"h16", "device":"of:0000000000000006/8" },
+ { "name":"h24", "device":"of:0000000000000007/8" }
+ ]
+ isolatedSenders = []
+ isolatedRecipients = [
+ { "name":"h24" }
+ ]
+ testResult = main.FALSE
+ installResult = main.FALSE
+ installResult = main.intentFunction.installSingleToMultiIntent(
+ main,
+ name="IPV4_2",
+ senders=senders,
+ recipients=recipients,
+ ethType="IPV4",
+ sw1="s5",
+ sw2="s2")
+
+ if installResult:
+ testResult = main.intentFunction.testEndPointFail(
+ main,
+ intentId=installResult,
+ name="IPV4_2",
+ senders=senders,
+ recipients=recipients,
+ isolatedSenders=isolatedSenders,
+ isolatedRecipients=isolatedRecipients,
+ sw1="s6",
+ sw2="s2",
+ sw3="s4",
+ sw4="s1",
+ sw5="s3",
+ expectedLink1=16,
+ expectedLink2=14 )
+ else:
+ main.CLIs[ 0 ].removeAllIntents( purge=True )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=testResult,
+ onpass=main.assertReturnString,
+ onfail=main.assertReturnString )
+
+ main.step( "VLAN: Add single point to multi point intents" )
+ main.assertReturnString = "Assertion results for IPV4 single to multi point\
+ intent endpoint failure with IPV4 type and MAC addresses in the same VLAN\n"
+ senders = [
+ { "name":"h4", "device":"of:0000000000000005/4", "mac":"00:00:00:00:00:04" }
+ ]
+ recipients = [
+ { "name":"h12", "device":"of:0000000000000006/4", "mac":"00:00:00:00:00:0C" },
+ { "name":"h20", "device":"of:0000000000000007/4", "mac":"00:00:00:00:00:14" }
+ ]
+ isolatedSenders = []
+ isolatedRecipients = [
+ { "name":"h20" }
+ ]
+ testResult = main.FALSE
+ installResult = main.FALSE
+ installResult = main.intentFunction.installSingleToMultiIntent(
+ main,
+ name="IPV4",
+ senders=senders,
+ recipients=recipients,
+ ethType="IPV4",
+ sw1="s5",
+ sw2="s2")
+
+ if installResult:
+ testResult = main.intentFunction.testEndPointFail(
+ main,
+ intentId=installResult,
+ name="IPV4",
+ senders=senders,
+ recipients=recipients,
+ isolatedSenders=isolatedSenders,
+ isolatedRecipients=isolatedRecipients,
+ sw1="s6",
+ sw2="s2",
+ sw3="s4",
+ sw4="s1",
+ sw5="s3",
+ expectedLink1=16,
+ expectedLink2=14 )
+ else:
+ main.CLIs[ 0 ].removeAllIntents( purge=True )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=testResult,
+ onpass=main.assertReturnString,
+ onfail=main.assertReturnString )
+
+ main.intentFunction.report( main )
\ No newline at end of file
diff --git a/TestON/tests/FUNC/FUNCintent/FUNCintent.topo b/TestON/tests/FUNC/FUNCintent/FUNCintent.topo
new file mode 100755
index 0000000..500fc3c
--- /dev/null
+++ b/TestON/tests/FUNC/FUNCintent/FUNCintent.topo
@@ -0,0 +1,62 @@
+<TOPOLOGY>
+ <COMPONENT>
+
+ <ONOSbench>
+ <host>localhost</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>1</connect_order>
+ <COMPONENTS>
+ <nodes>3</nodes>
+ </COMPONENTS>
+ </ONOSbench>
+
+ <ONOScli1>
+ <host>localhost</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosCliDriver</type>
+ <connect_order>2</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOScli1>
+
+ <ONOScli2>
+ <host>localhost</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosCliDriver</type>
+ <connect_order>3</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOScli2>
+
+ <ONOScli3>
+ <host>localhost</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosCliDriver</type>
+ <connect_order>4</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOScli3>
+
+ <Mininet1>
+ <host>OCN</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>MininetCliDriver</type>
+ <connect_order>5</connect_order>
+ <COMPONENTS>
+ <home>~/mininet/</home>
+ </COMPONENTS>
+ </Mininet1>
+
+ <Scapy1>
+ <host>OCN</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>ScapyCliDriver</type>
+ <connect_order>6</connect_order>
+ </Scapy1>
+
+ </COMPONENT>
+</TOPOLOGY>
diff --git a/TestON/tests/FUNC/FUNCintent/README b/TestON/tests/FUNC/FUNCintent/README
new file mode 100644
index 0000000..c05562f
--- /dev/null
+++ b/TestON/tests/FUNC/FUNCintent/README
@@ -0,0 +1,46 @@
+Summary:
+ This test suite consist of basic intent functionality testing.
+ The following is an overview of how host intents is being tested.
+ Steps:
+ - Discover hosts
+ - Add host intents
+ - Check intents
+ - Verify flows
+ - Ping hosts
+ - Reroute
+ - Link down
+ - Verify flows
+ - Check topology
+ - Ping hosts
+ - Link up
+ - Verify flows
+ - Check topology
+ - Ping hosts
+ - Remove intents
+ This test suite includes testing of different types of intents such as
+ host, point, single-to-multi and multi-to-single ( More intent types to
+ add later ). The same steps above is being performed to other type of
+ intents.
+
+Required:
+ This test requires Mininet topology file newFuncIntent.py that is in the
+ dependencies folder. You should run the topology file to check for any
+ missing packages. The mininet topology file has different type of hosts
+ including VLAN hosts. Therefore you need to install VLAN module to build
+ the topology correctly.
+
+NOTE:
+ This test is being updated to use Scapy for host discovery and verification of flows.
+ So, Scapy will be required to run the test in the future.
+
+VLAN configuration:
+ Execute command:
+ $ sudo apt-get install vlan
+ Configuration:
+ $ sudo modprobe 8021q
+ NOTE:To make this configuration permanent
+ $ sudo su -c 'echo "8021q" >> /etc/modules'
+
+Scapy install:
+ sudo apt-get install Scapy
+
diff --git a/TestON/tests/FUNC/FUNCintent/__init__.py b/TestON/tests/FUNC/FUNCintent/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/TestON/tests/FUNC/FUNCintent/__init__.py
diff --git a/TestON/tests/FUNC/FUNCintent/dependencies/FuncIntentFunction.py b/TestON/tests/FUNC/FUNCintent/dependencies/FuncIntentFunction.py
new file mode 100644
index 0000000..976838c
--- /dev/null
+++ b/TestON/tests/FUNC/FUNCintent/dependencies/FuncIntentFunction.py
@@ -0,0 +1,1734 @@
+"""
+ Wrapper functions for FuncIntent
+ This functions include Onosclidriver and Mininetclidriver driver functions
+ Author: kelvin@onlab.us
+"""
+import time
+import copy
+import json
+
+def __init__( self ):
+ self.default = ''
+
+def installHostIntent( main,
+ name,
+ host1,
+ host2,
+ onosNode=0,
+ ethType="",
+ bandwidth="",
+ lambdaAlloc=False,
+ ipProto="",
+ ipAddresses="",
+ tcp="",
+ sw1="",
+ sw2=""):
+ """
+ Installs a Host Intent
+
+ Description:
+ Install a host intent using
+ add-host-intent
+
+ Steps:
+ - Fetch host data if not given
+ - Add host intent
+ - Ingress device is the first sender host
+ - Egress devices are the recipient devices
+ - Ports if defined in senders or recipients
+ - MAC address ethSrc loaded from Ingress device
+ - Check intent state with retry
+ Required:
+ name - Type of point intent to add eg. IPV4 | VLAN | Dualstack
+ host1 - Dictionary for host1
+ { "name":"h8", "id":"of:0000000000000005/8" }
+ host2 - Dictionary for host2
+ { "name":"h16", "id":"of:0000000000000006/8" }
+ Optional:
+ onosNode - ONOS node to install the intents in main.CLIs[ ]
+ 0 by default so that it will always use the first
+ ONOS node
+ ethType - Ethernet type eg. IPV4, IPV6
+ bandwidth - Bandwidth capacity
+ lambdaAlloc - Allocate lambda, defaults to False
+ ipProto - IP protocol
+ tcp - TCP ports in the same order as the hosts in hostNames
+ """
+
+ assert main, "There is no main variable"
+ assert host1, "You must specify host1"
+ assert host2, "You must specify host2"
+
+ global itemName # The name of this run. Used for logs.
+ itemName = name
+ onosNode = int( onosNode )
+
+ main.log.info( itemName + ": Adding single point to multi point intents" )
+
+ if not host1.get( "id" ):
+ main.log.warn( "ID not given for host1 {0}. Loading from main.hostData".format( host1.get( "name" ) ) )
+ main.log.debug( main.hostsData.get( host1.get( "name" ) ) )
+ host1[ "id" ] = main.hostsData.get( host1.get( "name" ) ).get( "id" )
+
+ if not host2.get( "id" ):
+ main.log.warn( "ID not given for host2 {0}. Loading from main.h ostData".format( host2.get( "name" ) ) )
+ host2[ "id" ] = main.hostsData.get( host2.get( "name" ) ).get( "id" )
+
+ # Adding point intent
+ intentId = main.CLIs[ onosNode ].addHostIntent( hostIdOne=host1.get( "id" ),
+ hostIdTwo=host2.get( "id" ) )
+
+ # Check intents state
+ if utilities.retry( f=checkIntentState, retValue=main.FALSE,
+ args=( main, [ intentId ] ), sleep=main.checkIntentSleep ):
+ return intentId
+ else:
+ main.log.error( "Host Intent did not install correctly" )
+ return main.FALSE
+
+def testHostIntent( main,
+ name,
+ intentId,
+ host1,
+ host2,
+ onosNode=0,
+ sw1="s5",
+ sw2="s2",
+ expectedLink=0):
+ """
+ Test a Host Intent
+
+ Description:
+ Test a host intent of given ID between given hosts
+
+ Steps:
+ - Fetch host data if not given
+ - Check Intent State
+ - Check Flow State
+ - Check Connectivity
+ - Check Lack of Connectivity Between Hosts not in the Intent
+ - Reroute
+ - Take Expected Link Down
+ - Check Intent State
+ - Check Flow State
+ - Check Topology
+ - Check Connectivity
+ - Bring Expected Link Up
+ - Check Intent State
+ - Check Flow State
+ - Check Topology
+ - Check Connectivity
+ - Remove Topology
+
+ Required:
+ name - Type of point intent to add eg. IPV4 | VLAN | Dualstack
+ intentId - intent ID to be tested ( and removed )
+ host1 - Dictionary for host1
+ { "name":"h8", "id":"of:0000000000000005/8" }
+ host2 - Dictionary for host2
+ { "name":"h16", "id":"of:0000000000000006/8" }
+ Optional:
+ onosNode - ONOS node to install the intents in main.CLIs[ ]
+ 0 by default so that it will always use the first
+ ONOS node
+ sw1 - First switch to bring down & up for rerouting purpose
+ sw2 - Second switch to bring down & up for rerouting purpose
+ expectedLink - Expected link when the switches are down, it should
+ be two links lower than the links before the two
+ switches are down
+
+ """
+
+ # Parameter Validity Check
+ assert main, "There is no main variable"
+ assert host1, "You must specify host1"
+ assert host2, "You must specify host2"
+
+ global itemName
+ itemName = name
+ tempHostsData = {}
+ onosNode = int( onosNode )
+
+ main.log.info( itemName + ": Testing Host Intent" )
+
+ if not host1.get( "id" ):
+ main.log.warn( "Id not given for host1 {0}. Loading from main.hostData".format( host1.get( "name" ) ) )
+ host1[ "id" ] = main.hostsData.get( host1.get( "name" ) ).get( "location" )
+
+ if not host2.get( "id" ):
+ main.log.warn( "Id not given for host2 {0}. Loading from main.hostData".format( host2.get( "name" ) ) )
+ host2[ "id" ] = main.hostsData.get( host2.get( "name" ) ).get( "location" )
+
+ senderNames = [ host1.get( "name" ), host2.get( "name" ) ]
+ recipientNames = [ host1.get( "name" ), host2.get( "name" ) ]
+
+ testResult = main.TRUE
+ main.log.info( itemName + ": Adding single point to multi point intents" )
+
+ # Check intent state
+ if utilities.retry( f=checkIntentState, retValue=main.FALSE, args=( main, [ intentId ] ), sleep=main.checkIntentSleep ):
+ main.assertReturnString += 'Initial Intent State Passed\n'
+ else:
+ main.assertReturnString += 'Initial Intent State Failed\n'
+ testResult = main.FALSE
+
+ # Check flows count in each node
+ if utilities.retry( f=checkFlowsCount, retValue=main.FALSE, args=[ main ], sleep=20, attempts=3 ) and utilities.retry( f=checkFlowsState, retValue=main.FALSE, args=[ main ], sleep=20, attempts=3 ):
+ main.assertReturnString += 'Initial Flow State Passed\n'
+ else:
+ main.assertReturnString += 'Intial Flow State Failed\n'
+ testResult = main.FALSE
+
+ # Check Connectivity
+ if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, recipientNames ) ):
+ main.assertReturnString += 'Initial Ping Passed\n'
+ else:
+ main.assertReturnString += 'Initial Ping Failed\n'
+ testResult = main.FALSE
+
+ # Test rerouting if these variables exist
+ if sw1 and sw2 and expectedLink:
+ # Take link down
+ if utilities.retry( f=link, retValue=main.FALSE, args=( main, sw1, sw2, "down" ) ):
+ main.assertReturnString += 'Link Down Passed\n'
+ else:
+ main.assertReturnString += 'Link Down Failed\n'
+ testResult = main.FALSE
+
+ # Check intent state
+ if utilities.retry( f=checkIntentState, retValue=main.FALSE, args=( main, [ intentId ] ), sleep=main.checkIntentSleep ):
+ main.assertReturnString += 'Link Down Intent State Passed\n'
+ else:
+ main.assertReturnString += 'Link Down Intent State Failed\n'
+ testResult = main.FALSE
+
+ # Check flows count in each node
+ if utilities.retry( f=checkFlowsCount, retValue=main.FALSE, args=[ main ], sleep=20, attempts=3 ) and utilities.retry( f=checkFlowsState, retValue=main.FALSE, args=[ main ], sleep=20, attempts=3 ):
+ main.assertReturnString += 'Link Down Flow State Passed\n'
+ else:
+ main.assertReturnString += 'Link Down Flow State Failed\n'
+ testResult = main.FALSE
+
+ # Check OnosTopology
+ if utilities.retry( f=checkTopology, retValue=main.FALSE, args=( main, expectedLink ) ):
+ main.assertReturnString += 'Link Down Topology State Passed\n'
+ else:
+ main.assertReturnString += 'Link Down Topology State Failed\n'
+ testResult = main.FALSE
+
+ # Check Connection
+ if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, recipientNames ) ):
+ main.assertReturnString += 'Link Down Pingall Passed\n'
+ else:
+ main.assertReturnString += 'Link Down Pingall Failed\n'
+ testResult = main.FALSE
+
+ # Bring link up
+ if utilities.retry( f=link, retValue=main.FALSE, args=( main, sw1, sw2, "up" ) ):
+ main.assertReturnString += 'Link Up Passed\n'
+ else:
+ main.assertReturnString += 'Link Up Failed\n'
+ testResult = main.FALSE
+
+ # Wait for reroute
+ time.sleep( main.rerouteSleep )
+
+ # Check Intents
+ if utilities.retry( f=checkIntentState, retValue=main.FALSE, args=( main, [ intentId ] ), sleep=main.checkIntentSleep ):
+ main.assertReturnString += 'Link Up Intent State Passed\n'
+ else:
+ main.assertReturnString += 'Link Up Intent State Failed\n'
+ testResult = main.FALSE
+
+ # Check flows count in each node
+ if utilities.retry( f=checkFlowsCount, retValue=main.FALSE, args=[ main ], sleep=20, attempts=3 ) and utilities.retry( f=checkFlowsState, retValue=main.FALSE, args=[ main ], sleep=20, attempts=3 ):
+ main.assertReturnString += 'Link Up Flow State Passed\n'
+ else:
+ main.assertReturnString += 'Link Up Flow State Failed\n'
+ testResult = main.FALSE
+
+ # Check OnosTopology
+ if utilities.retry( f=checkTopology, retValue=main.FALSE, args=( main, main.numLinks ) ):
+ main.assertReturnString += 'Link Up Topology State Passed\n'
+ else:
+ main.assertReturnString += 'Link Up Topology State Failed\n'
+ testResult = main.FALSE
+
+ # Check Connection
+ if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, recipientNames ) ):
+ main.assertReturnString += 'Link Up Pingall Passed\n'
+ else:
+ main.assertReturnString += 'Link Up Pingall Failed\n'
+ testResult = main.FALSE
+
+ # Remove all intents
+ if utilities.retry( f=removeAllIntents, retValue=main.FALSE, args=( main, [ intentId ] ) ):
+ main.assertReturnString += 'Remove Intents Passed'
+ else:
+ main.assertReturnString += 'Remove Intents Failed'
+ testResult = main.FALSE
+
+ return testResult
+
+def installPointIntent( main,
+ name,
+ senders,
+ recipients,
+ onosNode=0,
+ ethType="",
+ bandwidth="",
+ lambdaAlloc=False,
+ ipProto="",
+ ipSrc="",
+ ipDst="",
+ tcpSrc="",
+ tcpDst=""):
+ """
+ Installs a Single to Single Point Intent
+
+ Description:
+ Install a single to single point intent
+
+ Steps:
+ - Fetch host data if not given
+ - Add point intent
+ - Ingress device is the first sender device
+ - Egress device is the first recipient device
+ - Ports if defined in senders or recipients
+ - MAC address ethSrc loaded from Ingress device
+ - Check intent state with retry
+ Required:
+ name - Type of point intent to add eg. IPV4 | VLAN | Dualstack
+ senders - List of host dictionaries i.e.
+ [ { "name":"h8", "device":"of:0000000000000005/8","mac":"00:00:00:00:00:08" } ]
+ recipients - List of host dictionaries i.e.
+ [ { "name":"h16", "device":"of:0000000000000006/8", "mac":"00:00:00:00:00:10" } ]
+ Optional:
+ onosNode - ONOS node to install the intents in main.CLIs[ ]
+ 0 by default so that it will always use the first
+ ONOS node
+ ethType - Ethernet type eg. IPV4, IPV6
+ bandwidth - Bandwidth capacity
+ lambdaAlloc - Allocate lambda, defaults to False
+ ipProto - IP protocol
+ tcp - TCP ports in the same order as the hosts in hostNames
+ sw1 - First switch to bring down & up for rerouting purpose
+ sw2 - Second switch to bring down & up for rerouting purpose
+ expectedLink - Expected link when the switches are down, it should
+ be two links lower than the links before the two
+ switches are down
+ """
+
+ assert main, "There is no main variable"
+ assert senders, "You must specify a sender"
+ assert recipients, "You must specify a recipient"
+ # Assert devices or main.hostsData, "You must specify devices"
+
+ global itemName # The name of this run. Used for logs.
+ itemName = name
+ onosNode = int( onosNode )
+
+ main.log.info( itemName + ": Adding point to point intents" )
+
+ for sender in senders:
+ if not sender.get( "device" ):
+ main.log.warn( "Device not given for sender {0}. Loading from main.hostData".format( sender.get( "name" ) ) )
+ sender[ "device" ] = main.hostsData.get( sender.get( "name" ) ).get( "location" )
+
+ for recipient in recipients:
+ if not recipient.get( "device" ):
+ main.log.warn( "Device not given for recipient {0}. Loading from main.hostData".format( recipient.get( "name" ) ) )
+ recipient[ "device" ] = main.hostsData.get( recipient.get( "name" ) ).get( "location" )
+
+
+ ingressDevice = senders[ 0 ].get( "device" )
+ egressDevice = recipients[ 0 ].get( "device" )
+
+ portIngress = senders[ 0 ].get( "port", "" )
+ portEgress = recipients[ 0 ].get( "port", "" )
+
+ dstMac = recipients[ 0 ].get( "mac" )
+
+ ipSrc = senders[ 0 ].get( "ip" )
+ ipDst = recipients[ 0 ].get( "ip" )
+
+ # Adding point intent
+ intentId = main.CLIs[ onosNode ].addPointIntent(
+ ingressDevice=ingressDevice,
+ egressDevice=egressDevice,
+ portIngress=portIngress,
+ portEgress=portEgress,
+ ethType=ethType,
+ ethDst=dstMac,
+ bandwidth=bandwidth,
+ lambdaAlloc=lambdaAlloc,
+ ipProto=ipProto,
+ ipSrc=ipSrc,
+ ipDst=ipDst,
+ tcpSrc=tcpSrc,
+ tcpDst=tcpDst )
+
+ # Check intents state
+ if utilities.retry( f=checkIntentState, retValue=main.FALSE, args=( main, [ intentId ] ), sleep=main.checkIntentSleep ):
+ return intentId
+ else:
+ main.log.error( "Point Intent did not install correctly" )
+ return main.FALSE
+
+def pointIntentTcp( main,
+ name,
+ host1,
+ host2,
+ onosNode=0,
+ deviceId1="",
+ deviceId2="",
+ port1="",
+ port2="",
+ ethType="",
+ mac1="",
+ mac2="",
+ bandwidth="",
+ lambdaAlloc=False,
+ ipProto="",
+ ip1="",
+ ip2="",
+ tcp1="",
+ tcp2="",
+ sw1="",
+ sw2="",
+ expectedLink=0 ):
+
+ """
+ Description:
+ Verify add-point-intent only for TCP
+ Steps:
+ - Get device ids | ports
+ - Add point intents
+ - Check intents
+ - Verify flows
+ - Ping hosts
+ - Reroute
+ - Link down
+ - Verify flows
+ - Check topology
+ - Ping hosts
+ - Link up
+ - Verify flows
+ - Check topology
+ - Ping hosts
+ - Remove intents
+ Required:
+ name - Type of point intent to add eg. IPV4 | VLAN | Dualstack
+ host1 - Name of first host
+ host2 - Name of second host
+ Optional:
+ onosNode - ONOS node to install the intents in main.CLIs[ ]
+ 0 by default so that it will always use the first
+ ONOS node
+ deviceId1 - ONOS device id of the first switch, the same as the
+ location of the first host eg. of:0000000000000001/1,
+ located at device 1 port 1
+ deviceId2 - ONOS device id of the second switch
+ port1 - The port number where the first host is attached
+ port2 - The port number where the second host is attached
+ ethType - Ethernet type eg. IPV4, IPV6
+ mac1 - Mac address of first host
+ mac2 - Mac address of the second host
+ bandwidth - Bandwidth capacity
+ lambdaAlloc - Allocate lambda, defaults to False
+ ipProto - IP protocol
+ ip1 - IP address of first host
+ ip2 - IP address of second host
+ tcp1 - TCP port of first host
+ tcp2 - TCP port of second host
+ sw1 - First switch to bring down & up for rerouting purpose
+ sw2 - Second switch to bring down & up for rerouting purpose
+ expectedLink - Expected link when the switches are down, it should
+ be two links lower than the links before the two
+ switches are down
+ """
+
+ assert main, "There is no main variable"
+ assert name, "variable name is empty"
+ assert host1 and host2, "You must specify hosts"
+
+ global itemName
+ itemName = name
+ host1 = host1
+ host2 = host2
+ hostNames = [ host1, host2 ]
+ intentsId = []
+
+ iperfResult = main.TRUE
+ intentResult = main.TRUE
+ removeIntentResult = main.TRUE
+ flowResult = main.TRUE
+ topoResult = main.TRUE
+ linkDownResult = main.TRUE
+ linkUpResult = main.TRUE
+ onosNode = int( onosNode )
+
+ # Adding bidirectional point intents
+ main.log.info( itemName + ": Adding point intents" )
+ intent1 = main.CLIs[ onosNode ].addPointIntent( ingressDevice=deviceId1,
+ egressDevice=deviceId2,
+ portIngress=port1,
+ portEgress=port2,
+ ethType=ethType,
+ ethSrc=mac1,
+ ethDst=mac2,
+ bandwidth=bandwidth,
+ lambdaAlloc=lambdaAlloc,
+ ipProto=ipProto,
+ ipSrc=ip1,
+ ipDst=ip2,
+ tcpSrc=tcp1,
+ tcpDst="" )
+
+ intent2 = main.CLIs[ onosNode ].addPointIntent( ingressDevice=deviceId2,
+ egressDevice=deviceId1,
+ portIngress=port2,
+ portEgress=port1,
+ ethType=ethType,
+ ethSrc=mac2,
+ ethDst=mac1,
+ bandwidth=bandwidth,
+ lambdaAlloc=lambdaAlloc,
+ ipProto=ipProto,
+ ipSrc=ip2,
+ ipDst=ip1,
+ tcpSrc=tcp2,
+ tcpDst="" )
+
+ intent3 = main.CLIs[ onosNode ].addPointIntent( ingressDevice=deviceId1,
+ egressDevice=deviceId2,
+ portIngress=port1,
+ portEgress=port2,
+ ethType=ethType,
+ ethSrc=mac1,
+ ethDst=mac2,
+ bandwidth=bandwidth,
+ lambdaAlloc=lambdaAlloc,
+ ipProto=ipProto,
+ ipSrc=ip1,
+ ipDst=ip2,
+ tcpSrc="",
+ tcpDst=tcp2 )
+
+ intent4 = main.CLIs[ onosNode ].addPointIntent( ingressDevice=deviceId2,
+ egressDevice=deviceId1,
+ portIngress=port2,
+ portEgress=port1,
+ ethType=ethType,
+ ethSrc=mac2,
+ ethDst=mac1,
+ bandwidth=bandwidth,
+ lambdaAlloc=lambdaAlloc,
+ ipProto=ipProto,
+ ipSrc=ip2,
+ ipDst=ip1,
+ tcpSrc="",
+ tcpDst=tcp1 )
+ intentsId.append( intent1 )
+ intentsId.append( intent2 )
+ intentsId.append( intent3 )
+ intentsId.append( intent4 )
+
+ # Check intents state
+ time.sleep( main.checkIntentSleep )
+ intentResult = checkIntentState( main, intentsId )
+ # Check flows count in each node
+ checkFlowsCount( main )
+
+ # Check intents state again if first check fails...
+ if not intentResult:
+ intentResult = checkIntentState( main, intentsId )
+
+ # Check flows count in each node
+ checkFlowsCount( main )
+
+ # Verify flows
+ checkFlowsState( main )
+
+ # Run iperf to both host
+ iperfTemp = main.Mininet1.iperftcp( host1,host2,10 )
+ iperfResult = iperfResult and iperfTemp
+ if iperfTemp:
+ main.assertReturnString += 'Initial Iperf Passed\n'
+ else:
+ main.assertReturnString += 'Initial Iperf Failed\n'
+
+ # Test rerouting if these variables exist
+ if sw1 and sw2 and expectedLink:
+ # link down
+ linkDownResult = link( main, sw1, sw2, "down" )
+
+ if linkDownResult:
+ main.assertReturnString += 'Link Down Passed\n'
+ else:
+ main.assertReturnString += 'Link Down Failed\n'
+
+ # Check flows count in each node
+ checkFlowsCount( main )
+ # Verify flows
+ checkFlowsState( main )
+
+ # Check OnosTopology
+ topoResult = checkTopology( main, expectedLink )
+ if topoResult:
+ main.assertReturnString += 'Link Down Topology State Passed\n'
+ else:
+ main.assertReturnString += 'Link Down Topology State Failed\n'
+
+ # Run iperf to both host
+ iperfTemp = main.Mininet1.iperftcp( host1,host2,10 )
+ iperfResult = iperfResult and iperfTemp
+ if iperfTemp:
+ main.assertReturnString += 'Link Down Iperf Passed\n'
+ else:
+ main.assertReturnString += 'Link Down Iperf Failed\n'
+
+ # Check intent state
+ intentTemp = checkIntentState( main, intentsId )
+ intentResult = intentResult and intentTemp
+ if intentTemp:
+ main.assertReturnString += 'Link Down Intent State Passed\n'
+ else:
+ main.assertReturnString += 'Link Down Intent State Failed\n'
+
+ # Checks ONOS state in link down
+ if linkDownResult and topoResult and iperfResult and intentResult:
+ main.log.info( itemName + ": Successfully brought link down" )
+ else:
+ main.log.error( itemName + ": Failed to bring link down" )
+
+ # link up
+ linkUpResult = link( main, sw1, sw2, "up" )
+ if linkUpTemp:
+ main.assertReturnString += 'Link Up Passed\n'
+ else:
+ main.assertReturnString += 'Link Up Failed\n'
+
+ time.sleep( main.rerouteSleep )
+
+ # Check flows count in each node
+ checkFlowsCount( main )
+ # Verify flows
+ checkFlowsState( main )
+
+ # Check OnosTopology
+ topoResult = checkTopology( main, main.numLinks )
+
+ if topoResult:
+ main.assertReturnString += 'Link Up Topology State Passed\n'
+ else:
+ main.assertReturnString += 'Link Up Topology State Failed\n'
+
+ # Run iperf to both host
+ iperfTemp = main.Mininet1.iperftcp( host1,host2,10 )
+ iperfResult = iperfResult and iperfTemp
+ if iperfTemp:
+ main.assertReturnString += 'Link Up Iperf Passed\n'
+ else:
+ main.assertReturnString += 'Link Up Iperf Failed\n'
+
+ # Check intent state
+ intentTemp = checkIntentState( main, intentsId )
+ intentResult = intentResult and intentTemp
+ if intentTemp:
+ main.assertReturnString += 'Link Down Intent State Passed\n'
+ else:
+ main.assertReturnString += 'Link Down Intent State Failed\n'
+
+ # Checks ONOS state in link up
+ if linkUpResult and topoResult and iperfResult and intentResult:
+ main.log.info( itemName + ": Successfully brought link back up" )
+ else:
+ main.log.error( itemName + ": Failed to bring link back up" )
+
+ # Remove all intents
+ removeIntentResult = removeAllIntents( main, intentsId )
+ if removeIntentResult:
+ main.assertReturnString += 'Remove Intents Passed'
+ else:
+ main.assertReturnString += 'Remove Intents Failed'
+
+ stepResult = iperfResult and linkDownResult and linkUpResult \
+ and intentResult and removeIntentResult
+
+ return stepResult
+
+def installSingleToMultiIntent( main,
+ name,
+ senders,
+ recipients,
+ onosNode=0,
+ ethType="",
+ bandwidth="",
+ lambdaAlloc=False,
+ ipProto="",
+ ipAddresses="",
+ tcp="",
+ sw1="",
+ sw2=""):
+ """
+ Installs a Single to Multi Point Intent
+
+ Description:
+ Install a single to multi point intent using
+ add-single-to-multi-intent
+
+ Steps:
+ - Fetch host data if not given
+ - Add single to multi intent
+ - Ingress device is the first sender host
+ - Egress devices are the recipient devices
+ - Ports if defined in senders or recipients
+ - MAC address ethSrc loaded from Ingress device
+ - Check intent state with retry
+ Required:
+ name - Type of point intent to add eg. IPV4 | VLAN | Dualstack
+ senders - List of host dictionaries i.e.
+ { "name":"h8", "device":"of:0000000000000005/8","mac":"00:00:00:00:00:08" }
+ recipients - List of host dictionaries i.e.
+ { "name":"h16", "device":"of:0000000000000006/8", "mac":"00:00:00:00:00:10" }
+ Optional:
+ onosNode - ONOS node to install the intents in main.CLIs[ ]
+ 0 by default so that it will always use the first
+ ONOS node
+ ethType - Ethernet type eg. IPV4, IPV6
+ bandwidth - Bandwidth capacity
+ lambdaAlloc - Allocate lambda, defaults to False
+ ipProto - IP protocol
+ tcp - TCP ports in the same order as the hosts in hostNames
+ sw1 - First switch to bring down & up for rerouting purpose
+ sw2 - Second switch to bring down & up for rerouting purpose
+ expectedLink - Expected link when the switches are down, it should
+ be two links lower than the links before the two
+ switches are down
+ """
+
+ assert main, "There is no main variable"
+ assert senders, "You must specify a sender"
+ assert recipients, "You must specify a recipient"
+ # Assert devices or main.hostsData, "You must specify devices"
+
+ global itemName # The name of this run. Used for logs.
+ itemName = name
+ onosNode = int( onosNode )
+
+ main.log.info( itemName + ": Adding single point to multi point intents" )
+
+ for sender in senders:
+ if not sender.get( "device" ):
+ main.log.warn( "Device not given for sender {0}. Loading from main.hostData".format( sender.get( "name" ) ) )
+ sender[ "device" ] = main.hostsData.get( sender.get( "name" ) ).get( "location" )
+
+ for recipient in recipients:
+ if not recipient.get( "device" ):
+ main.log.warn( "Device not given for recipient {0}. Loading from main.hostData".format( recipient.get( "name" ) ) )
+ recipient[ "device" ] = main.hostsData.get( recipient.get( "name" ) ).get( "location" )
+
+
+ ingressDevice = senders[ 0 ].get( "device" )
+ egressDeviceList = [ x.get( "device" ) for x in recipients if x.get( "device" ) ]
+
+ portIngress = senders[ 0 ].get( "port", "" )
+ portEgressList = [ x.get( "port" ) for x in recipients if x.get( "port" ) ]
+ if not portEgressList:
+ portEgressList = None
+
+ srcMac = senders[ 0 ].get( "mac" )
+
+ # Adding point intent
+ intentId = main.CLIs[ onosNode ].addSinglepointToMultipointIntent(
+ ingressDevice=ingressDevice,
+ egressDeviceList=egressDeviceList,
+ portIngress=portIngress,
+ portEgressList=portEgressList,
+ ethType=ethType,
+ ethSrc=srcMac,
+ bandwidth=bandwidth,
+ lambdaAlloc=lambdaAlloc,
+ ipProto=ipProto,
+ ipSrc="",
+ ipDst="",
+ tcpSrc="",
+ tcpDst="" )
+
+ # Check intents state
+ if utilities.retry( f=checkIntentState, retValue=main.FALSE, args=( main, [ intentId ] ), sleep=main.checkIntentSleep ):
+ return intentId
+ else:
+ main.log.error( "Single to Multi Intent did not install correctly" )
+ return main.FALSE
+
+def installMultiToSingleIntent( main,
+ name,
+ senders,
+ recipients,
+ onosNode=0,
+ ethType="",
+ bandwidth="",
+ lambdaAlloc=False,
+ ipProto="",
+ ipAddresses="",
+ tcp="",
+ sw1="",
+ sw2=""):
+ """
+ Installs a Multi to Single Point Intent
+
+ Description:
+ Install a multi to single point intent using
+ add-multi-to-single-intent
+
+ Steps:
+ - Fetch host data if not given
+ - Add multi to single intent
+ - Ingress devices are the senders devices
+ - Egress device is the first recipient host
+ - Ports if defined in senders or recipients
+ - MAC address ethSrc loaded from Ingress device
+ - Check intent state with retry
+ Required:
+ name - Type of point intent to add eg. IPV4 | VLAN | Dualstack
+ senders - List of host dictionaries i.e.
+ [ { "name":"h8", "device":"of:0000000000000005/8","mac":"00:00:00:00:00:08" } ]
+ recipients - List of host dictionaries i.e.
+ [ { "name":"h16", "device":"of:0000000000000006/8", "mac":"00:00:00:00:00:10" } ]
+ Optional:
+ onosNode - ONOS node to install the intents in main.CLIs[ ]
+ 0 by default so that it will always use the first
+ ONOS node
+ ethType - Ethernet type eg. IPV4, IPV6
+ bandwidth - Bandwidth capacity
+ lambdaAlloc - Allocate lambda, defaults to False
+ ipProto - IP protocol
+ tcp - TCP ports in the same order as the hosts in hostNames
+ sw1 - First switch to bring down & up for rerouting purpose
+ sw2 - Second switch to bring down & up for rerouting purpose
+ expectedLink - Expected link when the switches are down, it should
+ be two links lower than the links before the two
+ switches are down
+ """
+
+ assert main, "There is no main variable"
+ assert senders, "You must specify a sender"
+ assert recipients, "You must specify a recipient"
+ # Assert devices or main.hostsData, "You must specify devices"
+
+ global itemName # The name of this run. Used for logs.
+ itemName = name
+ onosNode = int( onosNode )
+
+ main.log.info( itemName + ": Adding mutli to single point intents" )
+
+ for sender in senders:
+ if not sender.get( "device" ):
+ main.log.warn( "Device not given for sender {0}. Loading from main.hostData".format( sender.get( "name" ) ) )
+ sender[ "device" ] = main.hostsData.get( sender.get( "name" ) ).get( "location" )
+
+ for recipient in recipients:
+ if not recipient.get( "device" ):
+ main.log.warn( "Device not given for recipient {0}. Loading from main.hostData".format( recipient.get( "name" ) ) )
+ recipient[ "device" ] = main.hostsData.get( recipient.get( "name" ) ).get( "location" )
+
+
+ ingressDeviceList = [ x.get( "device" ) for x in senders if x.get( "device" ) ]
+ egressDevice = recipients[ 0 ].get( "device" )
+
+ portIngressList = [ x.get( "port" ) for x in senders if x.get( "port" ) ]
+ portEgress = recipients[ 0 ].get( "port", "" )
+ if not portIngressList:
+ portIngressList = None
+
+ dstMac = recipients[ 0 ].get( "mac" )
+
+ # Adding point intent
+ intentId = main.CLIs[ onosNode ].addMultipointToSinglepointIntent(
+ ingressDeviceList=ingressDeviceList,
+ egressDevice=egressDevice,
+ portIngressList=portIngressList,
+ portEgress=portEgress,
+ ethType=ethType,
+ ethDst=dstMac,
+ bandwidth=bandwidth,
+ lambdaAlloc=lambdaAlloc,
+ ipProto=ipProto,
+ ipSrc="",
+ ipDst="",
+ tcpSrc="",
+ tcpDst="" )
+
+ # Check intents state
+ if utilities.retry( f=checkIntentState, retValue=main.FALSE, args=( main, [ intentId ] ), sleep=main.checkIntentSleep ):
+ return intentId
+ else:
+ main.log.error( "Multi to Single Intent did not install correctly" )
+ return main.FALSE
+
+def testPointIntent( main,
+ name,
+ intentId,
+ senders,
+ recipients,
+ badSenders={},
+ badRecipients={},
+ onosNode=0,
+ ethType="",
+ bandwidth="",
+ lambdaAlloc=False,
+ ipProto="",
+ ipAddresses="",
+ tcp="",
+ sw1="s5",
+ sw2="s2",
+ expectedLink=0):
+ """
+ Test a Point Intent
+
+ Description:
+ Test a point intent
+
+ Steps:
+ - Fetch host data if not given
+ - Check Intent State
+ - Check Flow State
+ - Check Connectivity
+ - Check Lack of Connectivity Between Hosts not in the Intent
+ - Reroute
+ - Take Expected Link Down
+ - Check Intent State
+ - Check Flow State
+ - Check Topology
+ - Check Connectivity
+ - Bring Expected Link Up
+ - Check Intent State
+ - Check Flow State
+ - Check Topology
+ - Check Connectivity
+ - Remove Topology
+
+ Required:
+ name - Type of point intent to add eg. IPV4 | VLAN | Dualstack
+
+ senders - List of host dictionaries i.e.
+ { "name":"h8", "device":"of:0000000000000005/8","mac":"00:00:00:00:00:08" }
+ recipients - List of host dictionaries i.e.
+ { "name":"h16", "device":"of:0000000000000006/8", "mac":"00:00:00:00:00:10" }
+ Optional:
+ onosNode - ONOS node to install the intents in main.CLIs[ ]
+ 0 by default so that it will always use the first
+ ONOS node
+ ethType - Ethernet type eg. IPV4, IPV6
+ bandwidth - Bandwidth capacity
+ lambdaAlloc - Allocate lambda, defaults to False
+ ipProto - IP protocol
+ tcp - TCP ports in the same order as the hosts in hostNames
+ sw1 - First switch to bring down & up for rerouting purpose
+ sw2 - Second switch to bring down & up for rerouting purpose
+ expectedLink - Expected link when the switches are down, it should
+ be two links lower than the links before the two
+ switches are down
+
+ """
+
+ # Parameter Validity Check
+ assert main, "There is no main variable"
+ assert senders, "You must specify a sender"
+ assert recipients, "You must specify a recipient"
+
+ global itemName
+ itemName = name
+ tempHostsData = {}
+ onosNode = int( onosNode )
+
+ main.log.info( itemName + ": Testing Point Intent" )
+
+ # Names for scapy
+ senderNames = [ x.get( "name" ) for x in senders ]
+ recipientNames = [ x.get( "name" ) for x in recipients ]
+ badSenderNames = [ x.get( "name" ) for x in badSenders ]
+ badRecipientNames = [ x.get( "name" ) for x in badRecipients ]
+
+ for sender in senders:
+ if not sender.get( "device" ):
+ main.log.warn( "Device not given for sender {0}. Loading from main.hostData".format( sender.get( "name" ) ) )
+ sender[ "device" ] = main.hostsData.get( sender.get( "name" ) ).get( "location" )
+
+ for recipient in recipients:
+ if not recipient.get( "device" ):
+ main.log.warn( "Device not given for recipient {0}. Loading from main.hostData".format( recipient.get( "name" ) ) )
+ recipient[ "device" ] = main.hostsData.get( recipient.get( "name" ) ).get( "location" )
+
+ testResult = main.TRUE
+ main.log.info( itemName + ": Adding single point to multi point intents" )
+
+ # Check intent state
+ if utilities.retry( f=checkIntentState, retValue=main.FALSE, args=( main, [ intentId ] ), sleep=main.checkIntentSleep ):
+ main.assertReturnString += 'Initial Intent State Passed\n'
+ else:
+ main.assertReturnString += 'Initial Intent State Failed\n'
+ testResult = main.FALSE
+
+ # Check flows count in each node
+ if utilities.retry( f=checkFlowsCount, retValue=main.FALSE, args=[ main ], sleep=20, attempts=3 ) and utilities.retry( f=checkFlowsState, retValue=main.FALSE, args=[ main ], sleep=20, attempts=3 ):
+ main.assertReturnString += 'Initial Flow State Passed\n'
+ else:
+ main.assertReturnString += 'Intial Flow State Failed\n'
+ testResult = main.FALSE
+
+ # Check Connectivity
+ if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, recipientNames ) ):
+ main.assertReturnString += 'Initial Ping Passed\n'
+ else:
+ main.assertReturnString += 'Initial Ping Failed\n'
+ testResult = main.FALSE
+
+ # Check connections that shouldn't work
+ if badSenderNames:
+ main.log.info( "Checking that packets from incorrect sender do not go through" )
+ if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, badSenderNames, recipientNames ), kwargs={ "expectFailure":True } ):
+ main.assertReturnString += 'Bad Sender Ping Passed\n'
+ else:
+ main.assertReturnString += 'Bad Sender Ping Failed\n'
+ testResult = main.FALSE
+
+ if badRecipientNames:
+ main.log.info( "Checking that packets to incorrect recipients do not go through" )
+ if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, badRecipientNames ), kwargs={ "expectFailure":True } ):
+ main.assertReturnString += 'Bad Recipient Ping Passed\n'
+ else:
+ main.assertReturnString += 'Bad Recipient Ping Failed\n'
+ testResult = main.FALSE
+
+ # Test rerouting if these variables exist
+ if sw1 and sw2 and expectedLink:
+ # Take link down
+ if utilities.retry( f=link, retValue=main.FALSE, args=( main, sw1, sw2, "down" ) ):
+ main.assertReturnString += 'Link Down Passed\n'
+ else:
+ main.assertReturnString += 'Link Down Failed\n'
+ testResult = main.FALSE
+
+ # Check intent state
+ if utilities.retry( f=checkIntentState, retValue=main.FALSE, args=( main, [ intentId ] ), sleep=main.checkIntentSleep ):
+ main.assertReturnString += 'Link Down Intent State Passed\n'
+ else:
+ main.assertReturnString += 'Link Down Intent State Failed\n'
+ testResult = main.FALSE
+
+ # Check flows count in each node
+ if utilities.retry( f=checkFlowsCount, retValue=main.FALSE, args=[ main ], sleep=20, attempts=3 ) and utilities.retry( f=checkFlowsState, retValue=main.FALSE, args=[ main ], sleep=20, attempts=3 ):
+ main.assertReturnString += 'Link Down Flow State Passed\n'
+ else:
+ main.assertReturnString += 'Link Down Flow State Failed\n'
+ testResult = main.FALSE
+
+ # Check OnosTopology
+ if utilities.retry( f=checkTopology, retValue=main.FALSE, args=( main, expectedLink ) ):
+ main.assertReturnString += 'Link Down Topology State Passed\n'
+ else:
+ main.assertReturnString += 'Link Down Topology State Failed\n'
+ testResult = main.FALSE
+
+ # Check Connection
+ if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, recipientNames ) ):
+ main.assertReturnString += 'Link Down Pingall Passed\n'
+ else:
+ main.assertReturnString += 'Link Down Pingall Failed\n'
+ testResult = main.FALSE
+
+ # Bring link up
+ if utilities.retry( f=link, retValue=main.FALSE, args=( main, sw1, sw2, "up" ) ):
+ main.assertReturnString += 'Link Up Passed\n'
+ else:
+ main.assertReturnString += 'Link Up Failed\n'
+ testResult = main.FALSE
+
+ # Wait for reroute
+ time.sleep( main.rerouteSleep )
+
+ # Check Intents
+ if utilities.retry( f=checkIntentState, retValue=main.FALSE, args=( main, [ intentId ] ), sleep=main.checkIntentSleep ):
+ main.assertReturnString += 'Link Up Intent State Passed\n'
+ else:
+ main.assertReturnString += 'Link Up Intent State Failed\n'
+ testResult = main.FALSE
+
+ # Check flows count in each node
+ if utilities.retry( f=checkFlowsCount, retValue=main.FALSE, args=[ main ], sleep=20, attempts=3 ) and utilities.retry( f=checkFlowsState, retValue=main.FALSE, args=[ main ], sleep=20, attempts=3 ):
+ main.assertReturnString += 'Link Up Flow State Passed\n'
+ else:
+ main.assertReturnString += 'Link Up Flow State Failed\n'
+ testResult = main.FALSE
+
+ # Check OnosTopology
+ if utilities.retry( f=checkTopology, retValue=main.FALSE, args=( main, main.numLinks ) ):
+ main.assertReturnString += 'Link Up Topology State Passed\n'
+ else:
+ main.assertReturnString += 'Link Up Topology State Failed\n'
+ testResult = main.FALSE
+
+ # Check Connection
+ if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, recipientNames ) ):
+ main.assertReturnString += 'Link Up Scapy Packet Received Passed\n'
+ else:
+ main.assertReturnString += 'Link Up Scapy Packet Recieved Failed\n'
+ testResult = main.FALSE
+
+ # Remove all intents
+ if utilities.retry( f=removeAllIntents, retValue=main.FALSE, args=( main, [ intentId ] ) ):
+ main.assertReturnString += 'Remove Intents Passed'
+ else:
+ main.assertReturnString += 'Remove Intents Failed'
+ testResult = main.FALSE
+
+ return testResult
+
+def testEndPointFail( main,
+ name,
+ intentId,
+ senders,
+ recipients,
+ isolatedSenders,
+ isolatedRecipients,
+ onosNode=0,
+ ethType="",
+ bandwidth="",
+ lambdaAlloc=False,
+ ipProto="",
+ ipAddresses="",
+ tcp="",
+ sw1="",
+ sw2="",
+ sw3="",
+ sw4="",
+ sw5="",
+ expectedLink1=0,
+ expectedLink2=0 ):
+ """
+ Test Single to Multipoint Topology for Endpoint failures
+ """
+
+ # Parameter Validity Check
+ assert main, "There is no main variable"
+ assert senders, "You must specify a sender"
+ assert recipients, "You must specify a recipient"
+
+ global itemName
+ itemName = name
+ tempHostsData = {}
+ onosNode = int( onosNode )
+
+ main.log.info( itemName + ": Testing Point Intent" )
+
+ # Names for scapy
+ senderNames = [ x.get( "name" ) for x in senders ]
+ recipientNames = [ x.get( "name" ) for x in recipients ]
+ isolatedSenderNames = [ x.get( "name" ) for x in isolatedSenders ]
+ isolatedRecipientNames = [ x.get( "name" ) for x in isolatedRecipients ]
+ connectedSenderNames = [x.get("name") for x in senders if x.get("name") not in isolatedSenderNames]
+ connectedRecipientNames = [x.get("name") for x in recipients if x.get("name") not in isolatedRecipientNames]
+
+ for sender in senders:
+ if not sender.get( "device" ):
+ main.log.warn( "Device not given for sender {0}. Loading from main.hostData".format( sender.get( "name" ) ) )
+ sender[ "device" ] = main.hostsData.get( sender.get( "name" ) ).get( "location" )
+
+ for recipient in recipients:
+ if not recipient.get( "device" ):
+ main.log.warn( "Device not given for recipient {0}. Loading from\
+ main.hostData".format( recipient.get( "name" ) ) )
+ recipient[ "device" ] = main.hostsData.get( recipient.get( "name" ) ).get( "location" )
+
+ testResult = main.TRUE
+ main.log.info( itemName + ": Adding multi point to single point intents" )
+
+ # Check intent state
+ if utilities.retry( f=checkIntentState, retValue=main.FALSE,
+ args=( main, [ intentId ] ), sleep=main.checkIntentSleep ):
+ main.assertReturnString += 'Initial Intent State Passed\n'
+ else:
+ main.assertReturnString += 'Initial Intent State Failed\n'
+ testResult = main.FALSE
+
+ # Check flows count in each node
+ if utilities.retry( f=checkFlowsCount, retValue=main.FALSE,
+ args=[ main ] ) and utilities.retry( f=checkFlowsState,
+ retValue=main.FALSE,
+ args=[ main ] ):
+ main.assertReturnString += 'Initial Flow State Passed\n'
+ else:
+ main.assertReturnString += 'Intial Flow State Failed\n'
+ testResult = main.FALSE
+
+ # Check Connectivity
+ if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE,
+ args=( main, senderNames, recipientNames ) ):
+ main.assertReturnString += 'Initial Connectivity Check Passed\n'
+ else:
+ main.assertReturnString += 'Initial Connectivity Check Failed\n'
+ testResult = main.FALSE
+
+ # Take two links down
+ # Take first link down
+ if utilities.retry( f=link, retValue=main.FALSE, args=( main, sw1, sw2, "down" ) ):
+ main.assertReturnString += 'Link Down Passed\n'
+ else:
+ main.assertReturnString += 'Link Down Failed\n'
+ testResult = main.FALSE
+
+ # Take second link down
+ if utilities.retry( f=link, retValue=main.FALSE, args=( main, sw3, sw4, "down" ) ):
+ main.assertReturnString += 'Link Down Passed\n'
+ else:
+ main.assertReturnString += 'Link Down Failed\n'
+ testResult = main.FALSE
+
+ # Check intent state
+ if utilities.retry( f=checkIntentState, retValue=main.FALSE,
+ args=( main, [ intentId ] ), sleep=main.checkIntentSleep ):
+ main.assertReturnString += 'Link Down Intent State Passed\n'
+ else:
+ main.assertReturnString += 'Link Down Intent State Failed\n'
+ testResult = main.FALSE
+
+ # Check flows count in each node
+ if utilities.retry( f=checkFlowsCount, retValue=main.FALSE,
+ args=[ main ] ) and utilities.retry( f=checkFlowsState,
+ retValue=main.FALSE, args=[ main ] ):
+ main.assertReturnString += 'Link Down Flow State Passed\n'
+ else:
+ main.assertReturnString += 'Link Down Flow State Failed\n'
+ testResult = main.FALSE
+
+ # Check OnosTopology
+ if utilities.retry( f=checkTopology, retValue=main.FALSE, args=( main, expectedLink1 ) ):
+ main.assertReturnString += 'Link Down Topology State Passed\n'
+ else:
+ main.assertReturnString += 'Link Down Topology State Failed\n'
+ testResult = main.FALSE
+
+ # Check Connection
+ if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE,
+ args=( main, senderNames, recipientNames ) ):
+ main.assertReturnString += 'Link Down Connectivity Check Passed\n'
+ else:
+ main.assertReturnString += 'Link Down Connectivity Check Failed\n'
+ testResult = main.FALSE
+
+ # Take a third link down to isolate one node
+ if utilities.retry( f=link, retValue=main.FALSE, args=( main, sw3, sw5, "down" ) ):
+ main.assertReturnString += 'Isolation link Down Passed\n'
+ else:
+ main.assertReturnString += 'Isolation link Down Failed\n'
+ testResult = main.FALSE
+
+ # Check intent state
+ if utilities.retry( f=checkIntentState, retValue=main.FALSE,
+ args=( main, [ intentId ] ), sleep=main.checkIntentSleep ):
+ main.assertReturnString += 'Isolation link Down Intent State Passed\n'
+ else:
+ main.assertReturnString += 'Isolation link Down Intent State Failed\n'
+ testResult = main.FALSE
+
+ # Check flows count in each node
+ if utilities.retry( f=checkFlowsCount, retValue=main.FALSE,
+ args=[ main ] ) and utilities.retry( f=checkFlowsState,
+ retValue=main.FALSE, args=[ main ] ):
+ main.assertReturnString += 'Isolation link Down Flow State Passed\n'
+ else:
+ main.assertReturnString += 'Isolation link Down Flow State Failed\n'
+ testResult = main.FALSE
+
+ # Check OnosTopology
+ if utilities.retry( f=checkTopology, retValue=main.FALSE, args=( main, expectedLink2 ) ):
+ main.assertReturnString += 'Isolation link Down Topology State Passed\n'
+ else:
+ main.assertReturnString += 'Isolation link Down Topology State Failed\n'
+ testResult = main.FALSE
+
+ # Check Connectivity
+ # First check connectivity of any isolated senders to recipients
+ if isolatedSenderNames:
+ if scapyCheckConnection( main, isolatedSenderNames, recipientNames, None, None, main.TRUE ):
+ main.assertReturnString += 'Isolation link Down Connectivity Check Passed\n'
+ else:
+ main.assertReturnString += 'Isolation link Down Connectivity Check Failed\n'
+ testResult = main.FALSE
+
+ # Next check connectivity of senders to any isolated recipients
+ if isolatedRecipientNames:
+ if scapyCheckConnection( main, senderNames, isolatedRecipientNames, None, None, main.TRUE ):
+ main.assertReturnString += 'Isolation link Down Connectivity Check Passed\n'
+ else:
+ main.assertReturnString += 'Isolation link Down Connectivity Check Failed\n'
+ testResult = main.FALSE
+
+ # Next check connectivity of connected senders and recipients
+ if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE,
+ args=( main, connectedSenderNames , connectedRecipientNames ) ):
+ main.assertReturnString += 'Isolation link Down Connectivity Check Passed\n'
+ else:
+ main.assertReturnString += 'Isolation link Down Connectivity Check Failed\n'
+ testResult = main.FALSE
+
+ # Bring the links back up
+ # Bring first link up
+ if utilities.retry( f=link, retValue=main.FALSE, args=( main, sw1, sw2, "up" ) ):
+ main.assertReturnString += 'Link Up Passed\n'
+ else:
+ main.assertReturnString += 'Link Up Failed\n'
+ testResult = main.FALSE
+
+ # Bring second link up
+ if utilities.retry( f=link, retValue=main.FALSE, args=( main, sw3, sw5, "up" ) ):
+ main.assertReturnString += 'Link Up Passed\n'
+ else:
+ main.assertReturnString += 'Link Up Failed\n'
+ testResult = main.FALSE
+
+ # Bring third link up
+ if utilities.retry( f=link, retValue=main.FALSE, args=( main, sw3, sw4, "up" ) ):
+ main.assertReturnString += 'Link Up Passed\n'
+ else:
+ main.assertReturnString += 'Link Up Failed\n'
+ testResult = main.FALSE
+
+ # Wait for reroute
+ time.sleep( main.rerouteSleep )
+
+ # Check Intents
+ if utilities.retry( f=checkIntentState, retValue=main.FALSE,
+ args=( main, [ intentId ] ), sleep=main.checkIntentSleep ):
+ main.assertReturnString += 'Link Up Intent State Passed\n'
+ else:
+ main.assertReturnString += 'Link Up Intent State Failed\n'
+ testResult = main.FALSE
+
+ # Check flows count in each node
+ if utilities.retry( f=checkFlowsCount, retValue=main.FALSE,
+ args=[ main ] ) and utilities.retry( f=checkFlowsState,
+ retValue=main.FALSE, args=[ main ] ):
+ main.assertReturnString += 'Link Up Flow State Passed\n'
+ else:
+ main.assertReturnString += 'Link Up Flow State Failed\n'
+ testResult = main.FALSE
+
+ # Check OnosTopology
+ if utilities.retry( f=checkTopology, retValue=main.FALSE, args=( main, main.numLinks ) ):
+ main.assertReturnString += 'Link Up Topology State Passed\n'
+ else:
+ main.assertReturnString += 'Link Up Topology State Failed\n'
+ testResult = main.FALSE
+
+ # Check Connection
+ if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE,
+ args=( main, senderNames, recipientNames ) ):
+ main.assertReturnString += 'Link Up Scapy Packet Received Passed\n'
+ else:
+ main.assertReturnString += 'Link Up Scapy Packet Recieved Failed\n'
+ testResult = main.FALSE
+
+ # Remove all intents
+ if utilities.retry( f=removeAllIntents, retValue=main.FALSE, args=( main, [ intentId ] ) ):
+ main.assertReturnString += 'Remove Intents Passed'
+ else:
+ main.assertReturnString += 'Remove Intents Failed'
+ testResult = main.FALSE
+
+ return testResult
+
+
+def pingallHosts( main, hostList ):
+ """
+ Ping all host in the hosts list variable
+ """
+ main.log.info( "Pinging: " + str( hostList ) )
+ return main.Mininet1.pingallHosts( hostList )
+
+def fwdPingall( main ):
+ """
+ Use fwd app and pingall to discover all the hosts
+ """
+ activateResult = main.TRUE
+ appCheck = main.TRUE
+ getDataResult = main.TRUE
+ main.log.info( "Activating reactive forwarding app " )
+ activateResult = main.CLIs[ 0 ].activateApp( "org.onosproject.fwd" )
+
+ # Wait for forward app activation to propagate
+ time.sleep( main.fwdSleep )
+
+ # Check that forwarding is enabled on all nodes
+ for i in range( main.numCtrls ):
+ appCheck = appCheck and main.CLIs[ i ].appToIDCheck()
+ if appCheck != main.TRUE:
+ main.log.warn( main.CLIs[ i ].apps() )
+ main.log.warn( main.CLIs[ i ].appIDs() )
+
+ # Send pingall in mininet
+ main.log.info( "Run Pingall" )
+ pingResult = main.Mininet1.pingall( timeout = 600 )
+
+ main.log.info( "Deactivating reactive forwarding app " )
+ deactivateResult = main.CLIs[ 0 ].deactivateApp( "org.onosproject.fwd" )
+ if activateResult and deactivateResult:
+ main.log.info( "Successfully used fwd app to discover hosts" )
+ getDataResult = main.TRUE
+ else:
+ main.log.info( "Failed to use fwd app to discover hosts" )
+ getDataResult = main.FALSE
+ return getDataResult
+
+def confirmHostDiscovery( main ):
+ """
+ Confirms that all ONOS nodes have discovered all scapy hosts
+ """
+ import collections
+ scapyHostCount = len( main.scapyHosts )
+ hosts = main.topo.getAllHosts( main ) # Get host data from each ONOS node
+ hostFails = [] # Reset for each failed attempt
+
+ # Check for matching hosts on each node
+ scapyHostIPs = [ x.hostIp for x in main.scapyHosts if x.hostIp != "0.0.0.0" ]
+ for controller in range( main.numCtrls ):
+ controllerStr = str( controller + 1 ) # ONOS node number
+ # Compare Hosts
+ # Load hosts data for controller node
+ if hosts[ controller ] and "Error" not in hosts[ controller ]:
+ try:
+ hostData = json.loads( hosts[ controller ] )
+ except ( TypeError, ValueError ):
+ main.log.error( "Could not load json:" + str( hosts[ controller ] ) )
+ hostFails.append( controllerStr )
+ else:
+ onosHostIPs = [ x.get( "ipAddresses" )[ 0 ]
+ for x in hostData
+ if len( x.get( "ipAddresses" ) ) > 0 ]
+ if not set( collections.Counter( scapyHostIPs ) ).issubset( set ( collections.Counter( onosHostIPs ) ) ):
+ main.log.warn( "Controller {0} only sees nodes with {1} IPs. It should see all of the following: {2}".format( controllerStr, onosHostIPs, scapyHostIPs ) )
+ hostFails.append( controllerStr )
+ else:
+ main.log.error( "Hosts returned nothing or an error." )
+ hostFails.append( controllerStr )
+
+ if hostFails:
+ main.log.error( "List of failed ONOS Nodes:" + ', '.join(map(str, hostFails )) )
+ return main.FALSE
+ else:
+ return main.TRUE
+
+def sendDiscoveryArp( main, hosts=None ):
+ """
+ Sends Discovery ARP packets from each host provided
+ Defaults to each host in main.scapyHosts
+ """
+ # Send an arp ping from each host
+ if not hosts:
+ hosts = main.scapyHosts
+ for host in hosts:
+ pkt = 'Ether( src="{0}")/ARP( psrc="{1}")'.format( host.hostMac ,host.hostIp )
+ # Send from the VLAN interface if there is one so ONOS discovers the VLAN correctly
+ iface = None
+ for interface in host.getIfList():
+ if '.' in interface:
+ main.log.debug( "Detected VLAN interface {0}. Sending ARP packet from {0}".format( interface ) )
+ iface = interface
+ break
+ host.sendPacket( packet=pkt, iface=iface )
+ main.log.info( "Sending ARP packet from {0}".format( host.name ) )
+
+def populateHostData( main ):
+ """
+ Populates hostsData
+ """
+ import json
+ try:
+ hostsJson = json.loads( main.CLIs[ 0 ].hosts() )
+ hosts = main.Mininet1.getHosts().keys()
+ # TODO: Make better use of new getHosts function
+ for host in hosts:
+ main.hostsData[ host ] = {}
+ main.hostsData[ host ][ 'mac' ] = \
+ main.Mininet1.getMacAddress( host ).upper()
+ for hostj in hostsJson:
+ if main.hostsData[ host ][ 'mac' ] == hostj[ 'mac' ]:
+ main.hostsData[ host ][ 'id' ] = hostj[ 'id' ]
+ main.hostsData[ host ][ 'vlan' ] = hostj[ 'vlan' ]
+ main.hostsData[ host ][ 'location' ] = \
+ hostj[ 'location' ][ 'elementId' ] + '/' + \
+ hostj[ 'location' ][ 'port' ]
+ main.hostsData[ host ][ 'ipAddresses' ] = hostj[ 'ipAddresses' ]
+ return main.TRUE
+ except KeyError:
+ main.log.error( "KeyError while populating hostsData")
+ return main.FALSE
+
+def checkTopology( main, expectedLink ):
+ statusResult = main.TRUE
+ # Check onos topology
+ main.log.info( itemName + ": Checking ONOS topology " )
+
+ for i in range( main.numCtrls ):
+ topologyResult = main.CLIs[ i ].topology()
+ statusResult = main.ONOSbench.checkStatus( topologyResult,
+ main.numSwitch,
+ expectedLink )\
+ and statusResult
+ if not statusResult:
+ main.log.error( itemName + ": Topology mismatch" )
+ else:
+ main.log.info( itemName + ": Topology match" )
+ return statusResult
+
+def checkIntentState( main, intentsId ):
+ """
+ This function will check intent state to make sure all the intents
+ are in INSTALLED state
+ """
+
+ intentResult = main.TRUE
+ results = []
+
+ main.log.info( itemName + ": Checking intents state" )
+ # First check of intents
+ for i in range( main.numCtrls ):
+ tempResult = main.CLIs[ i ].checkIntentState( intentsId=intentsId )
+ results.append( tempResult )
+
+ expectedState = [ 'INSTALLED', 'INSTALLING' ]
+
+ if all( result == main.TRUE for result in results ):
+ main.log.info( itemName + ": Intents are installed correctly" )
+ else:
+ # Wait for at least 5 second before checking the intents again
+ main.log.error( "Intents are not installed correctly. Waiting 5 sec" )
+ time.sleep( 5 )
+ results = []
+ # Second check of intents since some of the intents may be in
+ # INSTALLING state, they should be in INSTALLED at this time
+ for i in range( main.numCtrls ):
+ tempResult = main.CLIs[ i ].checkIntentState( intentsId=intentsId )
+ results.append( tempResult )
+ if all( result == main.TRUE for result in results ):
+ main.log.info( itemName + ": Intents are installed correctly" )
+ intentResult = main.TRUE
+ else:
+ main.log.error( itemName + ": Intents are NOT installed correctly" )
+ intentResult = main.FALSE
+
+ return intentResult
+
+def checkFlowsState( main ):
+
+ main.log.info( itemName + ": Check flows state" )
+ checkFlowsResult = main.CLIs[ 0 ].checkFlowsState()
+ return checkFlowsResult
+
+def link( main, sw1, sw2, option):
+
+ # link down
+ main.log.info( itemName + ": Bring link " + option + "between " +
+ sw1 + " and " + sw2 )
+ linkResult = main.Mininet1.link( end1=sw1, end2=sw2, option=option )
+ return linkResult
+
+def scapyCheckConnection( main, senders, recipients, packet=None, packetFilter=None, expectFailure=False ):
+ """
+ Checks the connectivity between all given sender hosts and all given recipient hosts
+ Packet may be specified. Defaults to Ether/IP packet
+ Packet Filter may be specified. Defaults to Ether/IP from current sender MAC
+ Todo: Optional packet and packet filter attributes for sender and recipients
+ Expect Failure when the sender and recipient are not supposed to have connectivity
+ Timeout of 1 second, returns main.TRUE if the filter is not triggered and kills the filter
+
+ """
+ connectionsFunctional = main.TRUE
+
+ if not packetFilter:
+ packetFilter = 'ether host {}'
+
+ if expectFailure:
+ timeout = 1
+ else:
+ timeout = 10
+
+ for sender in senders:
+ try:
+ senderComp = getattr( main, sender )
+ except AttributeError:
+ main.log.error( "main has no attribute {}".format( sender ) )
+ connectionsFunctional = main.FALSE
+ continue
+
+ for recipient in recipients:
+ # Do not send packets to self since recipient CLI will already be busy
+ if recipient == sender:
+ continue
+ try:
+ recipientComp = getattr( main, recipient )
+ except AttributeError:
+ main.log.error( "main has no attribute {}".format( recipient ) )
+ connectionsFunctional = main.FALSE
+ continue
+
+ recipientComp.startFilter( pktFilter = packetFilter.format( senderComp.hostMac ) )
+
+ if not packet:
+ pkt = 'Ether( src="{0}", dst="{2}" )/IP( src="{1}", dst="{3}" )'.format(
+ senderComp.hostMac,
+ senderComp.hostIp,
+ recipientComp.hostMac,
+ recipientComp.hostIp )
+ else:
+ pkt = packet
+ senderComp.sendPacket( packet = pkt )
+
+ if recipientComp.checkFilter( timeout ):
+ if expectFailure:
+ main.log.error( "Packet from {0} successfully received by {1} when it should not have been".format( sender , recipient ) )
+ connectionsFunctional = main.FALSE
+ else:
+ main.log.info( "Packet from {0} successfully received by {1}".format( sender , recipient ) )
+ else:
+ recipientComp.killFilter()
+ if expectFailure:
+ main.log.info( "As expected, packet from {0} was not received by {1}".format( sender , recipient ) )
+ else:
+ main.log.error( "Packet from {0} was not received by {1}".format( sender , recipient ) )
+ connectionsFunctional = main.FALSE
+
+ return connectionsFunctional
+
+def removeAllIntents( main, intentsId ):
+ """
+ Remove all intents in the intentsId
+ """
+
+ onosSummary = []
+ removeIntentResult = main.TRUE
+ # Remove intents
+ for intent in intentsId:
+ main.CLIs[ 0 ].removeIntent( intentId=intent, purge=True )
+
+ time.sleep( main.removeIntentSleep )
+
+ # If there is remianing intents then remove intents should fail
+ for i in range( main.numCtrls ):
+ onosSummary.append( json.loads( main.CLIs[ i ].summary() ) )
+
+ for summary in onosSummary:
+ if summary.get( 'intents' ) != 0:
+ main.log.warn( itemName + ": There are " +
+ str( summary.get( 'intents' ) ) +
+ " intents remaining in node " +
+ str( summary.get( 'node' ) ) +
+ ", failed to remove all the intents " )
+ removeIntentResult = main.FALSE
+
+ if removeIntentResult:
+ main.log.info( itemName + ": There are no more intents remaining, " +
+ "successfully removed all the intents." )
+
+ return removeIntentResult
+
+def checkFlowsCount( main ):
+ """
+ Check flows count in each node
+ """
+ flowsCount = []
+ main.log.info( itemName + ": Checking flows count in each ONOS node" )
+ for i in range( main.numCtrls ):
+ summaryResult = main.CLIs[ i ].summary()
+ if not summaryResult:
+ main.log.error( itemName + ": There is something wrong with " +
+ "summary command" )
+ return main.FALSE
+ else:
+ summaryJson = json.loads( summaryResult )
+ flowsCount.append( summaryJson.get( 'flows' ) )
+
+ if flowsCount:
+ if all( flows==flowsCount[ 0 ] for flows in flowsCount ):
+ main.log.info( itemName + ": There are " + str( flowsCount[ 0 ] ) +
+ " flows in all ONOS node" )
+ else:
+ for i in range( main.numCtrls ):
+ main.log.debug( itemName + ": ONOS node " + str( i ) + " has " +
+ str( flowsCount[ i ] ) + " flows" )
+ else:
+ main.log.error( "Checking flows count failed, check summary command" )
+ return main.FALSE
+
+ return main.TRUE
+
+def checkLeaderChange( leaders1, leaders2 ):
+ """
+ Checks for a change in intent partition leadership.
+
+ Takes the output of leaders -c in json string format before and after
+ a potential change as input
+
+ Returns main.TRUE if no mismatches are detected
+ Returns main.FALSE if there is a mismatch or on error loading the input
+ """
+ try:
+ leaders1 = json.loads( leaders1 )
+ leaders2 = json.loads( leaders2 )
+ except ( AttributeError, TypeError):
+ main.log.exception( self.name + ": Object not as expected" )
+ return main.FALSE
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
+ main.log.info( "Checking Intent Paritions for Change in Leadership" )
+ mismatch = False
+ for dict1 in leaders1:
+ if "intent" in dict1.get( "topic", [] ):
+ for dict2 in leaders2:
+ if dict1.get( "topic", 0 ) == dict2.get( "topic", 0 ) and \
+ dict1.get( "leader", 0 ) != dict2.get( "leader", 0 ):
+ mismatch = True
+ main.log.error( "{0} changed leader from {1} to {2}".\
+ format( dict1.get( "topic", "no-topic" ),\
+ dict1.get( "leader", "no-leader" ),\
+ dict2.get( "leader", "no-leader" ) ) )
+ if mismatch:
+ return main.FALSE
+ else:
+ return main.TRUE
+
+def report( main ):
+ """
+ Report errors/warnings/exceptions
+ """
+ main.ONOSbench.logReport( main.ONOSip[ 0 ],
+ [ "INFO",
+ "FOLLOWER",
+ "WARN",
+ "flow",
+ "ERROR",
+ "Except" ],
+ "s" )
+
+ main.log.info( "ERROR report: \n" )
+ for i in range( main.numCtrls ):
+ main.ONOSbench.logReport( main.ONOSip[ i ],
+ [ "ERROR" ],
+ "d" )
+
+ main.log.info( "EXCEPTIONS report: \n" )
+ for i in range( main.numCtrls ):
+ main.ONOSbench.logReport( main.ONOSip[ i ],
+ [ "Except" ],
+ "d" )
+
+ main.log.info( "WARNING report: \n" )
+ for i in range( main.numCtrls ):
+ main.ONOSbench.logReport( main.ONOSip[ i ],
+ [ "WARN" ],
+ "d" )
diff --git a/TestON/tests/FUNC/FUNCintent/dependencies/newFuncTopo.py b/TestON/tests/FUNC/FUNCintent/dependencies/newFuncTopo.py
new file mode 100755
index 0000000..df808a7
--- /dev/null
+++ b/TestON/tests/FUNC/FUNCintent/dependencies/newFuncTopo.py
@@ -0,0 +1,158 @@
+#!/usr/bin/python
+
+"""
+Custom topology for Mininet
+"""
+from mininet.topo import Topo
+from mininet.net import Mininet
+from mininet.node import Host, RemoteController
+from mininet.node import Node
+from mininet.node import CPULimitedHost
+from mininet.link import TCLink
+from mininet.cli import CLI
+from mininet.log import setLogLevel
+from mininet.util import dumpNodeConnections
+from mininet.node import ( UserSwitch, OVSSwitch, IVSSwitch )
+
+class VLANHost( Host ):
+ def config( self, vlan=100, v6Addr='3000::1/64', **params ):
+ r = super( Host, self ).config( **params )
+ intf = self.defaultIntf()
+ self.cmd( 'ifconfig %s inet 0' % intf )
+ self.cmd( 'vconfig add %s %d' % ( intf, vlan ) )
+ self.cmd( 'ifconfig %s.%d inet %s' % ( intf, vlan, params['ip'] ) )
+ self.cmd( 'ip -6 addr add %s dev %s.%d' % ( v6Addr, intf, vlan ) )
+ newName = '%s.%d' % ( intf, vlan )
+ intf.name = newName
+ self.nameToIntf[ newName ] = intf
+ return r
+
+class IPv6Host( Host ):
+ def config( self, v6Addr='1000::1/64', **params ):
+ r = super( Host, self ).config( **params )
+ intf = self.defaultIntf()
+ self.cmd( 'ifconfig %s inet 0' % intf )
+ self.cmd( 'ip -6 addr add %s dev %s' % ( v6Addr, intf ) )
+ return r
+
+class dualStackHost( Host ):
+ def config( self, v6Addr='2000:1/64', **params ):
+ r = super( Host, self ).config( **params )
+ intf = self.defaultIntf()
+ self.cmd( 'ip -6 addr add %s dev %s' % ( v6Addr, intf ) )
+ return r
+
+class MyTopo( Topo ):
+
+ def __init__( self ):
+ # Initialize topology
+ Topo.__init__( self )
+ # Switch S5 Hosts
+ # IPv4 only Host
+ host1=self.addHost( 'h1', ip='10.1.0.2/24' )
+ # IPv6 only Host
+ host2=self.addHost( 'h2', cls=IPv6Host, v6Addr='1000::2/64' )
+ # Dual Stack Host
+ host3=self.addHost( 'h3', ip='10.1.0.3/24', cls=dualStackHost, v6Addr='2000::2/64' )
+ # VLAN hosts
+ host4=self.addHost( 'h4', ip='100.1.0.2/24', cls=VLANHost, vlan=100, v6Addr='3000::2/64' )
+ host5=self.addHost( 'h5', ip='200.1.0.2/24', cls=VLANHost, vlan=200, v6Addr='4000::2/64' )
+ # VPN-1 and VPN-2 Hosts
+ host6=self.addHost( 'h6', ip='11.1.0.2/24' )
+ host7=self.addHost( 'h7', ip='12.1.0.2/24' )
+ # Multicast Sender
+ host8=self.addHost( 'h8', ip='10.1.0.4/24' )
+
+ # Switch S6 Hosts
+ # IPv4 only Host
+ host9=self.addHost( 'h9', ip='10.1.0.5/24' )
+ # IPv6 only Host
+ host10=self.addHost( 'h10', cls=IPv6Host, v6Addr='1000::3/64' )
+ # Dual Stack Host
+ host11=self.addHost( 'h11', ip='10.1.0.6/24', cls=dualStackHost, v6Addr='2000::3/64' )
+ # VLAN hosts
+ host12=self.addHost( 'h12', ip='100.1.0.3/24', cls=VLANHost, vlan=100, v6Addr='3000::3/64' )
+ host13=self.addHost( 'h13', ip='200.1.0.3/24', cls=VLANHost, vlan=200, v6Addr='4000::3/64' )
+ # VPN-1 and VPN-2 Hosts
+ host14=self.addHost( 'h14', ip='11.1.0.3/24' )
+ host15=self.addHost( 'h15', ip='12.1.0.3/24' )
+ # Multicast Receiver
+ host16=self.addHost( 'h16', ip='10.1.0.7/24' )
+
+ # Switch S7 Hosts
+ # IPv4 only Host
+ host17=self.addHost( 'h17', ip='10.1.0.8/24' )
+ # IPv6 only Host
+ host18=self.addHost( 'h18', cls=IPv6Host, v6Addr='1000::4/64' )
+ # Dual Stack Host
+ host19=self.addHost( 'h19', ip='10.1.0.9/24', cls=dualStackHost, v6Addr='2000::4/64' )
+ # VLAN hosts
+ host20=self.addHost( 'h20', ip='100.1.0.4/24', cls=VLANHost, vlan=100, v6Addr='3000::4/64' )
+ host21=self.addHost( 'h21', ip='200.1.0.4/24', cls=VLANHost, vlan=200, v6Addr='4000::4/64' )
+ # VPN-1 and VPN-2 Hosts
+ host22=self.addHost( 'h22', ip='11.1.0.4/24' )
+ host23=self.addHost( 'h23', ip='12.1.0.4/24' )
+ # Multicast Receiver
+ host24=self.addHost( 'h24', ip='10.1.0.10/24' )
+
+ s1 = self.addSwitch( 's1' )
+ s2 = self.addSwitch( 's2' )
+ s3 = self.addSwitch( 's3' )
+ s4 = self.addSwitch( 's4' )
+ s5 = self.addSwitch( 's5' )
+ s6 = self.addSwitch( 's6' )
+ s7 = self.addSwitch( 's7' )
+
+ self.addLink(s5,host1)
+ self.addLink(s5,host2)
+ self.addLink(s5,host3)
+ self.addLink(s5,host4)
+ self.addLink(s5,host5)
+ self.addLink(s5,host6)
+ self.addLink(s5,host7)
+ self.addLink(s5,host8)
+
+ self.addLink(s6,host9)
+ self.addLink(s6,host10)
+ self.addLink(s6,host11)
+ self.addLink(s6,host12)
+ self.addLink(s6,host13)
+ self.addLink(s6,host14)
+ self.addLink(s6,host15)
+ self.addLink(s6,host16)
+
+ self.addLink(s7,host17)
+ self.addLink(s7,host18)
+ self.addLink(s7,host19)
+ self.addLink(s7,host20)
+ self.addLink(s7,host21)
+ self.addLink(s7,host22)
+ self.addLink(s7,host23)
+ self.addLink(s7,host24)
+
+ self.addLink(s1,s2)
+ self.addLink(s1,s3)
+ self.addLink(s1,s4)
+ self.addLink(s1,s5)
+ self.addLink(s2,s3)
+ self.addLink(s2,s5)
+ self.addLink(s2,s6)
+ self.addLink(s3,s4)
+ self.addLink(s3,s6)
+ self.addLink(s4,s7)
+ topos = { 'mytopo': ( lambda: MyTopo() ) }
+
+# HERE THE CODE DEFINITION OF THE TOPOLOGY ENDS
+
+def setupNetwork():
+ "Create network"
+ topo = MyTopo()
+ network = Mininet(topo=topo, autoSetMacs=True, controller=None)
+ network.start()
+ CLI( network )
+ network.stop()
+
+if __name__ == '__main__':
+ setLogLevel('info')
+ #setLogLevel('debug')
+ setupNetwork()
diff --git a/TestON/tests/FUNC/FUNCintent/dependencies/startUp.py b/TestON/tests/FUNC/FUNCintent/dependencies/startUp.py
new file mode 100644
index 0000000..bf2a2b6
--- /dev/null
+++ b/TestON/tests/FUNC/FUNCintent/dependencies/startUp.py
@@ -0,0 +1,38 @@
+"""
+ This wrapper function is use for starting up onos instance
+"""
+
+import time
+import os
+import json
+
+def onosBuild( main, gitBranch ):
+ """
+ This includes pulling ONOS and building it using maven install
+ """
+
+ buildResult = main.FALSE
+
+ # Git checkout a branch of ONOS
+ checkOutResult = main.ONOSbench.gitCheckout( gitBranch )
+ # Does the git pull on the branch that was checked out
+ if not checkOutResult:
+ main.log.warn( "Failed to checked out " + gitBranch +
+ " branch")
+ else:
+ main.log.info( "Successfully checked out " + gitBranch +
+ " branch")
+ gitPullResult = main.ONOSbench.gitPull()
+ if gitPullResult == main.ERROR:
+ main.log.error( "Error pulling git branch" )
+ else:
+ main.log.info( "Successfully pulled " + gitBranch + " branch" )
+
+ # Maven clean install
+ buildResult = main.ONOSbench.cleanInstall()
+
+ return buildResult
+
+
+
+
diff --git a/TestON/tests/FUNC/FUNCintent/dependencies/topo.py b/TestON/tests/FUNC/FUNCintent/dependencies/topo.py
new file mode 100644
index 0000000..b44e3fc
--- /dev/null
+++ b/TestON/tests/FUNC/FUNCintent/dependencies/topo.py
@@ -0,0 +1,100 @@
+"""
+ These functions can be used for topology comparisons
+"""
+
+import time
+import os
+import json
+
+def getAllDevices( main ):
+ """
+ Return a list containing the devices output from each ONOS node
+ """
+ devices = []
+ threads = []
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].devices,
+ name="devices-" + str( i ),
+ args=[ ] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ devices.append( t.result )
+ return devices
+
+def getAllHosts( main ):
+ """
+ Return a list containing the hosts output from each ONOS node
+ """
+ hosts = []
+ ipResult = main.TRUE
+ threads = []
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].hosts,
+ name="hosts-" + str( i ),
+ args=[ ] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ hosts.append( t.result )
+ return hosts
+
+def getAllPorts( main ):
+ """
+ Return a list containing the ports output from each ONOS node
+ """
+ ports = []
+ threads = []
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].ports,
+ name="ports-" + str( i ),
+ args=[ ] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ ports.append( t.result )
+ return ports
+
+def getAllLinks( main ):
+ """
+ Return a list containing the links output from each ONOS node
+ """
+ links = []
+ threads = []
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].links,
+ name="links-" + str( i ),
+ args=[ ] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ links.append( t.result )
+ return links
+
+def getAllClusters( main ):
+ """
+ Return a list containing the clusters output from each ONOS node
+ """
+ clusters = []
+ threads = []
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].clusters,
+ name="clusters-" + str( i ),
+ args=[ ] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ clusters.append( t.result )
+ return clusters
+
+