Merge "Initial functions to use scapy to send and receive packets"
diff --git a/TestON/tests/CHOtest/CHOtest.params b/TestON/tests/CHOtest/CHOtest.params
index 590b37f..5f8c205 100644
--- a/TestON/tests/CHOtest/CHOtest.params
+++ b/TestON/tests/CHOtest/CHOtest.params
@@ -91,6 +91,7 @@
<SwitchDiscovery>10</SwitchDiscovery>
<IntentPurgeDelay>15</IntentPurgeDelay>
<CheckIntentDelay>8</CheckIntentDelay>
+ <pingSleep>3</pingSleep>
</timers>
<TEST>
diff --git a/TestON/tests/CHOtest/CHOtest.py b/TestON/tests/CHOtest/CHOtest.py
index 44f7bc9..a1a1610 100644
--- a/TestON/tests/CHOtest/CHOtest.py
+++ b/TestON/tests/CHOtest/CHOtest.py
@@ -37,6 +37,7 @@
main.emailOnStop = main.params['TEST']['email']
main.intentCheck = int( main.params['TEST']['intentChecks'] )
main.numPings = int( main.params['TEST']['numPings'] )
+ main.pingSleep = int( main.params['timers']['pingSleep'] )
main.newTopo = ""
main.CLIs = []
@@ -514,13 +515,15 @@
time.sleep( 10 )
- main.step( "Verify Pingall" )
- pingResult = main.FALSE
- time1 = time.time()
- pingResult = main.Mininet1.pingall( timeout=main.pingTimeout )
- if not pingResult:
- main.log.warn("First pingall failed. Trying again...")
- pingResult = main.Mininet1.pingall( timeout=main.pingTimeout)
+ main.step( "Verify Ping across all hosts" )
+ for i in range(main.numPings):
+ time1 = time.time()
+ pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
+ if not pingResult:
+ main.log.warn("First pingall failed. Retrying...")
+ time.sleep(main.pingSleep)
+ else: break
+
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
main.log.report(
@@ -573,13 +576,15 @@
time.sleep( 10 )
- main.step( "Verify Pingall" )
- pingResult = main.FALSE
- time1 = time.time()
- pingResult = main.Mininet1.pingall( timeout=main.pingTimeout )
- if not pingResult:
- main.log.warn("First pingall failed. Trying again...")
- pingResult = main.Mininet1.pingall( timeout=main.pingTimeout )
+ main.step( "Verify Ping across all hosts" )
+ for i in range(main.numPings):
+ time1 = time.time()
+ pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
+ if not pingResult:
+ main.log.warn("First pingall failed. Retrying...")
+ time.sleep(main.pingSleep)
+ else: break
+
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
main.log.report(
@@ -632,13 +637,15 @@
time.sleep( 10 )
- main.step( "Verify Pingall" )
- pingResult = main.FALSE
- time1 = time.time()
- pingResult = main.Mininet1.pingall( timeout=main.pingTimeout )
- if not pingResult:
- main.log.warn("First pingall failed. Trying again...")
- pingResult = main.Mininet1.pingall( timeout=main.pingTimeout )
+ main.step( "Verify Ping across all hosts" )
+ for i in range(main.numPings):
+ time1 = time.time()
+ pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
+ if not pingResult:
+ main.log.warn("First pingall failed. Retrying...")
+ time.sleep(main.pingSleep)
+ else: break
+
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
main.log.report(
@@ -1126,13 +1133,14 @@
onfail="SOME INTENTS NOT INSTALLED" )
main.step( "Verify Ping across all hosts" )
- pingResult = main.FALSE
- time1 = time.time()
- pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
- if not pingResult:
- main.log.warn("First pingall failed. Retrying...")
+ for i in range(main.numPings):
time1 = time.time()
pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
+ if not pingResult:
+ main.log.warn("First pingall failed. Retrying...")
+ time.sleep(main.pingSleep)
+ else: break
+
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
main.log.report(
@@ -1224,13 +1232,14 @@
onfail="SOME INTENTS NOT INSTALLED" )
main.step( "Verify Ping across all hosts" )
- pingResult = main.FALSE
- time1 = time.time()
- pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
- if not pingResult:
- main.log.warn("First pingall failed. Retrying...")
+ for i in range(main.numPings):
time1 = time.time()
pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
+ if not pingResult:
+ main.log.warn("First pingall failed. Retrying...")
+ time.sleep(main.pingSleep)
+ else: break
+
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
main.log.report(
@@ -1449,13 +1458,13 @@
onfail="SOME INTENTS NOT INSTALLED" )
main.step( "Verify Ping across all hosts" )
- pingResult = main.FALSE
- time1 = time.time()
- pingResult = main.Mininet1.pingall(timeout=main.pingTimeout )
- if not pingResult:
- main.log.warn("First pingall failed. Retrying...")
+ for i in range(main.numPings):
time1 = time.time()
- pingResult = main.Mininet1.pingall(timeout=main.pingTimeout )
+ pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
+ if not pingResult:
+ main.log.warn("First pingall failed. Retrying...")
+ time.sleep(main.pingSleep)
+ else: break
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
@@ -1559,13 +1568,13 @@
onfail="SOME INTENTS NOT INSTALLED" )
main.step( "Verify Ping across all hosts" )
- pingResult = main.FALSE
- time1 = time.time()
- pingResult = main.Mininet1.pingall( timeout=main.pingTimeout )
- if not pingResult:
- main.log.warn("First pingall failed. Retrying...")
+ for i in range(main.numPings):
time1 = time.time()
- pingResult = main.Mininet1.pingall(timeout=main.pingTimeout )
+ pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
+ if not pingResult:
+ main.log.warn("First pingall failed. Retrying...")
+ time.sleep(main.pingSleep)
+ else: break
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
@@ -1682,13 +1691,13 @@
onfail="SOME INTENTS NOT INSTALLED" )
main.step( "Verify Ping across all hosts" )
- pingResult = main.FALSE
- time1 = time.time()
- pingResult = main.Mininet1.pingall(timeout=main.pingTimeout )
- if not pingResult:
- main.log.warn("First pingall failed. Retrying...")
+ for i in range(main.numPings):
time1 = time.time()
- pingResult = main.Mininet1.pingall(timeout=main.pingTimeout )
+ pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
+ if not pingResult:
+ main.log.warn("First pingall failed. Retrying...")
+ time.sleep(main.pingSleep)
+ else: break
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
@@ -1792,13 +1801,13 @@
onfail="SOME INTENTS NOT INSTALLED" )
main.step( "Verify Ping across all hosts" )
- pingResult = main.FALSE
- time1 = time.time()
- pingResult = main.Mininet1.pingall( timeout=main.pingTimeout )
- if not pingResult:
- main.log.warn("First pingall failed. Retrying...")
+ for i in range(main.numPings):
time1 = time.time()
- pingResult = main.Mininet1.pingall(timeout=main.pingTimeout )
+ pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
+ if not pingResult:
+ main.log.warn("First pingall failed. Retrying...")
+ time.sleep(main.pingSleep)
+ else: break
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
@@ -1892,13 +1901,13 @@
onfail="SOME INTENTS NOT INSTALLED" )
main.step( "Verify Ping across all hosts" )
- pingResult = main.FALSE
- time1 = time.time()
- pingResult = main.Mininet1.pingall(timeout=main.pingTimeout )
- if not pingResult:
- main.log.warn("First pingall failed. Retrying...")
+ for i in range(main.numPings):
time1 = time.time()
- pingResult = main.Mininet1.pingall(timeout=main.pingTimeout )
+ pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
+ if not pingResult:
+ main.log.warn("First pingall failed. Retrying...")
+ time.sleep(main.pingSleep)
+ else: break
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
@@ -1989,13 +1998,13 @@
onfail="SOME INTENTS NOT INSTALLED" )
main.step( "Verify Ping across all hosts" )
- pingResult = main.FALSE
- time1 = time.time()
- pingResult = main.Mininet1.pingall( timeout=main.pingTimeout )
- if not pingResult:
- main.log.warn("First pingall failed. Retrying...")
+ for i in range(main.numPings):
time1 = time.time()
- pingResult = main.Mininet1.pingall(timeout=main.pingTimeout )
+ pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
+ if not pingResult:
+ main.log.warn("First pingall failed. Retrying...")
+ time.sleep(main.pingSleep)
+ else: break
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
@@ -2089,13 +2098,13 @@
onfail="SOME INTENTS NOT INSTALLED" )
main.step( "Verify Ping across all hosts" )
- pingResult = main.FALSE
- time1 = time.time()
- pingResult = main.Mininet1.pingall(timeout=main.pingTimeout )
- if not pingResult:
- main.log.warn("First pingall failed. Retrying...")
+ for i in range(main.numPings):
time1 = time.time()
- pingResult = main.Mininet1.pingall(timeout=main.pingTimeout )
+ pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
+ if not pingResult:
+ main.log.warn("First pingall failed. Retrying...")
+ time.sleep(main.pingSleep)
+ else: break
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
@@ -2186,13 +2195,13 @@
onfail="SOME INTENTS NOT INSTALLED" )
main.step( "Verify Ping across all hosts" )
- pingResult = main.FALSE
- time1 = time.time()
- pingResult = main.Mininet1.pingall( timeout=main.pingTimeout )
- if not pingResult:
- main.log.warn("First pingall failed. Retrying...")
+ for i in range(main.numPings):
time1 = time.time()
- pingResult = main.Mininet1.pingall(timeout=main.pingTimeout )
+ pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
+ if not pingResult:
+ main.log.warn("First pingall failed. Retrying...")
+ time.sleep(main.pingSleep)
+ else: break
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
@@ -2297,13 +2306,13 @@
onfail="SOME INTENTS NOT INSTALLED" )
main.step( "Verify Ping across all hosts" )
- pingResult = main.FALSE
- time1 = time.time()
- pingResult = main.Mininet1.pingall(timeout=main.pingTimeout )
- if not pingResult:
- main.log.warn("First pingall failed. Retrying...")
+ for i in range(main.numPings):
time1 = time.time()
- pingResult = main.Mininet1.pingall(timeout=main.pingTimeout )
+ pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
+ if not pingResult:
+ main.log.warn("First pingall failed. Retrying...")
+ time.sleep(main.pingSleep)
+ else: break
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
@@ -2395,13 +2404,13 @@
onfail="SOME INTENTS NOT INSTALLED" )
main.step( "Verify Ping across all hosts" )
- pingResult = main.FALSE
- time1 = time.time()
- pingResult = main.Mininet1.pingall( timeout=main.pingTimeout )
- if not pingResult:
- main.log.warn("First pingall failed. Retrying...")
+ for i in range(main.numPings):
time1 = time.time()
- pingResult = main.Mininet1.pingall(timeout=main.pingTimeout )
+ pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
+ if not pingResult:
+ main.log.warn("First pingall failed. Retrying...")
+ time.sleep(main.pingSleep)
+ else: break
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
@@ -2506,13 +2515,13 @@
onfail="SOME INTENTS NOT INSTALLED" )
main.step( "Verify Ping across all hosts" )
- pingResult = main.FALSE
- time1 = time.time()
- pingResult = main.Mininet1.pingall(timeout=main.pingTimeout )
- if not pingResult:
- main.log.warn("First pingall failed. Retrying...")
+ for i in range(main.numPings):
time1 = time.time()
- pingResult = main.Mininet1.pingall(timeout=main.pingTimeout )
+ pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
+ if not pingResult:
+ main.log.warn("First pingall failed. Retrying...")
+ time.sleep(main.pingSleep)
+ else: break
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
@@ -2604,13 +2613,13 @@
onfail="SOME INTENTS NOT INSTALLED" )
main.step( "Verify Ping across all hosts" )
- pingResult = main.FALSE
- time1 = time.time()
- pingResult = main.Mininet1.pingall( timeout=main.pingTimeout )
- if not pingResult:
- main.log.warn("First pingall failed. Retrying...")
+ for i in range(main.numPings):
time1 = time.time()
- pingResult = main.Mininet1.pingall(timeout=main.pingTimeout )
+ pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
+ if not pingResult:
+ main.log.warn("First pingall failed. Retrying...")
+ time.sleep(main.pingSleep)
+ else: break
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
@@ -3109,9 +3118,14 @@
onfail="SOME INTENTS NOT INSTALLED" )
main.step( "Verify Ping across all hosts" )
- pingResult = main.FALSE
- time1 = time.time()
- pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
+ for i in range(main.numPings):
+ time1 = time.time()
+ pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
+ if not pingResult:
+ main.log.warn("First pingall failed. Retrying...")
+ time.sleep(main.pingSleep)
+ else: break
+
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
main.log.report(
@@ -3119,7 +3133,7 @@
str( timeDiff ) +
" seconds" )
utilities.assert_equals( expect=main.TRUE, actual=pingResult,
- onpass="PING tALL PASS",
+ onpass="PING ALL PASS",
onfail="PING ALL FAIL" )
caseResult = ( intentState and pingResult )
@@ -3204,9 +3218,14 @@
onfail="SOME INTENTS NOT INSTALLED" )
main.step( "Verify Ping across all hosts" )
- pingResult = main.FALSE
- time1 = time.time()
- pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
+ for i in range(main.numPings):
+ time1 = time.time()
+ pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
+ if not pingResult:
+ main.log.warn("First pingall failed. Retrying...")
+ time.sleep(main.pingSleep)
+ else: break
+
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
main.log.report(
@@ -3302,9 +3321,14 @@
onfail="SOME INTENTS NOT INSTALLED" )
main.step( "Verify Ping across all hosts" )
- pingResult = main.FALSE
- time1 = time.time()
- pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
+ for i in range(main.numPings):
+ time1 = time.time()
+ pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
+ if not pingResult:
+ main.log.warn("First pingall failed. Retrying...")
+ time.sleep(main.pingSleep)
+ else: break
+
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
main.log.report(
@@ -3420,13 +3444,13 @@
onfail="SOME FLOWS NOT ADDED" )
main.step( "Verify Ping across all hosts" )
- pingResult = main.FALSE
- time1 = time.time()
- pingResult = main.Mininet1.pingall( timeout=main.pingTimeout )
- if not pingResult:
+ for i in range(main.numPings):
time1 = time.time()
- main.log.warn("First pingall failed. Retrying")
- pingResult = main.Mininet1.pingall( timeout=main.pingTimeout )
+ pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
+ if not pingResult:
+ main.log.warn("First pingall failed. Retrying...")
+ time.sleep(main.pingSleep)
+ else: break
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
@@ -3540,13 +3564,13 @@
onfail="SOME FLOWS NOT ADDED" )
main.step( "Verify Ping across all hosts" )
- pingResult = main.FALSE
- time1 = time.time()
- pingResult = main.Mininet1.pingall( timeout=main.pingTimeout )
- if not pingResult:
+ for i in range(main.numPings):
time1 = time.time()
- main.log.warn("First pingall failed. Retrying")
- pingResult = main.Mininet1.pingall( timeout=main.pingTimeout )
+ pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
+ if not pingResult:
+ main.log.warn("First pingall failed. Retrying...")
+ time.sleep(main.pingSleep)
+ else: break
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
@@ -3660,13 +3684,13 @@
onfail="SOME FLOWS NOT ADDED" )
main.step( "Verify Ping across all hosts" )
- pingResult = main.FALSE
- time1 = time.time()
- pingResult = main.Mininet1.pingall( timeout=main.pingTimeout )
- if not pingResult:
+ for i in range(main.numPings):
time1 = time.time()
- main.log.warn("First pingall failed. Retrying")
- pingResult = main.Mininet1.pingall( timeout=main.pingTimeout )
+ pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
+ if not pingResult:
+ main.log.warn("First pingall failed. Retrying...")
+ time.sleep(main.pingSleep)
+ else: break
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
@@ -3779,13 +3803,13 @@
onfail="SOME FLOWS NOT ADDED" )
main.step( "Verify Ping across all hosts" )
- pingResult = main.FALSE
- time1 = time.time()
- pingResult = main.Mininet1.pingall( timeout=main.pingTimeout )
- if not pingResult:
+ for i in range(main.numPings):
time1 = time.time()
- main.log.warn("First pingall failed. Retrying")
- pingResult = main.Mininet1.pingall( timeout=main.pingTimeout )
+ pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
+ if not pingResult:
+ main.log.warn("First pingall failed. Retrying...")
+ time.sleep(main.pingSleep)
+ else: break
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
@@ -3898,13 +3922,13 @@
onfail="SOME FLOWS NOT ADDED" )
main.step( "Verify Ping across all hosts" )
- pingResult = main.FALSE
- time1 = time.time()
- pingResult = main.Mininet1.pingall( timeout=main.pingTimeout )
- if not pingResult:
+ for i in range(main.numPings):
time1 = time.time()
- main.log.warn("First pingall failed. Retrying")
- pingResult = main.Mininet1.pingall( timeout=main.pingTimeout )
+ pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
+ if not pingResult:
+ main.log.warn("First pingall failed. Retrying...")
+ time.sleep(main.pingSleep)
+ else: break
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
@@ -4023,13 +4047,13 @@
onfail="SOME FLOWS NOT ADDED" )
main.step( "Verify Ping across all hosts" )
- pingResult = main.FALSE
- time1 = time.time()
- pingResult = main.Mininet1.pingall( timeout=main.pingTimeout )
- if not pingResult:
+ for i in range(main.numPings):
time1 = time.time()
- main.log.warn("First pingall failed. Retrying")
- pingResult = main.Mininet1.pingall( timeout=main.pingTimeout )
+ pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
+ if not pingResult:
+ main.log.warn("First pingall failed. Retrying...")
+ time.sleep(main.pingSleep)
+ else: break
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
@@ -4301,10 +4325,15 @@
installResult = main.TRUE
main.log.info("Time for feature:install onos-app-ifwd: %2f seconds" %(time2-time1))
- main.step( "Verify Pingall" )
- pingResult = main.FALSE
- time1 = time.time()
- pingResult = main.Mininet1.pingall(timeout=600)
+ main.step( "Verify Ping across all hosts" )
+ for i in range(main.numPings):
+ time1 = time.time()
+ pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
+ if not pingResult:
+ main.log.warn("First pingall failed. Retrying...")
+ time.sleep(main.pingSleep)
+ else: break
+
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
main.log.report(
diff --git a/TestON/tests/FUNCvirNetNB/FUNCvirNetNB.params b/TestON/tests/FUNCvirNetNB/FUNCvirNetNB.params
index a922e75..84cab8c 100644
--- a/TestON/tests/FUNCvirNetNB/FUNCvirNetNB.params
+++ b/TestON/tests/FUNCvirNetNB/FUNCvirNetNB.params
@@ -11,7 +11,7 @@
# 9 - Update Virtualport northbound test
#10 - Delete Virtualport northbound test
- <testcases>1,2,3,4,5,6,7,8,9,10</testcases>
+ <testcases>1,2,3,4,5,6,7,8,9,10,11,12,13</testcases>
<SLEEP>
<startup>15</startup>
diff --git a/TestON/tests/FUNCvirNetNB/FUNCvirNetNB.py b/TestON/tests/FUNCvirNetNB/FUNCvirNetNB.py
index 4bbc0bb..fd828e0 100644
--- a/TestON/tests/FUNCvirNetNB/FUNCvirNetNB.py
+++ b/TestON/tests/FUNCvirNetNB/FUNCvirNetNB.py
@@ -13,6 +13,9 @@
CASE8 - Create Virtualport northbound test
CASE9 - Update Virtualport northbound test
CASE10 - Delete Virtualport northbound test
+CASE11 - Post Error Json Create Network test
+CASE12 - Post Error Json Create Subnet test
+CASE13 - Post Error Json Create Virtualport test
lanqinglong@huawei.com
"""
@@ -1013,4 +1016,179 @@
expect='200',
actual=deletestatus,
onpass="Delete Network Success",
- onfail="Delete Network Failed" )
+ onfail="Delete Network Failed" )
+ def CASE11 ( self,main ):
+
+ """
+ Test Post Error Json Create Network
+ """
+ import os
+
+ try:
+ from tests.FUNCvirNetNB.dependencies.Nbdata import NetworkData
+ except ImportError:
+ main.log.exception( "Something wrong with import file or code error." )
+ main.log.info( "Import Error, please check!" )
+ main.cleanup()
+ main.exit()
+
+ main.log.info( "ONOS Post Error Json Create Network test Start" )
+ main.case( "Virtual Network NBI Test - Network" )
+ main.caseExplanation = "Test Network Post With Error json " +\
+ "The wrong Json can't post network successfully"
+
+ ctrlip = os.getenv( main.params['CTRL']['ip1'] )
+ port = main.params['HTTP']['port']
+ path = main.params['HTTP']['path']
+
+ main.step( "Generate Post Data" )
+ network = NetworkData()
+ network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
+ network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
+ #The network.admin_state_up should be True or False,when the admin_state_up is 'tttttttttt',the Json can't post.
+ network.admin_state_up = 'tttttttttt'
+ #The network.routerExternal should be True or False,when the routerExternal is 'ffffffffffff',the Json can't post.
+ network.routerExternal = 'ffffffffffff'
+ #The network.shared should be True or False,when the shared is 'ffffffffffffff',the Json can't post.
+ network.shared = 'ffffffffffffff'
+ postdata = network.DictoJson()
+
+ main.step( "Post Data via HTTP" )
+ Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path+'networks/',
+ 'POST', None, postdata)
+
+ utilities.assert_equals(
+ expect='500',
+ actual=Poststatus,
+ onpass="The Json is wrong,can't post",
+ onfail="Wrong Json can post successfully " )
+ def CASE12( self, main ):
+
+ """
+ Test Post Error Json Create Subnet
+ """
+ import os
+
+ try:
+ from tests.FUNCvirNetNB.dependencies.Nbdata import NetworkData
+ from tests.FUNCvirNetNB.dependencies.Nbdata import SubnetData
+ except ImportError:
+ main.log.exception( "Something wrong with import file or code error." )
+ main.log.info( "Import Error, please check!" )
+ main.cleanup()
+ main.exit()
+
+ main.log.info( "ONOS Post Error Json Create Subnet test Start" )
+ main.case( "Virtual Network NBI Test - Subnet" )
+ main.caseExplanation = "Test Subnet Post With Error json " +\
+ "The wrong Json can't post network successfully"
+
+ ctrlip = os.getenv( main.params['CTRL']['ip1'] )
+ port = main.params['HTTP']['port']
+ path = main.params['HTTP']['path']
+
+ main.step( "Generate Post Data" )
+ network = NetworkData()
+ network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
+ network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
+ subnet = SubnetData()
+ subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
+ #The subnet.enable_dhcp should be True or False,when the enable_dhcp is 'tttttttttttttt',the Json can't post.
+ subnet.enable_dhcp = 'tttttttttttttt'
+ #The subnet.tenant_id should be True or False,when the tenant_id is ffffffffffffff',the Json can't post.
+ subnet.shared = 'ffffffffffffff'
+ subnet.tenant_id = network.tenant_id
+ subnet.network_id = network.id
+
+ networkpostdata = network.DictoJson()
+ subnetpostdata = subnet.DictoJson()
+
+ main.step( "Post Network Data via HTTP(Post Subnet need post network)" )
+ Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path + 'networks/',
+ 'POST', None, networkpostdata )
+ utilities.assert_equals(
+ expect='200',
+ actual=Poststatus,
+ onpass="Post Network Success",
+ onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
+
+ main.step( "Post Subnet Data via HTTP" )
+ Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path + 'subnets/',
+ 'POST', None, subnetpostdata )
+ utilities.assert_equals(
+ expect='500',
+ actual=Poststatus,
+ onpass="The Json is wrong,can't post",
+ onfail="Wrong Json can post successfully " )
+ def CASE13( self, main ):
+
+ """
+ Test Post Error Json Create Virtualport
+ """
+ import os
+
+ try:
+ from tests.FUNCvirNetNB.dependencies.Nbdata import NetworkData
+ from tests.FUNCvirNetNB.dependencies.Nbdata import SubnetData
+ from tests.FUNCvirNetNB.dependencies.Nbdata import VirtualPortData
+ except ImportError:
+ main.log.exception( "Something wrong with import file or code error." )
+ main.log.info( "Import Error, please check!" )
+ main.cleanup()
+ main.exit()
+
+ main.log.info( "ONOS Post Error Json Create Subnet test Start" )
+ main.case( "Virtual Network NBI Test - Port" )
+ main.caseExplanation = "Test Subnet Post With Error json " +\
+ "The wrong Json can't create port successfully"
+
+ ctrlip = os.getenv( main.params['CTRL']['ip1'] )
+ httpport = main.params['HTTP']['port']
+ path = main.params['HTTP']['path']
+
+ main.step( "Generate Post Data" )
+ network = NetworkData()
+ network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
+ network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
+ subnet = SubnetData()
+ subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
+ subnet.tenant_id = network.tenant_id
+ subnet.network_id = network.id
+ port = VirtualPortData()
+ port.id = "9352e05c-58b8-4f2c-b4df-c20435ser56466"
+ port.subnet_id = subnet.id
+ port.tenant_id = network.tenant_id
+ port.network_id = network.id
+ #The port.adminStateUp should be True or False,when the adminStateUp is 'tttttttttttt',the Json can't post.
+ port.adminStateUp = 'tttttttttttt'
+
+ networkpostdata = network.DictoJson()
+ subnetpostdata = subnet.DictoJson()
+ portpostdata = port.DictoJson()
+
+ main.step( "Post Network Data via HTTP(Post port need post network)" )
+ Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'networks/',
+ 'POST', None, networkpostdata )
+ utilities.assert_equals(
+ expect='200',
+ actual=Poststatus,
+ onpass="Post Network Success",
+ onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
+
+ main.step( "Post Subnet Data via HTTP(Post port need post subnet)" )
+ Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'subnets/',
+ 'POST', None, subnetpostdata )
+ utilities.assert_equals(
+ expect='202',
+ actual=Poststatus,
+ onpass="Post Subnet Success",
+ onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
+
+ main.step( "Post Port Data via HTTP" )
+ Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'ports/',
+ 'POST', None, portpostdata )
+ utilities.assert_equals(
+ expect='500',
+ actual=Poststatus,
+ onpass="The Json is wrong,can't post",
+ onfail="Wrong Json can post successfully" )
diff --git a/TestON/tests/HAclusterRestart/HAclusterRestart.py b/TestON/tests/HAclusterRestart/HAclusterRestart.py
index d77450a..3e81d3e 100644
--- a/TestON/tests/HAclusterRestart/HAclusterRestart.py
+++ b/TestON/tests/HAclusterRestart/HAclusterRestart.py
@@ -3462,23 +3462,7 @@
onfail="Added counters are incorrect" )
main.step( "Check counters are consistant across nodes" )
- onosCounters = []
- threads = []
- for i in range( main.numCtrls ):
- t = main.Thread( target=main.CLIs[i].counters,
- name="counters-" + str( i ) )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- onosCounters.append( t.result )
- tmp = [ i == onosCounters[ 0 ] for i in onosCounters ]
- if all( tmp ):
- main.log.info( "Counters are consistent across all nodes" )
- consistentCounterResults = main.TRUE
- else:
- main.log.error( "Counters are not consistent across all nodes" )
- consistentCounterResults = main.FALSE
+ onosCounters, consistentCounterResults = main.Counters.consistentCheck()
utilities.assert_equals( expect=main.TRUE,
actual=consistentCounterResults,
onpass="ONOS counters are consistent " +
@@ -3494,7 +3478,6 @@
actual=incrementCheck,
onpass="Added counters are correct",
onfail="Added counters are incorrect" )
-
# DISTRIBUTED SETS
main.step( "Distributed Set get" )
size = len( onosSet )
diff --git a/TestON/tests/HAclusterRestart/dependencies/Counters.py b/TestON/tests/HAclusterRestart/dependencies/Counters.py
index 21308c2..6614887 100644
--- a/TestON/tests/HAclusterRestart/dependencies/Counters.py
+++ b/TestON/tests/HAclusterRestart/dependencies/Counters.py
@@ -1,14 +1,19 @@
def __init__( self ):
self.default = ''
-def counterCheck( counterName, counterValue ):
+def consistentCheck():
"""
- Add Text here
+ Checks that TestON counters are consistent across all nodes.
+
+ Returns the tuple (onosCounters, consistent)
+ - onosCounters is the parsed json output of the counters command on all nodes
+ - consistent is main.TRUE if all "TestON" counters are consitent across all
+ nodes or main.FALSE
"""
import json
correctResults = main.TRUE
# Get onos counters results
- onosCounters = []
+ onosCountersRaw = []
threads = []
for i in range( main.numCtrls ):
t = main.Thread( target=main.CLIs[i].counters,
@@ -17,25 +22,58 @@
t.start()
for t in threads:
t.join()
- onosCounters.append( t.result )
- tmp = [ i == onosCounters[ 0 ] for i in onosCounters ]
+ onosCountersRaw.append( t.result )
+ onosCounters = []
+ for i in range( main.numCtrls ):
+ try:
+ onosCounters.append( json.loads( onosCountersRaw[i] ) )
+ except ( ValueError, TypeError ):
+ main.log.error( "Could not parse counters response from ONOS" +
+ str( i + 1 ) )
+ main.log.warn( repr( onosCountersRaw[ i ] ) )
+ return main.FALSE
+
+ testCounters = {}
+ # make a list of all the "TestON-*" counters in ONOS
+ # lookes like a dict whose keys are the name of the ONOS node and values
+ # are a list of the counters. I.E.
+ # { "ONOS1": [ {"name":"TestON-inMemory","value":56},
+ # {"name":"TestON-Partitions","value":56} ]
+ # }
+ # NOTE: There is an assumtion that all nodes are active
+ # based on the above for loops
+ for controller in enumerate( onosCounters ):
+ for dbType in controller[1]:
+ for dbName, items in dbType.iteritems():
+ for item in items:
+ if 'TestON' in item['name']:
+ node = 'ONOS' + str( controller[0] + 1 )
+ try:
+ testCounters[node].append( item )
+ except KeyError:
+ testCounters[node] = [ item ]
+ # compare the counters on each node
+ tmp = [ v == testCounters['ONOS1'] for k, v in testCounters.iteritems() ]
if all( tmp ):
consistent = main.TRUE
else:
consistent = main.FALSE
- main.log.error( "ONOS nodes have different values for counters" )
- for node in onosCounters:
- main.log.debug( node )
+ main.log.error( "ONOS nodes have different values for counters:\n" +
+ testCounters )
+ return ( onosCounters, consistent )
+def counterCheck( counterName, counterValue ):
+ """
+ Checks that TestON counters are consistent across all nodes and that
+ specified counter is in ONOS with the given value
+ """
+ import json
+ correctResults = main.TRUE
+ # Get onos counters results and consistentCheck
+ onosCounters, consistent = main.Counters.consistentCheck()
# Check for correct values
for i in range( main.numCtrls ):
- try:
- current = json.loads( onosCounters[i] )
- except ( ValueError, TypeError ):
- main.log.error( "Could not parse counters response from ONOS" +
- str( i + 1 ) )
- main.log.warn( repr( onosCounters[ i ] ) )
- return main.FALSE
+ current = onosCounters[i]
onosValue = None
try:
for database in current:
diff --git a/TestON/tests/HAsanity/HAsanity.py b/TestON/tests/HAsanity/HAsanity.py
index 4f8fadc..3dfdde6 100644
--- a/TestON/tests/HAsanity/HAsanity.py
+++ b/TestON/tests/HAsanity/HAsanity.py
@@ -3361,23 +3361,7 @@
onfail="Added counters are incorrect" )
main.step( "Check counters are consistant across nodes" )
- onosCounters = []
- threads = []
- for i in range( main.numCtrls ):
- t = main.Thread( target=main.CLIs[i].counters,
- name="counters-" + str( i ) )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- onosCounters.append( t.result )
- tmp = [ i == onosCounters[ 0 ] for i in onosCounters ]
- if all( tmp ):
- main.log.info( "Counters are consistent across all nodes" )
- consistentCounterResults = main.TRUE
- else:
- main.log.error( "Counters are not consistent across all nodes" )
- consistentCounterResults = main.FALSE
+ onosCounters, consistentCounterResults = main.Counters.consistentCheck()
utilities.assert_equals( expect=main.TRUE,
actual=consistentCounterResults,
onpass="ONOS counters are consistent " +
@@ -3393,7 +3377,6 @@
actual=incrementCheck,
onpass="Added counters are correct",
onfail="Added counters are incorrect" )
-
# DISTRIBUTED SETS
main.step( "Distributed Set get" )
size = len( onosSet )
diff --git a/TestON/tests/HAsanity/dependencies/Counters.py b/TestON/tests/HAsanity/dependencies/Counters.py
index 21308c2..6614887 100644
--- a/TestON/tests/HAsanity/dependencies/Counters.py
+++ b/TestON/tests/HAsanity/dependencies/Counters.py
@@ -1,14 +1,19 @@
def __init__( self ):
self.default = ''
-def counterCheck( counterName, counterValue ):
+def consistentCheck():
"""
- Add Text here
+ Checks that TestON counters are consistent across all nodes.
+
+ Returns the tuple (onosCounters, consistent)
+ - onosCounters is the parsed json output of the counters command on all nodes
+ - consistent is main.TRUE if all "TestON" counters are consitent across all
+ nodes or main.FALSE
"""
import json
correctResults = main.TRUE
# Get onos counters results
- onosCounters = []
+ onosCountersRaw = []
threads = []
for i in range( main.numCtrls ):
t = main.Thread( target=main.CLIs[i].counters,
@@ -17,25 +22,58 @@
t.start()
for t in threads:
t.join()
- onosCounters.append( t.result )
- tmp = [ i == onosCounters[ 0 ] for i in onosCounters ]
+ onosCountersRaw.append( t.result )
+ onosCounters = []
+ for i in range( main.numCtrls ):
+ try:
+ onosCounters.append( json.loads( onosCountersRaw[i] ) )
+ except ( ValueError, TypeError ):
+ main.log.error( "Could not parse counters response from ONOS" +
+ str( i + 1 ) )
+ main.log.warn( repr( onosCountersRaw[ i ] ) )
+ return main.FALSE
+
+ testCounters = {}
+ # make a list of all the "TestON-*" counters in ONOS
+ # lookes like a dict whose keys are the name of the ONOS node and values
+ # are a list of the counters. I.E.
+ # { "ONOS1": [ {"name":"TestON-inMemory","value":56},
+ # {"name":"TestON-Partitions","value":56} ]
+ # }
+ # NOTE: There is an assumtion that all nodes are active
+ # based on the above for loops
+ for controller in enumerate( onosCounters ):
+ for dbType in controller[1]:
+ for dbName, items in dbType.iteritems():
+ for item in items:
+ if 'TestON' in item['name']:
+ node = 'ONOS' + str( controller[0] + 1 )
+ try:
+ testCounters[node].append( item )
+ except KeyError:
+ testCounters[node] = [ item ]
+ # compare the counters on each node
+ tmp = [ v == testCounters['ONOS1'] for k, v in testCounters.iteritems() ]
if all( tmp ):
consistent = main.TRUE
else:
consistent = main.FALSE
- main.log.error( "ONOS nodes have different values for counters" )
- for node in onosCounters:
- main.log.debug( node )
+ main.log.error( "ONOS nodes have different values for counters:\n" +
+ testCounters )
+ return ( onosCounters, consistent )
+def counterCheck( counterName, counterValue ):
+ """
+ Checks that TestON counters are consistent across all nodes and that
+ specified counter is in ONOS with the given value
+ """
+ import json
+ correctResults = main.TRUE
+ # Get onos counters results and consistentCheck
+ onosCounters, consistent = main.Counters.consistentCheck()
# Check for correct values
for i in range( main.numCtrls ):
- try:
- current = json.loads( onosCounters[i] )
- except ( ValueError, TypeError ):
- main.log.error( "Could not parse counters response from ONOS" +
- str( i + 1 ) )
- main.log.warn( repr( onosCounters[ i ] ) )
- return main.FALSE
+ current = onosCounters[i]
onosValue = None
try:
for database in current:
diff --git a/TestON/tests/HAsingleInstanceRestart/HAsingleInstanceRestart.py b/TestON/tests/HAsingleInstanceRestart/HAsingleInstanceRestart.py
index 19cc462..bdcf969 100644
--- a/TestON/tests/HAsingleInstanceRestart/HAsingleInstanceRestart.py
+++ b/TestON/tests/HAsingleInstanceRestart/HAsingleInstanceRestart.py
@@ -2533,23 +2533,7 @@
onfail="Added counters are incorrect" )
main.step( "Check counters are consistant across nodes" )
- onosCounters = []
- threads = []
- for i in range( main.numCtrls ):
- t = main.Thread( target=main.CLIs[i].counters,
- name="counters-" + str( i ) )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- onosCounters.append( t.result )
- tmp = [ i == onosCounters[ 0 ] for i in onosCounters ]
- if all( tmp ):
- main.log.info( "Counters are consistent across all nodes" )
- consistentCounterResults = main.TRUE
- else:
- main.log.error( "Counters are not consistent across all nodes" )
- consistentCounterResults = main.FALSE
+ onosCounters, consistentCounterResults = main.Counters.consistentCheck()
utilities.assert_equals( expect=main.TRUE,
actual=consistentCounterResults,
onpass="ONOS counters are consistent " +
@@ -2565,7 +2549,6 @@
actual=incrementCheck,
onpass="Added counters are correct",
onfail="Added counters are incorrect" )
-
# DISTRIBUTED SETS
main.step( "Distributed Set get" )
size = len( onosSet )
diff --git a/TestON/tests/HAsingleInstanceRestart/dependencies/Counters.py b/TestON/tests/HAsingleInstanceRestart/dependencies/Counters.py
index 21308c2..6614887 100644
--- a/TestON/tests/HAsingleInstanceRestart/dependencies/Counters.py
+++ b/TestON/tests/HAsingleInstanceRestart/dependencies/Counters.py
@@ -1,14 +1,19 @@
def __init__( self ):
self.default = ''
-def counterCheck( counterName, counterValue ):
+def consistentCheck():
"""
- Add Text here
+ Checks that TestON counters are consistent across all nodes.
+
+ Returns the tuple (onosCounters, consistent)
+ - onosCounters is the parsed json output of the counters command on all nodes
+ - consistent is main.TRUE if all "TestON" counters are consitent across all
+ nodes or main.FALSE
"""
import json
correctResults = main.TRUE
# Get onos counters results
- onosCounters = []
+ onosCountersRaw = []
threads = []
for i in range( main.numCtrls ):
t = main.Thread( target=main.CLIs[i].counters,
@@ -17,25 +22,58 @@
t.start()
for t in threads:
t.join()
- onosCounters.append( t.result )
- tmp = [ i == onosCounters[ 0 ] for i in onosCounters ]
+ onosCountersRaw.append( t.result )
+ onosCounters = []
+ for i in range( main.numCtrls ):
+ try:
+ onosCounters.append( json.loads( onosCountersRaw[i] ) )
+ except ( ValueError, TypeError ):
+ main.log.error( "Could not parse counters response from ONOS" +
+ str( i + 1 ) )
+ main.log.warn( repr( onosCountersRaw[ i ] ) )
+ return main.FALSE
+
+ testCounters = {}
+ # make a list of all the "TestON-*" counters in ONOS
+ # lookes like a dict whose keys are the name of the ONOS node and values
+ # are a list of the counters. I.E.
+ # { "ONOS1": [ {"name":"TestON-inMemory","value":56},
+ # {"name":"TestON-Partitions","value":56} ]
+ # }
+ # NOTE: There is an assumtion that all nodes are active
+ # based on the above for loops
+ for controller in enumerate( onosCounters ):
+ for dbType in controller[1]:
+ for dbName, items in dbType.iteritems():
+ for item in items:
+ if 'TestON' in item['name']:
+ node = 'ONOS' + str( controller[0] + 1 )
+ try:
+ testCounters[node].append( item )
+ except KeyError:
+ testCounters[node] = [ item ]
+ # compare the counters on each node
+ tmp = [ v == testCounters['ONOS1'] for k, v in testCounters.iteritems() ]
if all( tmp ):
consistent = main.TRUE
else:
consistent = main.FALSE
- main.log.error( "ONOS nodes have different values for counters" )
- for node in onosCounters:
- main.log.debug( node )
+ main.log.error( "ONOS nodes have different values for counters:\n" +
+ testCounters )
+ return ( onosCounters, consistent )
+def counterCheck( counterName, counterValue ):
+ """
+ Checks that TestON counters are consistent across all nodes and that
+ specified counter is in ONOS with the given value
+ """
+ import json
+ correctResults = main.TRUE
+ # Get onos counters results and consistentCheck
+ onosCounters, consistent = main.Counters.consistentCheck()
# Check for correct values
for i in range( main.numCtrls ):
- try:
- current = json.loads( onosCounters[i] )
- except ( ValueError, TypeError ):
- main.log.error( "Could not parse counters response from ONOS" +
- str( i + 1 ) )
- main.log.warn( repr( onosCounters[ i ] ) )
- return main.FALSE
+ current = onosCounters[i]
onosValue = None
try:
for database in current:
diff --git a/TestON/tests/SCPFscaleTopo/SCPFscaleTopo.params b/TestON/tests/SCPFscaleTopo/SCPFscaleTopo.params
index 5d1c7e1..cd9390c 100755
--- a/TestON/tests/SCPFscaleTopo/SCPFscaleTopo.params
+++ b/TestON/tests/SCPFscaleTopo/SCPFscaleTopo.params
@@ -1,15 +1,14 @@
<PARAMS>
- # 1 - Optional pull and build ONOS package
- # 2 - Set cell and install ONOS
- # 10 - start mininet and assign switches to controller
- # 11 - pingall
- # 12 - compare topology
- # 100 - balance master
- # 200 - bring down onos node
- # 300 - bring up onos node
+ # 1 - optional pull and build ONOS package
+ # 2 - set cell and install ONOS
+ # 10 - start mininet and verify topo
+ # 11 - verify topo
+ # 100 - balance master and bring onos node down
+ # 200 - bring onos node up and balance masters
+ # 1000 - report logs
- <testcases>1,2,[10,100,12,200,100,12,300,100,12,1000]*3</testcases>
+ <testcases>1,2,[10,100,11,200,11,1000]*3</testcases>
<DEPENDENCY>
<path>/tests/SCPFscaleTopo/Dependency/</path>
@@ -36,19 +35,32 @@
<SLEEP>
<startup>15</startup>
<fwd>30</fwd>
- <topoAttempts>1</topoAttempts>
<balance>10</balance>
<nodeDown>10</nodeDown>
<nodeUp>10</nodeUp>
+ <pingall>3</pingall>
+ <stopMN>5</stopMN>
+ <startMN>5</startMN>
</SLEEP>
<TIMEOUT>
- <pingall>60</pingall>
+ <pingall>240</pingall>
</TIMEOUT>
+ <ATTEMPTS>
+ <topoCmp>1</topoCmp>
+ <pingall>2</pingall>
+ </ATTEMPTS>
+
<TOPOLOGY>
<topology>torus</topology>
<scale>5,10,20</scale>
</TOPOLOGY>
+ <PINGALL>
+ <sleep>3</sleep>
+ <attempts>5</attempts>
+ <timeout>1000</timeout>
+ </PINGALL>
+
</PARAMS>
diff --git a/TestON/tests/SCPFscaleTopo/SCPFscaleTopo.py b/TestON/tests/SCPFscaleTopo/SCPFscaleTopo.py
index 5094f4d..e0f2f1a 100644
--- a/TestON/tests/SCPFscaleTopo/SCPFscaleTopo.py
+++ b/TestON/tests/SCPFscaleTopo/SCPFscaleTopo.py
@@ -23,73 +23,60 @@
- Build ONOS package
"""
- main.case( "Constructing test variables and building ONOS package" )
+ main.case( "Constructing test variables" )
main.step( "Constructing test variables" )
stepResult = main.FALSE
- try:
- main.testOnDirectory = os.path.dirname( os.getcwd ( ) )
- main.apps = main.params[ 'ENV' ][ 'cellApps' ]
- gitBranch = main.params[ 'GIT' ][ 'branch' ]
- main.dependencyPath = main.testOnDirectory + \
- main.params[ 'DEPENDENCY' ][ 'path' ]
- main.multiovs = main.params[ 'DEPENDENCY' ][ 'multiovs' ]
- main.topoName = main.params[ 'TOPOLOGY' ][ 'topology' ]
- main.numCtrls = int( main.params[ 'CTRL' ][ 'numCtrls' ] )
- main.topoScale = ( main.params[ 'TOPOLOGY' ][ 'scale' ] ).split( "," )
- main.topoScaleSize = len( main.topoScale )
- wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
- wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ]
- wrapperFile3 = main.params[ 'DEPENDENCY' ][ 'wrapper3' ]
- main.checkTopoAttempts = int( main.params['SLEEP']['topoAttempts'])
- main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
- main.fwdSleep = int( main.params[ 'SLEEP' ][ 'fwd' ] )
- main.balanceSleep = int( main.params[ 'SLEEP' ][ 'balance' ] )
- main.nodeDownSleep = int( main.params[ 'SLEEP' ][ 'nodeDown' ] )
- main.nodeUpSleep = int( main.params[ 'SLEEP' ][ 'nodeUp' ] )
- main.pingallTimeout = int( main.params[ 'TIMEOUT' ][ 'pingall' ] )
- gitPull = main.params[ 'GIT' ][ 'pull' ]
- main.homeDir = os.path.expanduser('~')
- main.cellData = {} # for creating cell file
- main.hostsData = {}
- main.CLIs = []
- main.ONOSip = []
- main.activeNodes = []
- main.ONOSip = main.ONOSbench.getOnosIps()
+ main.testOnDirectory = os.path.dirname( os.getcwd ( ) )
+ main.apps = main.params[ 'ENV' ][ 'cellApps' ]
+ gitBranch = main.params[ 'GIT' ][ 'branch' ]
+ main.dependencyPath = main.testOnDirectory + \
+ main.params[ 'DEPENDENCY' ][ 'path' ]
+ main.multiovs = main.params[ 'DEPENDENCY' ][ 'multiovs' ]
+ main.topoName = main.params[ 'TOPOLOGY' ][ 'topology' ]
+ main.numCtrls = int( main.params[ 'CTRL' ][ 'numCtrls' ] )
+ main.topoScale = ( main.params[ 'TOPOLOGY' ][ 'scale' ] ).split( "," )
+ main.topoScaleSize = len( main.topoScale )
+ wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
+ wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ]
+ wrapperFile3 = main.params[ 'DEPENDENCY' ][ 'wrapper3' ]
+ main.topoCmpAttempts = int( main.params[ 'ATTEMPTS' ][ 'topoCmp' ] )
+ main.pingallAttempts = int( main.params[ 'ATTEMPTS' ][ 'pingall' ] )
+ main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
+ main.fwdSleep = int( main.params[ 'SLEEP' ][ 'fwd' ] )
+ main.balanceSleep = int( main.params[ 'SLEEP' ][ 'balance' ] )
+ main.nodeDownSleep = int( main.params[ 'SLEEP' ][ 'nodeDown' ] )
+ main.nodeUpSleep = int( main.params[ 'SLEEP' ][ 'nodeUp' ] )
+ main.pingallSleep = int( main.params[ 'SLEEP' ][ 'pingall' ] )
+ main.stopMNSleep = int( main.params[ 'SLEEP' ][ 'stopMN' ] )
+ main.startMNSleep = int( main.params[ 'SLEEP' ][ 'startMN' ] )
+ main.pingTimeout = int( main.params[ 'TIMEOUT' ][ 'pingall' ] )
+ gitPull = main.params[ 'GIT' ][ 'pull' ]
+ main.homeDir = os.path.expanduser('~')
+ main.cellData = {} # for creating cell file
+ main.hostsData = {}
+ main.CLIs = []
+ main.ONOSip = []
+ main.activeNodes = []
+ main.ONOSip = main.ONOSbench.getOnosIps()
- except Exception:
- main.log.exception( "Exception: constructing test variables" )
- main.cleanup()
- main.exit()
-
- try:
- for i in range(main.numCtrls):
+ for i in range(main.numCtrls):
main.CLIs.append( getattr( main, 'ONOScli%s' % (i+1) ) )
- except Exception:
- main.log.exception( "Exception: assinging ONOS cli handles to a list" )
- main.cleanup()
- main.exit()
+ main.startUp = imp.load_source( wrapperFile1,
+ main.dependencyPath +
+ wrapperFile1 +
+ ".py" )
- try:
- main.startUp = imp.load_source( wrapperFile1,
- main.dependencyPath +
- wrapperFile1 +
- ".py" )
+ main.scaleTopoFunction = imp.load_source( wrapperFile2,
+ main.dependencyPath +
+ wrapperFile2 +
+ ".py" )
- main.scaleTopoFunction = imp.load_source( wrapperFile2,
- main.dependencyPath +
- wrapperFile2 +
- ".py" )
-
- main.topo = imp.load_source( wrapperFile3,
- main.dependencyPath +
- wrapperFile3 +
- ".py" )
- except Exception:
- main.log.exception( "Exception: importing wrapper files" )
- main.cleanup()
- main.exit()
+ main.topo = imp.load_source( wrapperFile3,
+ main.dependencyPath +
+ wrapperFile3 +
+ ".py" )
main.ONOSbench.scp( main.Mininet1,
main.dependencyPath +
@@ -243,31 +230,36 @@
def CASE10( self, main ):
"""
- Starting up torus topology
+ Starting up torus topology, pingall, and compare topo
"""
- main.case( "Starting up torus topology" )
- main.step( "Starting up torus topology" )
+ import json
+
+ main.case( "Starting up Mininet and verifying topology" )
+ main.caseExplanation = "Starting Mininet with a scalling topology and " +\
+ "comparing topology elements between Mininet and ONOS"
main.log.info( "Checking if mininet is already running" )
if len( main.topoScale ) < main.topoScaleSize:
main.log.info( "Mininet is already running. Stopping mininet." )
main.Mininet1.stopNet()
- time.sleep(5)
+ time.sleep(main.stopMNSleep)
else:
main.log.info( "Mininet was not running" )
- try:
+ if main.topoScale:
scale = main.topoScale.pop(0)
- except Exception:
- main.log.exception("Exception: popping from list of topology scales ")
- main.cleanup()
- main.exit()
+ else: main.log.error( "topology scale is empty" )
- mnCmd = " mn --custom=" + main.homeDir + "/mininet/custom/multiovs.py " +\
- "--switch=ovsm --topo " + main.topoName + ","+ scale + "," + scale +\
- " --controller=remote,ip=" + main.ONOSip[ 0 ] +\
- " --controller=remote,ip=" + main.ONOSip[ 1 ] +\
- " --controller=remote,ip=" + main.ONOSip[ 2 ] + " --mac"
+
+ main.step( "Starting up TORUS %sx%s topology" % (scale, scale) )
+
+ main.log.info( "Constructing Mininet command" )
+ mnCmd = " mn --custom " + main.Mininet1.home + main.multiovs +\
+ " --switch ovsm --topo " + main.topoName + ","+ scale + "," + scale
+
+ for i in range( main.numCtrls ):
+ mnCmd += " --controller remote,ip=" + main.ONOSip[ i ]
+
stepResult = main.Mininet1.startNet(mnCmd=mnCmd)
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
@@ -276,36 +268,23 @@
onfail=main.topoName +
" topology failed to start" )
+ time.sleep( main.startMNSleep )
- def CASE11( self, main ):
- '''
- Pingall
- '''
- main.case( "Pingall" )
- main.step( "Pingall" )
- pingResult = main.Mininet1.pingall()
- if not pingResult:
- main.log.warn( "First pingall failed. Retrying..." )
- time.sleep(3)
- pingResult = main.Mininet1.pingall( timeout=main.pingallTimeout )
+ main.step( "Pinging all hosts" )
+
+ for i in range(main.pingallAttempts):
+ pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
+ if not pingResult:
+ main.log.warn( "Pingall attempt: %s failed" % (i+1) )
+ time.sleep(main.pingallSleep)
+ else: break
utilities.assert_equals( expect=main.TRUE,
actual=pingResult,
onpass="Pingall successfull",
onfail="Pingall failed" )
-
- def CASE12( self, main ):
- """
- Compare Topo
- """
- import json
-
- main.case( "Compare ONOS Topology view to Mininet topology" )
- main.caseExplanation = "Compare topology elements between Mininet" +\
- " and ONOS"
-
- main.step( "Gathering topology information" )
+ main.log.info( "Gathering topology information" )
devicesResults = main.TRUE
linksResults = main.TRUE
hostsResults = main.TRUE
@@ -367,19 +346,112 @@
onfail="ONOS" + controllerStr +
" hosts don't match Mininet" )
+ def CASE11( self, main ):
+ """
+ Pingall, and compare topo
+ """
+ import json
+
+ scale = main.topoScale[0]
+
+ main.case( "Verifying topology: TORUS %sx%s" % (scale, scale) )
+ main.caseExplanation = "Pinging all hosts andcomparing topology " +\
+ "elements between Mininet and ONOS"
+ main.step( "Pinging all hosts" )
+
+ for i in range(main.pingallAttempts):
+ pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
+ if not pingResult:
+ main.log.warn( "Pingall attempt: %s failed" % (i+1) )
+ time.sleep(main.pingallSleep)
+ else: break
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=pingResult,
+ onpass="Pingall successfull",
+ onfail="Pingall failed" )
+
+ main.log.info( "Gathering topology information" )
+ devicesResults = main.TRUE
+ linksResults = main.TRUE
+ hostsResults = main.TRUE
+
+ devices = main.topo.getAllDevices( main )
+ hosts = main.topo.getAllHosts( main )
+ ports = main.topo.getAllPorts( main )
+ links = main.topo.getAllLinks( main )
+ clusters = main.topo.getAllClusters( main )
+
+ mnSwitches = main.Mininet1.getSwitches()
+ mnLinks = main.Mininet1.getLinks()
+ mnHosts = main.Mininet1.getHosts()
+
+ main.step( "Comparing MN topology to ONOS topology" )
+
+ for controller in range(len(main.activeNodes)):
+ controllerStr = str( main.activeNodes[controller] + 1 )
+ if devices[ controller ] and ports[ controller ] and\
+ "Error" not in devices[ controller ] and\
+ "Error" not in ports[ controller ]:
+
+ currentDevicesResult = main.Mininet1.compareSwitches(
+ mnSwitches,
+ json.loads( devices[ controller ] ),
+ json.loads( ports[ controller ] ) )
+ else:
+ currentDevicesResult = main.FALSE
+ utilities.assert_equals( expect=main.TRUE,
+ actual=currentDevicesResult,
+ onpass="ONOS" + controllerStr +
+ " Switches view is correct",
+ onfail="ONOS" + controllerStr +
+ " Switches view is incorrect" )
+
+ if links[ controller ] and "Error" not in links[ controller ]:
+ currentLinksResult = main.Mininet1.compareLinks(
+ mnSwitches, mnLinks,
+ json.loads( links[ controller ] ) )
+ else:
+ currentLinksResult = main.FALSE
+ utilities.assert_equals( expect=main.TRUE,
+ actual=currentLinksResult,
+ onpass="ONOS" + controllerStr +
+ " links view is correct",
+ onfail="ONOS" + controllerStr +
+ " links view is incorrect" )
+
+ if hosts[ controller ] or "Error" not in hosts[ controller ]:
+ currentHostsResult = main.Mininet1.compareHosts(
+ mnHosts,
+ json.loads( hosts[ controller ] ) )
+ else:
+ currentHostsResult = main.FALSE
+ utilities.assert_equals( expect=main.TRUE,
+ actual=currentHostsResult,
+ onpass="ONOS" + controllerStr +
+ " hosts exist in Mininet",
+ onfail="ONOS" + controllerStr +
+ " hosts don't match Mininet" )
+
+
def CASE100( self, main ):
'''
- Balance master
+ Balance masters, ping and bring third ONOS node down
'''
- main.case("Balancing Masters")
- main.step("Balancing Masters")
- try:
+ scale = main.topoScale[0]
+
+ main.case("Balancing Masters and bring ONOS node 3 down: TORUS %sx%s" % (scale, scale))
+ main.caseExplanation = "Balance masters to make sure " +\
+ "each controller has some devices and " +\
+ "stop ONOS node 3 service. "
+
+ main.step( "Balancing Masters" )
+ stepResult = main.FALSE
+ if main.activeNodes:
controller = main.activeNodes[0]
stepResult = main.CLIs[controller].balanceMasters()
- except Exception:
- main.log.exception("Exception: balancing masters")
- main.cleanup()
- main.exit()
+ else: main.log.error( "List of active nodes is empty" )
+
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
onpass="Balance masters was successfull",
@@ -387,32 +459,33 @@
time.sleep(main.balanceSleep)
+ main.step( "Pinging all hosts" )
- def CASE200( self, main ):
- '''
- Bring random node down
- '''
- import random
- main.case( "Randomly stopping an ONOS service" )
- main.step( "Bringing down an onos node" )
+ for i in range(main.pingallAttempts):
+ pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
+ if not pingResult:
+ main.log.warn( "Pingall attempt: %s failed" % (i+1) )
+ time.sleep(main.pingallSleep)
+ else: break
- random.seed()
- # Get the random index of the node
- main.deadNode = random.randrange(0,main.numCtrls)
+ utilities.assert_equals( expect=main.TRUE,
+ actual=pingResult,
+ onpass="Pingall successfull",
+ onfail="Pingall failed" )
+ main.step( "Bringing down node 3" )
+
+ # Always bring down the third node
+ main.deadNode = 2
+
+ # Printing purposes
node = main.deadNode + 1
- main.log.info( "deadnode: %s" % node )
-
main.log.info( "Stopping node %s" % node )
- startResult = main.ONOSbench.onosStop( main.ONOSip[ main.deadNode ] )
+ stepResult = main.ONOSbench.onosStop( main.ONOSip[ main.deadNode ] )
- try:
- main.activeNodes.pop( main.deadNode )
- except Exception:
- main.log.exception( "Exception: popping from list of active nodes" )
- main.cleanup()
- main.exit()
+ main.log.info( "Removing dead node from list of active nodes" )
+ main.activeNodes.pop( main.deadNode )
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
@@ -422,25 +495,27 @@
time.sleep(main.nodeDownSleep)
- def CASE300( self, main ):
+ def CASE200( self, main ):
'''
- Bring up onos node
+ Bring up onos node and balance masters
'''
- main.case( "Bring the dead ONOS node back up" )
- main.step( "Bringing up an onos node" )
+
+ scale = main.topoScale[0]
+
+ main.case("Bring ONOS node 3 up and balance masters: TORUS %sx%s" % (scale, scale))
+ main.caseExplanation = "Bring node 3 back up and balance the masters"
node = main.deadNode + 1
main.log.info( "Starting node %s" % node )
- startResult = main.ONOSbench.onosStart( main.ONOSip[ main.deadNode ] )
+ stepResult = main.ONOSbench.onosStart( main.ONOSip[ main.deadNode ] )
main.log.info( "Starting onos cli" )
- startCliResult = main.CLIs[ main.deadNode ].startOnosCli( main.ONOSip[ main.deadNode ] )
+ stepResult = stepResult and main.CLIs[ main.deadNode ].startOnosCli( main.ONOSip[ main.deadNode ] )
+ main.log.info( "Adding previously dead node to list of active nodes" )
main.activeNodes.append( main.deadNode )
- stepResult = startResult and startCliResult
-
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
onpass="Successfully brought up onos node %s" % node,
@@ -449,16 +524,38 @@
time.sleep(main.nodeUpSleep)
+ main.step( "Balancing Masters" )
+ stepResult = main.FALSE
+ if main.activeNodes:
+ controller = main.activeNodes[0]
+ stepResult = main.CLIs[controller].balanceMasters()
+ else: main.log.error( "List of active nodes is empty" )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Balance masters was successfull",
+ onfail="Failed to balance masters")
+
+ time.sleep(main.balanceSleep)
+
+ for i in range(main.pingallAttempts):
+ pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
+ if not pingResult:
+ main.log.warn( "Pingall attempt: %s failed" % (i+1) )
+ time.sleep(main.pingallSleep)
+ else: break
+
def CASE1000( self, main ):
'''
Report errors/warnings/exceptions
'''
+ main.case( "Checking logs for errors, warnings, and exceptions" )
main.log.info("Error report: \n" )
main.ONOSbench.logReport( main.ONOSip[ 0 ],
- [ "INFO",
- "FOLLOWER",
- "WARN",
- "flow",
- "ERROR",
- "Except" ],
- "s" )
+ [ "INFO",
+ "FOLLOWER",
+ "WARN",
+ "flow",
+ "ERROR",
+ "Except" ],
+ "s" )