[ONOS-7356] Initial commit to decouple Mininet from TestON tests:
- Add Network class
- Allow ONOS start up without Mininet component
- Migrate SAMP tests and FUNCintent to use Network class
Change-Id: I81b4a4dd27ff6b3a7f2b60abbbcef078b0fa0438
diff --git a/TestON/tests/dependencies/Cluster.py b/TestON/tests/dependencies/Cluster.py
index af17ab5..34a373a 100644
--- a/TestON/tests/dependencies/Cluster.py
+++ b/TestON/tests/dependencies/Cluster.py
@@ -149,14 +149,14 @@
"""
self.iterator = iter( self.active() )
- def createCell( self, cellName, cellApps, Mininet, useSSH, ips, installMax=False ):
+ def createCell( self, cellName, cellApps, mininetIp, useSSH, ips, installMax=False ):
"""
Description:
create a new cell
Required:
* cellName - The name of the cell.
* cellApps - The ONOS apps string.
- * Mininet - a mininet driver that will be used.
+ * mininetIp - Mininet IP address.
* useSSH - True for using ssh when creating a cell
* ips - ip( s ) of the node( s ).
Returns:
@@ -168,8 +168,7 @@
self.command( "createCellFile",
args=[ main.ONOSbench.ip_address,
cellName,
- Mininet if isinstance( Mininet, str ) else
- Mininet.ip_address,
+ mininetIp,
apps,
ips,
main.ONOScell.karafUser,
diff --git a/TestON/tests/dependencies/Network.py b/TestON/tests/dependencies/Network.py
new file mode 100644
index 0000000..6377c0c
--- /dev/null
+++ b/TestON/tests/dependencies/Network.py
@@ -0,0 +1,58 @@
+"""
+Copyright 2018 Open Networking Foundation ( ONF )
+
+Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
+the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
+or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg>
+
+ TestON is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ ( at your option ) any later version.
+
+ TestON is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with TestON. If not, see <http://www.gnu.org/licenses/>.
+"""
+import json
+class Network():
+
+ def __str__( self ):
+ return self.name
+
+ def __repr__( self ):
+ return "%s:%s" % ( self.name, self.components )
+
+ def __getattr__( self, name ):
+ """
+ Called when an attribute lookup has not found the attribute
+ in the usual places (i.e. it is not an instance attribute nor
+ is it found in the class tree for self). name is the attribute
+ name. This method should return the (computed) attribute value
+ or raise an AttributeError exception.
+
+ We will look into each of the network component handles to try
+ to find the attreibute.
+ """
+ #FIXME: allow to call a specific driver
+ for component in self.components:
+ if hasattr( component, name ):
+ main.log.debug( "%s has attribute '%s'" % ( component.options[ 'name' ], name ) )
+ return getattr( component, name )
+ raise AttributeError( "Could not find attribute '%s' in any of these components: %s" % ( name, self.components ) )
+
+ def __init__( self, name="Network" ):
+ """
+ components: network components created for the test
+ """
+ self.name = str( name )
+ # Get a list of network components that are created in the test
+ self.components = []
+ for key, value in main.componentDictionary.items():
+ if value[ 'type' ] in [ 'MininetCliDriver', 'RemoteMininetDriver', 'NetworkDriver' ] and hasattr( main, key ):
+ self.components.append( getattr( main, key ) )
+ main.log.debug( "%s initialized with components: %s" % ( self.name, self.components ) )
diff --git a/TestON/tests/dependencies/ONOSSetup.py b/TestON/tests/dependencies/ONOSSetup.py
index 11f5886..98f1d5b 100644
--- a/TestON/tests/dependencies/ONOSSetup.py
+++ b/TestON/tests/dependencies/ONOSSetup.py
@@ -198,7 +198,7 @@
return cluster.kill( killRemoveMax, stopOnos )
def createApplyCell( self, cluster, newCell, cellName, cellApps,
- Mininet, useSSH, ips, installMax=False ):
+ mininetIp, useSSH, ips, installMax=False ):
"""
Description:
create new cell ( optional ) and apply it. It will also verify the
@@ -208,14 +208,14 @@
* newCell - True for making a new cell and False for not making it.
* cellName - The name of the cell.
* cellApps - The onos apps string.
- * Mininet - a mininet driver that will be used.
+ * mininetIp - Mininet IP address.
* useSSH - True for using ssh when creating a cell
* ips - ip( s ) of the node( s ).
Returns:
Returns main.TRUE if it successfully executed.
"""
if newCell:
- cluster.createCell( cellName, cellApps, Mininet, useSSH, ips )
+ cluster.createCell( cellName, cellApps, mininetIp, useSSH, ips )
main.step( "Apply cell to environment" )
stepResult = cluster.applyCell( cellName )
utilities.assert_equals( expect=main.TRUE,
@@ -352,8 +352,8 @@
else:
functions( *args ) if args is not None else functions()
- def ONOSSetUp( self, Mininet, cluster, hasMultiNodeRounds=False, startOnos=True, newCell=True,
- cellName="temp", cellApps="drivers", removeLog=False, extraApply=None, applyArgs=None,
+ def ONOSSetUp( self, cluster, hasMultiNodeRounds=False, startOnos=True, newCell=True,
+ cellName="temp", cellApps="drivers", mininetIp="", removeLog=False, extraApply=None, applyArgs=None,
extraClean=None, cleanArgs=None, skipPack=False, installMax=False, useSSH=True,
killRemoveMax=True, stopOnos=False, installParallel=True ):
"""
@@ -372,13 +372,13 @@
checking the onos service
starting onos
Required:
- * Mininet - the mininet driver that will be used
* cluster - the cluster driver that will be used.
* hasMultiNodeRouds - True if the test is testing different set of nodes
* startOnos - True if wish to start onos.
* newCell - True for making a new cell and False for not making it.
* cellName - Name of the cell that will be used.
* cellApps - The cell apps string.
+ * mininetIp - Mininet IP address.
* removeLog - True if wish to remove raft logs
* extraApply - Function( s ) that will be called before building ONOS. Default to None.
* applyArgs - argument of the functon( s ) of the extraApply. Should be in list.
@@ -411,9 +411,15 @@
tempOnosIp = []
for ctrl in cluster.runningNodes:
tempOnosIp.append( ctrl.ipAddress )
+ if mininetIp == "":
+ mininetIp = "localhost"
+ for key, value in main.componentDictionary.items():
+ if value['type'] in ['MininetCliDriver', 'RemoteMininetDriver'] and hasattr( main, key ):
+ mininetIp = getattr( main, key ).ip_address
+ break
cellResult = self.createApplyCell( cluster, newCell,
cellName, cellApps,
- Mininet, useSSH,
+ mininetIp, useSSH,
tempOnosIp, installMax )
if removeLog:
main.log.info( "Removing raft logs" )