Merge "add case 7 for I2, add new drivers"
diff --git a/TestON/drivers/common/cli/emulator/mininetclidriver.py b/TestON/drivers/common/cli/emulator/mininetclidriver.py
index 1d75ae4..1e22267 100644
--- a/TestON/drivers/common/cli/emulator/mininetclidriver.py
+++ b/TestON/drivers/common/cli/emulator/mininetclidriver.py
@@ -1235,6 +1235,29 @@
main.exit()
return main.TRUE
+ def switch( self, **switchargs ):
+ """
+ start/stop a switch
+ """
+ args = utilities.parse_args( [ "SW", "OPTION" ], **switchargs )
+ sw = args[ "SW" ] if args[ "SW" ] is not None else ""
+ option = args[ "OPTION" ] if args[ "OPTION" ] is not None else ""
+ command = "switch " + str( sw ) + " " + str( option )
+ main.log.info( command )
+ try:
+ self.handle.sendline( command )
+ self.handle.expect( "mininet>" )
+ except pexpect.TIMEOUT:
+ main.log.error( self.name + ": pexpect.TIMEOUT found" )
+ 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()
+ return main.TRUE
+
def yank( self, **yankargs ):
"""
yank a mininet switch interface to a host"""
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index a361aca..32aef33 100644
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -1787,43 +1787,35 @@
main.cleanup()
main.exit()
- def intents( self, jsonFormat=True ):
+ def intents( self, jsonFormat = True, summary = False, **intentargs):
"""
Optional:
* jsonFormat: enable output formatting in json
+ * summary: whether only output the intent summary
+ * type: only output a certain type of intent
+ This options is valid only when jsonFormat is true and summary is
+ true
Description:
- Obtain intents currently installed
+ Obtain intents
"""
try:
cmdStr = "intents"
+ if summary:
+ cmdStr += " -s"
if jsonFormat:
cmdStr += " -j"
handle = self.sendline( cmdStr )
- return handle
- 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 m2SIntentInstalledNumber( self ):
- """
- Description:
- Obtain the number of multiple point to single point intents
- installed
- """
- try:
- cmdStr = "intents -s -j"
- handle = self.sendline( cmdStr )
- jsonResult = json.loads( handle )
- return jsonResult['multiPointToSinglePoint']['installed']
+ args = utilities.parse_args( [ "TYPE" ], **intentargs )
+ type = args[ "TYPE" ] if args[ "TYPE" ] is not None else ""
+ if jsonFormat and summary and ( type != "" ):
+ jsonResult = json.loads( handle )
+ if type in jsonResult.keys():
+ return jsonResult[ type ]
+ else:
+ main.log.error( "unknown TYPE, return all types of intents" )
+ return handle
+ else:
+ return handle
except TypeError:
main.log.exception( self.name + ": Object not as expected" )
@@ -1838,6 +1830,7 @@
main.cleanup()
main.exit()
+
def getIntentState(self, intentsId, intentsJson=None):
"""
Check intent state.
diff --git a/TestON/tests/USECASE_SdnipI2/Dependency/Functions.py b/TestON/tests/USECASE_SdnipI2/Dependency/Functions.py
index 16c8bf1..732ff41 100644
--- a/TestON/tests/USECASE_SdnipI2/Dependency/Functions.py
+++ b/TestON/tests/USECASE_SdnipI2/Dependency/Functions.py
@@ -10,17 +10,32 @@
utilities.assertEquals( \
expect = routeNumExpected, actual = routeNumActual,
onpass = "***Route number is correct!***",
- onfail = "***Routes number is wrong!***" )
+ onfail = "***Route number is wrong!***" )
def checkM2SintentNum( main, intentNumExpected ):
main.step( "Check M2S intents installed" )
main.log.info( "Intent number expected:" )
main.log.info( intentNumExpected )
main.log.info( "Intent number from ONOS CLI:" )
- intentNumActual = main.ONOScli.m2SIntentInstalledNumber()
+ jsonResult = main.ONOScli.intents( jsonFormat = True, summary = True,
+ TYPE = "multiPointToSinglePoint" )
+ intentNumActual = jsonResult['installed']
main.log.info( intentNumActual )
utilities.assertEquals( \
expect = intentNumExpected, actual = intentNumActual,
- onpass = "***Intents number is correct!***",
- onfail = "***Intents number is wrong!***" )
+ onpass = "***M2S intent number is correct!***",
+ onfail = "***M2S intent number is wrong!***" )
+def checkP2PintentNum( main, intentNumExpected ):
+ main.step( "Check P2P intents installed" )
+ main.log.info( "Intent number expected:" )
+ main.log.info( intentNumExpected )
+ main.log.info( "Intent number from ONOS CLI:" )
+ jsonResult = main.ONOScli.intents( jsonFormat = True, summary = True,
+ TYPE = "pointToPoint" )
+ intentNumActual = jsonResult['installed']
+ main.log.info( intentNumActual )
+ utilities.assertEquals( \
+ expect = intentNumExpected, actual = intentNumActual,
+ onpass = "***P2P intent number is correct!***",
+ onfail = "***P2P intent number is wrong!***" )
diff --git a/TestON/tests/USECASE_SdnipI2/USECASE_SdnipI2.params b/TestON/tests/USECASE_SdnipI2/USECASE_SdnipI2.params
index 15a4941..fd65488 100644
--- a/TestON/tests/USECASE_SdnipI2/USECASE_SdnipI2.params
+++ b/TestON/tests/USECASE_SdnipI2/USECASE_SdnipI2.params
@@ -1,6 +1,6 @@
<PARAMS>
- <testcases>100, 101, 102, 5, 6</testcases>
+ <testcases>100, 101, 102, 7, 8, 1, 4</testcases>
#Environment variables
<ENV>
diff --git a/TestON/tests/USECASE_SdnipI2/USECASE_SdnipI2.py b/TestON/tests/USECASE_SdnipI2/USECASE_SdnipI2.py
index 14d5cb8..6808576 100644
--- a/TestON/tests/USECASE_SdnipI2/USECASE_SdnipI2.py
+++ b/TestON/tests/USECASE_SdnipI2/USECASE_SdnipI2.py
@@ -329,6 +329,63 @@
else:
main.log.info( "Bring up link failed!!!" )
main.exit();
+ '''
+ Note: at the end of this test case, we should carry out ping test.
+ So we run CASE4 again after CASE6
+ '''
+
+
+ def CASE7(self, main):
+ '''
+ shut down a edge switch, check P-2-P and M-2-S intents, ping test
+ '''
+ import time
+ main.case( "This case is to stop 1 edge switch,\
+ check P-2-P and M-2-S intents, ping test")
+ main.step( "Stop sw32" )
+ result = main.Mininet.switch( SW = "sw32", OPTION = "stop" )
+ if result == main.TRUE:
+ time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
+ main.Functions.checkRouteNum( main, 2 )
+ main.Functions.checkM2SintentNum( main, 2 )
+ main.Functions.checkP2PintentNum( main, 12 )
+ else:
+ main.log.info( "Stop switch failed!!!" )
+ main.exit();
+
+ '''
+ main.step( "Stop sw8" )
+ result = main.Mininet.switch( SW = "sw8", OPTION = "stop" )
+ if result == main.TRUE:
+ time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
+ main.Functions.checkRouteNum( main, 1 )
+
+ # Note: there should be 0 M2S intent, not 1.
+ main.Functions.checkM2SintentNum( main, 0 )
+ main.Functions.checkP2PintentNum( main, 6 )
+ else:
+ main.log.info( "Stop switch failed!!!" )
+ main.exit();
+
+ main.step( "Stop sw28" )
+ result = main.Mininet.switch( SW = "sw28", OPTION = "stop" )
+ if result == main.TRUE:
+ time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
+ main.Functions.checkRouteNum( main, 0 )
+ main.Functions.checkM2SintentNum( main, 0 )
+ main.Functions.checkP2PintentNum( main, 0 )
+ else:
+ main.log.info( "Stop switch failed!!!" )
+ main.exit();
+ '''
+ '''
+ ping test between BGP speaker and BGP peers, ping test between hosts
+ behind BGP peers ===
+ '''
+
+ def CASE8( self, main ):
+ main.case( "This case is to bring up 1 edge switch,\
+ check P-2-P and M-2-S intents, ping test" )
def CASE20( self, main ):