Merge "Framework of the new CHOtest"
diff --git a/TestON/drivers/common/api/controller/onosrestdriver.py b/TestON/drivers/common/api/controller/onosrestdriver.py
index a9676a9..1b7c8fd 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, ip = "DEFAULT", port = "DEFAULT", base="/onos/v1", method="GET",
query=None, data=None, debug=False ):
"""
Arguments:
@@ -94,6 +94,14 @@
# 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
+ if ip == "DEFAULT":
+ main.log.warn( "No ip given, reverting to ip from topo file" )
+ ip = self.ip_address
+ if port == "DEFAULT":
+ main.log.warn( "No port given, reverting to port " +
+ "from topo file" )
+ port = self.port
+
try:
path = "http://" + str( ip ) + ":" + str( port ) + base + url
if self.user_name and self.pwd:
@@ -137,7 +145,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", ip = ip, port = port )
if response:
if 200 <= response[ 0 ] <= 299:
output = response[ 1 ]
@@ -185,7 +193,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, ip = ip, port = port )
if response:
if 200 <= response[ 0 ] <= 299:
output = response[ 1 ]
@@ -248,7 +256,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", ip = ip, port = port )
if response:
if 200 <= response[ 0 ] <= 299:
output = response[ 1 ]
@@ -291,8 +299,9 @@
"from topo file" )
port = self.port
query = "/" + str( appName ) + "/active"
- response = self.send( ip, port, method="POST",
- url="/applications" + query )
+ response = self.send( method="POST",
+ url="/applications" + query,
+ ip = ip, port = port)
if response:
output = response[ 1 ]
app = json.loads( output )
@@ -347,8 +356,9 @@
"from topo file" )
port = self.port
query = "/" + str( appName ) + "/active"
- response = self.send( ip, port, method="DELETE",
- url="/applications" + query )
+ response = self.send( method="DELETE",
+ url="/applications" + query,
+ ip = ip, port = port )
if response:
output = response[ 1 ]
app = json.loads( output )
@@ -401,7 +411,8 @@
"from topo file" )
port = self.port
query = "/" + project + str( appName )
- response = self.send( ip, port, url="/applications" + query )
+ response = self.send( url="/applications" + query,
+ ip = ip, port = port )
if response:
if 200 <= response[ 0 ] <= 299:
output = response[ 1 ]
@@ -451,10 +462,8 @@
main.log.warn( "No port given, reverting to port " +
"from topo file" )
port = self.port
- response = self.send( ip,
- port,
- method="POST",
- url="/intents",
+ response = self.send( method="POST",
+ url="/intents", ip = ip, port = port,
data=json.dumps( intentJson ) )
if response:
if 201:
@@ -603,10 +612,8 @@
main.log.warn( "No port given, reverting to port " +
"from topo file" )
port = self.port
- response = self.send( ip,
- port,
- method="POST",
- url="/intents",
+ response = self.send( method="POST",
+ url="/intents", ip = ip, port = port,
data=json.dumps( intentJson ) )
if response:
if 201:
@@ -644,10 +651,8 @@
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",
- url="/intents" + query )
+ response = self.send( method="DELETE",
+ url="/intents" + query, ip = ip, port = port )
if response:
if 200 <= response[ 0 ] <= 299:
return main.TRUE
@@ -747,7 +752,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", ip = ip, port = port )
if response:
if 200 <= response[ 0 ] <= 299:
output = response[ 1 ]
@@ -793,7 +798,7 @@
"from topo file" )
port = self.port
query = "/" + mac + "/" + vlan
- response = self.send( ip, port, url="/hosts" + query )
+ response = self.send( url="/hosts" + query, ip = ip, port = port )
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 +837,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", ip = ip, port = port )
if response:
if 200 <= response[ 0 ] <= 299:
output = response[ 1 ]
@@ -869,7 +874,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", ip = ip, port = port )
if response:
if 200 <= response[ 0 ] <= 299:
output = response[ 1 ]
@@ -1032,7 +1037,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", ip = ip, port = port )
if response:
if 200 <= response[ 0 ] <= 299:
output = response[ 1 ]
@@ -1075,7 +1080,7 @@
if flowId:
url += "/" + str( int( flowId ) )
print url
- response = self.send( ip, port, url=url )
+ response = self.send( url=url, ip = ip, port = port )
if response:
if 200 <= response[ 0 ] <= 299:
output = response[ 1 ]
@@ -1123,10 +1128,8 @@
"from topo file" )
port = self.port
url = "/flows/" + deviceId
- response = self.send( ip,
- port,
- method="POST",
- url=url,
+ response = self.send( method="POST",
+ url=url, ip = ip, port = port,
data=json.dumps( flowJson ) )
if response:
if 201:
@@ -1292,10 +1295,8 @@
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",
- url="/flows" + query )
+ response = self.send( method="DELETE",
+ url="/flows" + query, ip = ip, port = port )
if response:
if 200 <= response[ 0 ] <= 299:
return main.TRUE
@@ -1365,7 +1366,7 @@
url += "/" + subjectKey
if configKey:
url += "/" + configKey
- response = self.send( ip, port, url=url )
+ response = self.send( url=url, ip = ip, port = port )
if response:
if 200 <= response[ 0 ] <= 299:
output = response[ 1 ]
@@ -1415,9 +1416,8 @@
url += "/" + subjectKey
if configKey:
url += "/" + configKey
- response = self.send( ip, port,
- method="POST",
- url=url,
+ response = self.send( method="POST",
+ url=url, ip = ip, port = port,
data=json.dumps( cfgJson ) )
if response:
if 200 <= response[ 0 ] <= 299:
@@ -1462,9 +1462,8 @@
url += "/" + subjectKey
if configKey:
url += "/" + configKey
- response = self.send( ip, port,
- method="DELETE",
- url=url )
+ response = self.send( method="DELETE",
+ url=url, ip = ip, port = port )
if response:
if 200 <= response[ 0 ] <= 299:
main.log.info( self.name + ": Successfully delete cfg" )
@@ -1667,10 +1666,8 @@
"from topo file" )
port = self.port
url = "/flows/"
- response = self.send( ip,
- port,
- method="POST",
- url=url,
+ response = self.send( method="POST",
+ url=url, ip = ip, port = port,
data=json.dumps( batch ) )
#main.log.info("Post response is: ", str(response[0]))
if response[0] == 200:
@@ -1712,10 +1709,8 @@
port = self.port
# NOTE: REST url requires the intent id to be in decimal form
- response = self.send( ip,
- port,
- method="DELETE",
- url="/flows/",
+ response = self.send( method="DELETE",
+ url="/flows/", ip = ip, port = port,
data = json.dumps(batch) )
if response:
if 200 <= response[ 0 ] <= 299:
diff --git a/TestON/drivers/common/api/dockerapidriver.py b/TestON/drivers/common/api/dockerapidriver.py
index f8e9e23..4a874c6 100644
--- a/TestON/drivers/common/api/dockerapidriver.py
+++ b/TestON/drivers/common/api/dockerapidriver.py
@@ -242,14 +242,16 @@
main.cleanup()
main.exit()
- def onosFormCluster( self, onosIPs, cmdPath="~/OnosSystemTest/TestON/tests/PLATdockertest/Dependency", user="karaf", passwd="karaf" ):
+ def onosFormCluster( self, onosIPs, cmdPath, user="karaf", passwd="karaf" ):
"""
From ONOS cluster for IP addresses in onosIPs list
"""
try:
onosIPs = " ".join(onosIPs)
- command = cmdPath + "/onos-form-cluster -u " + user + " -p " + passwd + \
- " " + onosIPs
+ command = "{}/onos-form-cluster -u {} -p {} {}".format( cmdPath,
+ user,
+ passwd,
+ onosIPs )
result = subprocess.call( command, shell=True )
if result == 0:
return main.TRUE
diff --git a/TestON/drivers/common/cli/emulator/mininetclidriver.py b/TestON/drivers/common/cli/emulator/mininetclidriver.py
index b6fbded..8165d3a 100644
--- a/TestON/drivers/common/cli/emulator/mininetclidriver.py
+++ b/TestON/drivers/common/cli/emulator/mininetclidriver.py
@@ -2129,6 +2129,8 @@
def flowTableComp( self, flowTable1, flowTable2 ):
# This function compares the selctors and treatments of each flow
try:
+ assert flowTable1, "flowTable1 is empty or None"
+ assert flowTable2, "flowTable2 is empty or None"
returnValue = main.TRUE
if len(flowTable1) != len(flowTable2):
main.log.warn( "Flow table lengths do not match" )
@@ -2151,6 +2153,9 @@
returnValue = main.FALSE
break
return returnValue
+ except AssertionError:
+ main.log.exception( "Nothing to compare" )
+ return main.FALSE
except Exception:
main.log.exception( "Uncaught exception!" )
main.cleanup()
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index c7ae79b..0822879 100644
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -301,11 +301,93 @@
main.cleanup()
main.exit()
- def log( self, cmdStr, level="" ):
+ 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="",noExit=False):
"""
log the commands in the onos CLI.
returns main.TRUE on success
returns main.FALSE if Error occurred
+ if noExit is True, TestON will not exit, but clean up
Available level: DEBUG, TRACE, INFO, WARN, ERROR
Level defaults to INFO
"""
@@ -343,31 +425,47 @@
return main.TRUE
except pexpect.TIMEOUT:
main.log.exception( self.name + ": TIMEOUT exception found" )
- main.cleanup()
- main.exit()
+ if noExit:
+ main.cleanup()
+ return None
+ else:
+ main.cleanup()
+ main.exit()
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
- main.cleanup()
- main.exit()
+ if noExit:
+ main.cleanup()
+ return None
+ else:
+ main.cleanup()
+ main.exit()
except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
- main.cleanup()
- main.exit()
+ if noExit:
+ main.cleanup()
+ return None
+ else:
+ main.cleanup()
+ main.exit()
- def sendline( self, cmdStr, showResponse=False, debug=False, timeout=10 ):
+ def sendline( self, cmdStr, showResponse=False, debug=False, timeout=10, noExit=False ):
"""
Send a completely user specified string to
the onos> prompt. Use this function if you have
a very specific command to send.
+ if noExit is True, TestON will not exit, but clean up
+
Warning: There are no sanity checking to commands
sent using this method.
"""
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,noExit=noExit )
self.handle.sendline( cmdStr )
i = self.handle.expect( ["onos>", "\$"], timeout )
response = self.handle.before
@@ -422,12 +520,20 @@
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
- main.cleanup()
- main.exit()
+ if noExit:
+ main.cleanup()
+ return None
+ else:
+ main.cleanup()
+ main.exit()
except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
- main.cleanup()
- main.exit()
+ if noExit:
+ main.cleanup()
+ return None
+ else:
+ main.cleanup()
+ main.exit()
# IMPORTANT NOTE:
# For all cli commands, naming convention should match
@@ -1032,11 +1138,13 @@
main.cleanup()
main.exit()
- def addHostIntent( self, hostIdOne, hostIdTwo ):
+ def addHostIntent( self, hostIdOne, hostIdTwo, vlanId="" ):
"""
Required:
* hostIdOne: ONOS host id for host1
* hostIdTwo: ONOS host id for host2
+ Optional:
+ * vlanId: specify a VLAN id for the intent
Description:
Adds a host-to-host intent ( bidirectional ) by
specifying the two hosts.
@@ -1044,8 +1152,10 @@
A string of the intent id or None on Error
"""
try:
- cmdStr = "add-host-intent " + str( hostIdOne ) +\
- " " + str( hostIdTwo )
+ cmdStr = "add-host-intent "
+ if vlanId:
+ cmdStr += "-v " + str( vlanId ) + " "
+ cmdStr += str( hostIdOne ) + " " + str( hostIdTwo )
handle = self.sendline( cmdStr )
assert "Command not found:" not in handle, handle
if re.search( "Error", handle ):
@@ -1141,7 +1251,8 @@
ipSrc="",
ipDst="",
tcpSrc="",
- tcpDst="" ):
+ tcpDst="",
+ vlanId="" ):
"""
Required:
* ingressDevice: device id of ingress device
@@ -1158,6 +1269,7 @@
* ipDst: specify ip destination address
* tcpSrc: specify tcp source port
* tcpDst: specify tcp destination port
+ * vlanId: specify vlan ID
Description:
Adds a point-to-point intent ( uni-directional ) by
specifying device id's and optional fields
@@ -1199,6 +1311,8 @@
cmd += " --tcpSrc " + str( tcpSrc )
if tcpDst:
cmd += " --tcpDst " + str( tcpDst )
+ if vlanId:
+ cmd += " -v " + str( vlanId )
# Check whether the user appended the port
# or provided it as an input
@@ -1277,7 +1391,8 @@
tcpSrc="",
tcpDst="",
setEthSrc="",
- setEthDst="" ):
+ setEthDst="",
+ vlanId="" ):
"""
Note:
This function assumes the format of all ingress devices
@@ -1302,6 +1417,7 @@
* tcpDst: specify tcp destination port
* setEthSrc: action to Rewrite Source MAC Address
* setEthDst: action to Rewrite Destination MAC Address
+ * vlanId: specify vlan Id
Description:
Adds a multipoint-to-singlepoint intent ( uni-directional ) by
specifying device id's and optional fields
@@ -1348,6 +1464,8 @@
cmd += " --setEthSrc " + str( setEthSrc )
if setEthDst:
cmd += " --setEthDst " + str( setEthDst )
+ if vlanId:
+ cmd += " -v " + str( vlanId )
# Check whether the user appended the port
# or provided it as an input
@@ -1430,7 +1548,8 @@
tcpSrc="",
tcpDst="",
setEthSrc="",
- setEthDst="" ):
+ setEthDst="",
+ vlanId="" ):
"""
Note:
This function assumes the format of all egress devices
@@ -1455,6 +1574,7 @@
* tcpDst: specify tcp destination port
* setEthSrc: action to Rewrite Source MAC Address
* setEthDst: action to Rewrite Destination MAC Address
+ * vlanId: specify vlan Id
Description:
Adds a singlepoint-to-multipoint intent ( uni-directional ) by
specifying device id's and optional fields
@@ -1501,6 +1621,8 @@
cmd += " --setEthSrc " + str( setEthSrc )
if setEthDst:
cmd += " --setEthDst " + str( setEthDst )
+ if vlanId:
+ cmd += " -v " + str( vlanId )
# Check whether the user appended the port
# or provided it as an input
@@ -2101,8 +2223,11 @@
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
+ except pexpect.TIMEOUT:
+ main.log.error( self.name + ": ONOS timeout" )
+ return None
- def flows( self, state="", jsonFormat=True, timeout=60 ):
+ def flows( self, state="", jsonFormat=True, timeout=60, noExit=False ):
"""
Optional:
* jsonFormat: enable output formatting in json
@@ -2114,7 +2239,7 @@
if jsonFormat:
cmdStr += " -j "
cmdStr += state
- handle = self.sendline( cmdStr, timeout=timeout )
+ handle = self.sendline( cmdStr, timeout=timeout, noExit=noExit )
assert "Command not found:" not in handle, handle
if re.search( "Error:", handle ):
main.log.error( self.name + ": flows() response: " +
@@ -2143,7 +2268,7 @@
count = int(self.getTotalFlowsNum( timeout=timeout ))
return count if (count > min) else False
- def checkFlowsState( self, isPENDING=True, timeout=60 ):
+ def checkFlowsState( self, isPENDING=True, timeout=60,noExit=False ):
"""
Description:
Check the if all the current flows are in ADDED state
@@ -2192,9 +2317,13 @@
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
+ except pexpect.TIMEOUT:
+ main.log.error( self.name + ": ONOS timeout" )
+ return None
+
def pushTestIntents( self, ingress, egress, batchSize, offset="",
- options="", timeout=10, background = False ):
+ options="", timeout=10, background = False, noExit=False ):
"""
Description:
Push a number of intents in a batch format to
@@ -2223,7 +2352,7 @@
batchSize,
offset,
back )
- response = self.sendline( cmd, timeout=timeout )
+ response = self.sendline( cmd, timeout=timeout, noExit=noExit )
assert "Command not found:" not in response, response
main.log.info( response )
if response == None:
@@ -2251,7 +2380,7 @@
main.cleanup()
main.exit()
- def getTotalFlowsNum( self, timeout=60 ):
+ def getTotalFlowsNum( self, timeout=60, noExit=False ):
"""
Description:
Get the number of ADDED flows.
@@ -2262,7 +2391,7 @@
try:
# get total added flows number
cmd = "flows -s|grep ADDED|wc -l"
- totalFlows = self.sendline( cmd, timeout=timeout )
+ totalFlows = self.sendline( cmd, timeout=timeout, noExit=noExit )
if totalFlows == None:
# if timeout, we will get total number of all flows, and subtract other states
@@ -2272,7 +2401,7 @@
statesCount = [0, 0, 0, 0]
# get total flows from summary
- response = json.loads( self.sendline( "summary -j", timeout=timeout ) )
+ response = json.loads( self.sendline( "summary -j", timeout=timeout, noExit=noExit ) )
totalFlows = int( response.get("flows") )
for s in states:
@@ -2308,8 +2437,11 @@
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
+ except pexpect.TIMEOUT:
+ main.log.error( self.name + ": ONOS timeout" )
+ return None
- def getTotalIntentsNum( self ):
+ def getTotalIntentsNum( self, timeout=60 ):
"""
Description:
Get the total number of intents, include every states.
@@ -2318,7 +2450,7 @@
"""
try:
cmd = "summary -j"
- response = self.sendline( cmd )
+ response = self.sendline( cmd, timeout=timeout )
if response == None:
return -1
response = json.loads( response )
@@ -4240,6 +4372,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 ad8a284..1aed954 100644
--- a/TestON/drivers/common/cli/onosdriver.py
+++ b/TestON/drivers/common/cli/onosdriver.py
@@ -194,28 +194,33 @@
ret = main.TRUE
self.handle.sendline( "onos-package" )
self.handle.expect( "onos-package" )
- i = self.handle.expect( [ "Downloading",
- "tar.gz",
- "\$",
- "Unknown options" ],
- opTimeout )
- handle = str( self.handle.before + self.handle.after )
- if i == 0:
- # Give more time to download the file
- self.handle.expect( "\$", opTimeout * 2 )
- handle += str( self.handle.before )
- elif i == 1:
- self.handle.expect( "\$" )
- handle += str( self.handle.before )
- elif i == 2:
- # This seems to be harmless, but may be a problem
- main.log.warn( "onos-package output not as expected" )
- elif i == 3:
- # Incorrect usage
- main.log.error( "onos-package does not recognize the given options" )
- self.handle.expect( "\$" )
- handle += str( self.handle.before )
- ret = main.FALSE
+ while True:
+ i = self.handle.expect( [ "Downloading",
+ "Unknown options",
+ "No such file or directory",
+ "tar.gz",
+ "\$" ],
+ opTimeout )
+ handle = str( self.handle.before + self.handle.after )
+ if i == 0:
+ # Give more time to download the file
+ continue # expect again
+ elif i == 1:
+ # Incorrect usage
+ main.log.error( "onos-package does not recognize the given options" )
+ ret = main.FALSE
+ continue # expect again
+ elif i == 2:
+ # File(s) not found
+ main.log.error( "onos-package could not find a file or directory" )
+ ret = main.FALSE
+ continue # expect again
+ elif i == 3:
+ # tar.gz
+ continue # expect again
+ elif i == 4:
+ # Prompt returned
+ break
main.log.info( "onos-package command returned: " + handle )
# As long as the sendline does not time out,
# return true. However, be careful to interpret
@@ -790,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 )
@@ -2248,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/FUNC/FUNCintent/FUNCintent.py b/TestON/tests/FUNC/FUNCintent/FUNCintent.py
index 080aa8f..1bff0f1 100644
--- a/TestON/tests/FUNC/FUNCintent/FUNCintent.py
+++ b/TestON/tests/FUNC/FUNCintent/FUNCintent.py
@@ -836,8 +836,8 @@
main.step( "VLAN1: Add vlan host intents between h4 and h12" )
main.assertReturnString = "Assertion Result vlan IPV4\n"
- host1 = { "name":"h4","id":"00:00:00:00:00:04/100" }
- host2 = { "name":"h12","id":"00:00:00:00:00:0C/100 "}
+ host1 = { "name":"h4","id":"00:00:00:00:00:04/100", "vlan":"100" }
+ host2 = { "name":"h12","id":"00:00:00:00:00:0C/100", "vlan":"100" }
testResult = main.FALSE
installResult = main.FALSE
installResult = main.intentFunction.installHostIntent( main,
@@ -864,36 +864,6 @@
onpass=main.assertReturnString,
onfail=main.assertReturnString)
- main.step( "VLAN2: Add inter vlan host intents between h13 and h20" )
- main.assertReturnString = "Assertion Result different VLAN negative test\n"
- host1 = { "name":"h13" }
- host2 = { "name":"h20" }
- testResult = main.FALSE
- installResult = main.FALSE
- installResult = main.intentFunction.installHostIntent( main,
- name='VLAN2',
- onosNode='0',
- host1=host1,
- host2=host2)
-
- if installResult:
- testResult = main.intentFunction.testHostIntent( main,
- name='VLAN2',
- intentId = installResult,
- onosNode='0',
- host1=host1,
- host2=host2,
- sw1='s5',
- sw2='s2',
- expectedLink = 18)
- else:
- main.CLIs[ 0 ].removeAllIntents( purge=True )
-
- utilities.assert_equals( expect=main.TRUE,
- actual=testResult,
- onpass=main.assertReturnString,
- onfail=main.assertReturnString)
-
main.step( "Confirm that ONOS leadership is unchanged")
intentLeadersNew = main.CLIs[ 0 ].leaderCandidates()
main.intentFunction.checkLeaderChange( intentLeadersOld,
@@ -1184,25 +1154,24 @@
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" }
+ { "name":"h5","device":"of:0000000000000005/5","mac":"00:00:00:00:00:05", "vlan":"200" }
]
recipients = [
- { "name":"h21","device":"of:0000000000000007/5","mac":"00:00:00:00:00:15" }
+ { "name":"h21","device":"of:0000000000000007/5","mac":"00:00:00:00:00:15", "vlan":"200" }
]
testResult = main.FALSE
installResult = main.FALSE
installResult = main.intentFunction.installPointIntent(
main,
- name="DUALSTACK1",
+ name="VLAN",
senders=senders,
- recipients=recipients,
- ethType="IPV4" )
+ recipients=recipients)
if installResult:
testResult = main.intentFunction.testPointIntent(
main,
intentId=installResult,
- name="DUALSTACK1",
+ name="VLAN",
senders=senders,
recipients=recipients,
sw1="s5",
@@ -1434,11 +1403,11 @@
main.step( "VLAN: Add single point to multi point intents" )
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" }
+ { "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" },
- { "name":"h20", "device":"of:0000000000000007/4", "mac":"00:00:00:00:00:14" }
+ { "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
@@ -1446,10 +1415,9 @@
installResult = main.FALSE
installResult = main.intentFunction.installSingleToMultiIntent(
main,
- name="IPV4",
+ name="VLAN`",
senders=senders,
recipients=recipients,
- ethType="IPV4",
sw1="s5",
sw2="s2")
@@ -1457,7 +1425,7 @@
testResult = main.intentFunction.testPointIntent(
main,
intentId=installResult,
- name="IPV4",
+ name="VLAN",
senders=senders,
recipients=recipients,
badSenders=badSenders,
@@ -1658,11 +1626,11 @@
main.step( "VLAN: Add multi point to single point intents" )
main.assertReturnString = "Assertion results for IPV4 multi to single point intent with IPV4 type and no MAC addresses in the same VLAN\n"
senders = [
- { "name":"h13", "device":"of:0000000000000006/5" },
- { "name":"h21", "device":"of:0000000000000007/5" }
+ { "name":"h13", "device":"of:0000000000000006/5", "vlan":"200" },
+ { "name":"h21", "device":"of:0000000000000007/5", "vlan":"200" }
]
recipients = [
- { "name":"h5", "device":"of:0000000000000005/5" }
+ { "name":"h5", "device":"of:0000000000000005/5", "vlan":"200" }
]
badSenders=[ { "name":"h12" } ] # Senders that are not in the intent
badRecipients=[ { "name":"h20" } ] # Recipients that are not in the intent
@@ -1673,7 +1641,6 @@
name="VLAN",
senders=senders,
recipients=recipients,
- ethType="IPV4",
sw1="s5",
sw2="s2")
@@ -1863,156 +1830,8 @@
onpass=main.assertReturnString,
onfail=main.assertReturnString )
- main.step( "IPV4: Add multi point to single point intents" )
- main.assertReturnString = "Assertion results for IPV4 multi to single \
- point intent end point failure with IPV4 type and MAC addresses\n"
- senders = [
- { "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" }
- ]
- recipients = [
- { "name":"h8", "device":"of:0000000000000005/8", "mac":"00:00:00:00:00:08" }
- ]
- isolatedSenders = [
- { "name":"h24"}
- ]
- isolatedRecipients = []
- testResult = main.FALSE
- installResult = main.FALSE
- installResult = main.intentFunction.installMultiToSingleIntent(
- main,
- name="IPV4",
- senders=senders,
- recipients=recipients,
- ethType="IPV4",
- sw1="s5",
- sw2="s2")
-
- if installResult:
- testResult = main.intentFunction.testEndPointFail(
- main,
- intentId=installResult,
- name="IPV4",
- senders=senders,
- recipients=recipients,
- isolatedSenders=isolatedSenders,
- isolatedRecipients=isolatedRecipients,
- sw1="s6",
- sw2="s2",
- sw3="s4",
- sw4="s1",
- sw5="s3",
- expectedLink1=16,
- expectedLink2=14 )
- else:
- main.CLIs[ 0 ].removeAllIntents( purge=True )
-
- utilities.assert_equals( expect=main.TRUE,
- actual=testResult,
- onpass=main.assertReturnString,
- onfail=main.assertReturnString )
-
- main.step( "IPV4_2: Add multi point to single point intents" )
- main.assertReturnString = "Assertion results for IPV4 multi to single \
- point intent end point failure with IPV4 type and no MAC addresses\n"
- senders = [
- { "name":"h16", "device":"of:0000000000000006/8" },
- { "name":"h24", "device":"of:0000000000000007/8" }
- ]
- recipients = [
- { "name":"h8", "device":"of:0000000000000005/8" }
- ]
- isolatedSenders = [
- { "name":"h24"}
- ]
- isolatedRecipients = []
- testResult = main.FALSE
- installResult = main.FALSE
- installResult = main.intentFunction.installMultiToSingleIntent(
- main,
- name="IPV4_2",
- senders=senders,
- recipients=recipients,
- ethType="IPV4",
- sw1="s5",
- sw2="s2")
-
- if installResult:
- testResult = main.intentFunction.testEndPointFail(
- main,
- intentId=installResult,
- name="IPV4_2",
- senders=senders,
- recipients=recipients,
- isolatedSenders=isolatedSenders,
- isolatedRecipients=isolatedRecipients,
- sw1="s6",
- sw2="s2",
- sw3="s4",
- sw4="s1",
- sw5="s3",
- expectedLink1=16,
- expectedLink2=14 )
- else:
- main.CLIs[ 0 ].removeAllIntents( purge=True )
-
- utilities.assert_equals( expect=main.TRUE,
- actual=testResult,
- onpass=main.assertReturnString,
- onfail=main.assertReturnString )
-
- main.step( "VLAN: Add multi point to single point intents" )
- main.assertReturnString = "Assertion results for IPV4 multi to single \
- point intent end point failure with IPV4 type and no MAC addresses in the same VLAN\n"
- senders = [
- { "name":"h13", "device":"of:0000000000000006/5" },
- { "name":"h21", "device":"of:0000000000000007/5" }
- ]
- recipients = [
- { "name":"h5", "device":"of:0000000000000005/5" }
- ]
- isolatedSenders = [
- { "name":"h21"}
- ]
- isolatedRecipients = []
- testResult = main.FALSE
- installResult = main.FALSE
- installResult = main.intentFunction.installMultiToSingleIntent(
- main,
- name="VLAN",
- senders=senders,
- recipients=recipients,
- ethType="IPV4",
- sw1="s5",
- sw2="s2")
-
- if installResult:
- testResult = main.intentFunction.testEndPointFail(
- main,
- intentId=installResult,
- name="VLAN",
- senders=senders,
- recipients=recipients,
- isolatedSenders=isolatedSenders,
- isolatedRecipients=isolatedRecipients,
- sw1="s6",
- sw2="s2",
- sw3="s4",
- sw4="s1",
- sw5="s3",
- expectedLink1=16,
- expectedLink2=14 )
- else:
- main.CLIs[ 0 ].removeAllIntents( purge=True )
-
- utilities.assert_equals( expect=main.TRUE,
- actual=testResult,
- onpass=main.assertReturnString,
- onfail=main.assertReturnString )
-
main.step( "NOOPTION: Install and test single point to multi point intents" )
- main.assertReturnString = "Assertion results for IPV4 single to multi \
- point intent end point failure with no options set\n"
+ main.assertReturnString = "Assertion results for IPV4 single to multi point intent with no options set\n"
senders = [
{ "name":"h8", "device":"of:0000000000000005/8" }
]
@@ -2020,9 +1839,8 @@
{ "name":"h16", "device":"of:0000000000000006/8" },
{ "name":"h24", "device":"of:0000000000000007/8" }
]
- isolatedSenders = []
- isolatedRecipients = [
- { "name":"h24" }
+ isolatedSenders = [
+ { "name":"h24"}
]
testResult = main.FALSE
installResult = main.FALSE
@@ -2058,151 +1876,4 @@
onpass=main.assertReturnString,
onfail=main.assertReturnString )
- main.step( "IPV4: Install and test single point to multi point intents" )
- main.assertReturnString = "Assertion results for IPV4 single to multi \
- point intent end point failure with IPV4 type and no 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" }
- ]
- isolatedSenders = []
- isolatedRecipients = [
- { "name":"h24" }
- ]
- testResult = main.FALSE
- installResult = main.FALSE
- installResult = main.intentFunction.installSingleToMultiIntent(
- main,
- name="IPV4",
- senders=senders,
- recipients=recipients,
- ethType="IPV4",
- sw1="s5",
- sw2="s2")
-
- if installResult:
- testResult = main.intentFunction.testEndPointFail(
- main,
- intentId=installResult,
- name="IPV4",
- senders=senders,
- recipients=recipients,
- isolatedSenders=isolatedSenders,
- isolatedRecipients=isolatedRecipients,
- sw1="s6",
- sw2="s2",
- sw3="s4",
- sw4="s1",
- sw5="s3",
- expectedLink1=16,
- expectedLink2=14 )
- else:
- main.CLIs[ 0 ].removeAllIntents( purge=True )
-
- utilities.assert_equals( expect=main.TRUE,
- actual=testResult,
- onpass=main.assertReturnString,
- onfail=main.assertReturnString )
-
- main.step( "IPV4_2: Add single point to multi point intents" )
- main.assertReturnString = "Assertion results for IPV4 single to multi\
- point intent endpoint failure 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" }
- ]
- isolatedSenders = []
- isolatedRecipients = [
- { "name":"h24" }
- ]
- testResult = main.FALSE
- installResult = main.FALSE
- installResult = main.intentFunction.installSingleToMultiIntent(
- main,
- name="IPV4_2",
- senders=senders,
- recipients=recipients,
- ethType="IPV4",
- sw1="s5",
- sw2="s2")
-
- if installResult:
- testResult = main.intentFunction.testEndPointFail(
- main,
- intentId=installResult,
- name="IPV4_2",
- senders=senders,
- recipients=recipients,
- isolatedSenders=isolatedSenders,
- isolatedRecipients=isolatedRecipients,
- sw1="s6",
- sw2="s2",
- sw3="s4",
- sw4="s1",
- sw5="s3",
- expectedLink1=16,
- expectedLink2=14 )
- else:
- main.CLIs[ 0 ].removeAllIntents( purge=True )
-
- utilities.assert_equals( expect=main.TRUE,
- actual=testResult,
- onpass=main.assertReturnString,
- onfail=main.assertReturnString )
-
- main.step( "VLAN: Add single point to multi point intents" )
- main.assertReturnString = "Assertion results for IPV4 single to multi point\
- intent endpoint failure 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" }
- ]
- recipients = [
- { "name":"h12", "device":"of:0000000000000006/4", "mac":"00:00:00:00:00:0C" },
- { "name":"h20", "device":"of:0000000000000007/4", "mac":"00:00:00:00:00:14" }
- ]
- isolatedSenders = []
- isolatedRecipients = [
- { "name":"h20" }
- ]
- testResult = main.FALSE
- installResult = main.FALSE
- installResult = main.intentFunction.installSingleToMultiIntent(
- main,
- name="IPV4",
- senders=senders,
- recipients=recipients,
- ethType="IPV4",
- sw1="s5",
- sw2="s2")
-
- if installResult:
- testResult = main.intentFunction.testEndPointFail(
- main,
- intentId=installResult,
- name="IPV4",
- senders=senders,
- recipients=recipients,
- isolatedSenders=isolatedSenders,
- isolatedRecipients=isolatedRecipients,
- sw1="s6",
- sw2="s2",
- sw3="s4",
- sw4="s1",
- sw5="s3",
- expectedLink1=16,
- expectedLink2=14 )
- else:
- main.CLIs[ 0 ].removeAllIntents( purge=True )
-
- utilities.assert_equals( expect=main.TRUE,
- actual=testResult,
- onpass=main.assertReturnString,
- onfail=main.assertReturnString )
-
main.intentFunction.report( main )
\ No newline at end of file
diff --git a/TestON/tests/FUNC/FUNCintent/dependencies/FuncIntentFunction.py b/TestON/tests/FUNC/FUNCintent/dependencies/FuncIntentFunction.py
index 88a0cad..dede2c8 100644
--- a/TestON/tests/FUNC/FUNCintent/dependencies/FuncIntentFunction.py
+++ b/TestON/tests/FUNC/FUNCintent/dependencies/FuncIntentFunction.py
@@ -22,7 +22,7 @@
ipAddresses="",
tcp="",
sw1="",
- sw2=""):
+ sw2="" ):
"""
Installs a Host Intent
@@ -75,8 +75,10 @@
host2[ "id" ] = main.hostsData.get( host2.get( "name" ) ).get( "id" )
# Adding point intent
+ vlanId = host1.get( "vlan" )
intentId = main.CLIs[ onosNode ].addHostIntent( hostIdOne=host1.get( "id" ),
- hostIdTwo=host2.get( "id" ) )
+ hostIdTwo=host2.get( "id" ),
+ vlanId=vlanId )
except (KeyError, TypeError):
errorMsg = "There was a problem loading the hosts data."
if intentId:
@@ -168,6 +170,7 @@
senderNames = [ host1.get( "name" ), host2.get( "name" ) ]
recipientNames = [ host1.get( "name" ), host2.get( "name" ) ]
+ vlanId = host1.get( "vlan" )
testResult = main.TRUE
except (KeyError, TypeError):
@@ -191,7 +194,7 @@
testResult = main.FALSE
# Check Connectivity
- if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, recipientNames ) ):
+ if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, recipientNames, vlanId ) ):
main.assertReturnString += 'Initial Ping Passed\n'
else:
main.assertReturnString += 'Initial Ping Failed\n'
@@ -228,7 +231,7 @@
testResult = main.FALSE
# Check Connection
- if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, recipientNames ) ):
+ if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, recipientNames, vlanId ) ):
main.assertReturnString += 'Link Down Pingall Passed\n'
else:
main.assertReturnString += 'Link Down Pingall Failed\n'
@@ -266,7 +269,7 @@
testResult = main.FALSE
# Check Connection
- if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, recipientNames ) ):
+ if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, recipientNames, vlanId ) ):
main.assertReturnString += 'Link Up Pingall Passed\n'
else:
main.assertReturnString += 'Link Up Pingall Failed\n'
@@ -364,6 +367,8 @@
ipSrc = senders[ 0 ].get( "ip" )
ipDst = recipients[ 0 ].get( "ip" )
+ vlanId = senders[ 0 ].get( "vlan" )
+
# Adding point intent
intentId = main.CLIs[ onosNode ].addPointIntent(
ingressDevice=ingressDevice,
@@ -378,7 +383,8 @@
ipSrc=ipSrc,
ipDst=ipDst,
tcpSrc=tcpSrc,
- tcpDst=tcpDst )
+ tcpDst=tcpDst,
+ vlanId=vlanId )
except (KeyError, TypeError):
errorMsg = "There was a problem loading the hosts data."
if intentId:
@@ -758,6 +764,7 @@
portEgressList = None
srcMac = senders[ 0 ].get( "mac" )
+ vlanId = senders[ 0 ].get( "vlan" )
# Adding point intent
intentId = main.CLIs[ onosNode ].addSinglepointToMultipointIntent(
@@ -773,7 +780,8 @@
ipSrc="",
ipDst="",
tcpSrc="",
- tcpDst="" )
+ tcpDst="",
+ vlanId=vlanId )
except (KeyError, TypeError):
errorMsg = "There was a problem loading the hosts data."
if intentId:
@@ -869,6 +877,7 @@
portIngressList = None
dstMac = recipients[ 0 ].get( "mac" )
+ vlanId = senders[ 0 ].get( "vlan" )
# Adding point intent
intentId = main.CLIs[ onosNode ].addMultipointToSinglepointIntent(
@@ -884,7 +893,8 @@
ipSrc="",
ipDst="",
tcpSrc="",
- tcpDst="" )
+ tcpDst="",
+ vlanId=vlanId )
except (KeyError, TypeError):
errorMsg = "There was a problem loading the hosts data."
if intentId:
@@ -993,6 +1003,7 @@
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( "vlan" )
except (KeyError, TypeError):
main.log.error( "There was a problem loading the hosts data." )
return main.FALSE
@@ -1015,7 +1026,7 @@
testResult = main.FALSE
# Check Connectivity
- if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, recipientNames ), attempts=3, sleep=5 ):
+ if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, recipientNames, vlanId ), attempts=3, sleep=5 ):
main.assertReturnString += 'Initial Ping Passed\n'
else:
main.assertReturnString += 'Initial Ping Failed\n'
@@ -1069,7 +1080,7 @@
testResult = main.FALSE
# Check Connection
- if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, recipientNames ) ):
+ if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, recipientNames, vlanId ) ):
main.assertReturnString += 'Link Down Pingall Passed\n'
else:
main.assertReturnString += 'Link Down Pingall Failed\n'
@@ -1107,7 +1118,7 @@
testResult = main.FALSE
# Check Connection
- if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, recipientNames ) ):
+ if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, recipientNames, vlanId ) ):
main.assertReturnString += 'Link Up Scapy Packet Received Passed\n'
else:
main.assertReturnString += 'Link Up Scapy Packet Recieved Failed\n'
@@ -1292,7 +1303,7 @@
# Check Connectivity
# First check connectivity of any isolated senders to recipients
if isolatedSenderNames:
- if scapyCheckConnection( main, isolatedSenderNames, recipientNames, None, None, main.TRUE ):
+ if scapyCheckConnection( main, isolatedSenderNames, recipientNames, None, None, None, main.TRUE ):
main.assertReturnString += 'Isolation link Down Connectivity Check Passed\n'
else:
main.assertReturnString += 'Isolation link Down Connectivity Check Failed\n'
@@ -1300,7 +1311,7 @@
# Next check connectivity of senders to any isolated recipients
if isolatedRecipientNames:
- if scapyCheckConnection( main, senderNames, isolatedRecipientNames, None, None, main.TRUE ):
+ if scapyCheckConnection( main, senderNames, isolatedRecipientNames, None, None, None, main.TRUE ):
main.assertReturnString += 'Isolation link Down Connectivity Check Passed\n'
else:
main.assertReturnString += 'Isolation link Down Connectivity Check Failed\n'
@@ -1592,7 +1603,7 @@
linkResult = main.Mininet1.link( end1=sw1, end2=sw2, option=option )
return linkResult
-def scapyCheckConnection( main, senders, recipients, packet=None, packetFilter=None, expectFailure=False ):
+def scapyCheckConnection( main, senders, recipients, vlanId=None, packet=None, packetFilter=None, expectFailure=False ):
"""
Checks the connectivity between all given sender hosts and all given recipient hosts
Packet may be specified. Defaults to Ether/IP packet
@@ -1631,17 +1642,31 @@
connectionsFunctional = main.FALSE
continue
- recipientComp.startFilter( pktFilter = packetFilter.format( senderComp.hostMac ) )
+ if vlanId:
+ recipientComp.startFilter( pktFilter = ( "vlan {}".format( vlanId ) + " && " + packetFilter.format( senderComp.hostMac ) ) )
+ else:
+ recipientComp.startFilter( pktFilter = packetFilter.format( senderComp.hostMac ) )
if not packet:
- pkt = 'Ether( src="{0}", dst="{2}" )/IP( src="{1}", dst="{3}" )'.format(
- senderComp.hostMac,
- senderComp.hostIp,
- recipientComp.hostMac,
- recipientComp.hostIp )
+ if vlanId:
+ pkt = 'Ether( src="{0}", dst="{2}" )/Dot1Q(vlan={4})/IP( src="{1}", dst="{3}" )'.format(
+ senderComp.hostMac,
+ senderComp.hostIp,
+ recipientComp.hostMac,
+ recipientComp.hostIp,
+ vlanId )
+ else:
+ pkt = 'Ether( src="{0}", dst="{2}" )/IP( src="{1}", dst="{3}" )'.format(
+ senderComp.hostMac,
+ senderComp.hostIp,
+ recipientComp.hostMac,
+ recipientComp.hostIp )
else:
pkt = packet
- senderComp.sendPacket( packet = pkt )
+ if vlanId:
+ senderComp.sendPacket( iface=( "{0}-eth0.{1}".format( sender, vlanId ) ), packet = pkt )
+ else:
+ senderComp.sendPacket( packet = pkt )
if recipientComp.checkFilter( timeout ):
if expectFailure:
diff --git a/TestON/tests/HA/HAclusterRestart/HAclusterRestart.py b/TestON/tests/HA/HAclusterRestart/HAclusterRestart.py
index c229b03..69f094d 100644
--- a/TestON/tests/HA/HAclusterRestart/HAclusterRestart.py
+++ b/TestON/tests/HA/HAclusterRestart/HAclusterRestart.py
@@ -261,12 +261,11 @@
onfail="Nodes check NOT successful" )
if not nodeResults:
- for cli in main.CLIs:
+ for i in main.activeNodes:
+ cli = main.CLIs[i]
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()
@@ -1680,8 +1679,9 @@
actual=consistentClustersResult,
onpass="Clusters view is consistent across all ONOS nodes",
onfail="ONOS nodes have different views of clusters" )
- if consistentClustersResult != main.TRUE:
+ if not consistentClustersResult:
main.log.debug( clusters )
+
# there should always only be one cluster
main.step( "Cluster view correct across ONOS nodes" )
try:
@@ -1853,7 +1853,8 @@
for i in range( 10 ):
ready = True
- for cli in main.CLIs:
+ for i in main.activeNodes:
+ cli = main.CLIs[i]
output = cli.summary()
if not output:
ready = False
@@ -1874,7 +1875,8 @@
# Rerun for election on restarted nodes
runResults = main.TRUE
- for cli in main.CLIs:
+ for i in main.activeNodes:
+ cli = main.CLIs[i]
run = cli.electionTestRun()
if run != main.TRUE:
main.log.error( "Error running for election on " + cli.name )
@@ -2554,6 +2556,8 @@
actual=consistentClustersResult,
onpass="Clusters view is consistent across all ONOS nodes",
onfail="ONOS nodes have different views of clusters" )
+ if not consistentClustersResult:
+ main.log.debug( clusters )
main.step( "There is only one SCC" )
# there should always only be one cluster
@@ -4211,6 +4215,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 dd1e1fb..a48a460 100644
--- a/TestON/tests/HA/HAfullNetPartition/HAfullNetPartition.py
+++ b/TestON/tests/HA/HAfullNetPartition/HAfullNetPartition.py
@@ -286,12 +286,11 @@
onfail="Nodes check NOT successful" )
if not nodeResults:
- for cli in main.CLIs:
+ for i in main.activeNodes:
+ cli = main.CLIs[i]
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()
@@ -1682,8 +1681,9 @@
actual=consistentClustersResult,
onpass="Clusters view is consistent across all ONOS nodes",
onfail="ONOS nodes have different views of clusters" )
- if consistentClustersResult != main.TRUE:
+ if not consistentClustersResult:
main.log.debug( clusters )
+
# there should always only be one cluster
main.step( "Cluster view correct across ONOS nodes" )
try:
@@ -2540,6 +2540,8 @@
actual=consistentClustersResult,
onpass="Clusters view is consistent across all ONOS nodes",
onfail="ONOS nodes have different views of clusters" )
+ if not consistentClustersResult:
+ main.log.debug( clusters )
main.step( "There is only one SCC" )
# there should always only be one cluster
@@ -4199,6 +4201,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 52a242c..6fb4d6c 100644
--- a/TestON/tests/HA/HAkillNodes/HAkillNodes.py
+++ b/TestON/tests/HA/HAkillNodes/HAkillNodes.py
@@ -297,12 +297,11 @@
onfail="Nodes check NOT successful" )
if not nodeResults:
- for cli in main.CLIs:
+ for i in main.activeNodes:
+ cli = main.CLIs[i]
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()
@@ -1702,8 +1701,9 @@
actual=consistentClustersResult,
onpass="Clusters view is consistent across all ONOS nodes",
onfail="ONOS nodes have different views of clusters" )
- if consistentClustersResult != main.TRUE:
+ if not consistentClustersResult:
main.log.debug( clusters )
+
# there should always only be one cluster
main.step( "Cluster view correct across ONOS nodes" )
try:
@@ -2575,6 +2575,8 @@
actual=consistentClustersResult,
onpass="Clusters view is consistent across all ONOS nodes",
onfail="ONOS nodes have different views of clusters" )
+ if not consistentClustersResult:
+ main.log.debug( clusters )
main.step( "There is only one SCC" )
# there should always only be one cluster
@@ -4234,6 +4236,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 3c77dd0..aa66574 100644
--- a/TestON/tests/HA/HAsanity/HAsanity.py
+++ b/TestON/tests/HA/HAsanity/HAsanity.py
@@ -262,12 +262,11 @@
onfail="Nodes check NOT successful" )
if not nodeResults:
- for cli in main.CLIs:
+ for i in main.activeNodes:
+ cli = main.CLIs[i]
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()
@@ -1668,8 +1667,9 @@
actual=consistentClustersResult,
onpass="Clusters view is consistent across all ONOS nodes",
onfail="ONOS nodes have different views of clusters" )
- if consistentClustersResult != main.TRUE:
+ if not consistentClustersResult:
main.log.debug( clusters )
+
# there should always only be one cluster
main.step( "Cluster view correct across ONOS nodes" )
try:
@@ -2476,6 +2476,8 @@
actual=consistentClustersResult,
onpass="Clusters view is consistent across all ONOS nodes",
onfail="ONOS nodes have different views of clusters" )
+ if not consistentClustersResult:
+ main.log.debug( clusters )
main.step( "There is only one SCC" )
# there should always only be one cluster
@@ -4135,6 +4137,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.params b/TestON/tests/HA/HAscaling/HAscaling.params
index 3959ec0..5b5358d 100644
--- a/TestON/tests/HA/HAscaling/HAscaling.params
+++ b/TestON/tests/HA/HAscaling/HAscaling.params
@@ -20,6 +20,7 @@
<testcases>1,[2,8,21,3,8,4,5,14,16,17]*1,[6,8,3,7,4,15,17,9,8,4,10,8,4,11,8,4,12,8,4]*13,13</testcases>
<scaling>1,3b,3,5b,5,7b,7,7b,5,5b,3,3b,1</scaling>
+ <serverPort>8000</serverPort>
<apps></apps>
<ONOS_Configuration>
<org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator>
diff --git a/TestON/tests/HA/HAscaling/HAscaling.py b/TestON/tests/HA/HAscaling/HAscaling.py
index 8cf1026..3eb95c6 100644
--- a/TestON/tests/HA/HAscaling/HAscaling.py
+++ b/TestON/tests/HA/HAscaling/HAscaling.py
@@ -130,7 +130,7 @@
killResults = killResults and killed
main.step( "Setup server for cluster metadata file" )
- port = 8000
+ port = main.params['serverPort']
rootDir = os.path.dirname( main.testFile ) + "/dependencies"
main.log.debug( "Root dir: {}".format( rootDir ) )
status = main.Server.start( main.ONOSbench,
@@ -319,12 +319,11 @@
onfail="Nodes check NOT successful" )
if not nodeResults:
- for cli in main.CLIs:
+ for i in main.activeNodes:
+ cli = main.CLIs[i]
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()
@@ -1720,8 +1719,9 @@
actual=consistentClustersResult,
onpass="Clusters view is consistent across all ONOS nodes",
onfail="ONOS nodes have different views of clusters" )
- if consistentClustersResult != main.TRUE:
+ if not consistentClustersResult:
main.log.debug( clusters )
+
# there should always only be one cluster
main.step( "Cluster view correct across ONOS nodes" )
try:
@@ -2615,6 +2615,8 @@
actual=consistentClustersResult,
onpass="Clusters view is consistent across all ONOS nodes",
onfail="ONOS nodes have different views of clusters" )
+ if not consistentClustersResult:
+ main.log.debug( clusters )
main.step( "There is only one SCC" )
# there should always only be one cluster
@@ -4263,6 +4265,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 25aa0ba..1d4db86 100644
--- a/TestON/tests/HA/HAsingleInstanceRestart/HAsingleInstanceRestart.py
+++ b/TestON/tests/HA/HAsingleInstanceRestart/HAsingleInstanceRestart.py
@@ -251,12 +251,11 @@
onfail="Nodes check NOT successful" )
if not nodeResults:
- for cli in main.CLIs:
+ for i in main.activeNodes:
+ cli = main.CLIs[i]
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()
@@ -3425,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 240c9c4..0f33ec0 100644
--- a/TestON/tests/HA/HAstopNodes/HAstopNodes.py
+++ b/TestON/tests/HA/HAstopNodes/HAstopNodes.py
@@ -286,12 +286,11 @@
onfail="Nodes check NOT successful" )
if not nodeResults:
- for cli in main.CLIs:
+ for i in main.activeNodes:
+ cli = main.CLIs[i]
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()
@@ -1681,8 +1680,9 @@
actual=consistentClustersResult,
onpass="Clusters view is consistent across all ONOS nodes",
onfail="ONOS nodes have different views of clusters" )
- if consistentClustersResult != main.TRUE:
+ if not consistentClustersResult:
main.log.debug( clusters )
+
# there should always only be one cluster
main.step( "Cluster view correct across ONOS nodes" )
try:
@@ -2552,6 +2552,8 @@
actual=consistentClustersResult,
onpass="Clusters view is consistent across all ONOS nodes",
onfail="ONOS nodes have different views of clusters" )
+ if not consistentClustersResult:
+ main.log.debug( clusters )
main.step( "There is only one SCC" )
# there should always only be one cluster
@@ -4211,6 +4213,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/PLAT/PLATdockertest/PLATdockertest.py b/TestON/tests/PLAT/PLATdockertest/PLATdockertest.py
index 6e4acda..7133931 100755
--- a/TestON/tests/PLAT/PLATdockertest/PLATdockertest.py
+++ b/TestON/tests/PLAT/PLATdockertest/PLATdockertest.py
@@ -163,7 +163,7 @@
main.ONOSbenchDocker.onosFormCluster(cmdPath = clcmdpath, onosIPs=IPlist, user=dkruser, passwd = dkrpasswd)
main.log.info("Wait for cluster to form with sleep time of " + str(startupSleep))
time.sleep(startupSleep)
- status, response = main.ONOSbenchRest.send(ip=IPlist[0],port=8181, url="/cluster")
+ status, response = main.ONOSbenchRest.send(ip=IPlist[0], port=8181, url="/cluster")
main.log.debug("Rest call response: " + str(status) + " - " + response)
if status == 200:
jrsp = json.loads(response)
diff --git a/TestON/tests/SAMP/SAMPstartTemplate/Dependency/newFuncTopo.py b/TestON/tests/SAMP/SAMPstartTemplate/dependencies/newFuncTopo.py
similarity index 100%
copy from TestON/tests/SAMP/SAMPstartTemplate/Dependency/newFuncTopo.py
copy to TestON/tests/SAMP/SAMPstartTemplate/dependencies/newFuncTopo.py
diff --git a/TestON/tests/SAMP/SAMPstartTemplate/Dependency/startUp.py b/TestON/tests/SAMP/SAMPstartTemplate/dependencies/startUp.py
similarity index 100%
rename from TestON/tests/SAMP/SAMPstartTemplate/Dependency/startUp.py
rename to TestON/tests/SAMP/SAMPstartTemplate/dependencies/startUp.py
diff --git a/TestON/tests/SAMP/SAMPstartTemplate/Dependency/newFuncTopo.py b/TestON/tests/SAMP/SAMPstartTemplate2/Dependency/newFuncTopo.py
similarity index 100%
rename from TestON/tests/SAMP/SAMPstartTemplate/Dependency/newFuncTopo.py
rename to TestON/tests/SAMP/SAMPstartTemplate2/Dependency/newFuncTopo.py
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/SCPF/SCPFmaxIntents/Dependency/maxIntentFunctions.py b/TestON/tests/SCPF/SCPFmaxIntents/dependencies/maxIntentFunctions.py
similarity index 100%
rename from TestON/tests/SCPF/SCPFmaxIntents/Dependency/maxIntentFunctions.py
rename to TestON/tests/SCPF/SCPFmaxIntents/dependencies/maxIntentFunctions.py
diff --git a/TestON/tests/SCPF/SCPFmaxIntents/Dependency/rerouteTopo.py b/TestON/tests/SCPF/SCPFmaxIntents/dependencies/rerouteTopo.py
similarity index 100%
rename from TestON/tests/SCPF/SCPFmaxIntents/Dependency/rerouteTopo.py
rename to TestON/tests/SCPF/SCPFmaxIntents/dependencies/rerouteTopo.py
diff --git a/TestON/tests/SCPF/SCPFmaxIntents/Dependency/startUp.py b/TestON/tests/SCPF/SCPFmaxIntents/dependencies/startUp.py
similarity index 100%
rename from TestON/tests/SCPF/SCPFmaxIntents/Dependency/startUp.py
rename to TestON/tests/SCPF/SCPFmaxIntents/dependencies/startUp.py
diff --git a/TestON/tests/SCPF/SCPFscalingMaxIntents/SCPFscalingMaxIntents.params b/TestON/tests/SCPF/SCPFscalingMaxIntents/SCPFscalingMaxIntents.params
index 6efe17e..cb75b01 100644
--- a/TestON/tests/SCPF/SCPFscalingMaxIntents/SCPFscalingMaxIntents.params
+++ b/TestON/tests/SCPF/SCPFscalingMaxIntents/SCPFscalingMaxIntents.params
@@ -13,14 +13,14 @@
<SCALE>1,3,5,7</SCALE>
<DEPENDENCY>
- <path>/tests/SCPFscalingMaxIntents/dependencies/</path>
+ <path>/tests/SCPF/SCPFscalingMaxIntents/dependencies/</path>
<wrapper1>startUp</wrapper1>
<topology>rerouteTopo.py</topology>
</DEPENDENCY>
<ENV>
<cellName>productionCell</cellName>
- <cellApps>drivers</cellApps>
+ <cellApps>drivers,openflow</cellApps>
</ENV>
<GIT>
@@ -61,10 +61,10 @@
<NULL>
# CASE20
<PUSH>
- <batch_size>100</batch_size>
- <min_intents>100</min_intents>
- <max_intents>100000</max_intents>
- <check_interval>100</check_interval>
+ <batch_size>1000</batch_size>
+ <min_intents>10000</min_intents>
+ <max_intents>70000</max_intents>
+ <check_interval>10000</check_interval>
</PUSH>
# if reroute is true
diff --git a/TestON/tests/SCPF/SCPFscalingMaxIntents/SCPFscalingMaxIntents.py b/TestON/tests/SCPF/SCPFscalingMaxIntents/SCPFscalingMaxIntents.py
index 27bc5c2..bf34f83 100644
--- a/TestON/tests/SCPF/SCPFscalingMaxIntents/SCPFscalingMaxIntents.py
+++ b/TestON/tests/SCPF/SCPFscalingMaxIntents/SCPFscalingMaxIntents.py
@@ -54,10 +54,6 @@
main.reroute = False
main.CLIs = []
- main.ONOSip = []
- main.maxNumBatch = 0
- main.ONOSip = main.ONOSbench.getOnosIps()
- main.log.info(main.ONOSip)
main.setupSkipped = False
wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
@@ -82,6 +78,13 @@
# main.scale[ 0 ] determines the current number of ONOS controller
main.CLIs = []
main.numCtrls = int( main.scale[ 0 ] )
+ main.ONOSip = []
+ main.maxNumBatch = 0
+ main.AllONOSip = main.ONOSbench.getOnosIps()
+ for i in range(main.numCtrls):
+ main.ONOSip.append(main.AllONOSip[i])
+ main.log.info(main.ONOSip)
+
main.log.info( "Creating list of ONOS cli handles" )
for i in range(main.numCtrls):
main.CLIs.append( getattr( main, 'ONOScli%s' % (i+1) ) )
@@ -302,19 +305,11 @@
'''
import json
import time
-
- time.sleep(main.startUpSleep)
-
- main.step("Activating openflow")
- appStatus = utilities.retry( main.ONOSrest1.activateApp,
- main.FALSE,
- ['org.onosproject.openflow'],
- sleep=3,
- attempts=3 )
- utilities.assert_equals( expect=main.TRUE,
- actual=appStatus,
- onpass="Successfully activated openflow",
- onfail="Failed activate openflow" )
+
+ devices = []
+ devices = main.CLIs[0].getAllDevicesId()
+ for d in devices:
+ main.CLIs[0].deviceRemove( d )
time.sleep(main.startUpSleep)
main.step('Starting mininet topology')
@@ -333,13 +328,26 @@
onfail="Failed assign switches to masters" )
time.sleep(main.startUpSleep)
+ # Balancing Masters
+ main.step( "Balancing Masters" )
+ stepResult = main.FALSE
+ stepResult = utilities.retry( main.CLIs[0].balanceMasters,
+ main.FALSE,
+ [],
+ sleep=3,
+ attempts=3 )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Balance masters was successfull",
+ onfail="Failed to balance masters" )
main.log.info("Getting default flows")
jsonSum = json.loads(main.CLIs[0].summary())
main.defaultFlows = jsonSum["flows"]
main.step("Check status of Mininet setup")
- caseResult = appStatus and mnStatus and swStatus
+ caseResult = mnStatus and swStatus
utilities.assert_equals( expect=main.TRUE,
actual=caseResult,
onpass="Successfully setup Mininet",
@@ -393,6 +401,7 @@
# keeps track of how many flows have been installed, set to 0 at start
currFlows = 0
# limit for the number of intents that can be installed
+ main.batchSize = int( int(main.batchSize)/int(main.numCtrls))
limit = main.maxIntents / main.batchSize
# total intents installed
totalIntents = 0
@@ -404,7 +413,12 @@
stepResult = main.TRUE
# temp variable to contain the number of flows
flowsNum = 0
+ if main.numCtrls > 1:
+ # if more than one onos nodes, we should check more frequently
+ main.checkInterval = main.checkInterval/4
+ # make sure the checkInterval divisible batchSize
+ main.checkInterval = int( int( main.checkInterval / main.batchSize ) * main.batchSize )
for i in range(limit):
# Threads pool
@@ -424,7 +438,8 @@
kwargs={ "offset": offtmp,
"options": "-i",
"timeout": main.timeout,
- "background":False } )
+ "background":False,
+ "noExit":True} )
pool.append(t)
t.start()
main.threadID = main.threadID + 1
@@ -441,108 +456,45 @@
main.log.info("Verify Intents states")
# k is a control variable for verify retry attempts
k = 1
- intentVerify = main.FALSE
while k <= main.verifyAttempts:
# while loop for check intents by using REST api
time.sleep(5)
temp = 0
- intentsState = json.loads( main.ONOSrest1.intents() )
- for f in intentsState:
- # get INSTALLED intents number
- if f.get("state") == "INSTALLED":
- temp = temp + 1
-
- main.log.info("Total Intents: {} INSTALLED: {}".format(totalIntents, temp))
- if totalIntents == temp:
- intentVerify = main.TRUE
+ intentsState = main.CLIs[0].checkIntentSummary(timeout=600)
+ if intentsState:
+ totalIntents = main.CLIs[0].getTotalIntentsNum(timeout=600)
+ if temp < totalIntents:
+ temp = totalIntents
+ else:
+ totalIntents = temp
break
- intentVerify = main.FALSE
+ main.log.info("Total Intents: {}".format( totalIntents) )
k = k+1
- if not intentVerify:
+
+ if not intentsState:
# If some intents are not installed, grep the previous flows list, and finished this test case
main.log.warn( "Some intens did not install" )
- # We don't want to check flows if intents not installed, because onos will drop flows
- if currFlows == 0:
- # If currFlows equal 0, which means we failed to install intents at first, or we didn't get
- # the correct number, so we need get flows here.
- flowsState = json.loads( main.ONOSrest1.flows() )
+ main.log.info("Total Intents: {}".format( totalIntents) )
break
-
- main.log.info("Verify Flows states")
- k = 1
- flowsVerify = main.TRUE
- while k <= main.verifyAttempts:
- # while loop for check flows by using REST api
- time.sleep(3)
- temp = 0
- flowsStateCount = []
- flowsState = json.loads( main.ONOSrest1.flows() )
- main.log.info("Total flows now: {}".format(len(flowsState)))
- if ( flowsNum < len(flowsState) ):
- flowsNum = len(flowsState)
- print(flowsNum)
- for f in flowsState:
- # get PENDING_ADD flows
- if f.get("state") == "PENDING_ADD":
- temp = temp + 1
-
- flowsStateCount.append(temp)
- temp = 0
-
- for f in flowsState:
- # get PENDING_REMOVE flows
- if f.get("state") == "PENDING_REMOVE":
- temp = temp + 1
-
- flowsStateCount.append(temp)
- temp = 0
-
- for f in flowsState:
- # get REMOVED flows
- if f.get("state") == "REMOVED":
- temp = temp + 1
-
- flowsStateCount.append(temp)
- temp = 0
-
- for f in flowsState:
- # get FAILED flwos
- if f.get("state") == "FAILED":
- temp = temp + 1
-
- flowsStateCount.append(temp)
- temp = 0
- k = k + 1
- for c in flowsStateCount:
- if int(c) > 0:
- flowsVerify = main.FALSE
-
- main.log.info( "Check flows States:" )
- main.log.info( "PENDING_ADD: {}".format( flowsStateCount[0]) )
- main.log.info( "PENDING_REMOVE: {}".format( flowsStateCount[1]) )
- main.log.info( "REMOVED: {}".format( flowsStateCount[2]) )
- main.log.info( "FAILED: {}".format( flowsStateCount[3]) )
-
- if flowsVerify == main.TRUE:
- break
-
+ # We don't want to check flows if intents not installed, because onos will drop flows
+ temp = 0
+ totalFlows = 0
+ if temp < totalFlows:
+ temp = totalFlows
+ else:
+ totalFlows = main.CLIs[0].getTotalFlowsNum(timeout=600, noExit=True)
del main.scale[0]
utilities.assert_equals( expect = main.TRUE,
- actual = intentVerify,
+ actual = intentsState,
onpass = "Successfully pushed and verified intents",
onfail = "Failed to push and verify intents" )
- # we need the total intents before crash
- totalIntents = len(intentsState)
- totalFlows = flowsNum
-
main.log.info( "Total Intents Installed before crash: {}".format( totalIntents ) )
main.log.info( "Total Flows ADDED before crash: {}".format( totalFlows ) )
main.step('clean up Mininet')
main.Mininet1.stopNet()
-
main.log.info("Writing results to DS file")
with open(main.dbFileName, "a") as dbFile:
# Scale number
diff --git a/TestON/tests/SCPF/SCPFscalingMaxIntents/dependencies/__init__.py b/TestON/tests/SCPF/SCPFscalingMaxIntents/dependencies/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/TestON/tests/SCPF/SCPFscalingMaxIntents/dependencies/__init__.py
diff --git a/TestON/tests/SCPF/SCPFscalingMaxIntents/Dependency/rerouteTopo.py b/TestON/tests/SCPF/SCPFscalingMaxIntents/dependencies/rerouteTopo.py
similarity index 100%
rename from TestON/tests/SCPF/SCPFscalingMaxIntents/Dependency/rerouteTopo.py
rename to TestON/tests/SCPF/SCPFscalingMaxIntents/dependencies/rerouteTopo.py
diff --git a/TestON/tests/SCPF/SCPFscalingMaxIntents/Dependency/startUp.py b/TestON/tests/SCPF/SCPFscalingMaxIntents/dependencies/startUp.py
similarity index 100%
rename from TestON/tests/SCPF/SCPFscalingMaxIntents/Dependency/startUp.py
rename to TestON/tests/SCPF/SCPFscalingMaxIntents/dependencies/startUp.py
diff --git a/TestON/tests/SCPF/SCPFscalingMaxIntentsWithFlowObj/SCPFscalingMaxIntentsWithFlowObj.params b/TestON/tests/SCPF/SCPFscalingMaxIntentsWithFlowObj/SCPFscalingMaxIntentsWithFlowObj.params
index ed0badf..8083e7a 100644
--- a/TestON/tests/SCPF/SCPFscalingMaxIntentsWithFlowObj/SCPFscalingMaxIntentsWithFlowObj.params
+++ b/TestON/tests/SCPF/SCPFscalingMaxIntentsWithFlowObj/SCPFscalingMaxIntentsWithFlowObj.params
@@ -13,14 +13,14 @@
<SCALE>1,3,5,7</SCALE>
<DEPENDENCY>
- <path>/tests/SCPFscalingMaxIntents/dependencies/</path>
+ <path>/tests/SCPF/SCPFscalingMaxIntentsWithFlowObj/dependencies/</path>
<wrapper1>startUp</wrapper1>
<topology>rerouteTopo.py</topology>
</DEPENDENCY>
<ENV>
<cellName>productionCell</cellName>
- <cellApps>drivers</cellApps>
+ <cellApps>drivers,openflow</cellApps>
</ENV>
<GIT>
@@ -61,10 +61,10 @@
<NULL>
# CASE20
<PUSH>
- <batch_size>100</batch_size>
- <min_intents>100</min_intents>
- <max_intents>100000</max_intents>
- <check_interval>100</check_interval>
+ <batch_size>1000</batch_size>
+ <min_intents>10000</min_intents>
+ <max_intents>70000</max_intents>
+ <check_interval>10000</check_interval>
</PUSH>
# if reroute is true
diff --git a/TestON/tests/SCPF/SCPFscalingMaxIntentsWithFlowObj/SCPFscalingMaxIntentsWithFlowObj.py b/TestON/tests/SCPF/SCPFscalingMaxIntentsWithFlowObj/SCPFscalingMaxIntentsWithFlowObj.py
index e405fd3..b959666 100644
--- a/TestON/tests/SCPF/SCPFscalingMaxIntentsWithFlowObj/SCPFscalingMaxIntentsWithFlowObj.py
+++ b/TestON/tests/SCPF/SCPFscalingMaxIntentsWithFlowObj/SCPFscalingMaxIntentsWithFlowObj.py
@@ -3,7 +3,7 @@
import time
import os
'''
-SCPFscalingMaxIntentsWithFlowObj
+SCPFscalingMaxIntents
Push test Intents to onos
CASE10: set up Null Provider
CASE11: set up Open Flows
@@ -54,10 +54,6 @@
main.reroute = False
main.CLIs = []
- main.ONOSip = []
- main.maxNumBatch = 0
- main.ONOSip = main.ONOSbench.getOnosIps()
- main.log.info(main.ONOSip)
main.setupSkipped = False
wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
@@ -82,6 +78,13 @@
# main.scale[ 0 ] determines the current number of ONOS controller
main.CLIs = []
main.numCtrls = int( main.scale[ 0 ] )
+ main.ONOSip = []
+ main.maxNumBatch = 0
+ main.AllONOSip = main.ONOSbench.getOnosIps()
+ for i in range(main.numCtrls):
+ main.ONOSip.append(main.AllONOSip[i])
+ main.log.info(main.ONOSip)
+
main.log.info( "Creating list of ONOS cli handles" )
for i in range(main.numCtrls):
main.CLIs.append( getattr( main, 'ONOScli%s' % (i+1) ) )
@@ -301,25 +304,16 @@
Setting up mininet
'''
import json
- import time
+ import time
+ devices = []
+ devices = main.CLIs[0].getAllDevicesId()
+ for d in devices:
+ main.CLIs[0].deviceRemove( d )
- time.sleep(main.startUpSleep)
-
- main.step("Activating openflow")
- appStatus = utilities.retry( main.ONOSrest1.activateApp,
- main.FALSE,
- ['org.onosproject.openflow'],
- sleep=3,
- attempts=3 )
- utilities.assert_equals( expect=main.TRUE,
- actual=appStatus,
- onpass="Successfully activated openflow",
- onfail="Failed activate openflow" )
-
- time.sleep(main.startUpSleep)
main.log.info("Set Intent Compiler use Flow Object")
- main.CLIs[0].setCfg( "org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator", "useFlowObjectives", "true" )
-
+ main.CLIs[0].setCfg("org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator",
+ "useFlowObjectives", "true")
+ time.sleep(main.startUpSleep)
main.step('Starting mininet topology')
mnStatus = main.Mininet1.startNet(topoFile='~/mininet/custom/rerouteTopo.py')
utilities.assert_equals( expect=main.TRUE,
@@ -336,13 +330,26 @@
onfail="Failed assign switches to masters" )
time.sleep(main.startUpSleep)
+ # Balancing Masters
+ main.step( "Balancing Masters" )
+ stepResult = main.FALSE
+ stepResult = utilities.retry( main.CLIs[0].balanceMasters,
+ main.FALSE,
+ [],
+ sleep=3,
+ attempts=3 )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Balance masters was successfull",
+ onfail="Failed to balance masters" )
main.log.info("Getting default flows")
jsonSum = json.loads(main.CLIs[0].summary())
main.defaultFlows = jsonSum["flows"]
main.step("Check status of Mininet setup")
- caseResult = appStatus and mnStatus and swStatus
+ caseResult = mnStatus and swStatus
utilities.assert_equals( expect=main.TRUE,
actual=caseResult,
onpass="Successfully setup Mininet",
@@ -396,6 +403,7 @@
# keeps track of how many flows have been installed, set to 0 at start
currFlows = 0
# limit for the number of intents that can be installed
+ main.batchSize = int( int(main.batchSize)/int(main.numCtrls))
limit = main.maxIntents / main.batchSize
# total intents installed
totalIntents = 0
@@ -407,7 +415,12 @@
stepResult = main.TRUE
# temp variable to contain the number of flows
flowsNum = 0
+ if main.numCtrls > 1:
+ # if more than one onos nodes, we should check more frequently
+ main.checkInterval = main.checkInterval/4
+ # make sure the checkInterval divisible batchSize
+ main.checkInterval = int( int( main.checkInterval / main.batchSize ) * main.batchSize )
for i in range(limit):
# Threads pool
@@ -427,7 +440,8 @@
kwargs={ "offset": offtmp,
"options": "-i",
"timeout": main.timeout,
- "background":False } )
+ "background":False,
+ "noExit":True} )
pool.append(t)
t.start()
main.threadID = main.threadID + 1
@@ -444,108 +458,45 @@
main.log.info("Verify Intents states")
# k is a control variable for verify retry attempts
k = 1
- intentVerify = main.FALSE
while k <= main.verifyAttempts:
# while loop for check intents by using REST api
time.sleep(5)
temp = 0
- intentsState = json.loads( main.ONOSrest1.intents() )
- for f in intentsState:
- # get INSTALLED intents number
- if f.get("state") == "INSTALLED":
- temp = temp + 1
-
- main.log.info("Total Intents: {} INSTALLED: {}".format(totalIntents, temp))
- if totalIntents == temp:
- intentVerify = main.TRUE
+ intentsState = main.CLIs[0].checkIntentSummary(timeout=600)
+ if intentsState:
+ totalIntents = main.CLIs[0].getTotalIntentsNum(timeout=600)
+ if temp < totalIntents:
+ temp = totalIntents
+ else:
+ totalIntents = temp
break
- intentVerify = main.FALSE
+ main.log.info("Total Intents: {}".format( totalIntents) )
k = k+1
- if not intentVerify:
+
+ if not intentsState:
# If some intents are not installed, grep the previous flows list, and finished this test case
main.log.warn( "Some intens did not install" )
- # We don't want to check flows if intents not installed, because onos will drop flows
- if currFlows == 0:
- # If currFlows equal 0, which means we failed to install intents at first, or we didn't get
- # the correct number, so we need get flows here.
- flowsState = json.loads( main.ONOSrest1.flows() )
+ main.log.info("Total Intents: {}".format( totalIntents) )
break
-
- main.log.info("Verify Flows states")
- k = 1
- flowsVerify = main.TRUE
- while k <= main.verifyAttempts:
- # while loop for check flows by using REST api
- time.sleep(3)
- temp = 0
- flowsStateCount = []
- flowsState = json.loads( main.ONOSrest1.flows() )
- main.log.info("Total flows now: {}".format(len(flowsState)))
- if ( flowsNum < len(flowsState) ):
- flowsNum = len(flowsState)
- print(flowsNum)
- for f in flowsState:
- # get PENDING_ADD flows
- if f.get("state") == "PENDING_ADD":
- temp = temp + 1
-
- flowsStateCount.append(temp)
- temp = 0
-
- for f in flowsState:
- # get PENDING_REMOVE flows
- if f.get("state") == "PENDING_REMOVE":
- temp = temp + 1
-
- flowsStateCount.append(temp)
- temp = 0
-
- for f in flowsState:
- # get REMOVED flows
- if f.get("state") == "REMOVED":
- temp = temp + 1
-
- flowsStateCount.append(temp)
- temp = 0
-
- for f in flowsState:
- # get FAILED flwos
- if f.get("state") == "FAILED":
- temp = temp + 1
-
- flowsStateCount.append(temp)
- temp = 0
- k = k + 1
- for c in flowsStateCount:
- if int(c) > 0:
- flowsVerify = main.FALSE
-
- main.log.info( "Check flows States:" )
- main.log.info( "PENDING_ADD: {}".format( flowsStateCount[0]) )
- main.log.info( "PENDING_REMOVE: {}".format( flowsStateCount[1]) )
- main.log.info( "REMOVED: {}".format( flowsStateCount[2]) )
- main.log.info( "FAILED: {}".format( flowsStateCount[3]) )
-
- if flowsVerify == main.TRUE:
- break
-
+ # We don't want to check flows if intents not installed, because onos will drop flows
+ temp = 0
+ totalFlows = 0
+ if temp < totalFlows:
+ temp = totalFlows
+ else:
+ totalFlows = main.CLIs[0].getTotalFlowsNum(timeout=600, noExit=True)
del main.scale[0]
utilities.assert_equals( expect = main.TRUE,
- actual = intentVerify,
+ actual = intentsState,
onpass = "Successfully pushed and verified intents",
onfail = "Failed to push and verify intents" )
- # we need the total intents before crash
- totalIntents = len(intentsState)
- totalFlows = flowsNum
-
main.log.info( "Total Intents Installed before crash: {}".format( totalIntents ) )
main.log.info( "Total Flows ADDED before crash: {}".format( totalFlows ) )
main.step('clean up Mininet')
main.Mininet1.stopNet()
-
main.log.info("Writing results to DS file")
with open(main.dbFileName, "a") as dbFile:
# Scale number
diff --git a/TestON/tests/SCPF/SCPFscalingMaxIntentsWithFlowObj/Dependency/rerouteTopo.py b/TestON/tests/SCPF/SCPFscalingMaxIntentsWithFlowObj/dependencies/rerouteTopo.py
similarity index 100%
rename from TestON/tests/SCPF/SCPFscalingMaxIntentsWithFlowObj/Dependency/rerouteTopo.py
rename to TestON/tests/SCPF/SCPFscalingMaxIntentsWithFlowObj/dependencies/rerouteTopo.py
diff --git a/TestON/tests/SCPF/SCPFscalingMaxIntentsWithFlowObj/Dependency/startUp.py b/TestON/tests/SCPF/SCPFscalingMaxIntentsWithFlowObj/dependencies/startUp.py
similarity index 100%
rename from TestON/tests/SCPF/SCPFscalingMaxIntentsWithFlowObj/Dependency/startUp.py
rename to TestON/tests/SCPF/SCPFscalingMaxIntentsWithFlowObj/dependencies/startUp.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 )