[ONOS-5037] Modify FUNCintentRest to test SinglePointToMultiPointIntent
Change-Id: I188e38f96fac1a52068009968b3823cb12a07247
diff --git a/TestON/tests/FUNC/FUNCintentRest/FUNCintentRest.params b/TestON/tests/FUNC/FUNCintentRest/FUNCintentRest.params
index 4b3af6a..7e8b105 100644
--- a/TestON/tests/FUNC/FUNCintentRest/FUNCintentRest.params
+++ b/TestON/tests/FUNC/FUNCintentRest/FUNCintentRest.params
@@ -20,8 +20,7 @@
# 4000 - Test multi to single point intents
# 5000 - Test host mobility
- <testcases>1,[2,10,12,13,15,16,1000,2000,5000,18,19]*2,[2,10,12,13,15,16,17,1000,2000,5000,18,19]*2,[2,11,12,13,15,16,1000,2000,5000,18,19]*2,[2,11,12,13,15,16,17,1000,2000,5000,18,19]*2</testcases>
-
+ <testcases>1,[2,10,12,13,15,16,1000,2000,3000,5000,18,19]*2,[2,10,12,13,15,16,17,1000,2000,3000,5000,18,19]*2,[2,11,12,13,15,16,1000,2000,3000,5000,18,19]*2,[2,11,12,13,15,16,17,1000,2000,3000,5000,18,19]*2</testcases>
<SCALE>
<size>1,3,1,3,1,3,1,3</size>
</SCALE>
@@ -66,6 +65,7 @@
<SDNIP>
<tcpProto>6</tcpProto>
<icmpProto>1</icmpProto>
+ <ipPrototype>6</ipPrototype>
<srcPort>5001</srcPort>
<dstPort>5001</dstPort>
</SDNIP>
diff --git a/TestON/tests/FUNC/FUNCintentRest/FUNCintentRest.py b/TestON/tests/FUNC/FUNCintentRest/FUNCintentRest.py
index b99d449..7a9d295 100644
--- a/TestON/tests/FUNC/FUNCintentRest/FUNCintentRest.py
+++ b/TestON/tests/FUNC/FUNCintentRest/FUNCintentRest.py
@@ -405,7 +405,8 @@
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 ] ) ) )
+ 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(
@@ -795,7 +796,8 @@
"/tmp/karaf.log",
direction="from" )
copyResult = copyResult and main.ONOSbench.cpLogsToDir( "/tmp/karaf.log", main.logdir,
- copyFileName=( "karaf.log.node{0}.cycle{1}".format( str( i + 1 ), str( main.cycle ) ) ) )
+ copyFileName=( "karaf.log.node{0}.cycle{1}".format(
+ str( i + 1 ), str( main.cycle ) ) ) )
if scpResult and copyResult:
stepResult = main.TRUE and stepResult
else:
@@ -1063,14 +1065,11 @@
- Ping hosts
- Remove intents
"""
- import time
- import json
- import re
if main.initialized == main.FALSE:
main.log.error( "Test components did not start correctly, skipping further tests" )
main.skipCase()
- # Assert variables - These variable's name|format must be followed
- # if you want to use the wrapper function
+ # Assert variables - These variable's name|format must be followed
+ # if you want to use the wrapper function
assert main, "There is no main"
try:
assert main.RESTs
@@ -1093,31 +1092,31 @@
main.skipCase()
main.case( "Point Intents 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" +\
+ " 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
+ # No option point intent
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" }
+ { "name": "h1", "device": "of:0000000000000005/1" }
]
recipients = [
- { "name":"h9","device":"of:0000000000000006/1" }
+ { "name": "h9", "device": "of:0000000000000006/1" }
]
testResult = main.FALSE
installResult = main.intentFunction.installPointIntent(
- main,
- name="NOOPTION",
- senders=senders,
- recipients=recipients )
+ main,
+ name="NOOPTION",
+ senders=senders,
+ recipients=recipients )
if installResult:
testResult = main.intentFunction.testPointIntent(
@@ -1138,17 +1137,17 @@
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" }
+ { "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" }
+ { "name": "h9", "device": "of:0000000000000006/1", "mac": "00:00:00:00:00:09" }
]
installResult = main.intentFunction.installPointIntent(
- main,
- name="IPV4",
- senders=senders,
- recipients=recipients,
- ethType="IPV4" )
+ main,
+ name="IPV4",
+ senders=senders,
+ recipients=recipients,
+ ethType="IPV4" )
if installResult:
testResult = main.intentFunction.testPointIntent(
@@ -1165,20 +1164,21 @@
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" }
+ { "name": "h1", "device": "of:0000000000000005/1" }
]
recipients = [
- { "name":"h9","device":"of:0000000000000006/1" }
+ { "name": "h9", "device": "of:0000000000000006/1" }
]
installResult = main.intentFunction.installPointIntent(
- main,
- name="IPV4_2",
- senders=senders,
- recipients=recipients,
- ethType="IPV4" )
+ main,
+ name="IPV4_2",
+ senders=senders,
+ recipients=recipients,
+ ethType="IPV4" )
if installResult:
testResult = main.intentFunction.testPointIntent(
@@ -1199,39 +1199,40 @@
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 }
+ { "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 }
+ { "name": "h9", "device": "of:0000000000000006/1", "mac": "00:00:00:00:00:09",
+ "ip": ( main.h9.hostIp + "/24" ) }
]
- ipProto = main.params[ 'SDNIP' ][ 'icmpProto' ]
+ # ipProto = main.params['SDNIP']['icmpProto']
+ ipProto = main.params[ 'SDNIP' ][ 'ipPrototype' ]
# Uneccessary, not including this in the selectors
- tcpSrc = main.params[ 'SDNIP' ][ 'srcPort' ]
- tcpDst = main.params[ 'SDNIP' ][ 'dstPort' ]
+ tcpSrc = main.params['SDNIP']['srcPort']
+ tcpDst = main.params['SDNIP']['dstPort']
installResult = main.intentFunction.installPointIntent(
- main,
- name="SDNIP-ICMP",
- senders=senders,
- recipients=recipients,
- ethType="IPV4",
- ipProto=ipProto,
- tcpSrc=tcpSrc,
- tcpDst=tcpDst )
+ 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,
- useTCP=True )
+ main,
+ intentId=installResult,
+ name="SDNIP_ICMP",
+ senders=senders,
+ recipients=recipients,
+ sw1="s5",
+ sw2="s2",
+ expectedLink=18,
+ useTCP=True )
utilities.assert_equals( expect=main.TRUE,
actual=testResult,
@@ -1240,60 +1241,60 @@
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' ]
+ 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 )
+ 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,
+ 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" }
+ { "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" }
+ { "name": "h11", "device": "of:0000000000000006/3", "mac": "00:00:00:00:00:0B" }
]
installResult = main.intentFunction.installPointIntent(
- main,
- name="DUALSTACK1",
- senders=senders,
- recipients=recipients,
- ethType="IPV4" )
+ 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 )
+ main,
+ intentId=installResult,
+ name="DUALSTACK1",
+ senders=senders,
+ recipients=recipients,
+ sw1="s5",
+ sw2="s2",
+ expectedLink=18 )
utilities.assert_equals( expect=main.TRUE,
actual=testResult,
@@ -1303,16 +1304,16 @@
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", "vlanId":"200" }
+ { "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", "vlanId":"200" }
+ { "name": "h21", "device": "of:0000000000000007/5", "mac": "00:00:00:00:00:15", "vlanId": "200" }
]
installResult = main.intentFunction.installPointIntent(
- main,
- name="VLAN",
- senders=senders,
- recipients=recipients )
+ main,
+ name="VLAN",
+ senders=senders,
+ recipients=recipients )
if installResult:
testResult = main.intentFunction.testPointIntent(
@@ -1335,17 +1336,17 @@
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" }
+ { "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" }
+ { "name": "h3", "device": "of:0000000000000005/3", "mac": "00:00:00:00:00:03" }
]
installResult = main.intentFunction.installPointIntent(
- main,
- name="1HOP IPV4",
- senders=senders,
- recipients=recipients,
- ethType="IPV4" )
+ main,
+ name="1HOP IPV4",
+ senders=senders,
+ recipients=recipients,
+ ethType="IPV4" )
if installResult:
testResult = main.intentFunction.testPointIntent(
@@ -1365,6 +1366,7 @@
main.intentFunction.report( main )
+
def CASE3000( self, main ):
"""
Add single point to multi point intents
@@ -1384,127 +1386,229 @@
- Ping hosts
- Remove intents
"""
+ if main.initialized == main.FALSE:
+ main.log.error( "Test components did not start correctly, skipping further tests" )
+ main.skipCase()
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( "Single To Multi Point Intents 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" +\
+ try:
+ assert main.CLIs, "There is no main.CLIs, skipping test cases"
+ assert main.Mininet1, "Mininet handle should be named Mininet1, skipping test cases"
+ assert main.numSwitch, "Place the total number of switch topology in main.numSwitch"
+ except AssertionError:
+ main.initialized = main.FALSE
+ main.skipCase()
+
+ 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: Add single point to multi point intents" )
- stepResult = main.TRUE
- hostNames = [ 'h8', 'h16', 'h24' ]
- devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', \
- 'of:0000000000000007/8' ]
- macs = [ '00:00:00:00:00:08', '00:00:00:00:00:10', '00:00:00:00:00:18' ]
- stepResult = main.intentFunction.singleToMultiIntent(
- main,
- name="NOOPTION",
- hostNames=hostNames,
- devices=devices,
- sw1="s5",
- sw2="s2",
- expectedLink=18 )
+ 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.intentFunction.installSingleToMultiIntent(
+ main,
+ name="NOOPTION",
+ senders=senders,
+ recipients=recipients )
+
+ 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=stepResult,
- onpass="NOOPTION: Successfully added single "
- + " point to multi point intents" +
- " with no match action",
- onfail="NOOPTION: Failed to add single point"
- + " point to multi point intents" +
- " with no match action" )
+ actual=testResult,
+ onpass=main.assertReturnString,
+ onfail=main.assertReturnString )
- main.step( "IPV4: Add single point to multi point intents" )
- stepResult = main.TRUE
- stepResult = main.intentFunction.singleToMultiIntent(
- main,
- name="IPV4",
- hostNames=hostNames,
- devices=devices,
- ports=None,
- ethType="IPV4",
- macs=macs,
- bandwidth="",
- lambdaAlloc=False,
- ipProto="",
- ipAddresses="",
- tcp="",
- sw1="s5",
- sw2="s2",
- expectedLink=18 )
+ 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
+ installResult = main.intentFunction.installSingleToMultiIntent(
+ main,
+ name="IPV4",
+ senders=senders,
+ recipients=recipients,
+ ethType="IPV4")
+
+ 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=stepResult,
- onpass="IPV4: Successfully added single "
- + " point to multi point intents" +
- " with IPV4 type and MAC addresses",
- onfail="IPV4: Failed to add single point"
- + " point to multi point intents" +
- " with IPV4 type and MAC addresses" )
+ actual=testResult,
+ onpass=main.assertReturnString,
+ onfail=main.assertReturnString )
main.step( "IPV4_2: Add single point to multi point intents" )
- stepResult = main.TRUE
- hostNames = [ 'h8', 'h16', 'h24' ]
- stepResult = main.intentFunction.singleToMultiIntent(
- main,
- name="IPV4",
- hostNames=hostNames,
- ethType="IPV4",
- lambdaAlloc=False )
+ 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
+ installResult = main.intentFunction.installSingleToMultiIntent(
+ 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,
+ badSenders=badSenders,
+ badRecipients=badRecipients,
+ sw1="s5",
+ sw2="s2",
+ expectedLink=18 )
+ else:
+ main.CLIs[ 0 ].removeAllIntents( purge=True )
utilities.assert_equals( expect=main.TRUE,
- actual=stepResult,
- onpass="IPV4_2: Successfully added single "
- + " point to multi point intents" +
- " with IPV4 type and no MAC addresses",
- onfail="IPV4_2: Failed to add single point"
- + " point to multi point intents" +
- " with IPV4 type and no MAC addresses" )
+ actual=testResult,
+ onpass=main.assertReturnString,
+ onfail=main.assertReturnString )
main.step( "VLAN: Add single point to multi point intents" )
- stepResult = main.TRUE
- hostNames = [ 'h4', 'h12', 'h20' ]
- devices = [ 'of:0000000000000005/4', 'of:0000000000000006/4', \
- 'of:0000000000000007/4' ]
- macs = [ '00:00:00:00:00:04', '00:00:00:00:00:0C', '00:00:00:00:00:14' ]
- stepResult = main.intentFunction.singleToMultiIntent(
- main,
- name="VLAN",
- hostNames=hostNames,
- devices=devices,
- ports=None,
- ethType="IPV4",
- macs=macs,
- bandwidth="",
- lambdaAlloc=False,
- ipProto="",
- ipAddresses="",
- tcp="",
- sw1="s5",
- sw2="s2",
- expectedLink=18 )
+ 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", "vlan": "100" }
+ ]
+ recipients = [
+ { "name": "h12", "device": "of:0000000000000006/4", "mac": "00:00:00:00:00:0C", "vlan": "100" },
+ { "name": "h20", "device": "of:0000000000000007/4", "mac": "00:00:00:00:00:14", "vlan": "100" }
+ ]
+ badSenders = [ { "name": "h13" } ] # Senders that are not in the intent
+ badRecipients = [ { "name": "h21" } ] # Recipients that are not in the intent
+ installResult = main.intentFunction.installSingleToMultiIntent(
+ main,
+ name="VLAN",
+ senders=senders,
+ recipients=recipients,
+ 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()
utilities.assert_equals( expect=main.TRUE,
- actual=stepResult,
- onpass="VLAN: Successfully added single "
- + " point to multi point intents" +
- " with IPV4 type and MAC addresses" +
- " in the same VLAN",
- onfail="VLAN: Failed to add single point"
- + " point to multi point intents" +
- " with IPV4 type and MAC addresses" +
- " in the same VLAN")
+ actual=testResult,
+ onpass=main.assertReturnString,
+ onfail=main.assertReturnString )
+
+ main.step( "VLAN: Add single point to multi point intents" )
+ main.assertReturnString = "Assertion results for single to multi point intent with VLAN treatment\n"
+ senders = [
+ { "name": "h5", "vlan": "200" }
+ ]
+ recipients = [
+ { "name": "h12", "device": "of:0000000000000006/4", "mac": "00:00:00:00:00:0C", "vlan": "100" },
+ { "name": "h20", "device": "of:0000000000000007/4", "mac": "00:00:00:00:00:14", "vlan": "100" }
+ ]
+ 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.intentFunction.installSingleToMultiIntent(
+ main,
+ name="VLAN2",
+ senders=senders,
+ recipients=recipients,
+ sw1="s5",
+ sw2="s2" )
+ #setVlan=100 )
+
+ if installResult:
+ testResult = main.intentFunction.testPointIntent(
+ main,
+ intentId=installResult,
+ name="VLAN2",
+ senders=senders,
+ recipients=recipients,
+ badSenders=badSenders,
+ badRecipients=badRecipients,
+ sw1="s5",
+ sw2="s2",
+ expectedLink=18 )
+ else:
+ main.CLIs[ 0 ].removeAllIntents()
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=testResult,
+ onpass=main.assertReturnString,
+ onfail=main.assertReturnString )
+
+ main.intentFunction.report( main )
def CASE4000( self, main ):
"""
@@ -1729,5 +1833,4 @@
onpass=main.assertReturnString,
onfail=main.assertReturnString )
- main.intentFunction.report( main )
-
+ main.intentFunction.report( main )
\ No newline at end of file
diff --git a/TestON/tests/FUNC/FUNCintentRest/dependencies/FuncIntentFunction.py b/TestON/tests/FUNC/FUNCintentRest/dependencies/FuncIntentFunction.py
index 1d4499c..088d38d 100755
--- a/TestON/tests/FUNC/FUNCintentRest/dependencies/FuncIntentFunction.py
+++ b/TestON/tests/FUNC/FUNCintentRest/dependencies/FuncIntentFunction.py
@@ -886,22 +886,21 @@
return stepResult
-def singleToMultiIntent( main,
- name,
- hostNames,
- onosNode=0,
- devices="",
- ports=None,
- ethType="",
- macs=None,
- bandwidth="",
- lambdaAlloc=False,
- ipProto="",
- ipAddresses="",
- tcp="",
- sw1="",
- sw2="",
- expectedLink=0 ):
+
+def installSingleToMultiIntent( main,
+ name,
+ senders,
+ recipients,
+ onosNode=0,
+ ethType="",
+ bandwidth="",
+ lambdaAlloc=False,
+ ipProto="",
+ ipAddresses="",
+ tcp="",
+ sw1="",
+ sw2="",
+ partial=False ):
"""
Verify Single to Multi Point intents
NOTE:If main.hostsData is not defined, variables data should be passed
@@ -958,176 +957,85 @@
"""
assert main, "There is no main variable"
- assert hostNames, "You must specify hosts"
- assert devices or main.hostsData, "You must specify devices"
+ 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
+ global itemName # The name of this run. Used for logs.
itemName = name
- tempHostsData = {}
- intentsId = []
onosNode = int( onosNode )
- macsDict = {}
- ipDict = {}
- if hostNames and devices:
- if len( hostNames ) != len( devices ):
- main.log.debug( "hosts and devices does not have the same length" )
- #print "len hostNames = ", len( hostNames )
- #print "len devices = ", len( devices )
- return main.FALSE
- if ports:
- if len( ports ) != len( devices ):
- main.log.error( "Ports and devices does " +
- "not have the same length" )
- #print "len devices = ", len( devices )
- #print "len ports = ", len( ports )
- return main.FALSE
- else:
- main.log.info( "Device Ports are not specified" )
- if macs:
- for i in range( len( devices ) ):
- macsDict[ devices[ i ] ] = macs[ i ]
-
- elif hostNames and not devices and main.hostsData:
- devices = []
- main.log.info( "singleToMultiIntent function is using main.hostsData" )
- for host in hostNames:
- devices.append( main.hostsData.get( host ).get( 'location' ) )
- macsDict[ main.hostsData.get( host ).get( 'location' ) ] = \
- main.hostsData.get( host ).get( 'mac' )
- ipDict[ main.hostsData.get( host ).get( 'location' ) ] = \
- main.hostsData.get( host ).get( 'ipAddresses' )
- #print main.hostsData
-
- #print 'host names = ', hostNames
- #print 'devices = ', devices
- #print "macsDict = ", macsDict
-
- pingResult = main.TRUE
- intentResult = main.TRUE
- removeIntentResult = main.TRUE
- flowResult = main.TRUE
- topoResult = main.TRUE
- linkDownResult = main.TRUE
- linkUpResult = main.TRUE
-
- devicesCopy = copy.copy( devices )
- if ports:
- portsCopy = copy.copy( ports )
main.log.info( itemName + ": Adding single point to multi point intents" )
- # Check flows count in each node
- checkFlowsCount( main )
+ try:
+ 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" )
- # Adding bidirectional point intents
- for i in range( len( devices ) ):
- ingressDevice = devicesCopy[ i ]
- egressDeviceList = copy.copy( devicesCopy )
- egressDeviceList.remove( ingressDevice )
- if ports:
- portIngress = portsCopy[ i ]
- portEgressList = copy.copy( portsCopy )
- del portEgressList[ i ]
- else:
- portIngress = ""
- portEgressList = None
- if not macsDict:
- srcMac = ""
- else:
- srcMac = macsDict[ ingressDevice ]
- if srcMac == None:
- main.log.debug( "There is no MAC in device - " + ingressDevice )
- srcMac = ""
+ 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" )
+ vlanId = senders[ 0 ].get( "vlanId" )
- intentsId.append(
- main.RESTs[ onosNode ].addSinglepointToMultipointIntent(
+ 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 = []
+
+ main.log.debug( ingressDevice )
+ main.log.debug( egressDeviceList )
+
+ srcMac = senders[ 0 ].get( "mac" )
+ dstMac = []
+ for r in recipients:
+ mac = r.get( "mac" )
+ dstMac.append( mac )
+
+ ipSrc = senders[ 0 ].get( "ip" )
+ ipDst = []
+ for r in recipients:
+ ip = r.get( "ip" )
+ ipDst.append( ip )
+
+ # Adding point intent
+ intentId = main.RESTs[ onosNode ].addSinglepointToMultipointIntent(
ingressDevice=ingressDevice,
egressDeviceList=egressDeviceList,
portIngress=portIngress,
portEgressList=portEgressList,
ethType=ethType,
ethSrc=srcMac,
+ #ethDst=dstMac, #Isn't working because of ONOS itself
bandwidth=bandwidth,
lambdaAlloc=lambdaAlloc,
ipProto=ipProto,
- ipSrc="",
- ipDst="",
+ ipSrc=ipSrc,
+ ipDst=ipDst,
tcpSrc="",
- tcpDst="" ) )
+ tcpDst="",
+ vlanId=vlanId,
+ partial=partial )
- # Wait some time for the flow to go through when using multi instance
- pingResult = pingallHosts( main, hostNames )
+ time.sleep( main.addIntentSleep )
+ intentsId = main.RESTs[ 0 ].getIntentsId()
+ except ( KeyError, TypeError ):
+ errorMsg = "There was a problem loading the hosts data."
+ if intentId:
+ errorMsg += " There was a problem installing Singlepoint to Multipoint intent."
+ main.log.error( errorMsg )
+ return main.FALSE
# Check intents state
- time.sleep( main.checkIntentSleep )
- intentResult = checkIntentState( main, intentsId )
-
- # 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 )
-
- pingResult = pingResult and pingallHosts( main, hostNames )
-
- # Test rerouting if these variables exist
- if sw1 and sw2 and expectedLink:
- # link down
- linkDownResult = link( main, sw1, sw2, "down" )
- intentResult = intentResult and checkIntentState( main, intentsId )
-
- # Check flows count in each node
- checkFlowsCount( main )
- # Verify flows
- checkFlowsState( main )
-
- # Check OnosTopology
- topoResult = checkTopology( main, expectedLink )
-
- # Ping hosts
- pingResult = pingResult and pingallHosts( main, hostNames )
-
- intentResult = checkIntentState( main, intentsId )
-
- # Checks ONOS state in link down
- if linkDownResult and topoResult and pingResult 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" )
- time.sleep( main.rerouteSleep )
-
- # Check flows count in each node
- checkFlowsCount( main )
- # Verify flows
- checkFlowsState( main )
-
- # Check OnosTopology
- topoResult = checkTopology( main, main.numLinks )
-
- # Ping hosts
- pingResult = pingResult and pingallHosts( main, hostNames )
-
- intentResult = checkIntentState( main, intentsId )
-
- # Checks ONOS state in link up
- if linkUpResult and topoResult and pingResult 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 )
-
- stepResult = pingResult and linkDownResult and linkUpResult \
- and intentResult and removeIntentResult
-
- return stepResult
+ if utilities.retry( f=checkIntentState, retValue=main.FALSE, args=( main, intentsId ), sleep=main.checkIntentSleep ):
+ return intentsId
+ else:
+ main.log.error( "Single to Multi Intent did not install correctly" )
+ return main.FALSE
def multiToSingleIntent( main,
name,
@@ -1822,4 +1730,4 @@
return main.FALSE
else:
return main.FALSE
- return main.TRUE
\ No newline at end of file
+ return main.TRUE