Fixed FuncIntent.params conflict
diff --git a/TestON/drivers/common/cli/emulator/mininetclidriver.py b/TestON/drivers/common/cli/emulator/mininetclidriver.py
index eae172e..b4e7154 100644
--- a/TestON/drivers/common/cli/emulator/mininetclidriver.py
+++ b/TestON/drivers/common/cli/emulator/mininetclidriver.py
@@ -1921,6 +1921,7 @@
hostStr = handlePy.replace( "]", "" )
hostStr = hostStr.replace( "'", "" )
hostStr = hostStr.replace( "[", "" )
+ hostStr = hostStr.replace( " ", "" )
hostList = hostStr.split( "," )
return hostList
diff --git a/TestON/tests/FuncIntent/Dependency/FuncIntentFunction.py b/TestON/tests/FuncIntent/Dependency/FuncIntentFunction.py
new file mode 100644
index 0000000..0045c64
--- /dev/null
+++ b/TestON/tests/FuncIntent/Dependency/FuncIntentFunction.py
@@ -0,0 +1,527 @@
+"""
+ Wrapper functions for FuncIntent
+ This functions include Onosclidriver and Mininetclidriver driver functions
+"""
+def __init__( self ):
+ self.default = ''
+
+def hostIntent( main,
+ name="",
+ host1="",
+ host2="",
+ host1Id="",
+ host2Id="",
+ mac1="",
+ mac2="",
+ vlan1="-1",
+ vlan2="-1",
+ sw1="",
+ sw2="",
+ expectedLink=0 ):
+ """
+ Add host intents
+ """
+ import time
+
+ # Assert variables
+ 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
+ h1Name = host1
+ h2Name = host2
+ h1Id = host1Id
+ h2Id = host2Id
+ h1Mac = mac1
+ h2Mac = mac2
+ vlan1 = vlan1
+ vlan2 = vlan2
+ intentsId = []
+ stepResult = main.TRUE
+ pingResult = main.TRUE
+ intentResult = main.TRUE
+ flowResult = main.TRUE
+ topoResult = main.TRUE
+ linkDownResult = main.TRUE
+ linkUpResult = main.TRUE
+
+ if main.hostsData:
+ if not h1Mac:
+ h1Mac = main.hostsData[ h1Name ][ 'mac' ]
+ if not h2Mac:
+ h2Mac = main.hostsData[ h2Name ][ 'mac' ]
+ print '1', main.hostsData[ h1Name ]
+ print '2', main.hostsData[ h2Name ]
+ if main.hostsData[ h1Name ][ 'vlan' ] != '-1':
+ print 'vlan1', main.hostsData[ h1Name ][ 'vlan' ]
+ vlan1 = main.hostsData[ h1Name ][ 'vlan' ]
+ if main.hostsData[ h2Name ][ 'vlan' ] != '-1':
+ print 'vlan2', main.hostsData[ h2Name ][ 'vlan' ]
+ vlan2 = main.hostsData[ h2Name ][ 'vlan' ]
+ if not h1Id:
+ h1Id = main.hostsData[ h1Name ][ 'id' ]
+ if not h2Id:
+ h2Id = main.hostsData[ h2Name ][ 'id' ]
+
+ assert h1Id and h2Id, "You must specify host IDs"
+ if not ( h1Id and h2Id ):
+ main.log.info( "There are no host IDs" )
+ return main.FALSE
+
+ # Discover hosts using arping
+ main.log.info( itemName + ": Discover host using arping" )
+ main.Mininet1.arping( host=h1Name )
+ main.Mininet1.arping( host=h2Name )
+ host1 = main.CLIs[ 0 ].getHost( mac=h1Mac )
+ host2 = main.CLIs[ 0 ].getHost( mac=h2Mac )
+
+ # Adding host intents
+ main.log.info( itemName + ": Adding host intents" )
+ intent1 = main.CLIs[ 0 ].addHostIntent( hostIdOne=h1Id,
+ hostIdTwo=h2Id )
+ intentsId.append( intent1 )
+ time.sleep( 5 )
+ intent2 = main.CLIs[ 0 ].addHostIntent( hostIdOne=h2Id,
+ hostIdTwo=h1Id )
+ intentsId.append( intent2 )
+
+ # Check intents state
+ time.sleep( 50 )
+ intentResult = checkIntentState( main, intentsId )
+
+ # Verify flows
+ checkFlowsState( main )
+
+ # Ping hosts
+ pingHost( main, h1Name, h2Name )
+ # Ping hosts again...
+ pingResult = pingHost( main, h1Name, h2Name )
+ time.sleep( 5 )
+
+ # Test rerouting if these variables exist
+ if sw1 and sw2 and expectedLink:
+ # link down
+ link( main, sw1, sw2, "down" )
+ intentResult = intentResult and checkIntentState( main, intentsId )
+
+ # Verify flows
+ checkFlowsState( main )
+
+ # Check OnosTopology
+ topoResult = checkTopology( main, expectedLink )
+
+ # Ping hosts
+ pingResult = pingResult and pingHost( main, h1Name, h2Name )
+
+ intentResult = checkIntentState( main, intentsId )
+
+ # link up
+ link( main, sw1, sw2, "up" )
+ time.sleep( 5 )
+
+ # Verify flows
+ checkFlowsState( main )
+
+ # Check OnosTopology
+ topoResult = checkTopology( main, expectedLink )
+
+ # Ping hosts
+ pingResult = pingResult and pingHost( main, h1Name, h2Name )
+
+ # Remove intents
+ for intent in intentsId:
+ main.CLIs[ 0 ].removeIntent( intentId=intent, purge=True )
+
+ print main.CLIs[ 0 ].intents()
+ stepResult = pingResult and linkDownResult and linkUpResult \
+ and intentResult
+
+ return stepResult
+
+def pointIntent( main,
+ name="",
+ host1="",
+ host2="",
+ deviceId1="",
+ deviceId2="",
+ port1="",
+ port2="",
+ ethType="",
+ mac1="",
+ mac2="",
+ bandwidth="",
+ lambdaAlloc=False,
+ ipProto="",
+ ip1="",
+ ip2="",
+ tcp1="",
+ tcp2="",
+ sw1="",
+ sw2="",
+ expectedLink=0 ):
+ """
+ Add Point intents
+ """
+ import time
+ 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
+ h1Name = host1
+ h2Name = host2
+ intentsId = []
+
+ pingResult = main.TRUE
+ intentResult = main.TRUE
+ flowResult = main.TRUE
+ topoResult = main.TRUE
+ linkDownResult = main.TRUE
+ linkUpResult = main.TRUE
+
+ # Adding bidirectional point intents
+ main.log.info( itemName + ": Adding host intents" )
+ intent1 = main.CLIs[ 0 ].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=tcp2 )
+
+ intentsId.append( intent1 )
+ time.sleep( 5 )
+ intent2 = main.CLIs[ 0 ].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=tcp1 )
+ intentsId.append( intent2 )
+
+ # Check intents state
+ time.sleep( 50 )
+ intentResult = checkIntentState( main, intentsId )
+
+ # Verify flows
+ checkFlowsState( main )
+
+ # Ping hosts
+ pingHost( main, h1Name, h2Name )
+ # Ping hosts again...
+ pingResult = pingHost( main, h1Name, h2Name )
+ time.sleep( 5 )
+
+ if sw1 and sw2 and expectedLink:
+ # link down
+ link( main, sw1, sw2, "down" )
+ intentResult = intentResult and checkIntentState( main, intentsId )
+
+ # Verify flows
+ checkFlowsState( main )
+
+ # Check OnosTopology
+ topoResult = checkTopology( main, expectedLink )
+
+ # Ping hosts
+ pingResult = pingResult and pingHost( main, h1Name, h2Name )
+
+ intentResult = checkIntentState( main, intentsId )
+
+ # link up
+ link( main, sw1, sw2, "up" )
+ time.sleep( 5 )
+
+ # Verify flows
+ checkFlowsState( main )
+
+ # Check OnosTopology
+ topoResult = checkTopology( main, expectedLink )
+
+ # Ping hosts
+ pingResult = pingResult and pingHost( main, h1Name, h2Name )
+
+ # Remove intents
+ for intent in intentsId:
+ main.CLIs[ 0 ].removeIntent( intentId=intent, purge=True )
+
+ print main.CLIs[ 0 ].intents()
+ stepResult = pingResult and linkDownResult and linkUpResult \
+ and intentResult
+
+ return stepResult
+
+def singleToMultiIntent( main,
+ name="",
+ hostNames=None,
+ devices=None,
+ ports=None,
+ ethType="",
+ macs=None,
+ bandwidth="",
+ lambdaAlloc=False,
+ ipProto="",
+ ipAddresses="",
+ tcp="",
+ sw1="",
+ sw2="",
+ expectedLink=0 ):
+ """
+ Add Single to Multi Point intents
+ """
+ import time
+ assert main, "There is no main variable"
+ assert name, "variable name is empty"
+ assert hostNames, "You must specify hosts"
+ assert devices or main.hostsData, "You must specify devices"
+
+ global itemName
+ itemName = name
+ h1Name = host1
+ h2Name = host2
+ intentsId = []
+
+ if devices and ports:
+ if len( devices ) and len( ports ):
+ main.log.info( itemName +
+ ": devices and ports are not the same lenght " +
+ "devices - " + str( len( devices ) ) + " ports - "
+ + str( len( ports ) ) )
+
+
+
+ pingResult = main.TRUE
+ intentResult = main.TRUE
+ flowResult = main.TRUE
+ topoResult = main.TRUE
+ linkDownResult = main.TRUE
+ linkUpResult = main.TRUE
+
+ # Adding bidirectional point intents
+ main.log.info( itemName + ": Adding host intents" )
+ intent1 = main.CLIs[ 0 ].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=tcp2 )
+
+ intentsId.append( intent1 )
+ time.sleep( 5 )
+ intent2 = main.CLIs[ 0 ].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=tcp1 )
+ intentsId.append( intent2 )
+
+ # Check intents state
+ time.sleep( 50 )
+ intentResult = checkIntentState( main, intentsId )
+
+ # Verify flows
+ checkFlowsState( main )
+
+ # Ping hosts
+ pingHost( main, h1Name, h2Name )
+ # Ping hosts again...
+ pingResult = pingHost( main, h1Name, h2Name )
+ time.sleep( 5 )
+
+ if sw1 and sw2 and expectedLink:
+ # link down
+ link( main, sw1, sw2, "down" )
+ intentResult = intentResult and checkIntentState( main, intentsId )
+
+ # Verify flows
+ checkFlowsState( main )
+
+ # Check OnosTopology
+ topoResult = checkTopology( main, expectedLink )
+
+ # Ping hosts
+ pingResult = pingResult and pingHost( main, h1Name, h2Name )
+
+ intentResult = checkIntentState( main, intentsId )
+
+ # link up
+ link( main, sw1, sw2, "up" )
+ time.sleep( 5 )
+
+ # Verify flows
+ checkFlowsState( main )
+
+ # Check OnosTopology
+ topoResult = checkTopology( main, expectedLink )
+
+ # Ping hosts
+ pingResult = pingResult and pingHost( main, h1Name, h2Name )
+
+ # Remove intents
+ for intent in intentsId:
+ main.CLIs[ 0 ].removeIntent( intentId=intent, purge=True )
+
+ print main.CLIs[ 0 ].intents()
+ stepResult = pingResult and linkDownResult and linkUpResult \
+ and intentResult
+
+ return stepResult
+
+def link( main, sw1, sw2, option):
+
+ # link down
+ main.log.info( itemName + ": Bring link " + option + "between " +
+ sw1 + " and " + sw2 )
+ main.Mininet1.link( end1=sw1, end2=sw2, option=option )
+
+def pingAllHost( main, hosts ):
+ # Ping all host in the hosts list variable
+ import itertools
+
+ main.log.info( itemName + ": Ping host list - " + hosts )
+ hostCombination = itertools.permutation( hosts, 2 )
+ pingResult = main.TRUE
+ for hostPair in hostCombination:
+ pingResult = pingResult and main.Mininet.pingHost(
+ src=hostPair[ 0 ],
+ target=hostPair[ 1 ] )
+ return pingResult
+
+def pingHost( main, h1Name, h2Name ):
+
+ # Ping hosts
+ main.log.info( itemName + ": Ping " + h1Name + " and " +
+ h2Name )
+ pingResult1 = main.Mininet1.pingHost( src=h1Name , target=h2Name )
+ if not pingResult1:
+ main.log.info( itemName + ": " + h1Name + " cannot ping "
+ + h2Name )
+ pingResult2 = main.Mininet1.pingHost( src=h2Name , target=h1Name )
+ if not pingResult2:
+ main.log.info( itemName + ": " + h2Name + " cannot ping "
+ + h1Name )
+ pingResult = pingResult1 and pingResult2
+ if pingResult:
+ main.log.info( itemName + ": Successfully pinged " +
+ "both hosts" )
+ else:
+ main.log.info( itemName + ": Failed to ping " +
+ "both hosts" )
+ return pingResult
+
+def getHostsData( main ):
+ """
+ Use fwd app and pingall to discover all the hosts
+ """
+ """
+ hosts json format:
+ """
+ import json
+ activateResult = main.TRUE
+ appCheck = main.TRUE
+ main.log.info( "Activating reactive forwarding app " )
+ activateResult = main.CLIs[ 0 ].activateApp( "org.onosproject.fwd" )
+
+ for i in range( main.numCtrls ):
+ appCheck = appCheck and main.CLIs[ i ].appToIDCheck()
+
+ if appCheck != main.TRUE:
+ main.log.warn( main.CLIs[ 0 ].apps() )
+ main.log.warn( main.CLIs[ 0 ].appIDs() )
+
+ pingResult = main.Mininet1.pingall()
+ hostsJson = json.loads( main.CLIs[ 0 ].hosts() )
+ hosts = main.Mininet1.getHosts()
+ 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' ]
+
+ main.log.info( "Deactivating reactive forwarding app " )
+ activateResult = main.CLIs[ 0 ].deactivateApp( "org.onosproject.fwd" )
+ print main.hostsData
+ return pingResult
+
+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.info( itemName + ": Topology mismatch" )
+ else:
+ main.log.info( itemName + ": Topology match" )
+ return statusResult
+
+def checkIntentState( main, intentsId ):
+
+ main.log.info( itemName + ": Check host intents state" )
+ for i in range( main.numCtrls ):
+ intentResult = main.CLIs[ i ].checkIntentState( intentsId=intentsId )
+ if not intentResult:
+ main.log.info( itemName + ": Check host intents state again")
+ for i in range( main.numCtrls ):
+ intentResult = main.CLIs[ i ].checkIntentState(
+ intentsId=intentsId )
+ return intentResult
+
+def checkFlowsState( main ):
+
+ main.log.info( itemName + ": Check flows state" )
+ checkFlowsResult = main.CLIs[ 0 ].checkFlowsState()
+ return checkFlowsResult
+
+def printMsg( main, h1Name, h2Name ):
+ main.log.info("PINGING HOST INSIDE printMSG")
+ pingHost( main, itemName, h1Name, h2Name )
+ print 'lala'
+
diff --git a/TestON/tests/FuncIntent/Dependency/__init__.py b/TestON/tests/FuncIntent/Dependency/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/TestON/tests/FuncIntent/Dependency/__init__.py
diff --git a/TestON/tests/FuncIntent/FuncIntent.params b/TestON/tests/FuncIntent/FuncIntent.params
index 08cce42..a2386d9 100755
--- a/TestON/tests/FuncIntent/FuncIntent.params
+++ b/TestON/tests/FuncIntent/FuncIntent.params
@@ -1,6 +1,6 @@
<PARAMS>
- <testcases>10,11,9,12,1001,10,12,1001</testcases>
+ <testcases>10,11,12,13,1002</testcases>
<SCALE>1,3</SCALE>
<availableNodes>3</availableNodes>
diff --git a/TestON/tests/FuncIntent/FuncIntent.py b/TestON/tests/FuncIntent/FuncIntent.py
index b0ff4c2..6d604a1 100644
--- a/TestON/tests/FuncIntent/FuncIntent.py
+++ b/TestON/tests/FuncIntent/FuncIntent.py
@@ -15,6 +15,7 @@
def CASE10( self, main ):
import time
import os
+ import imp
"""
Startup sequence:
cell <name>
@@ -47,10 +48,15 @@
main.numSwitch = int( main.params[ 'MININET' ][ 'switch' ] )
main.numLinks = int( main.params[ 'MININET' ][ 'links' ] )
main.numCtrls = main.params[ 'CTRL' ][ 'num' ]
+ main.wrapper = imp.load_source( 'FuncIntentFunction',
+ '/home/admin/ONLabTest/TestON/tests/' +
+ 'FuncIntent/Dependency/' +
+ 'FuncIntentFunction.py' )
PULLCODE = False
if main.params[ 'GIT' ][ 'pull' ] == 'True':
PULLCODE = True
main.case( "Setting up test environment" )
+ main.hostsData = {}
main.CLIs = []
for i in range( 1, int( main.numCtrls ) + 1 ):
main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
@@ -62,6 +68,7 @@
# -- INIT SECTION, ONLY RUNS ONCE -- #
if init == False:
init = True
+ main.MNisUp = main.FALSE
#main.ONOSip = []
main.ONOSport = []
@@ -112,17 +119,6 @@
" before initiating enviornment setup" )
for i in range( maxNodes ):
main.ONOSbench.onosDie( main.ONOSip[ i ] )
- """
- main.step( "Apply cell to environment" )
- cellResult = main.ONOSbench.setCell( cellName )
- 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( "Removing raft logs" )
removeRaftResult = main.ONOSbench.onosRemoveRaftLogs()
stepResult = removeRaftResult
@@ -223,9 +219,14 @@
"""
Start mininet
"""
+ import time
main.log.report( "Start Mininet topology" )
- main.log.case( "Start Mininet topology" )
-
+ main.case( "Start Mininet topology" )
+ if not main.MNisUp:
+ main.MNisUp = main.TRUE
+ else:
+ main.Mininet1.stopNet()
+ time.sleep( 30 )
main.step( "Starting Mininet Topology" )
topoResult = main.Mininet1.startNet( topoFile=topology )
stepResult = topoResult
@@ -244,6 +245,7 @@
"""
import re
+ main.case( "Assign switches to controllers" )
main.step( "Assigning switches to controllers" )
assignResult = main.TRUE
for i in range( 1, ( main.numSwitch + 1 ) ):
@@ -265,6 +267,19 @@
"to controller",
onfail="Failed to assign switches to " +
"controller" )
+ def CASE13( self, main ):
+ """
+ Discover all hosts and store its data to a dictionary
+ """
+ main.case( "Discover all hosts" )
+
+ stepResult = main.TRUE
+ main.step( "IPV4: Add host intents between h1 and h9" )
+ stepResult = main.wrapper.getHostsData( main )
+ utilities.assert_equals( expect=main.FALSE,
+ actual=stepResult,
+ onpass="Successfully discovered hosts",
+ onfail="Failed to discover hosts" )
def CASE1001( self, main ):
"""
@@ -272,12 +287,16 @@
- Discover hosts
- Add host intents
- Check intents
- - Check flows
+ - Verify flows
- Ping hosts
- Reroute
- Link down
+ - Verify flows
+ - Check topology
- Ping hosts
- Link up
+ - Verify flows
+ - Check topology
- Ping hosts
- Remove intents
"""
@@ -291,203 +310,146 @@
'id':'00:00:00:00:00:0X/-X' } , 'host2':
{ 'name': '', 'MAC': '00:00:00:00:00:0X',
'id':'00:00:00:00:00:0X/-X'}, 'link': { 'switch1': '',
- 'switch2': '', 'num':'' } }
+ 'switch2': '', 'expect':'' } }
"""
- # Local variables
- items = []
- ipv4 = { 'name': 'IPV4', 'host1':
- { 'name': 'h1', 'MAC': '00:00:00:00:00:01',
- 'id':'00:00:00:00:00:01/-1' } , 'host2':
- { 'name': 'h9', 'MAC': '00:00:00:00:00:09',
- 'id':'00:00:00:00:00:09/-1'}, 'link': { 'switch1': 's5',
- 'switch2': 's2', 'num':'18' } }
- dualStack1 = { 'name': 'DUALSTACK1', 'host1':
- { 'name': 'h3', 'MAC': '00:00:00:00:00:03',
- 'id':'00:00:00:00:00:03/-1' } , 'host2':
- { 'name': 'h11', 'MAC': '00:00:00:00:00:0B',
- 'id':'00:00:00:00:00:0B/-1'}, 'link': { 'switch1': 's5',
- 'switch2': 's2', 'num':'18' } }
- items.append( ipv4 )
- items.append( dualStack1 )
- # Global variables
-
- main.log.case( "Add host intents between 2 host" )
-
- for item in items:
- stepResult = main.TRUE
- itemName = item[ 'name' ]
- h1Name = item[ 'host1' ][ 'name' ]
- h2Name = item[ 'host2' ][ 'name' ]
- h1Mac = item[ 'host1' ][ 'MAC' ]
- h2Mac = item[ 'host2' ][ 'MAC' ]
- h1Id = item[ 'host1' ][ 'id']
- h2Id = item[ 'host2' ][ 'id']
- # Link down/up for rerouting
- sw1 = item[ 'link' ][ 'switch1' ]
- sw2 = item[ 'link' ][ 'switch2' ]
- remLink = item[ 'link' ][ 'num' ]
- pingResult = main.TRUE
- statusResult = main.TRUE
- linkDownResult = main.TRUE
- linkUpResult = main.TRUE
- intentsId = []
- main.step( itemName + ": Add host intents between " + h1Name
- + " and " + h2Name )
- main.log.info( itemName + ": Discover host using arping" )
- main.Mininet1.arping( host=h1Name )
- main.Mininet1.arping( host=h2Name )
- host1 = main.CLIs[ 0 ].getHost( mac=h1Mac )
- host2 = main.CLIs[ 0 ].getHost( mac=h2Mac )
- print host1
- print host2
- # Adding intents
- main.log.info( itemName + ": Adding host intents" )
- intent1 = main.CLIs[ 0 ].addHostIntent( hostIdOne=h1Id,
- hostIdTwo=h2Id )
- intentsId.append( intent1 )
- time.sleep( 5 )
- intent2 = main.CLIs[ 0 ].addHostIntent( hostIdOne=h2Id,
- hostIdTwo=h1Id )
- intentsId.append( intent2 )
- # Checking intents
- main.log.info( itemName + ": Check host intents state" )
- time.sleep( 30 )
- for i in range( main.numCtrls ):
- intentResult = main.CLIs[ i ].checkIntentState(
- intentsId=intentsId )
- if not intentResult:
- main.log.info( itemName + ": Check host intents state" +
- " again")
- for i in range( main.numCtrls ):
- intentResult = main.CLIs[ i ].checkIntentState(
- intentsId=intentsId )
- # Ping hosts
- time.sleep( 10 )
- main.log.info( itemName + ": Ping " + h1Name + " and " +
- h2Name )
- pingResult1 = main.Mininet1.pingHost( src=h1Name , target=h2Name )
- if not pingResult1:
- main.log.info( itemName + ": " + h1Name + " cannot ping "
- + h2Name )
- pingResult2 = main.Mininet1.pingHost( src=h2Name , target=h1Name )
- if not pingResult2:
- main.log.info( itemName + ": " + h2Name + " cannot ping "
- + h1Name )
- pingResult = pingResult1 and pingResult2
- if pingResult:
- main.log.info( itemName + ": Successfully pinged " +
- "both hosts" )
- else:
- main.log.info( itemName + ": Failed to ping " +
- "both hosts" )
- # Rerouting ( link down )
- main.log.info( itemName + ": Bring link down between " +
- sw1 + " and " + sw2 )
- main.Mininet1.link( end1=sw1,
- end2=sw2,
- option="down" )
- time.sleep( 5 )
- # Check onos topology
- main.log.info( itemName + ": Checking ONOS topology " )
+ # 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"
- for i in range( main.numCtrls ):
- topologyResult = main.CLIs[ i ].topology()
- linkDownResult = main.ONOSbench.checkStatus( topologyResult,
- main.numSwitch,
- remLink )\
- and linkDownResult
- if not linkDownResult:
- main.log.info( itemName + ": Topology mismatch" )
- else:
- main.log.info( itemName + ": Topology match" )
+ main.case( "Add host intents between 2 host" )
- # Ping hosts
- main.log.info( itemName + ": Ping " + h1Name + " and " +
- h2Name )
- pingResult1 = main.Mininet1.pingHost( src=h1Name , target=h2Name )
- if not pingResult1:
- main.log.info( itemName + ": " + h1Name + " cannot ping "
- + h2Name )
- pingResult2 = main.Mininet1.pingHost( src=h2Name , target=h1Name )
- if not pingResult2:
- main.log.info( itemName + ": " + h2Name + " cannot ping "
- + h1Name )
- pingResult = pingResult1 and pingResult2
- if pingResult:
- main.log.info( itemName + ": Successfully pinged " +
- "both hosts" )
- else:
- main.log.info( itemName + ": Failed to ping " +
- "both hosts" )
- # link up
- main.log.info( itemName + ": Bring link up between " +
- sw1 + " and " + sw2 )
- main.Mininet1.link( end1=sw1,
- end2=sw2,
- option="up" )
- time.sleep( 5 )
+ stepResult = main.TRUE
+ main.step( "IPV4: Add host intents between h1 and h9" )
+ stepResult = main.wrapper.hostIntent( main,
+ name='IPV4',
+ host1='h1',
+ host2='h9',
+ host1Id='00:00:00:00:00:01/-1',
+ host2Id='00:00:00:00:00:09/-1',
+ sw1='s5',
+ sw2='s2',
+ expectedLink=18 )
- # Check onos topology
- main.log.info( itemName + ": Checking ONOS topology " )
- for i in range( main.numCtrls ):
- topologyResult = main.CLIs[ i ].topology()
- linkUpResult = main.ONOSbench.checkStatus( topologyResult,
- main.numSwitch,
- main.numLinks )\
- and linkUpResult
- if not linkUpResult:
- main.log.info( itemName + ": Topology mismatch" )
- else:
- main.log.info( itemName + ": Topology match" )
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="IPV4: Add host intent successful",
+ onfail="IPV4: Add host intent failed" )
+ stepResult = main.TRUE
- # Ping hosts
- main.log.info( itemName + ": Ping " + h1Name + " and " +
- h2Name )
- pingResult1 = main.Mininet1.pingHost( src=h1Name , target=h2Name )
- if not pingResult1:
- main.log.info( itemName + ": " + h1Name + " cannot ping "
- + h2Name )
- pingResult2 = main.Mininet1.pingHost( src=h2Name , target=h1Name )
- if not pingResult2:
- main.log.info( itemName + ": " + h2Name + " cannot ping "
- + h1Name )
- pingResult = pingResult1 and pingResult2
- if pingResult:
- main.log.info( itemName + ": Successfully pinged " +
- "both hosts" )
- else:
- main.log.info( itemName + ": Failed to ping " +
- "both hosts" )
+ main.step( "DUALSTACK: Add host intents between h3 and h11" )
+ stepResult = main.wrapper.hostIntent( main,
+ name='DUALSTACK',
+ host1='h3',
+ host2='h11',
+ host1Id='00:00:00:00:00:03/-1',
+ host2Id='00:00:00:00:00:011/-1',
+ sw1='s5',
+ sw2='s2',
+ expectedLink=18 )
- # Remove intents
- for intent in intentsId:
- main.CLIs[ 0 ].removeIntent( intentId=intent, purge=True )
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="DUALSTACK: Add host intent successful",
+ onfail="DUALSTACK: Add host intent failed" )
- print main.CLIs[ 0 ].intents()
- stepResult = pingResult and linkDownResult and linkUpResult \
- and intentResult
- utilities.assert_equals( expect=main.TRUE,
- actual=stepResult,
- onpass=itemName +
- ": host intent successful",
- onfail=itemName +
- ": Add host intent failed" )
def CASE1002( self, main ):
"""
Add point intents between 2 hosts:
- - Get device ids
+ - Get device ids | ports
- Add point intents
- Check intents
- - Check flows
+ - 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
+ """
+ Create your item(s) here
+ item = { 'name':'', 'host1': { 'name': '' },
+ 'host2': { 'name': '' },
+ 'ingressDevice':'' , 'egressDevice':'',
+ 'ingressPort':'', 'egressPort':'',
+ 'option':{ 'ethType':'', 'ethSrc':'', 'ethDst':'' } ,
+ 'link': { 'switch1': '', 'switch2':'', 'expect':'' } }
+
+ """
+
+ # 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"
+
+ ipv4 = { 'name':'IPV4', 'ingressDevice':'of:0000000000000005/1' ,
+ 'host1': { 'name': 'h1' }, 'host2': { 'name': 'h9' },
+ 'egressDevice':'of:0000000000000006/1', 'option':
+ { 'ethType':'IPV4', 'ethSrc':'00:00:00:00:00:01',
+ 'ethDst':'00:00:00:00:00:09' }, 'link': { 'switch1':'s5',
+ 'switch2':'s2', 'expect':'18' } }
+
+ """
+ ipv4 = { 'name':'IPV4', 'ingressDevice':'of:0000000000000005/1' ,
+ 'host1': { 'name': 'h1' }, 'host2': { 'name': 'h9' },
+ 'egressDevice':'of:0000000000000006/1', 'option':
+ { 'ethType':'IPV4', 'ethSrc':'00:00:00:00:00:01' },
+ 'link': { 'switch1':'s5', 'switch2':'s2', 'expect':'18' } }
+ """
+ dualStack1 = { 'name':'IPV4', 'ingressDevice':'0000000000000005/3' ,
+ 'host1': { 'name': 'h3' }, 'host2': { 'name': 'h11' },
+ 'egressDevice':'0000000000000006/3', 'option':
+ { 'ethType':'IPV4', 'ethSrc':'00:00:00:00:00:03',
+ 'ethDst':'00:00:00:00:00:0B' }, 'link': { 'switch1':'s5',
+ 'switch2':'s2', 'expect':'18' } }
+
+ main.case( "Add point intents between 2 devices" )
+
+ stepResult = main.TRUE
+ main.step( "IPV4: Add point intents between h1 and h9" )
+ stepResult = main.wrapper.pointIntent(
+ main,
+ name="IPV4",
+ host1="h1",
+ host2="h9",
+ deviceId1="of:0000000000000005/1",
+ deviceId2="of:0000000000000006/1",
+ port1="",
+ port2="",
+ ethType="IPV4",
+ mac1="00:00:00:00:00:01",
+ mac2="00:00:00:00:00:09",
+ bandwidth="",
+ lambdaAlloc=False,
+ ipProto="",
+ ip1="",
+ ip2="",
+ tcp1="",
+ tcp2="",
+ sw1="s5",
+ sw2="s2",
+ expectedLink=18 )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="IPV4: Add point intent successful",
+ onfail="IPV4: Add point intent failed" )
def CASE1003( self, main ):
"""
@@ -495,12 +457,16 @@
- Get device ids
- Add single point to multi point intents
- Check intents
- - Check flows
+ - Verify flows
- Ping hosts
- Reroute
- Link down
+ - Verify flows
+ - Check topology
- Ping hosts
- Link up
+ - Verify flows
+ - Check topology
- Ping hosts
- Remove intents
"""
@@ -511,12 +477,16 @@
- Get device ids
- Add multi point to single point intents
- Check intents
- - Check flows
+ - Verify flows
- Ping hosts
- Reroute
- Link down
+ - Verify flows
+ - Check topology
- Ping hosts
- Link up
+ - Verify flows
+ - Check topology
- Ping hosts
- Remove intents
"""