[ONOS-7356] Decouple Scapy from TestON tests
- Create MininetScapyCliDriver for mininet based scapy tests
- Move scapy related setup to a single test case in FUNCflow and
FUNCgroup
Change-Id: I02e628b1fda6e6f6f7cafde420749ddda88e898f
diff --git a/TestON/tests/FUNC/FUNCbgpls/FUNCbgpls.topo b/TestON/tests/FUNC/FUNCbgpls/FUNCbgpls.topo
index c8b48a0..1dd294d 100755
--- a/TestON/tests/FUNC/FUNCbgpls/FUNCbgpls.topo
+++ b/TestON/tests/FUNC/FUNCbgpls/FUNCbgpls.topo
@@ -25,7 +25,7 @@
<host>OCN</host>
<user>sdn</user>
<password>rocks</password>
- <type>ScapyCliDriver</type>
+ <type>MininetScapyCliDriver</type>
<connect_order>2</connect_order>
<COMPONENTS>
<prompt></prompt>
diff --git a/TestON/tests/FUNC/FUNCflow/FUNCflow.params b/TestON/tests/FUNC/FUNCflow/FUNCflow.params
index 6eda334..f40372c 100755
--- a/TestON/tests/FUNC/FUNCflow/FUNCflow.params
+++ b/TestON/tests/FUNC/FUNCflow/FUNCflow.params
@@ -6,6 +6,8 @@
# 1 - Variable initialization and optional pull and build ONOS package
# 2 - install ONOS
# 10 - Start mininet and verify topology
+ # 11 - Start mininet scapy hosts
+ # 12 - Stop mininet and scapy hosts
# 66 - Testing Scapy
# 100 - Check logs for Errors and Warnings
# 1000 - Add flows with MAC selector
@@ -21,7 +23,7 @@
# 2000 - Add flows with ICMPv6 selector
# 3000 - Delete flows
- <testcases>1,2,10,1000,3000,1100,3000,1200,3000,1300,3000,1400,3000,1500,3000,1600,3000,1700,3000,1800,3000,1900,3000,2000,100</testcases>
+ <testcases>1,2,10,11,1000,3000,1100,3000,1200,3000,1300,3000,1400,3000,1500,3000,1600,3000,1700,3000,1800,3000,1900,3000,2000,12,100</testcases>
<GRAPH>
<nodeCluster>VM</nodeCluster>
@@ -82,4 +84,8 @@
<delFlow>10</delFlow>
</SLEEP>
+ <SCAPY>
+ <HOSTNAMES>h1,h2,h3,h4,h5,h6</HOSTNAMES>
+ </SCAPY>
+
</PARAMS>
diff --git a/TestON/tests/FUNC/FUNCflow/FUNCflow.py b/TestON/tests/FUNC/FUNCflow/FUNCflow.py
index 7f2f01c..f161202 100644
--- a/TestON/tests/FUNC/FUNCflow/FUNCflow.py
+++ b/TestON/tests/FUNC/FUNCflow/FUNCflow.py
@@ -59,6 +59,8 @@
main.delFlowSleep = int( main.params[ 'SLEEP' ][ 'delFlow' ] )
main.debug = main.params[ 'DEBUG' ]
main.swDPID = main.params[ 'TEST' ][ 'swDPID' ]
+ main.scapyHostNames = main.params[ 'SCAPY' ][ 'HOSTNAMES' ].split( ',' )
+ main.scapyHosts = [] # List of scapy hosts for iterating
main.debug = True if "on" in main.debug else False
@@ -145,17 +147,77 @@
main.topoRelated.compareTopos( main.Mininet1 )
+ def CASE11( self, main ):
+ """
+ Start Scapy with Mininet
+ """
+ main.case( "Starting scapy with Mininet" )
+ main.step( "Creating Host component" )
+ scapyResult = main.TRUE
+ for hostName in main.scapyHostNames:
+ main.Scapy.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 CASE12( self, main ):
+ """
+ Stop mininet and remove scapy host
+ """
+ try:
+ from tests.dependencies.utils import Utils
+ except ImportError:
+ main.log.error( "Utils not found exiting the test" )
+ main.cleanAndExit()
+ try:
+ main.Utils
+ except ( NameError, AttributeError ):
+ main.Utils = Utils()
+ 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.Scapy.removeHostComponent( host.name )
+ main.log.info( "Removed Scapy Host Component: {0}".format( host.name ) )
+
+ main.scapyHosts = []
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=scapyResult,
+ onpass="Successfully stopped scapy and removed host components",
+ onfail="Failed to stop mininet and scapy" )
+
+ mininetResult = main.Utils.mininetCleanup( main.Mininet1 )
+ # Exit if topology did not load properly
+ if not ( mininetResult and scapyResult ):
+ main.cleanAndExit()
+
def CASE66( self, main ):
"""
Testing scapy
"""
main.case( "Testing scapy" )
- main.step( "Creating Host1 component" )
- main.Scapy.createHostComponent( "h1" )
- main.Scapy.createHostComponent( "h2" )
- hosts = [ main.h1, main.h2 ]
- for host in hosts:
- host.startHostCli()
+ for host in main.scapyHosts:
+ host.stopScapy()
host.startScapy()
host.updateSelf()
main.log.debug( host.name )
@@ -210,12 +272,6 @@
onpass="Pass",
onfail="Fail" )
- main.step( "Clean up host components" )
- for host in hosts:
- host.stopScapy()
- main.Mininet1.removeHostComponent( "h1" )
- main.Mininet1.removeHostComponent( "h2" )
-
def CASE1000( self, main ):
"""
Add flows with MAC selectors and verify the flows
@@ -229,15 +285,13 @@
"send a packet that only specifies the MAC src and dst."
main.step( "Add flows with MAC addresses as the only selectors" )
-
- main.log.info( "Creating host components" )
- main.Scapy.createHostComponent( "h1" )
- main.Scapy.createHostComponent( "h2" )
- hosts = [ main.h1, main.h2 ]
- for host in hosts:
- host.startHostCli()
+ for host in main.scapyHosts:
+ host.stopScapy()
host.startScapy()
host.updateSelf()
+ main.log.debug( host.name )
+ main.log.debug( host.hostIp )
+ main.log.debug( host.hostMac )
# Add a flow that connects host1 on port1 to host2 on port2
# send output on port2
@@ -288,12 +342,6 @@
else:
main.h2.killFilter()
- main.log.info( "Clean up host components" )
- for host in hosts:
- host.stopScapy()
- main.Mininet1.removeHostComponent( "h1" )
- main.Mininet1.removeHostComponent( "h2" )
-
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
onpass="Successfully sent a packet",
@@ -312,15 +360,13 @@
"send a packet that only specifies the IP src and dst."
main.step( "Add flows with IPv4 addresses as the only selectors" )
-
- main.log.info( "Creating host components" )
- main.Scapy.createHostComponent( "h1" )
- main.Scapy.createHostComponent( "h2" )
- hosts = [ main.h1, main.h2 ]
- for host in hosts:
- host.startHostCli()
+ for host in main.scapyHosts:
+ host.stopScapy()
host.startScapy()
host.updateSelf()
+ main.log.debug( host.name )
+ main.log.debug( host.hostIp )
+ main.log.debug( host.hostMac )
# Add a flow that connects host1 on port1 to host2 on port2
# send output on port2
@@ -371,12 +417,6 @@
else:
main.h2.killFilter()
- main.log.info( "Clean up host components" )
- for host in hosts:
- host.stopScapy()
- main.Mininet1.removeHostComponent( "h1" )
- main.Mininet1.removeHostComponent( "h2" )
-
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
onpass="Successfully sent a packet",
@@ -394,17 +434,13 @@
"send a packet that only specifies the IP src and dst."
main.step( "Add flows with IPv6 addresses as the only selectors" )
-
- main.log.info( "Creating host components" )
- ctrl = main.Cluster.active( 0 )
- main.Scapy.createHostComponent( "h5" )
- main.Scapy.createHostComponent( "h6" )
- hosts = [ main.h5, main.h6 ]
-
- for host in hosts:
- host.startHostCli()
+ for host in main.scapyHosts:
+ host.stopScapy()
host.startScapy()
host.updateSelf( IPv6=True )
+ main.log.debug( host.name )
+ main.log.debug( host.hostIp )
+ main.log.debug( host.hostMac )
# Add a flow that connects host1 on port1 to host2 on port2
# send output on port2
@@ -454,12 +490,6 @@
else:
main.h6.killFilter()
- main.log.info( "Clean up host components" )
- for host in hosts:
- host.stopScapy()
- main.Mininet1.removeHostComponent( "h5" )
- main.Mininet1.removeHostComponent( "h6" )
-
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
onpass="Successfully sent a packet",
@@ -477,16 +507,13 @@
"specified, then verify the flow is added in ONOS, and finally " +\
"broadcast a packet with the correct VLAN tag."
- # We do this here to utilize the hosts information
- main.log.info( "Creating host components" )
- ctrl = main.Cluster.active( 0 )
- main.Scapy.createHostComponent( "h3" )
- main.Scapy.createHostComponent( "h4" )
- hosts = [ main.h3, main.h4 ]
- for host in hosts:
- host.startHostCli()
+ for host in main.scapyHosts:
+ host.stopScapy()
host.startScapy()
host.updateSelf()
+ main.log.debug( host.name )
+ main.log.debug( host.hostIp )
+ main.log.debug( host.hostMac )
main.step( "Add a flow with the VLAN tag as the only selector" )
@@ -539,12 +566,6 @@
else:
main.h4.killFilter()
- main.log.info( "Clean up host components" )
- for host in hosts:
- host.stopScapy()
- main.Mininet1.removeHostComponent( "h3" )
- main.Mininet1.removeHostComponent( "h4" )
-
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
onpass="Successfully sent a packet",
@@ -563,16 +584,15 @@
"send a packet via scapy that has a MPLS label."
main.step( "Add a flow with a MPLS selector" )
-
- main.log.info( "Creating host components" )
- ctrl = main.Cluster.active( 0 )
- main.Scapy.createHostComponent( "h1" )
- main.Scapy.createHostComponent( "h2" )
- hosts = [ main.h1, main.h2 ]
- for host in hosts:
- host.startHostCli()
+ for host in main.scapyHosts:
+ host.stopScapy()
host.startScapy( main.dependencyPath )
host.updateSelf()
+ main.log.debug( host.name )
+ main.log.debug( host.hostIp )
+ main.log.debug( host.hostMac )
+
+ ctrl = main.Cluster.active( 0 )
# ports
egress = 2
@@ -655,12 +675,6 @@
else:
main.h2.killFilter()
- main.log.info( "Clean up host components" )
- for host in hosts:
- host.stopScapy()
- main.Mininet1.removeHostComponent( "h1" )
- main.Mininet1.removeHostComponent( "h2" )
-
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
onpass="Successfully sent a packet",
@@ -680,14 +694,13 @@
main.step( "Add a flow with a TCP selector" )
ctrl = main.Cluster.active( 0 )
- main.log.info( "Creating host components" )
- main.Scapy.createHostComponent( "h1" )
- main.Scapy.createHostComponent( "h2" )
- hosts = [ main.h1, main.h2 ]
- for host in hosts:
- host.startHostCli()
+ for host in main.scapyHosts:
+ host.stopScapy()
host.startScapy()
host.updateSelf()
+ main.log.debug( host.name )
+ main.log.debug( host.hostIp )
+ main.log.debug( host.hostMac )
# Add a flow that connects host1 on port1 to host2 on port2
egress = 2
@@ -740,12 +753,6 @@
else:
main.h2.killFilter()
- main.log.info( "Clean up host components" )
- for host in hosts:
- host.stopScapy()
- main.Mininet1.removeHostComponent( "h1" )
- main.Mininet1.removeHostComponent( "h2" )
-
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
onpass="Successfully sent a packet",
@@ -765,14 +772,13 @@
main.step( "Add a flow with a UDP selector" )
ctrl = main.Cluster.active( 0 )
- main.log.info( "Creating host components" )
- main.Scapy.createHostComponent( "h1" )
- main.Scapy.createHostComponent( "h2" )
- hosts = [ main.h1, main.h2 ]
- for host in hosts:
- host.startHostCli()
+ for host in main.scapyHosts:
+ host.stopScapy()
host.startScapy()
host.updateSelf()
+ main.log.debug( host.name )
+ main.log.debug( host.hostIp )
+ main.log.debug( host.hostMac )
# Add a flow that connects host1 on port1 to host2 on port2
egress = 2
@@ -825,12 +831,6 @@
else:
main.h2.killFilter()
- main.log.info( "Clean up host components" )
- for host in hosts:
- host.stopScapy()
- main.Mininet1.removeHostComponent( "h1" )
- main.Mininet1.removeHostComponent( "h2" )
-
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
onpass="Successfully sent a packet",
@@ -850,14 +850,13 @@
main.step( "Add a flow with a ICMPv4 selector" )
- main.log.info( "Creating host components" )
- main.Scapy.createHostComponent( "h1" )
- main.Scapy.createHostComponent( "h2" )
- hosts = [ main.h1, main.h2 ]
- for host in hosts:
- host.startHostCli()
+ for host in main.scapyHosts:
+ host.stopScapy()
host.startScapy()
host.updateSelf()
+ main.log.debug( host.name )
+ main.log.debug( host.hostIp )
+ main.log.debug( host.hostMac )
# Add a flow that connects host1 on port1 to host2 on port2
egress = 2
@@ -907,12 +906,6 @@
else:
main.h2.killFilter()
- main.log.info( "Clean up host components" )
- for host in hosts:
- host.stopScapy()
- main.Mininet1.removeHostComponent( "h1" )
- main.Mininet1.removeHostComponent( "h2" )
-
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
onpass="Successfully sent a packet",
@@ -932,14 +925,13 @@
main.step( "Add a flow with a ICMPv6 selector" )
- main.log.info( "Creating host components" )
- main.Scapy.createHostComponent( "h5" )
- main.Scapy.createHostComponent( "h6" )
- hosts = [ main.h5, main.h6 ]
- for host in hosts:
- host.startHostCli()
+ for host in main.scapyHosts:
+ host.stopScapy()
host.startScapy()
host.updateSelf( IPv6=True )
+ main.log.debug( host.name )
+ main.log.debug( host.hostIp )
+ main.log.debug( host.hostMac )
# Add a flow that connects host1 on port1 to host2 on port2
egress = 6
@@ -989,12 +981,6 @@
else:
main.h6.killFilter()
- main.log.info( "Clean up host components" )
- for host in hosts:
- host.stopScapy()
- main.Mininet1.removeHostComponent( "h5" )
- main.Mininet1.removeHostComponent( "h6" )
-
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
onpass="Successfully sent a packet",
@@ -1047,14 +1033,14 @@
main.step( "Add flows with ARP addresses as the only selectors" )
- main.log.info( "Creating host components" )
- main.Scapy.createHostComponent( "h1" )
- main.Scapy.createHostComponent( "h2" )
- hosts = [ main.h1, main.h2 ]
- for host in hosts:
- host.startHostCli()
+ for host in main.scapyHosts:
+ host.stopScapy()
host.startScapy()
host.updateSelf()
+ main.log.debug( host.name )
+ main.log.debug( host.hostIp )
+ main.log.debug( host.hostMac )
+
ctrl = main.Cluster.active( 0 )
# Add a flow that connects host1 on port1 to host2 on port2
# send output on port2
@@ -1104,12 +1090,6 @@
else:
main.h2.killFilter()
- main.log.info( "Clean up host components" )
- for host in hosts:
- host.stopScapy()
- main.Mininet1.removeHostComponent( "h1" )
- main.Mininet1.removeHostComponent( "h2" )
-
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
onpass="Successfully sent a packet",
@@ -1129,14 +1109,13 @@
main.step( "Add a flow with a SCTP selector" )
- main.log.info( "Creating host components" )
- main.Scapy.createHostComponent( "h1" )
- main.Scapy.createHostComponent( "h2" )
- hosts = [ main.h1, main.h2 ]
- for host in hosts:
- host.startHostCli()
+ for host in main.scapyHosts:
+ host.stopScapy()
host.startScapy()
host.updateSelf()
+ main.log.debug( host.name )
+ main.log.debug( host.hostIp )
+ main.log.debug( host.hostMac )
# Add a flow that connects host1 on port1 to host2 on port2
egress = 2
@@ -1186,12 +1165,6 @@
else:
main.h2.killFilter()
- main.log.info( "Clean up host components" )
- for host in hosts:
- host.stopScapy()
- main.Mininet1.removeHostComponent( "h1" )
- main.Mininet1.removeHostComponent( "h2" )
-
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
onpass="Successfully sent a packet",
diff --git a/TestON/tests/FUNC/FUNCflow/FUNCflow.topo b/TestON/tests/FUNC/FUNCflow/FUNCflow.topo
index 41c97e3..6959073 100755
--- a/TestON/tests/FUNC/FUNCflow/FUNCflow.topo
+++ b/TestON/tests/FUNC/FUNCflow/FUNCflow.topo
@@ -36,7 +36,7 @@
<host>OCN</host>
<user>sdn</user>
<password>rocks</password>
- <type>ScapyCliDriver</type>
+ <type>MininetScapyCliDriver</type>
<connect_order>3</connect_order>
<COMPONENTS>
<prompt></prompt>
diff --git a/TestON/tests/FUNC/FUNCgroup/FUNCgroup.params b/TestON/tests/FUNC/FUNCgroup/FUNCgroup.params
index 90a5082..99a8e01 100644
--- a/TestON/tests/FUNC/FUNCgroup/FUNCgroup.params
+++ b/TestON/tests/FUNC/FUNCgroup/FUNCgroup.params
@@ -3,14 +3,15 @@
# CASE - Description
# 1 - Variable initialization and optional pull and build ONOS package
# 2 - install ONOS
- # 3 - Start mininet and verify topology
+ # 3 - Start mininet and scapy and verify topology
# 4 - Testing Scapy
# 5 - Testing GROUP with type "ALL"
# 6 - Deleting the Group and Flow
# 7 - Testing GROUP with type "INDIRECT"
# 8 - Deleting the group and flow
+ # 10 - Stop mininet and scapy
# 100 - Check logs for Errors and Warnings
- <testcases>1,2,3,5,6,7,6,100</testcases>
+ <testcases>1,2,3,5,6,7,6,10,100</testcases>
<GRAPH>
<nodeCluster>VM</nodeCluster>
@@ -68,4 +69,8 @@
<delGroup>10</delGroup>
</SLEEP>
+ <SCAPY>
+ <HOSTNAMES>h1,h2,h3,h4</HOSTNAMES>
+ </SCAPY>
+
</PARAMS>
diff --git a/TestON/tests/FUNC/FUNCgroup/FUNCgroup.py b/TestON/tests/FUNC/FUNCgroup/FUNCgroup.py
index 80ffe94..bbe759d 100644
--- a/TestON/tests/FUNC/FUNCgroup/FUNCgroup.py
+++ b/TestON/tests/FUNC/FUNCgroup/FUNCgroup.py
@@ -73,6 +73,8 @@
groupId = main.params[ 'TEST' ][ 'groupId' ]
priority = main.params[ 'TEST' ][ 'priority' ]
deviceId = main.params[ 'TEST' ][ 'swDPID' ]
+ main.scapyHostNames = main.params[ 'SCAPY' ][ 'HOSTNAMES' ].split( ',' )
+ main.scapyHosts = [] # List of scapy hosts for iterating
main.debug = True if "on" in main.debug else False
# -- INIT SECTION, ONLY RUNS ONCE -- #
@@ -153,17 +155,33 @@
main.topoRelated.compareTopos( main.Mininet1 )
+ main.step( "Create hosts and start scapy" )
+ scapyResult = main.TRUE
+ for hostName in main.scapyHostNames:
+ main.Scapy.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 CASE4( self, main ):
"""
Testing scapy
"""
main.case( "Testing scapy" )
- main.step( "Creating Host1 component" )
- main.Scapy.createHostComponent( "h1" )
- main.Scapy.createHostComponent( "h2" )
- hosts = [ main.h1, main.h2 ]
- for host in hosts:
- host.startHostCli()
+ for host in main.scapyHosts:
+ host.stopScapy()
host.startScapy()
host.updateSelf()
main.log.debug( host.name )
@@ -218,12 +236,6 @@
onpass="Pass",
onfail="Fail" )
- main.step( "Clean up host components" )
- for host in hosts:
- host.stopScapy()
- main.Mininet1.removeHostComponent( "h1" )
- main.Mininet1.removeHostComponent( "h2" )
-
def CASE5( self, main ):
"""
Adding Group of type "ALL" using Rest api
@@ -307,17 +319,14 @@
Sends a packet using scapy
"""
main.step( "Testing Group by sending packet using Scapy" )
- main.log.info( "Creating host components" )
- main.Scapy.createHostComponent( "h1" )
- main.Scapy.createHostComponent( "h2" )
- main.Scapy.createHostComponent( "h3" )
- main.Scapy.createHostComponent( "h4" )
-
- hosts = [ main.h1, main.h2, main.h3, main.h4 ]
- for host in hosts:
- host.startHostCli()
+ for host in main.scapyHosts:
+ host.stopScapy()
host.startScapy()
host.updateSelf()
+ main.log.debug( host.name )
+ main.log.debug( host.hostIp )
+ main.log.debug( host.hostMac )
+
main.log.info( "Constructing Packet" )
main.h1.buildEther( dst=main.h1.hostMac )
main.h1.buildIP( dst=main.h1.hostIp )
@@ -354,14 +363,6 @@
main.log.info( "Failure!!!Packet sent to port 1 is not received at port 2,3 and 4" )
stepResult = main.FALSE
- main.log.info( "Clean up host components" )
- for host in hosts:
- host.stopScapy()
- main.Mininet1.removeHostComponent( "h1" )
- main.Mininet1.removeHostComponent( "h2" )
- main.Mininet1.removeHostComponent( "h3" )
- main.Mininet1.removeHostComponent( "h4" )
-
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
onpass="Packet sent to port 1 is received at port 2,3,4 ",
@@ -489,15 +490,14 @@
Sends a packet using scapy
"""
main.step( "Testing Group by sending packet using Scapy" )
- main.log.info( "Creating host components" )
- main.Scapy.createHostComponent( "h1" )
- main.Scapy.createHostComponent( "h2" )
-
- hosts = [ main.h1, main.h2 ]
- for host in hosts:
- host.startHostCli()
+ for host in main.scapyHosts:
+ host.stopScapy()
host.startScapy()
host.updateSelf()
+ main.log.debug( host.name )
+ main.log.debug( host.hostIp )
+ main.log.debug( host.hostMac )
+
main.log.info( "Constructing Packet" )
main.h1.buildEther( dst=main.h1.hostMac )
main.h1.buildIP( dst=main.h1.hostIp )
@@ -513,17 +513,50 @@
else:
main.h2.killFilter()
- main.log.info( "Clean up host components" )
- for host in hosts:
- host.stopScapy()
- main.Mininet1.removeHostComponent( "h1" )
- main.Mininet1.removeHostComponent( "h2" )
-
utilities.assert_equals( expect=main.TRUE,
actual=stepResultH2,
onpass="Packet sent to port 1 is received at port 2 successfully!!!",
onfail="Failure!!!Packet sent to port 1 is not received at port 2" )
+ def CASE10( self, main ):
+ """
+ Stop mininet and remove scapy host
+ """
+ try:
+ from tests.dependencies.utils import Utils
+ except ImportError:
+ main.log.error( "Utils not found exiting the test" )
+ main.cleanAndExit()
+ try:
+ main.Utils
+ except ( NameError, AttributeError ):
+ main.Utils = Utils()
+ 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.Scapy.removeHostComponent( host.name )
+ main.log.info( "Removed Scapy Host Component: {0}".format( host.name ) )
+
+ main.scapyHosts = []
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=scapyResult,
+ onpass="Successfully stopped scapy and removed host components",
+ onfail="Failed to stop mininet and scapy" )
+
+ mininetResult = main.Utils.mininetCleanup( main.Mininet1 )
+ # Exit if topology did not load properly
+ if not ( mininetResult and scapyResult ):
+ main.cleanAndExit()
+
def CASE100( self, main ):
"""
Report errors/warnings/exceptions
diff --git a/TestON/tests/FUNC/FUNCgroup/FUNCgroup.topo b/TestON/tests/FUNC/FUNCgroup/FUNCgroup.topo
index 41c97e3..6959073 100644
--- a/TestON/tests/FUNC/FUNCgroup/FUNCgroup.topo
+++ b/TestON/tests/FUNC/FUNCgroup/FUNCgroup.topo
@@ -36,7 +36,7 @@
<host>OCN</host>
<user>sdn</user>
<password>rocks</password>
- <type>ScapyCliDriver</type>
+ <type>MininetScapyCliDriver</type>
<connect_order>3</connect_order>
<COMPONENTS>
<prompt></prompt>
diff --git a/TestON/tests/FUNC/FUNCintent/FUNCintent.topo b/TestON/tests/FUNC/FUNCintent/FUNCintent.topo
index ff5eccd..b5e4f03 100755
--- a/TestON/tests/FUNC/FUNCintent/FUNCintent.topo
+++ b/TestON/tests/FUNC/FUNCintent/FUNCintent.topo
@@ -37,7 +37,7 @@
<host>OCN</host>
<user>sdn</user>
<password>rocks</password>
- <type>ScapyCliDriver</type>
+ <type>MininetScapyCliDriver</type>
<connect_order>3</connect_order>
<COMPONENTS>
<prompt></prompt>
diff --git a/TestON/tests/FUNC/FUNCintentRest/FUNCintentRest.topo b/TestON/tests/FUNC/FUNCintentRest/FUNCintentRest.topo
index 33bcf52..9f36491 100755
--- a/TestON/tests/FUNC/FUNCintentRest/FUNCintentRest.topo
+++ b/TestON/tests/FUNC/FUNCintentRest/FUNCintentRest.topo
@@ -37,7 +37,7 @@
<host>OCN</host>
<user>sdn</user>
<password>rocks</password>
- <type>ScapyCliDriver</type>
+ <type>MininetScapyCliDriver</type>
<connect_order>3</connect_order>
<COMPONENTS>
<prompt></prompt>