Changed FuncIntent function structure
diff --git a/TestON/drivers/common/cli/emulator/mininetclidriver.py b/TestON/drivers/common/cli/emulator/mininetclidriver.py
index 32339a4..e0e938c 100644
--- a/TestON/drivers/common/cli/emulator/mininetclidriver.py
+++ b/TestON/drivers/common/cli/emulator/mininetclidriver.py
@@ -1915,6 +1915,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
index f6996bb..07944aa 100644
--- a/TestON/tests/FuncIntent/Dependency/FuncIntentFunction.py
+++ b/TestON/tests/FuncIntent/Dependency/FuncIntentFunction.py
@@ -5,24 +5,41 @@
def __init__( self ):
self.default = ''
-def addHostIntent( main, item ):
+def hostIntent( main,
+ name="",
+ host1="",
+ host2="",
+ host1Id="",
+ host2Id="",
+ mac1="",
+ mac2="",
+ vlan1="-1",
+ vlan2="-1",
+ sw1="",
+ sw2="",
+ expectedLink=0 ):
"""
Add host intents
"""
import time
- stepResult = main.TRUE
+
+ # 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 = 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']
- sw1 = item[ 'link' ][ 'switch1' ]
- sw2 = item[ 'link' ][ 'switch2' ]
- expectLink = item[ 'link' ][ 'expect' ]
+ 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
@@ -30,6 +47,25 @@
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' ]
+ if main.hostsData[ h1Name ][ 'vlan' ] != '-1':
+ vlan1 = main.hostsData[ h1Name ][ 'vlan' ]
+ if main.hostsData[ h2Name ][ 'vlan' ] != '-1':
+ 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 )
@@ -60,33 +96,35 @@
pingResult = pingHost( main, h1Name, h2Name )
time.sleep( 5 )
- # link down
- link( main, sw1, sw2, "down" )
- intentResult = intentResult and checkIntentState( main, intentsId )
+ # 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 )
+ # Verify flows
+ checkFlowsState( main )
- # Check OnosTopology
- topoResult = checkTopology( main, expectLink )
+ # Check OnosTopology
+ topoResult = checkTopology( main, expectedLink )
- # Ping hosts
- pingResult = pingResult and pingHost( main, h1Name, h2Name )
+ # Ping hosts
+ pingResult = pingResult and pingHost( main, h1Name, h2Name )
- intentResult = checkIntentState( main, intentsId )
+ intentResult = checkIntentState( main, intentsId )
- # link up
- link( main, sw1, sw2, "up" )
- time.sleep( 5 )
+ # link up
+ link( main, sw1, sw2, "up" )
+ time.sleep( 5 )
- # Verify flows
- checkFlowsState( main )
+ # Verify flows
+ checkFlowsState( main )
- # Check OnosTopology
- topoResult = checkTopology( main, expectLink )
+ # Check OnosTopology
+ topoResult = checkTopology( main, expectedLink )
- # Ping hosts
- pingResult = pingResult and pingHost( main, h1Name, h2Name )
+ # Ping hosts
+ pingResult = pingResult and pingHost( main, h1Name, h2Name )
# Remove intents
for intent in intentsId:
@@ -98,80 +136,40 @@
return stepResult
-def addPointIntent( main, item ):
+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
- stepResult = main.TRUE
+ assert main, "There is no main variable"
+ assert name, "variable name is empty"
+ assert host1 and host2, "You must specify hosts"
+
global itemName
- itemName = item[ 'name' ]
- h1Name = item[ 'host1' ][ 'name' ]
- h2Name = item[ 'host2' ][ 'name' ]
- ingressDevice = item[ 'ingressDevice' ]
- egressDevice = item[ 'egressDevice' ]
- option = item[ 'option' ]
- sw1 = item[ 'link' ][ 'switch1' ]
- sw2 = item[ 'link' ][ 'switch2' ]
- expectLink = item[ 'link' ][ 'expect' ]
+ itemName = name
+ h1Name = host1
+ h2Name = host2
intentsId = []
-
- # Assign options to variables
- ingressPort = item.get( 'ingressPort' )
- egressPort = item.get( 'egressPort' )
- ethType = option.get( 'ethType' )
- ethSrc = option.get( 'ethSrc' )
- ethDst = option.get( 'ethDst' )
- bandwidth = option.get( 'bandwidth' )
- lambdaAlloc = option.get( 'lambdaAlloc' )
- ipProto = option.get( 'ipProto' )
- ipSrc = option.get( 'ipSrc' )
- ipDst = option.get( 'ipDst' )
- tcpSrc = option.get( 'tcpSrc' )
- tcpDst = option.get( 'tcpDst' )
-
- if ingressPort == None:
- ingressPort = ""
- if egressPort == None:
- egressPort = ""
- if ethType == None:
- ethType = ""
- if ethSrc == None:
- ethSrc = ""
- if ethDst == None:
- ethDst = ""
- if bandwidth == None:
- bandwidth = ""
- if lambdaAlloc == None:
- lambdaAlloc = False
- if ipProto == None:
- ipProto = ""
- if ipSrc == None:
- ipSrc = ""
- if ipDst == None:
- ipDst = ""
- if tcpSrc == None:
- tcpSrc = ""
- if tcpDst == None:
- tcpDst = ""
-
- """
- print 'ethType: ', ethType
- print 'ethSrc: ', ethSrc
- print 'ethDst: ', ethDst
- print 'bandwidth', bandwidth
- print 'lambdaAlloc: ', lambdaAlloc
- print 'ipProto: ', ipProto
- print 'ipSrc: ', ipSrc
- print 'ipDst:', ipDst
- print 'tcpSrc: ', tcpSrc
- print 'tcpDst: ', tcpDst
- """
- addedOption = ""
- for i in range( len( option ) ):
- addedOption = addedOption + option.keys()[ i ] + " = " + \
- option.values()[ i ] + "\n"
- main.log.info( itemName + ": Printing added options...\n" + addedOption )
pingResult = main.TRUE
intentResult = main.TRUE
@@ -182,37 +180,37 @@
# Adding bidirectional point intents
main.log.info( itemName + ": Adding host intents" )
- intent1 = main.CLIs[ 0 ].addPointIntent( ingressDevice=ingressDevice,
- egressDevice=egressDevice,
- portIngress=ingressPort,
- portEgress=egressPort,
+ intent1 = main.CLIs[ 0 ].addPointIntent( ingressDevice=deviceId1,
+ egressDevice=deviceId2,
+ portIngress=port1,
+ portEgress=port2,
ethType=ethType,
- ethSrc=ethSrc,
- ethDst=ethDst,
+ ethSrc=mac1,
+ ethDst=mac2,
bandwidth=bandwidth,
lambdaAlloc=lambdaAlloc,
ipProto=ipProto,
- ipSrc=ipSrc,
- ipDst=ipDst,
- tcpSrc=tcpSrc,
- tcpDst=tcpDst )
+ ipSrc=ip1,
+ ipDst=ip2,
+ tcpSrc=tcp1,
+ tcpDst=tcp2 )
intentsId.append( intent1 )
time.sleep( 5 )
- intent2 = main.CLIs[ 0 ].addPointIntent( ingressDevice=egressDevice,
- egressDevice=ingressDevice,
- portIngress=egressPort,
- portEgress=ingressPort,
+ intent2 = main.CLIs[ 0 ].addPointIntent( ingressDevice=deviceId2,
+ egressDevice=deviceId1,
+ portIngress=port2,
+ portEgress=port1,
ethType=ethType,
- ethSrc=ethDst,
- ethDst=ethSrc,
+ ethSrc=mac2,
+ ethDst=mac1,
bandwidth=bandwidth,
lambdaAlloc=lambdaAlloc,
ipProto=ipProto,
- ipSrc=ipDst,
- ipDst=ipSrc,
- tcpSrc=tcpDst,
- tcpDst=tcpSrc )
+ ipSrc=ip2,
+ ipDst=ip1,
+ tcpSrc=tcp2,
+ tcpDst=tcp1 )
intentsId.append( intent2 )
# Check intents state
@@ -228,33 +226,34 @@
pingResult = pingHost( main, h1Name, h2Name )
time.sleep( 5 )
- # link down
- link( main, sw1, sw2, "down" )
- intentResult = intentResult and checkIntentState( main, intentsId )
+ if sw1 and sw2 and expectedLink:
+ # link down
+ link( main, sw1, sw2, "down" )
+ intentResult = intentResult and checkIntentState( main, intentsId )
- # Verify flows
- checkFlowsState( main )
+ # Verify flows
+ checkFlowsState( main )
- # Check OnosTopology
- topoResult = checkTopology( main, expectLink )
+ # Check OnosTopology
+ topoResult = checkTopology( main, expectedLink )
- # Ping hosts
- pingResult = pingResult and pingHost( main, h1Name, h2Name )
+ # Ping hosts
+ pingResult = pingResult and pingHost( main, h1Name, h2Name )
- intentResult = checkIntentState( main, intentsId )
+ intentResult = checkIntentState( main, intentsId )
- # link up
- link( main, sw1, sw2, "up" )
- time.sleep( 5 )
+ # link up
+ link( main, sw1, sw2, "up" )
+ time.sleep( 5 )
- # Verify flows
- checkFlowsState( main )
+ # Verify flows
+ checkFlowsState( main )
- # Check OnosTopology
- topoResult = checkTopology( main, expectLink )
+ # Check OnosTopology
+ topoResult = checkTopology( main, expectedLink )
- # Ping hosts
- pingResult = pingResult and pingHost( main, h1Name, h2Name )
+ # Ping hosts
+ pingResult = pingResult and pingHost( main, h1Name, h2Name )
# Remove intents
for intent in intentsId:
@@ -295,10 +294,43 @@
"both hosts" )
return pingResult
-def checkItem( item ):
+def getHostsData( main ):
"""
- Checks the dictionary
+ 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 )
+ 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' ]
+
+ print main.hostsData
+ return pingResult
def checkTopology( main, expectedLink ):
statusResult = main.TRUE
diff --git a/TestON/tests/FuncIntent/FuncIntent.params b/TestON/tests/FuncIntent/FuncIntent.params
index 14bda6d..8a1ce1d 100755
--- a/TestON/tests/FuncIntent/FuncIntent.params
+++ b/TestON/tests/FuncIntent/FuncIntent.params
@@ -1,6 +1,6 @@
<PARAMS>
- <testcases>10,11,12,1001,1002</testcases>
+ <testcases>10,11,12,1002</testcases>
<SCALE>1,3</SCALE>
<availableNodes>3</availableNodes>
diff --git a/TestON/tests/FuncIntent/FuncIntent.py b/TestON/tests/FuncIntent/FuncIntent.py
index 2ffb25f..19a3c4a 100644
--- a/TestON/tests/FuncIntent/FuncIntent.py
+++ b/TestON/tests/FuncIntent/FuncIntent.py
@@ -52,6 +52,7 @@
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 ) ) )
@@ -241,6 +242,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 ):
"""
@@ -282,45 +296,41 @@
assert main.numSwitch, "Placed the total number of switch topology in \
main.numSwitch"
- # Local variables
- 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', 'expect':'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', 'expect':'18' } }
-
main.case( "Add host intents between 2 host" )
stepResult = main.TRUE
- main.step( ipv4[ 'name' ] + ": Add host intents between " +
- ipv4[ 'host1' ][ 'name' ] + " and " +
- ipv4[ 'host2' ][ 'name' ] )
- stepResult = main.wrapper.addHostIntent( main, ipv4 )
- utilities.assert_equals( expect=main.TRUE,
- actual=stepResult,
- onpass=ipv4[ 'name' ] +
- ": Add host intent successful",
- onfail=ipv4[ 'name' ] +
- ": Add host intent failed" )
+ 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 )
- stepResult = main.TRUE
- main.step( dualStack1[ 'name' ] + ": Add host intents between " +
- dualStack1[ 'host1' ][ 'name' ] + " and " +
- dualStack1[ 'host2' ][ 'name' ] )
- stepResult = main.wrapper.addHostIntent( main, dualStack1 )
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
- onpass=dualStack1[ 'name' ] +
- ": Add host intent successful",
- onfail=dualStack1[ 'name' ] +
- ": Add host intent failed" )
+ onpass="IPV4: Add host intent successful",
+ onfail="IPV4: Add host intent failed" )
+ stepResult = main.TRUE
+
+ 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 )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="DUALSTACK: Add host intent successful",
+ onfail="DUALSTACK: Add host intent failed" )
def CASE1002( self, main ):
"""
@@ -368,7 +378,7 @@
'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' } }
+ 'switch2':'s2', 'expect':'18' } }
"""
ipv4 = { 'name':'IPV4', 'ingressDevice':'of:0000000000000005/1' ,
@@ -376,7 +386,7 @@
'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':
@@ -384,20 +394,37 @@
'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[ 'name' ] + ": Add point intents between " +
- ipv4[ 'host1' ][ 'name' ] + " and " +
- ipv4[ 'host2' ][ 'name' ] )
- stepResult = main.wrapper.addPointIntent( main, ipv4 )
+ 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[ 'name' ] +
- ": Point intent successful",
- onfail=ipv4[ 'name' ] +
- ": Point intent failed" )
+ onpass="IPV4: Add point intent successful",
+ onfail="IPV4: Add point intent failed" )
def CASE1003( self, main ):
"""