Merge "Refactor VLAN intent tests to actually use VLAN selectors"
diff --git a/TestON/drivers/common/api/controller/onosrestdriver.py b/TestON/drivers/common/api/controller/onosrestdriver.py
index a9676a9..50e4847 100644
--- a/TestON/drivers/common/api/controller/onosrestdriver.py
+++ b/TestON/drivers/common/api/controller/onosrestdriver.py
@@ -75,7 +75,7 @@
main.log.exception( "Error parsing jsonObject" )
return None
- def send( self, ip, port, url, base="/onos/v1", method="GET",
+ def send( self, url, base="/onos/v1", method="GET",
query=None, data=None, debug=False ):
"""
Arguments:
@@ -94,6 +94,9 @@
# TODO: should we maybe just pass kwargs straight to response?
# TODO: Do we need to allow for other protocols besides http?
# ANSWER: Not yet, but potentially https with certificates
+ ip = self.ip_address
+ port = self.port
+
try:
path = "http://" + str( ip ) + ":" + str( port ) + base + url
if self.user_name and self.pwd:
@@ -137,7 +140,7 @@
main.log.warn( "No port given, reverting to port " +
"from topo file" )
port = self.port
- response = self.send( ip, port, url="/intents" )
+ response = self.send( url="/intents" )
if response:
if 200 <= response[ 0 ] <= 299:
output = response[ 1 ]
@@ -185,7 +188,7 @@
port = self.port
# NOTE: REST url requires the intent id to be in decimal form
query = "/" + str( appId ) + "/" + str( intentId )
- response = self.send( ip, port, url="/intents" + query )
+ response = self.send( url="/intents" + query )
if response:
if 200 <= response[ 0 ] <= 299:
output = response[ 1 ]
@@ -248,7 +251,7 @@
main.log.warn( "No port given, reverting to port " +
"from topo file" )
port = self.port
- response = self.send( ip, port, url="/applications" )
+ response = self.send( url="/applications" )
if response:
if 200 <= response[ 0 ] <= 299:
output = response[ 1 ]
@@ -291,7 +294,7 @@
"from topo file" )
port = self.port
query = "/" + str( appName ) + "/active"
- response = self.send( ip, port, method="POST",
+ response = self.send( method="POST",
url="/applications" + query )
if response:
output = response[ 1 ]
@@ -347,7 +350,7 @@
"from topo file" )
port = self.port
query = "/" + str( appName ) + "/active"
- response = self.send( ip, port, method="DELETE",
+ response = self.send( method="DELETE",
url="/applications" + query )
if response:
output = response[ 1 ]
@@ -401,7 +404,7 @@
"from topo file" )
port = self.port
query = "/" + project + str( appName )
- response = self.send( ip, port, url="/applications" + query )
+ response = self.send( url="/applications" + query )
if response:
if 200 <= response[ 0 ] <= 299:
output = response[ 1 ]
@@ -451,9 +454,7 @@
main.log.warn( "No port given, reverting to port " +
"from topo file" )
port = self.port
- response = self.send( ip,
- port,
- method="POST",
+ response = self.send( method="POST",
url="/intents",
data=json.dumps( intentJson ) )
if response:
@@ -603,9 +604,7 @@
main.log.warn( "No port given, reverting to port " +
"from topo file" )
port = self.port
- response = self.send( ip,
- port,
- method="POST",
+ response = self.send( method="POST",
url="/intents",
data=json.dumps( intentJson ) )
if response:
@@ -644,9 +643,7 @@
port = self.port
# NOTE: REST url requires the intent id to be in decimal form
query = "/" + str( appId ) + "/" + str( int( intentId, 16 ) )
- response = self.send( ip,
- port,
- method="DELETE",
+ response = self.send( method="DELETE",
url="/intents" + query )
if response:
if 200 <= response[ 0 ] <= 299:
@@ -747,7 +744,7 @@
main.log.warn( "No port given, reverting to port " +
"from topo file" )
port = self.port
- response = self.send( ip, port, url="/hosts" )
+ response = self.send( url="/hosts" )
if response:
if 200 <= response[ 0 ] <= 299:
output = response[ 1 ]
@@ -793,7 +790,7 @@
"from topo file" )
port = self.port
query = "/" + mac + "/" + vlan
- response = self.send( ip, port, url="/hosts" + query )
+ response = self.send( url="/hosts" + query )
if response:
# NOTE: What if the person wants other values? would it be better
# to have a function that gets a key and return a value instead?
@@ -832,7 +829,7 @@
main.log.warn( "No port given, reverting to port " +
"from topo file" )
port = self.port
- response = self.send( ip, port, url="/topology" )
+ response = self.send( url="/topology" )
if response:
if 200 <= response[ 0 ] <= 299:
output = response[ 1 ]
@@ -869,7 +866,7 @@
main.log.warn( "No port given, reverting to port " +
"from topo file" )
port = self.port
- response = self.send( ip, port, url="/devices" )
+ response = self.send( url="/devices" )
if response:
if 200 <= response[ 0 ] <= 299:
output = response[ 1 ]
@@ -1032,7 +1029,7 @@
main.log.warn( "No port given, reverting to port " +
"from topo file" )
port = self.port
- response = self.send( ip, port, url="/flows" )
+ response = self.send( url="/flows" )
if response:
if 200 <= response[ 0 ] <= 299:
output = response[ 1 ]
@@ -1075,7 +1072,7 @@
if flowId:
url += "/" + str( int( flowId ) )
print url
- response = self.send( ip, port, url=url )
+ response = self.send( url=url )
if response:
if 200 <= response[ 0 ] <= 299:
output = response[ 1 ]
@@ -1123,9 +1120,7 @@
"from topo file" )
port = self.port
url = "/flows/" + deviceId
- response = self.send( ip,
- port,
- method="POST",
+ response = self.send( method="POST",
url=url,
data=json.dumps( flowJson ) )
if response:
@@ -1292,9 +1287,7 @@
port = self.port
# NOTE: REST url requires the intent id to be in decimal form
query = "/" + str( deviceId ) + "/" + str( int( flowId ) )
- response = self.send( ip,
- port,
- method="DELETE",
+ response = self.send( method="DELETE",
url="/flows" + query )
if response:
if 200 <= response[ 0 ] <= 299:
@@ -1365,7 +1358,7 @@
url += "/" + subjectKey
if configKey:
url += "/" + configKey
- response = self.send( ip, port, url=url )
+ response = self.send( url=url )
if response:
if 200 <= response[ 0 ] <= 299:
output = response[ 1 ]
@@ -1415,8 +1408,7 @@
url += "/" + subjectKey
if configKey:
url += "/" + configKey
- response = self.send( ip, port,
- method="POST",
+ response = self.send( method="POST",
url=url,
data=json.dumps( cfgJson ) )
if response:
@@ -1462,8 +1454,7 @@
url += "/" + subjectKey
if configKey:
url += "/" + configKey
- response = self.send( ip, port,
- method="DELETE",
+ response = self.send( method="DELETE",
url=url )
if response:
if 200 <= response[ 0 ] <= 299:
@@ -1667,9 +1658,7 @@
"from topo file" )
port = self.port
url = "/flows/"
- response = self.send( ip,
- port,
- method="POST",
+ response = self.send( method="POST",
url=url,
data=json.dumps( batch ) )
#main.log.info("Post response is: ", str(response[0]))
@@ -1712,9 +1701,7 @@
port = self.port
# NOTE: REST url requires the intent id to be in decimal form
- response = self.send( ip,
- port,
- method="DELETE",
+ response = self.send( method="DELETE",
url="/flows/",
data = json.dumps(batch) )
if response:
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index 9fcf42d..7e5cb3c 100644
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -301,6 +301,87 @@
main.cleanup()
main.exit()
+ def startCellCli( self, karafTimeout="",
+ commandlineTimeout=10, onosStartTimeout=60 ):
+ """
+ Start CLI on onos ecll handle.
+
+ karafTimeout is an optional argument. karafTimeout value passed
+ by user would be used to set the current karaf shell idle timeout.
+ Note that when ever this property is modified the shell will exit and
+ the subsequent login would reflect new idle timeout.
+ Below is an example to start a session with 60 seconds idle timeout
+ ( input value is in milliseconds ):
+
+ tValue = "60000"
+
+ Note: karafTimeout is left as str so that this could be read
+ and passed to startOnosCli from PARAMS file as str.
+ """
+
+ try:
+ self.handle.sendline( "" )
+ x = self.handle.expect( [
+ "\$", "onos>" ], commandlineTimeout)
+
+ if x == 1:
+ main.log.info( "ONOS cli is already running" )
+ return main.TRUE
+
+ # Wait for onos start ( -w ) and enter onos cli
+ self.handle.sendline( "/opt/onos/bin/onos" )
+ i = self.handle.expect( [
+ "onos>",
+ pexpect.TIMEOUT ], onosStartTimeout )
+
+ if i == 0:
+ main.log.info( self.name + " CLI Started successfully" )
+ if karafTimeout:
+ self.handle.sendline(
+ "config:property-set -p org.apache.karaf.shell\
+ sshIdleTimeout " +
+ karafTimeout )
+ self.handle.expect( "\$" )
+ self.handle.sendline( "/opt/onos/bin/onos" )
+ self.handle.expect( "onos>" )
+ return main.TRUE
+ else:
+ # If failed, send ctrl+c to process and try again
+ main.log.info( "Starting CLI failed. Retrying..." )
+ self.handle.send( "\x03" )
+ self.handle.sendline( "/opt/onos/bin/onos" )
+ i = self.handle.expect( [ "onos>", pexpect.TIMEOUT ],
+ timeout=30 )
+ if i == 0:
+ main.log.info( self.name + " CLI Started " +
+ "successfully after retry attempt" )
+ if karafTimeout:
+ self.handle.sendline(
+ "config:property-set -p org.apache.karaf.shell\
+ sshIdleTimeout " +
+ karafTimeout )
+ self.handle.expect( "\$" )
+ self.handle.sendline( "/opt/onos/bin/onos" )
+ self.handle.expect( "onos>" )
+ return main.TRUE
+ else:
+ main.log.error( "Connection to CLI " +
+ self.name + " timeout" )
+ return main.FALSE
+
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ return None
+ except pexpect.EOF:
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
+ main.cleanup()
+ main.exit()
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
+
def log( self, cmdStr, level="" ):
"""
log the commands in the onos CLI.
@@ -366,8 +447,10 @@
"""
try:
- logStr = "\"Sending CLI command: '" + cmdStr + "'\""
- self.log( logStr )
+ if debug:
+ # NOTE: This adds and average of .4 seconds per call
+ logStr = "\"Sending CLI command: '" + cmdStr + "'\""
+ self.log( logStr )
self.handle.sendline( cmdStr )
i = self.handle.expect( ["onos>", "\$"], timeout )
response = self.handle.before
@@ -4256,6 +4339,7 @@
return None
pattern = "Key-value pair \(" + keyName + ", (?P<value>.+)\) found."
if "Key " + keyName + " not found." in output:
+ main.log.warn( output )
return None
else:
match = re.search( pattern, output )
diff --git a/TestON/drivers/common/cli/onosdriver.py b/TestON/drivers/common/cli/onosdriver.py
index 8572131..1aed954 100644
--- a/TestON/drivers/common/cli/onosdriver.py
+++ b/TestON/drivers/common/cli/onosdriver.py
@@ -795,7 +795,7 @@
handleMore = self.handle.before
cell_result = handleBefore + handleAfter + handleMore
- print cell_result
+ #print cell_result
if( re.search( "No such cell", cell_result ) ):
main.log.error( "Cell call returned: " + handleBefore +
handleAfter + handleMore )
@@ -2253,3 +2253,39 @@
return localhost
except Exception:
main.log.exception( "Uncaught exception" )
+
+ def startBasicONOS(self, nodeList, opSleep = 60, onosStartupSleep = 60):
+
+ '''
+ Start onos cluster with defined nodes, but only with drivers app
+
+ '''
+ import time
+
+ self.createCellFile( self.ip_address,
+ "temp",
+ self.ip_address,
+ "drivers",
+ nodeList )
+
+ main.log.info( self.name + ": Apply cell to environment" )
+ cellResult = self.setCell( "temp" )
+ verifyResult = self.verifyCell()
+
+ main.log.info( self.name + ": Creating ONOS package" )
+ packageResult = self.onosPackage( opTimeout=opSleep )
+
+ main.log.info( self.name + ": Installing ONOS package" )
+ for nd in nodeList:
+ self.onosInstall( node=nd )
+
+ main.log.info( self.name + ": Starting ONOS service" )
+ time.sleep( onosStartupSleep )
+
+ onosStatus = True
+ for nd in nodeList:
+ onosStatus = onosStatus & self.isup( node = nd )
+ #print "onosStatus is: " + str( onosStatus )
+
+ return main.TRUE if onosStatus else main.FALSE
+
diff --git a/TestON/tests/HA/HAclusterRestart/HAclusterRestart.py b/TestON/tests/HA/HAclusterRestart/HAclusterRestart.py
index 6bb32e2..6aab7aa 100644
--- a/TestON/tests/HA/HAclusterRestart/HAclusterRestart.py
+++ b/TestON/tests/HA/HAclusterRestart/HAclusterRestart.py
@@ -266,8 +266,6 @@
main.log.debug( "{} components not ACTIVE: \n{}".format(
cli.name,
cli.sendline( "scr:list | grep -v ACTIVE" ) ) )
-
- if cliResults == main.FALSE:
main.log.error( "Failed to start ONOS, stopping test" )
main.cleanup()
main.exit()
@@ -4214,6 +4212,9 @@
onfail="Partitioned Transactional Map put values are incorrect" )
main.step( "Partitioned Transactional maps get" )
+ # FIXME: is this sleep needed?
+ time.sleep( 5 )
+
getCheck = True
for n in range( 1, numKeys + 1 ):
getResponses = []
diff --git a/TestON/tests/HA/HAfullNetPartition/HAfullNetPartition.py b/TestON/tests/HA/HAfullNetPartition/HAfullNetPartition.py
index 6eb81d9..25b9772 100644
--- a/TestON/tests/HA/HAfullNetPartition/HAfullNetPartition.py
+++ b/TestON/tests/HA/HAfullNetPartition/HAfullNetPartition.py
@@ -291,8 +291,6 @@
main.log.debug( "{} components not ACTIVE: \n{}".format(
cli.name,
cli.sendline( "scr:list | grep -v ACTIVE" ) ) )
-
- if cliResults == main.FALSE:
main.log.error( "Failed to start ONOS, stopping test" )
main.cleanup()
main.exit()
@@ -4200,6 +4198,9 @@
onfail="Partitioned Transactional Map put values are incorrect" )
main.step( "Partitioned Transactional maps get" )
+ # FIXME: is this sleep needed?
+ time.sleep( 5 )
+
getCheck = True
for n in range( 1, numKeys + 1 ):
getResponses = []
diff --git a/TestON/tests/HA/HAkillNodes/HAkillNodes.py b/TestON/tests/HA/HAkillNodes/HAkillNodes.py
index 62062fc..bda572f 100644
--- a/TestON/tests/HA/HAkillNodes/HAkillNodes.py
+++ b/TestON/tests/HA/HAkillNodes/HAkillNodes.py
@@ -302,8 +302,6 @@
main.log.debug( "{} components not ACTIVE: \n{}".format(
cli.name,
cli.sendline( "scr:list | grep -v ACTIVE" ) ) )
-
- if cliResults == main.FALSE:
main.log.error( "Failed to start ONOS, stopping test" )
main.cleanup()
main.exit()
@@ -4235,6 +4233,9 @@
onfail="Partitioned Transactional Map put values are incorrect" )
main.step( "Partitioned Transactional maps get" )
+ # FIXME: is this sleep needed?
+ time.sleep( 5 )
+
getCheck = True
for n in range( 1, numKeys + 1 ):
getResponses = []
diff --git a/TestON/tests/HA/HAsanity/HAsanity.py b/TestON/tests/HA/HAsanity/HAsanity.py
index 13b4084..cb6929a 100644
--- a/TestON/tests/HA/HAsanity/HAsanity.py
+++ b/TestON/tests/HA/HAsanity/HAsanity.py
@@ -267,8 +267,6 @@
main.log.debug( "{} components not ACTIVE: \n{}".format(
cli.name,
cli.sendline( "scr:list | grep -v ACTIVE" ) ) )
-
- if cliResults == main.FALSE:
main.log.error( "Failed to start ONOS, stopping test" )
main.cleanup()
main.exit()
@@ -4136,6 +4134,9 @@
onfail="Partitioned Transactional Map put values are incorrect" )
main.step( "Partitioned Transactional maps get" )
+ # FIXME: is this sleep needed?
+ time.sleep( 5 )
+
getCheck = True
for n in range( 1, numKeys + 1 ):
getResponses = []
diff --git a/TestON/tests/HA/HAscaling/HAscaling.py b/TestON/tests/HA/HAscaling/HAscaling.py
index fcec126..3c98ab7 100644
--- a/TestON/tests/HA/HAscaling/HAscaling.py
+++ b/TestON/tests/HA/HAscaling/HAscaling.py
@@ -324,8 +324,6 @@
main.log.debug( "{} components not ACTIVE: \n{}".format(
cli.name,
cli.sendline( "scr:list | grep -v ACTIVE" ) ) )
-
- if cliResults == main.FALSE:
main.log.error( "Failed to start ONOS, stopping test" )
main.cleanup()
main.exit()
@@ -4264,6 +4262,9 @@
onfail="Partitioned Transactional Map put values are incorrect" )
main.step( "Partitioned Transactional maps get" )
+ # FIXME: is this sleep needed?
+ time.sleep( 5 )
+
getCheck = True
for n in range( 1, numKeys + 1 ):
getResponses = []
diff --git a/TestON/tests/HA/HAsingleInstanceRestart/HAsingleInstanceRestart.py b/TestON/tests/HA/HAsingleInstanceRestart/HAsingleInstanceRestart.py
index 1adb53c..1d4db86 100644
--- a/TestON/tests/HA/HAsingleInstanceRestart/HAsingleInstanceRestart.py
+++ b/TestON/tests/HA/HAsingleInstanceRestart/HAsingleInstanceRestart.py
@@ -256,8 +256,6 @@
main.log.debug( "{} components not ACTIVE: \n{}".format(
cli.name,
cli.sendline( "scr:list | grep -v ACTIVE" ) ) )
-
- if cliResults == main.FALSE:
main.log.error( "Failed to start ONOS, stopping test" )
main.cleanup()
main.exit()
@@ -3426,6 +3424,9 @@
onfail="Partitioned Transactional Map put values are incorrect" )
main.step( "Partitioned Transactional maps get" )
+ # FIXME: is this sleep needed?
+ time.sleep( 5 )
+
getCheck = True
for n in range( 1, numKeys + 1 ):
getResponses = []
diff --git a/TestON/tests/HA/HAstopNodes/HAstopNodes.py b/TestON/tests/HA/HAstopNodes/HAstopNodes.py
index f329fd8..26f255f 100644
--- a/TestON/tests/HA/HAstopNodes/HAstopNodes.py
+++ b/TestON/tests/HA/HAstopNodes/HAstopNodes.py
@@ -291,8 +291,6 @@
main.log.debug( "{} components not ACTIVE: \n{}".format(
cli.name,
cli.sendline( "scr:list | grep -v ACTIVE" ) ) )
-
- if cliResults == main.FALSE:
main.log.error( "Failed to start ONOS, stopping test" )
main.cleanup()
main.exit()
@@ -4212,6 +4210,9 @@
onfail="Partitioned Transactional Map put values are incorrect" )
main.step( "Partitioned Transactional maps get" )
+ # FIXME: is this sleep needed?
+ time.sleep( 5 )
+
getCheck = True
for n in range( 1, numKeys + 1 ):
getResponses = []
diff --git a/TestON/tests/SAMP/SAMPstartTemplate2/Dependency/newFuncTopo.py b/TestON/tests/SAMP/SAMPstartTemplate2/Dependency/newFuncTopo.py
new file mode 100755
index 0000000..7fe68c1
--- /dev/null
+++ b/TestON/tests/SAMP/SAMPstartTemplate2/Dependency/newFuncTopo.py
@@ -0,0 +1,152 @@
+#!/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/SAMP/SAMPstartTemplate2/README b/TestON/tests/SAMP/SAMPstartTemplate2/README
new file mode 100644
index 0000000..7df40db
--- /dev/null
+++ b/TestON/tests/SAMP/SAMPstartTemplate2/README
@@ -0,0 +1,2 @@
+Summary:
+ Sample test case how onos test should start up.
\ No newline at end of file
diff --git a/TestON/tests/SAMP/SAMPstartTemplate2/SAMPstartTemplate2.params b/TestON/tests/SAMP/SAMPstartTemplate2/SAMPstartTemplate2.params
new file mode 100755
index 0000000..8fde55a
--- /dev/null
+++ b/TestON/tests/SAMP/SAMPstartTemplate2/SAMPstartTemplate2.params
@@ -0,0 +1,64 @@
+<PARAMS>
+ <!--
+ CASE0: pull onos code - this case should be skipped on Jenkins-driven prod test
+ -->
+ <!--
+ CASE1: setup and clean test env
+ -->
+ <!--
+ CASE2: get onos warnings, errors from log
+ -->
+ <!--
+ CASE10: start a 3-node ONOS Cluster
+ -->
+ <!--
+ CASE11: Start Mininet and assign controllers
+ -->
+ <!--
+ CASE12: Sample case of using onos cli
+ -->
+ <!--
+ CASE22: Sample case of using onos rest
+ -->
+
+ <testcases>0,1,10,11,12,22,2</testcases>
+
+ <CASE0>
+ <gitPull>False</gitPull> # False or True
+ <gitBranch>master</gitBranch>
+ </CASE0>
+
+ <CASE1>
+ <NodeList>OC1,OC2,OC3</NodeList>
+ <SleepTimers>
+ <onosStartup>60</onosStartup>
+ <onosCfg>5</onosCfg>
+ <mnStartup>15</mnStartup>
+ <mnCfg>10</mnCfg>
+ </SleepTimers>
+ </CASE1>
+
+ <CASE10>
+ <numNodes>3</numNodes>
+ <Apps>
+ org.onosproject.openflow,org.onosproject.fwd
+ </Apps>
+ <ONOS_Configuration>
+ <org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator>
+ <useFlowObjectives>true</useFlowObjectives>
+ </org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator>
+ </ONOS_Configuration>
+ </CASE10>
+
+ <CASE11>
+ <path>~/OnosSystemTest/TestON/tests/SAMP/SAMPstartTemplate2/Dependency/</path>
+ <topo>newFuncTopo.py</topo>
+ </CASE11>
+
+ <CASE12>
+ </CASE12>
+
+ <CASE22>
+ </CASE22>
+
+</PARAMS>
diff --git a/TestON/tests/SAMP/SAMPstartTemplate2/SAMPstartTemplate2.py b/TestON/tests/SAMP/SAMPstartTemplate2/SAMPstartTemplate2.py
new file mode 100644
index 0000000..ce057f4
--- /dev/null
+++ b/TestON/tests/SAMP/SAMPstartTemplate2/SAMPstartTemplate2.py
@@ -0,0 +1,228 @@
+
+# This is a sample template that starts up ONOS cluster, this template
+# can be use as a base script for ONOS System Testing.
+
+class SAMPstartTemplate2:
+
+ def __init__( self ):
+ self.default = ''
+
+
+ def CASE0(self, main):
+ '''
+ Pull specific ONOS branch, then Build ONOS ono ONOS Bench.
+ This step is usually skipped. Because in a Jenkins driven automated
+ test env. We want Jenkins jobs to pull&build for flexibility to handle
+ different versions of ONOS.
+ '''
+ gitPull = main.params['CASE0']['gitPull']
+ gitBranch = main.params['CASE0']['gitBranch']
+
+ main.case("Pull onos branch and build onos on Teststation.")
+
+ if gitPull == 'True':
+ main.step( "Git Checkout ONOS branch: " + gitBranch)
+ stepResult = main.ONOSbench.gitCheckout( branch = gitBranch )
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully checkout onos branch.",
+ onfail="Failed to checkout onos branch. Exiting test..." )
+ if not stepResult: main.exit()
+
+ main.step( "Git Pull on ONOS branch:" + gitBranch)
+ stepResult = main.ONOSbench.gitPull( )
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully pull onos. ",
+ onfail="Failed to pull onos. Exiting test ..." )
+ if not stepResult: main.exit()
+
+ main.step( "Building ONOS branch: " + gitBranch )
+ stepResult = main.ONOSbench.cleanInstall( skipTest = True )
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully build onos.",
+ onfail="Failed to build onos. Exiting test..." )
+ if not stepResult: main.exit()
+
+ else:
+ main.log.warn( "Skipped pulling onos and Skipped building ONOS" )
+
+
+ def CASE1( self, main ):
+ '''
+ Set up global test variables;
+ Uninstall all running cells in test env defined in .topo file
+
+ '''
+
+ main.case( "Constructing global test variables and clean cluster env." )
+
+ main.step( "Constructing test variables" )
+ main.branch = main.ONOSbench.getBranchName()
+ main.log.info( "Running onos branch: " + main.branch )
+ main.commitNum = main.ONOSbench.getVersion().split(' ')[1]
+ main.log.info( "Running onos commit Number: " + main.commitNum)
+ main.nodeList = main.params['CASE1']['NodeList'].split(",")
+ main.onosStartupSleep = float( main.params['CASE1']['SleepTimers']['onosStartup'] )
+ main.onosCfgSleep = float( main.params['CASE1']['SleepTimers']['onosCfg'] )
+ main.mnStartupSleep = float( main.params['CASE1']['SleepTimers']['mnStartup'] )
+ main.mnCfgSleep = float( main.params['CASE1']['SleepTimers']['mnCfg'] )
+ utilities.assert_equals( expect=main.TRUE,
+ actual=main.TRUE,
+ onpass="Successfully construct " +
+ "test variables ",
+ onfail="Failed to construct test variables" )
+
+
+
+ main.step( "Uninstall all onos nodes in the env.")
+ stepResult = main.TRUE
+ for node in main.nodeList:
+ nodeResult = main.ONOSbench.onosUninstall( nodeIp = "$" + node )
+ stepResult = stepResult & nodeResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully uninstall onos on all nodes in env.",
+ onfail="Failed to uninstall onos on all nodes in env!" )
+ if not stepResult:
+ main.log.error( "Failure to clean test env. Exiting test..." )
+ main.exit()
+
+ def CASE2( self, main ):
+ '''
+ Report errors/warnings/exceptions
+ '''
+ main.log.info("Error report: \n" )
+ main.ONOSbench.logReport( main.ONOScli1.ip_address,
+ [ "INFO",
+ "FOLLOWER",
+ "WARN",
+ "flow",
+ "ERROR",
+ "Except" ],
+ "s" )
+
+ def CASE10( self, main ):
+ """
+ Start ONOS cluster (3 nodes in this example) in three steps:
+ 1) start a basic cluster with drivers app via ONOSDriver;
+ 2) activate apps via ONOSCliDriver;
+ 3) configure onos via ONOSCliDriver;
+ """
+
+ import time
+
+ numNodes = int( main.params['CASE10']['numNodes'] )
+ main.case( "Start up " + str( numNodes ) + "-node onos cluster.")
+
+ main.step( "Start ONOS cluster with basic (drivers) app.")
+ onosClusterIPs = []
+ for n in range( 1, numNodes + 1 ):
+ handle = "main.ONOScli" + str( n )
+ onosClusterIPs.append( eval( handle ).ip_address )
+
+ stepResult = main.ONOSbench.startBasicONOS(nodeList = onosClusterIPs, opSleep = 200 )
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully started basic ONOS cluster ",
+ onfail="Failed to start basic ONOS Cluster " )
+
+ main.step( "Establishing Handles on ONOS CLIs.")
+ cliResult = main.TRUE
+ for n in range( 1, numNodes + 1 ):
+ handle = "main.ONOScli" + str( n )
+ cliResult = cliResult & ( eval( handle ).startCellCli() )
+ utilities.assert_equals( expect=main.TRUE,
+ actual=cliResult,
+ onpass="Successfully started onos cli's ",
+ onfail="Failed to start onos cli's " )
+
+ main.step( "Activate onos apps.")
+ apps = main.params['CASE10'].get( 'Apps' )
+ if apps:
+ main.log.info( "Apps to activate: " + apps )
+ activateResult = main.TRUE
+ for a in apps.split(","):
+ activateResult = activateResult & main.ONOScli1.activateApp(a)
+ # TODO: check this worked
+ time.sleep( main.onosCfgSleep ) # wait for apps to activate
+ else:
+ main.log.warn( "No configurations were specified to be changed after startup" )
+ utilities.assert_equals( expect=main.TRUE,
+ actual=activateResult,
+ onpass="Successfully set config",
+ onfail="Failed to set config" )
+
+ main.step( "Set ONOS configurations" )
+ config = main.params['CASE10'].get( 'ONOS_Configuration' )
+ if config:
+ main.log.debug( config )
+ checkResult = main.TRUE
+ for component in config:
+ for setting in config[component]:
+ value = config[component][setting]
+ check = main.ONOScli1.setCfg( component, setting, value )
+ main.log.info( "Value was changed? {}".format( main.TRUE == check ) )
+ checkResult = check and checkResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=checkResult,
+ onpass="Successfully set config",
+ onfail="Failed to set config" )
+ else:
+ main.log.warn( "No configurations were specified to be changed after startup" )
+
+ def CASE11( self, main ):
+ """
+ Start mininet and assign controllers
+ """
+ import time
+
+ dependencyPath = main.params['CASE11']['path']
+ topology = main.params['CASE11']['topo']
+ main.log.report( "Start Mininet topology" )
+ main.log.case( "Start Mininet topology" )
+
+ main.step( "Starting Mininet Topology" )
+ topoResult = main.Mininet1.startNet( topoFile=dependencyPath + topology )
+ stepResult = topoResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully loaded topology",
+ onfail="Failed to load topology" )
+ # Exit if topology did not load properly
+ if not topoResult:
+ main.cleanup()
+ main.exit()
+
+ main.step( "Assign switches to controllers.")
+ assignResult = main.TRUE
+ onosNodes = [ main.ONOScli1.ip_address, main.ONOScli2.ip_address, main.ONOScli3.ip_address ]
+ for i in range(1, 8):
+ assignResult = assignResult & main.Mininet1.assignSwController( sw="s" + str( i ),
+ ip=onosNodes,
+ port='6653' )
+ time.sleep(main.mnCfgSleep)
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully assign switches to controllers",
+ onfail="Failed to assign switches to controllers" )
+
+
+ def CASE12( self, main ):
+ """
+ Tests using through ONOS CLI handles
+ """
+
+ main.log.case( "Test some onos commands through CLI. ")
+ main.log.debug( main.ONOScli1.sendline("summary") )
+ main.log.debug( main.ONOScli3.sendline("devices") )
+
+ def CASE22( self, main ):
+ """
+ Tests using ONOS REST API handles
+ """
+
+ main.case( " Sample tests using ONOS REST API handles. ")
+ main.log.debug( main.ONOSrest1.send("/devices") )
+ main.log.debug( main.ONOSrest2.apps() )
\ No newline at end of file
diff --git a/TestON/tests/SAMP/SAMPstartTemplate2/SAMPstartTemplate2.topo b/TestON/tests/SAMP/SAMPstartTemplate2/SAMPstartTemplate2.topo
new file mode 100755
index 0000000..9f23369
--- /dev/null
+++ b/TestON/tests/SAMP/SAMPstartTemplate2/SAMPstartTemplate2.topo
@@ -0,0 +1,94 @@
+<TOPOLOGY>
+ <COMPONENT>
+ <!--
+ This is a list of all components and their handles in the test setup.
+ Even with some handles not used in test cases, we want to define
+ all onos cells here, for cases to set up onos cluster.
+ -->
+ <ONOSbench>
+ <host>localhost</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>1</connect_order>
+ <COMPONENTS>
+ <home></home> #defines where onos home is
+ </COMPONENTS>
+ </ONOSbench>
+
+ <ONOScli1>
+ <host>OC1</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosCliDriver</type>
+ <connect_order>2</connect_order>
+ <COMPONENTS>
+ </COMPONENTS>
+ </ONOScli1>
+
+ <ONOScli2>
+ <host>OC2</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosCliDriver</type>
+ <connect_order>3</connect_order>
+ <COMPONENTS>
+ </COMPONENTS>
+ </ONOScli2>
+
+ <ONOScli3>
+ <host>OC3</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosCliDriver</type>
+ <connect_order>4</connect_order>
+ <COMPONENTS>
+ </COMPONENTS>
+ </ONOScli3>
+
+ <Mininet1>
+ <host>localhost</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>MininetCliDriver</type>
+ <connect_order>5</connect_order>
+ <COMPONENTS>
+ <home>~/mininet/custom/</home>
+ </COMPONENTS>
+ </Mininet1>
+
+ <ONOSrest1>
+ <host>OC1</host>
+ <port>8181</port>
+ <user>onos</user>
+ <password>rocks</password>
+ <type>OnosRestDriver</type>
+ <connect_order>6</connect_order>
+ <COMPONENTS>
+ </COMPONENTS>
+ </ONOSrest1>
+
+ <ONOSrest2>
+ <host>OC2</host>
+ <port>8181</port>
+ <user>onos</user>
+ <password>rocks</password>
+ <type>OnosRestDriver</type>
+ <connect_order>7</connect_order>
+ <COMPONENTS>
+ </COMPONENTS>
+ </ONOSrest2>
+
+ <ONOSrest3>
+ <host>OC3</host>
+ <port>8181</port>
+ <user>onos</user>
+ <password>rocks</password>
+ <type>OnosRestDriver</type>
+ <connect_order>8</connect_order>
+ <COMPONENTS>
+ </COMPONENTS>
+ </ONOSrest3>
+
+ </COMPONENT>
+</TOPOLOGY>
diff --git a/TestON/tests/SAMP/SAMPstartTemplate2/__init__.py b/TestON/tests/SAMP/SAMPstartTemplate2/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/TestON/tests/SAMP/SAMPstartTemplate2/__init__.py
diff --git a/TestON/tests/USECASE/USECASE_SegmentRouting/USECASE_SegmentRouting.py b/TestON/tests/USECASE/USECASE_SegmentRouting/USECASE_SegmentRouting.py
index 0057a10..9822b8b 100644
--- a/TestON/tests/USECASE/USECASE_SegmentRouting/USECASE_SegmentRouting.py
+++ b/TestON/tests/USECASE/USECASE_SegmentRouting/USECASE_SegmentRouting.py
@@ -191,7 +191,7 @@
onpass="ONOS service is ready",
onfail="ONOS service did not start properly" )
#time.sleep( 2*main.startUpSleep )
- main.ONOSbench.handle.sendline( "onos-secure-ssh")
+ #main.ONOSbench.handle.sendline( "onos-secure-ssh")
main.step( "Checking if ONOS CLI is ready" )
cliResult = main.CLIs[0].startOnosCli( main.ONOSip[ 0 ],
commandlineTimeout=100, onosStartTimeout=600 )