Merge "Minor fix to return values and error checks in OnosCliDriver"
diff --git a/TestON/drivers/common/api/controller/onosrestdriver.py b/TestON/drivers/common/api/controller/onosrestdriver.py
index 1b7c8fd..08f242d 100644
--- a/TestON/drivers/common/api/controller/onosrestdriver.py
+++ b/TestON/drivers/common/api/controller/onosrestdriver.py
@@ -431,7 +431,7 @@
main.exit()
def addHostIntent( self, hostIdOne, hostIdTwo, appId='org.onosproject.cli',
- ip="DEFAULT", port="DEFAULT" ):
+ ip="DEFAULT", port="DEFAULT", vlanId="" ):
"""
Description:
Adds a host-to-host intent ( bidirectional ) by
@@ -454,6 +454,9 @@
"constraints": [{"type": "LinkTypeConstraint",
"types": ["OPTICAL"],
"inclusive": 'false' }]}
+ if vlanId:
+ intentJson[ 'selector' ][ 'criteria' ].append( { "type":"VLAN_VID",
+ "vlanId":vlanId } )
output = None
if ip == "DEFAULT":
main.log.warn( "No ip given, reverting to ip from topo file" )
@@ -501,7 +504,8 @@
tcpSrc="",
tcpDst="",
ip="DEFAULT",
- port="DEFAULT" ):
+ port="DEFAULT",
+ vlanId="" ):
"""
Description:
Adds a point-to-point intent ( uni-directional ) by
@@ -599,6 +603,10 @@
intentJson[ 'selector' ][ 'criteria' ].append(
{ "type":"IP_PROTO",
"protocol": ipProto } )
+ if vlanId:
+ intentJson[ 'selector' ][ 'criteria' ].append(
+ { "type":"VLAN_VID",
+ "vlanId": vlanId } )
# TODO: Bandwidth and Lambda will be implemented if needed
diff --git a/TestON/tests/FUNC/FUNCintentRest/FUNCintentRest.py b/TestON/tests/FUNC/FUNCintentRest/FUNCintentRest.py
index f48ae3b..60fc47f 100644
--- a/TestON/tests/FUNC/FUNCintentRest/FUNCintentRest.py
+++ b/TestON/tests/FUNC/FUNCintentRest/FUNCintentRest.py
@@ -941,8 +941,8 @@
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" }
+ host1 = { "name":"h4","id":"00:00:00:00:00:04/100", "vlanId":"100" }
+ host2 = { "name":"h12","id":"00:00:00:00:00:0C/100", "vlanId":"100" }
testResult = main.FALSE
installResult = main.intentFunction.installHostIntent( main,
name='VLAN1',
@@ -966,32 +966,33 @@
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.intentFunction.installHostIntent( main,
- name='VLAN2',
- onosNode='0',
- host1=host1,
- host2=host2 )
+ # This step isn't currently possible to perform in the REST API
+ # 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.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 )
+ # if installResult:
+ # testResult = main.intentFunction.testHostIntent( main,
+ # name='VLAN2',
+ # 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 )
+ # utilities.assert_equals( expect=main.TRUE,
+ # actual=testResult,
+ # onpass=main.assertReturnString,
+ # onfail=main.assertReturnString )
# Change the following to use the REST API when leader checking is
# supported by it
@@ -1194,7 +1195,8 @@
recipients=recipients,
sw1="s5",
sw2="s2",
- expectedLink=18)
+ expectedLink=18,
+ useTCP=True )
utilities.assert_equals( expect=main.TRUE,
actual=testResult,
@@ -1266,23 +1268,22 @@
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" }
+ { "name":"h5","device":"of:0000000000000005/5","mac":"00:00:00:00:00:05", "vlanId":"200" }
]
recipients = [
- { "name":"h21","device":"of:0000000000000007/5","mac":"00:00:00:00:00:15" }
+ { "name":"h21","device":"of:0000000000000007/5","mac":"00:00:00:00:00:15", "vlanId":"200" }
]
installResult = main.intentFunction.installPointIntent(
main,
- name="DUALSTACK1",
+ name="VLAN",
senders=senders,
- recipients=recipients,
- ethType="IPV4" )
+ recipients=recipients )
if installResult:
testResult = main.intentFunction.testPointIntent(
main,
intentId=installResult,
- name="DUALSTACK1",
+ name="VLAN",
senders=senders,
recipients=recipients,
sw1="s5",
@@ -1294,6 +1295,8 @@
onpass=main.assertReturnString,
onfail=main.assertReturnString )
+ # TODO: implement VLAN selector REST API intent test once supported
+
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 = [
diff --git a/TestON/tests/FUNC/FUNCintentRest/dependencies/FuncIntentFunction.py b/TestON/tests/FUNC/FUNCintentRest/dependencies/FuncIntentFunction.py
index 4ad42b2..cefb077 100644
--- a/TestON/tests/FUNC/FUNCintentRest/dependencies/FuncIntentFunction.py
+++ b/TestON/tests/FUNC/FUNCintentRest/dependencies/FuncIntentFunction.py
@@ -75,12 +75,14 @@
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( "id" )
+ vlanId = host1.get( "vlanId" )
# Adding host intents
main.log.info( itemName + ": Adding host intents" )
intent1 = main.CLIs[ onosNode ].addHostIntent( hostIdOne=host1.get( "id" ),
- hostIdTwo=host2.get( "id" ) )
+ hostIdTwo=host2.get( "id" ),
+ vlanId=vlanId )
# Get all intents ID in the system, time delay right after intents are added
time.sleep( main.addIntentSleep )
@@ -175,6 +177,7 @@
senderNames = [ host1.get( "name" ), host2.get( "name" ) ]
recipientNames = [ host1.get( "name" ), host2.get( "name" ) ]
+ vlanId = host1.get( "vlanId" )
except ( KeyError, TypeError ):
main.log.error( "There was a problem loading the hosts data." )
return main.FALSE
@@ -197,7 +200,7 @@
testResult = main.FALSE
# Check Connectivity
- if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, recipientNames ) ):
+ if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, recipientNames, vlanId ) ):
main.assertReturnString += 'Initial Ping Passed\n'
else:
main.assertReturnString += 'Initial Ping Failed\n'
@@ -234,7 +237,7 @@
testResult = main.FALSE
# Check Connection
- if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, recipientNames ) ):
+ if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, recipientNames, vlanId ) ):
main.assertReturnString += 'Link Down Pingall Passed\n'
else:
main.assertReturnString += 'Link Down Pingall Failed\n'
@@ -272,7 +275,7 @@
testResult = main.FALSE
# Check Connection
- if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, recipientNames ) ):
+ if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, recipientNames, vlanId ) ):
main.assertReturnString += 'Link Up Pingall Passed\n'
else:
main.assertReturnString += 'Link Up Pingall Failed\n'
@@ -357,6 +360,7 @@
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" )
+ vlanId = senders[ 0 ].get( "vlanId" )
ingressDevice = senders[ 0 ].get( "device" )
@@ -387,7 +391,8 @@
ipSrc=ipSrc,
ipDst=ipDst,
tcpSrc=tcpSrc,
- tcpDst=tcpDst )
+ tcpDst=tcpDst,
+ vlanId=vlanId )
time.sleep( main.addIntentSleep )
intentsId = main.CLIs[ 0 ].getIntentsId()
@@ -422,7 +427,8 @@
tcp="",
sw1="s5",
sw2="s2",
- expectedLink=0):
+ expectedLink=0,
+ useTCP=False ):
"""
Test a Point Intent
@@ -500,6 +506,7 @@
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" )
+ vlanId=senders[ 0 ].get( "vlanId" )
except (KeyError, TypeError):
main.log.error( "There was a problem loading the hosts data." )
return main.FALSE
@@ -522,7 +529,7 @@
testResult = main.FALSE
# Check Connectivity
- if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, recipientNames ) ):
+ if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, recipientNames, vlanId, useTCP ) ):
main.assertReturnString += 'Initial Ping Passed\n'
else:
main.assertReturnString += 'Initial Ping Failed\n'
@@ -576,7 +583,7 @@
testResult = main.FALSE
# Check Connection
- if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, recipientNames ) ):
+ if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, recipientNames, vlanId, useTCP ) ):
main.assertReturnString += 'Link Down Pingall Passed\n'
else:
main.assertReturnString += 'Link Down Pingall Failed\n'
@@ -614,7 +621,7 @@
testResult = main.FALSE
# Check Connection
- if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, recipientNames ) ):
+ if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, recipientNames, vlanId, useTCP ) ):
main.assertReturnString += 'Link Up Scapy Packet Received Passed\n'
else:
main.assertReturnString += 'Link Up Scapy Packet Recieved Failed\n'
@@ -1616,7 +1623,7 @@
main.log.error( "TypeError while populating hostsData" )
return main.FALSE
-def scapyCheckConnection( main, senders, recipients, packet=None, packetFilter=None, expectFailure=False ):
+def scapyCheckConnection( main, senders, recipients, vlanId=None, useTCP=False, 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
@@ -1630,7 +1637,8 @@
if not packetFilter:
packetFilter = 'ether host {}'
-
+ if useTCP:
+ packetFilter += ' ip proto \\tcp tcp port {}'.format(main.params[ 'SDNIP' ][ 'dstPort' ])
if expectFailure:
timeout = 1
else:
@@ -1655,17 +1663,31 @@
connectionsFunctional = main.FALSE
continue
- recipientComp.startFilter( pktFilter = packetFilter.format( senderComp.hostMac ) )
+ if vlanId:
+ recipientComp.startFilter( pktFilter = ( "vlan {}".format( vlanId ) + " && " + packetFilter.format( senderComp.hostMac ) ) )
+ else:
+ 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 )
+ if vlanId:
+ pkt = 'Ether( src="{0}", dst="{2}" )/Dot1Q(vlan={4})/IP( src="{1}", dst="{3}" )'.format(
+ senderComp.hostMac,
+ senderComp.hostIp,
+ recipientComp.hostMac,
+ recipientComp.hostIp,
+ vlanId )
+ else:
+ 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 vlanId:
+ senderComp.sendPacket( iface=( "{0}-eth0.{1}".format( sender, vlanId ) ), packet = pkt )
+ else:
+ senderComp.sendPacket( packet = pkt )
if recipientComp.checkFilter( timeout ):
if expectFailure:
diff --git a/TestON/tests/MISC/SCPFbatchFlowResp/SCPFbatchFlowResp.py b/TestON/tests/MISC/SCPFbatchFlowResp/SCPFbatchFlowResp.py
index ca5e240..b767835 100755
--- a/TestON/tests/MISC/SCPFbatchFlowResp/SCPFbatchFlowResp.py
+++ b/TestON/tests/MISC/SCPFbatchFlowResp/SCPFbatchFlowResp.py
@@ -184,8 +184,8 @@
cliResult = main.TRUE
for i in range( i, main.numCtrls ):
cliResult = cliResult and \
- main.CLIs[ i ].startOnosCli( ONOSIp=main.ONOSip[ i ] )
- main.log.info("ONOSip is: " + main.ONOSip[i])
+ main.ONOScli1.startCellCli( )
+ main.log.info("ONOSip is: " + main.ONOScli1.ip_address)
stepResult = cliResult
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
@@ -204,8 +204,7 @@
main.step("Activate openflow-base App")
app = main.params['CASE10']['app']
- stepResult = main.ONOSbench.onosCli( ONOSIp = main.ONOSip[0],
- cmdstr = "app activate " + app )
+ stepResult = main.ONOScli1.activateApp( app )
time.sleep(main.cfgSleep)
main.log.info(stepResult)
utilities.assert_equals( expect=main.TRUE,
@@ -216,9 +215,9 @@
time.sleep(main.cfgSleep)
- main.step( "Disable AdaptiveFlowSampling ")
- stepResult = main.ONOSbench.onosCfgSet( main.ONOSip[0], "org.onosproject.provider.of.flow.impl.OpenFlowRuleProvider",
- "adaptiveFlowSampling " + main.params['CASE10']['adaptiveFlowenabled'])
+ main.step( "Configure AdaptiveFlowSampling ")
+ stepResult = main.ONOScli1.setCfg( component = "org.onosproject.provider.of.flow.impl.OpenFlowRuleProvider",
+ propName = "adaptiveFlowSampling ", value = main.params['CASE10']['adaptiveFlowenabled'])
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
onpass="App Configuration Succeeded! ",
diff --git a/TestON/tests/MISC/__init__.py b/TestON/tests/MISC/__init__.py
new file mode 100755
index 0000000..e69de29
--- /dev/null
+++ b/TestON/tests/MISC/__init__.py