ONOS-2392 SCPFscaleTopo move to production
Change-Id: Ib744222b9006973ad082b6ccdf4399bc2173a365
diff --git a/TestON/tests/SCPFscaleTopo/Dependency/newFuncTopo.py b/TestON/tests/SCPFscaleTopo/Dependency/newFuncTopo.py
new file mode 100755
index 0000000..5552aa9
--- /dev/null
+++ b/TestON/tests/SCPFscaleTopo/Dependency/newFuncTopo.py
@@ -0,0 +1,148 @@
+#!/usr/bin/python
+
+"""
+Custom topology for Mininet
+"""
+from mininet.topo import Topo
+from mininet.net import Mininet
+from mininet.node import Host, RemoteController
+from mininet.node import Node
+from mininet.node import CPULimitedHost
+from mininet.link import TCLink
+from mininet.cli import CLI
+from mininet.log import setLogLevel
+from mininet.util import dumpNodeConnections
+from mininet.node import ( UserSwitch, OVSSwitch, IVSSwitch )
+
+class VLANHost( Host ):
+ def config( self, vlan=100, **params ):
+ r = super( Host, self ).config( **params )
+ intf = self.defaultIntf()
+ self.cmd( 'ifconfig %s inet 0' % intf )
+ self.cmd( 'vconfig add %s %d' % ( intf, vlan ) )
+ self.cmd( 'ifconfig %s.%d inet %s' % ( intf, vlan, params['ip'] ) )
+ newName = '%s.%d' % ( intf, vlan )
+ intf.name = newName
+ self.nameToIntf[ newName ] = intf
+ return r
+
+class IPv6Host( Host ):
+ def config( self, v6Addr='1000:1/64', **params ):
+ r = super( Host, self ).config( **params )
+ intf = self.defaultIntf()
+ self.cmd( 'ifconfig %s inet 0' % intf )
+ self.cmd( 'ip -6 addr add %s dev %s' % ( v6Addr, intf ) )
+ return r
+
+class dualStackHost( Host ):
+ def config( self, v6Addr='2000:1/64', **params ):
+ r = super( Host, self ).config( **params )
+ intf = self.defaultIntf()
+ self.cmd( 'ip -6 addr add %s dev %s' % ( v6Addr, intf ) )
+ return r
+
+class MyTopo( Topo ):
+
+ def __init__( self ):
+ # Initialize topology
+ Topo.__init__( self )
+ # Switch S5 Hosts
+ host1=self.addHost( 'h1', ip='10.1.0.2/24' )
+ host2=self.addHost( 'h2', cls=IPv6Host, v6Addr='1000::2/64' )
+ host3=self.addHost( 'h3', ip='10.1.0.3/24', cls=dualStackHost, v6Addr='2000::2/64' )
+ #VLAN hosts
+ host4=self.addHost( 'h4', ip='100.1.0.2/24', cls=VLANHost, vlan=100 )
+ host5=self.addHost( 'h5', ip='200.1.0.2/24', cls=VLANHost, vlan=200 )
+ #VPN-1 and VPN-2 Hosts
+ host6=self.addHost( 'h6', ip='11.1.0.2/24' )
+ host7=self.addHost( 'h7', ip='12.1.0.2/24' )
+ #Multicast Sender
+ host8=self.addHost( 'h8', ip='10.1.0.4/24' )
+
+ # Switch S6 Hosts
+ host9=self.addHost( 'h9', ip='10.1.0.5/24' )
+ host10=self.addHost( 'h10', cls=IPv6Host, v6Addr='1000::3/64' )
+ host11=self.addHost( 'h11', ip='10.1.0.6/24', cls=dualStackHost, v6Addr='2000::3/64' )
+ #VLAN hosts
+ host12=self.addHost( 'h12', ip='100.1.0.3/24', cls=VLANHost, vlan=100 )
+ host13=self.addHost( 'h13', ip='200.1.0.3/24', cls=VLANHost, vlan=200 )
+ #VPN-1 and VPN-2 Hosts
+ host14=self.addHost( 'h14', ip='11.1.0.3/24' )
+ host15=self.addHost( 'h15', ip='12.1.0.3/24' )
+ #Multicast Receiver
+ host16=self.addHost( 'h16', ip='10.1.0.7/24' )
+
+ # Switch S7 Hosts
+ host17=self.addHost( 'h17', ip='10.1.0.8/24' )
+ host18=self.addHost( 'h18', cls=IPv6Host, v6Addr='1000::4/64' )
+ host19=self.addHost( 'h19', ip='10.1.0.9/24', cls=dualStackHost, v6Addr='2000::4/64' )
+ #VLAN hosts
+ host20=self.addHost( 'h20', ip='100.1.0.4/24', cls=VLANHost, vlan=100 )
+ host21=self.addHost( 'h21', ip='200.1.0.4/24', cls=VLANHost, vlan=200 )
+ #VPN-1 and VPN-2 Hosts
+ host22=self.addHost( 'h22', ip='11.1.0.4/24' )
+ host23=self.addHost( 'h23', ip='12.1.0.4/24' )
+ #Multicast Receiver
+ host24=self.addHost( 'h24', ip='10.1.0.10/24' )
+
+ s1 = self.addSwitch( 's1' )
+ s2 = self.addSwitch( 's2' )
+ s3 = self.addSwitch( 's3' )
+ s4 = self.addSwitch( 's4' )
+ s5 = self.addSwitch( 's5' )
+ s6 = self.addSwitch( 's6' )
+ s7 = self.addSwitch( 's7' )
+
+ self.addLink(s5,host1)
+ self.addLink(s5,host2)
+ self.addLink(s5,host3)
+ self.addLink(s5,host4)
+ self.addLink(s5,host5)
+ self.addLink(s5,host6)
+ self.addLink(s5,host7)
+ self.addLink(s5,host8)
+
+ self.addLink(s6,host9)
+ self.addLink(s6,host10)
+ self.addLink(s6,host11)
+ self.addLink(s6,host12)
+ self.addLink(s6,host13)
+ self.addLink(s6,host14)
+ self.addLink(s6,host15)
+ self.addLink(s6,host16)
+
+ self.addLink(s7,host17)
+ self.addLink(s7,host18)
+ self.addLink(s7,host19)
+ self.addLink(s7,host20)
+ self.addLink(s7,host21)
+ self.addLink(s7,host22)
+ self.addLink(s7,host23)
+ self.addLink(s7,host24)
+
+ self.addLink(s1,s2)
+ self.addLink(s1,s3)
+ self.addLink(s1,s4)
+ self.addLink(s1,s5)
+ self.addLink(s2,s3)
+ self.addLink(s2,s5)
+ self.addLink(s2,s6)
+ self.addLink(s3,s4)
+ self.addLink(s3,s6)
+ self.addLink(s4,s7)
+ topos = { 'mytopo': ( lambda: MyTopo() ) }
+
+# HERE THE CODE DEFINITION OF THE TOPOLOGY ENDS
+
+def setupNetwork():
+ "Create network"
+ topo = MyTopo()
+ network = Mininet(topo=topo, autoSetMacs=True, controller=None)
+ network.start()
+ CLI( network )
+ network.stop()
+
+if __name__ == '__main__':
+ setLogLevel('info')
+ #setLogLevel('debug')
+ setupNetwork()
diff --git a/TestON/tests/SCPFscaleTopo/Dependency/scaleTopoFunction.py b/TestON/tests/SCPFscaleTopo/Dependency/scaleTopoFunction.py
new file mode 100644
index 0000000..b634f83
--- /dev/null
+++ b/TestON/tests/SCPFscaleTopo/Dependency/scaleTopoFunction.py
@@ -0,0 +1,355 @@
+"""
+ Wrapper function for FuncTopo
+ Includes onosclidriver and mininetclidriver functions
+"""
+import time
+import json
+import re
+
+def __init__( self ):
+ self.default = ''
+
+def testTopology( main, topoFile='', args='', mnCmd='', clean=True ):
+ """
+ Description:
+ This function combines different wrapper functions in this module
+ to simulate a topology test
+ Test Steps:
+ - Load topology
+ - Discover topology
+ - Compare topology
+ - pingall
+ - Bring links down
+ - Compare topology
+ - pingall
+ - Bring links up
+ - Compare topology
+ - pingall
+ Options:
+ clean: Does sudo mn -c to clean mininet residue
+ Please read mininetclidriver.py >> startNet( .. ) function for details
+ Returns:
+ Returns main.TRUE if the test is successful, main.FALSE otherwise
+ """
+ testTopoResult = main.TRUE
+ compareTopoResult = main.TRUE
+ topoObjectResult = main.TRUE
+ stopResult = main.TRUE
+
+ if clean:
+ # Cleans minient
+ stopResult = stopMininet( main )
+
+ # Restart ONOS to clear hosts test new mininet topology
+ reinstallOnosResult = reinstallOnos( main )
+
+ # Starts topology
+ startResult = startNewTopology( main, topoFile, args, mnCmd )
+
+ # Gets list of switches in mininet
+ assignSwitch( main )
+
+ # This function activates fwd app then does pingall as well as store
+ # hosts data in a variable main.hostsData
+ getHostsResult = getHostsData( main )
+
+ # Compare Topology
+ compareTopoResult = compareTopo( main )
+
+ testTopoResult = startResult and topoObjectResult and \
+ compareTopoResult and getHostsResult
+
+
+ return testTopoResult
+
+def startNewTopology( main, topoFile='', args='', mnCmd='' ):
+ """
+ Description:
+ This wrapper function starts new topology
+ Options:
+ Please read mininetclidriver.py >> startNet( .. ) function for details
+ Return:
+ Returns main.TRUE if topology is successfully created by mininet,
+ main.FALSE otherwise
+ NOTE:
+ Assumes Mininet1 is the name of the handler
+ """
+ assert main, "There is no main variable"
+ assert main.Mininet1, "Mininet 1 is not created"
+ result = main.TRUE
+
+ main.log.info( main.topoName + ": Starting new Mininet topology" )
+
+ # log which method is being used
+ if topoFile:
+ main.log.info( main.topoName + ": Starting topology with " +
+ topoFile + "topology file" )
+ elif not topoFile and not mnCmd:
+ main.log.info( main.topoName + ": Starting topology using" +
+ " the topo file" )
+ elif topoFile and mnCmd:
+ main.log.error( main.topoName + ": You can only use one " +
+ "method to start a topology" )
+ elif mnCmd:
+ main.log.info( main.topoName + ": Starting topology with '" +
+ mnCmd + "' Mininet command" )
+
+
+ result = main.Mininet1.startNet( topoFile=topoFile,
+ args=args,
+ mnCmd=mnCmd )
+
+ return result
+
+def stopMininet( main ):
+ """
+ Stops current topology and execute mn -c basically triggers
+ stopNet in mininetclidrivers
+
+ NOTE: Mininet should be running when issuing this command other wise
+ the this function will cause the test to stop
+ """
+ stopResult = main.TRUE
+ stopResult = main.Mininet1.stopNet()
+ time.sleep( 30 )
+ if not stopResult:
+ main.log.info( main.topoName + ": Did not stop Mininet topology" )
+ return stopResult
+
+def compareTopo( main ):
+ """
+ Compare topology( devices, links, ports, hosts ) between ONOS and
+ mininet using sts
+ """
+ devices = []
+ links = []
+ ports = []
+ hosts = []
+ switchResult = []
+ linksResult = []
+ portsResult = []
+ hostsResult = []
+ mnSwitches = main.Mininet1.getSwitches()
+ mnLinks = main.Mininet1.getLinks()
+ mnHosts = main.Mininet1.getHosts()
+ compareTopoResult = main.TRUE
+
+ for i in range( main.numCtrls ):
+ devices.append( json.loads( main.CLIs[ i ].devices() ) )
+ links.append( json.loads( main.CLIs[ i ].links() ) )
+ ports.append( json.loads( main.CLIs[ i ].ports() ) )
+ hosts.append( json.loads( main.CLIs[ i ].hosts() ) )
+
+ # Comparing switches
+ main.log.info( main.topoName + ": Comparing switches in each ONOS nodes" +
+ " with Mininet" )
+ for i in range( main.numCtrls ):
+ tempResult = main.Mininet1.compareSwitches( mnSwitches,
+ devices[ i ],
+ ports[ i ] )
+ switchResult.append( tempResult )
+ if tempResult == main.FALSE:
+ main.log.error( main.topoName + ": ONOS-" + str( i + 1 ) +
+ " switch view is incorrect " )
+
+ if all( result == main.TRUE for result in switchResult ):
+ main.log.info( main.topoName + ": Switch view in all ONOS nodes "+
+ "are correct " )
+ else:
+ compareTopoResult = main.FALSE
+
+ # Comparing links
+ main.log.info( main.topoName + ": Comparing links in each ONOS nodes" +
+ " with Mininet" )
+ for i in range( main.numCtrls ):
+ tempResult = main.Mininet1.compareLinks( mnSwitches,
+ mnLinks,
+ links[ i ] )
+ linksResult.append( tempResult )
+ if tempResult == main.FALSE:
+ main.log.error( main.topoName + ": ONOS-" + str( i + 1 ) +
+ " links view are incorrect " )
+
+ if all( result == main.TRUE for result in linksResult ):
+ main.log.info( main.topoName + ": Links view in all ONOS nodes "+
+ "are correct " )
+ else:
+ compareTopoResult = main.FALSE
+
+ # Comparing hosts
+ main.log.info( main.topoName + ": Comparing hosts in each ONOS nodes" +
+ " with Mininet" )
+ for i in range( main.numCtrls ):
+ tempResult = main.Mininet1.compareHosts( mnHosts, hosts[ i ] )
+ hostsResult.append( tempResult )
+ if tempResult == main.FALSE:
+ main.log.error( main.topoName + ": ONOS-" + str( i + 1 ) +
+ " hosts view are incorrect " )
+
+ if all( result == main.TRUE for result in hostsResult ):
+ main.log.info( main.topoName + ": Hosts view in all ONOS nodes "+
+ "are correct " )
+ else:
+ compareTopoResult = main.FALSE
+
+ return compareTopoResult
+
+def assignSwitch( main ):
+ """
+ Returns switch list using getSwitch in Mininet driver
+ """
+ switchList = []
+ assignResult = main.TRUE
+ switchList = main.Mininet1.getSwitch()
+ assignResult = main.Mininet1.assignSwController( sw=switchList,
+ ip=main.ONOSip[ 0 ],
+ port=6633 )
+
+ for sw in switchList:
+ response = main.Mininet1.getSwController( sw )
+ if re.search( "tcp:" + main.ONOSip[ 0 ], response ):
+ assignResult = assignResult and main.TRUE
+ else:
+ assignResult = main.FALSE
+
+ return switchList
+
+def getHostsData( main ):
+ """
+ Use fwd app and pingall to discover all the hosts
+ """
+ activateResult = main.TRUE
+ appCheck = main.TRUE
+ getDataResult = main.TRUE
+ main.log.info( main.topoName + ": Activating reactive forwarding app " )
+ activateResult = main.CLIs[ 0 ].activateApp( "org.onosproject.fwd" )
+
+ if main.hostsData:
+ main.hostsData = {}
+ for i in range( main.numCtrls ):
+ appCheck = appCheck and main.CLIs[ i ].appToIDCheck()
+ if appCheck != main.TRUE:
+ main.log.warn( main.CLIs[ i ].apps() )
+ main.log.warn( main.CLIs[ i ].appIDs() )
+
+ time.sleep( main.fwdSleep )
+ # Discover hosts using pingall
+ pingResult = main.Mininet1.pingall( timeout=900 )
+
+ hostsJson = json.loads( main.CLIs[ 0 ].hosts() )
+ hosts = main.Mininet1.getHosts().keys()
+
+ for host in hosts:
+ main.hostsData[ host ] = {}
+ main.hostsData[ host ][ 'mac' ] = \
+ main.Mininet1.getMacAddress( host ).upper()
+ 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' ]
+
+ if activateResult and main.hostsData:
+ main.log.info( main.topoName + ": Successfully used fwd app" +
+ " to discover hosts " )
+ getDataResult = main.TRUE
+ else:
+ main.log.info( main.topoName + ": Failed to use fwd app" +
+ " to discover hosts " )
+ getDataResult = main.FALSE
+
+ main.log.info( main.topoName + ": Deactivate reactive forwarding app " )
+ activateResult = main.CLIs[ 0 ].deactivateApp( "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[ i ].apps() )
+ main.log.warn( main.CLIs[ i ].appIDs() )
+
+ # This data can be use later for intents
+ print main.hostsData
+
+ return getDataResult
+
+def reinstallOnos( main ):
+ """
+ Description:
+ Stop and start ONOS that clears hosts,devices etc. in order to test
+ new mininet topology
+ Return:
+ Retruns main.TRUE for a successful restart, main.FALSE otherwise.
+ """
+ uninstallResult = []
+ installResult = []
+ stopResult = []
+ startResult = []
+ onosIsUpResult = []
+ restartResult = main.TRUE
+
+ main.log.info( main.topoName + ": Uninstall ONOS cluster" )
+ for ip in main.ONOSip:
+ uninstallResult.append( main.ONOSbench.onosUninstall( nodeIp=ip ) )
+
+ if all( result == main.TRUE for result in uninstallResult ):
+ main.log.info( main.topoName + ": Successfully uninstall ONOS cluster" )
+ else:
+ restartResult = main.FALSE
+ main.log.error( main.topoName + ": Failed to uninstall ONOS cluster" )
+
+ time.sleep( main.startUpSleep )
+
+ main.log.info( main.topoName + ": Installing ONOS cluster" )
+
+ for i in range( main.numCtrls ):
+ installResult.append( main.ONOSbench.onosInstall(
+ node=main.ONOSip[ i ] ) )
+
+ if all( result == main.TRUE for result in installResult ):
+ main.log.info( main.topoName + ": Successfully installed ONOS cluster" )
+ else:
+ restartResult = main.FALSE
+ main.log.error( main.topoName + ": Failed to install ONOS cluster" )
+
+ for i in range( main.numCtrls ):
+ onosIsUpResult.append( main.ONOSbench.isup( main.ONOSip[ i ] ) )
+
+ if all( result == main.TRUE for result in onosIsUpResult ):
+ main.log.report( "ONOS instance is up and ready" )
+ else:
+ main.log.report( "ONOS instance may not be up, stop and " +
+ "start ONOS again " )
+ for i in range( main.numCtrls ):
+ stopResult.append( main.ONOSbench.onosStop( main.ONOSip[ i ] ) )
+
+ if all( result == main.TRUE for result in stopResult ):
+ main.log.info( main.topoName + ": Successfully stop ONOS cluster" )
+ else:
+ main.log.error( main.topoName + ": Failed to stop ONOS cluster" )
+
+ for i in range( main.numCtrls ):
+ startResult.append( main.ONOSbench.onosStart( main.ONOSip[ i ] ) )
+
+ if all( result == main.TRUE for result in startResult ):
+ main.log.info( main.topoName + ": Successfully start ONOS cluster" )
+ else:
+ main.log.error( main.topoName + ": Failed to start ONOS cluster" )
+
+ main.log.info( main.topoName + ": Starting ONOS CLI" )
+ cliResult = []
+ for i in range( main.numCtrls ):
+ cliResult.append( main.CLIs[ i ].startOnosCli( main.ONOSip[ i ] ) )
+
+ if all( result == main.TRUE for result in cliResult ):
+ main.log.info( main.topoName + ": Successfully start ONOS cli" )
+ else:
+ main.log.error( main.topoName + ": Failed to start ONOS cli" )
+ restartResult = main.FALSE
+
+
+ return restartResult
+
+
+
diff --git a/TestON/tests/SCPFscaleTopo/Dependency/startUp.py b/TestON/tests/SCPFscaleTopo/Dependency/startUp.py
new file mode 100644
index 0000000..bf2a2b6
--- /dev/null
+++ b/TestON/tests/SCPFscaleTopo/Dependency/startUp.py
@@ -0,0 +1,38 @@
+"""
+ This wrapper function is use for starting up onos instance
+"""
+
+import time
+import os
+import json
+
+def onosBuild( main, gitBranch ):
+ """
+ This includes pulling ONOS and building it using maven install
+ """
+
+ buildResult = main.FALSE
+
+ # Git checkout a branch of ONOS
+ checkOutResult = main.ONOSbench.gitCheckout( gitBranch )
+ # Does the git pull on the branch that was checked out
+ if not checkOutResult:
+ main.log.warn( "Failed to checked out " + gitBranch +
+ " branch")
+ else:
+ main.log.info( "Successfully checked out " + gitBranch +
+ " branch")
+ gitPullResult = main.ONOSbench.gitPull()
+ if gitPullResult == main.ERROR:
+ main.log.error( "Error pulling git branch" )
+ else:
+ main.log.info( "Successfully pulled " + gitBranch + " branch" )
+
+ # Maven clean install
+ buildResult = main.ONOSbench.cleanInstall()
+
+ return buildResult
+
+
+
+