Merge "add test case 10, 11 for I2, add check flow status to test cases"
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index cf2f54a..2eca3da 100644
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -1990,31 +1990,44 @@
main.cleanup()
main.exit()
- def checkFlowsState( self ):
+ def checkFlowsState( self, isPENDING_ADD = True ):
"""
Description:
Check the if all the current flows are in ADDED state or
PENDING_ADD state
+ Optional:
+ * isPENDING_ADD: whether the PENDING_ADD is also a correct status
Return:
returnValue - Returns main.TRUE only if all flows are in
- ADDED state or PENDING_ADD, return main.FALSE
- otherwise.
+ ADDED state or PENDING_ADD if the PENDING_ADD
+ parameter is set true, return main.FALSE otherwise.
"""
try:
tempFlows = json.loads( self.flows() )
#print tempFlows[0]
returnValue = main.TRUE
- for device in tempFlows:
- for flow in device.get( 'flows' ):
- if flow.get( 'state' ) != 'ADDED' and flow.get( 'state' ) != \
- 'PENDING_ADD':
+ if isPENDING_ADD:
+ for device in tempFlows:
+ for flow in device.get( 'flows' ):
+ if flow.get( 'state' ) != 'ADDED' and \
+ flow.get( 'state' ) != 'PENDING_ADD':
- main.log.info( self.name + ": flow Id: " +
- str( flow.get( 'groupId' ) ) +
- " | state:" +
- str( flow.get( 'state' ) ) )
- returnValue = main.FALSE
+ main.log.info( self.name + ": flow Id: " +
+ str( flow.get( 'groupId' ) ) +
+ " | state:" +
+ str( flow.get( 'state' ) ) )
+ returnValue = main.FALSE
+ else:
+ for device in tempFlows:
+ for flow in device.get( 'flows' ):
+ if flow.get( 'state' ) != 'ADDED':
+
+ main.log.info( self.name + ": flow Id: " +
+ str( flow.get( 'groupId' ) ) +
+ " | state:" +
+ str( flow.get( 'state' ) ) )
+ returnValue = main.FALSE
return returnValue
except TypeError:
diff --git a/TestON/tests/USECASE_SdnipI2/Dependency/Functions.py b/TestON/tests/USECASE_SdnipI2/Dependency/Functions.py
index 732ff41..0b860a1 100644
--- a/TestON/tests/USECASE_SdnipI2/Dependency/Functions.py
+++ b/TestON/tests/USECASE_SdnipI2/Dependency/Functions.py
@@ -39,3 +39,16 @@
expect = intentNumExpected, actual = intentNumActual,
onpass = "***P2P intent number is correct!***",
onfail = "***P2P intent number is wrong!***" )
+
+def checkFlowNum( main, switch, flowNumExpected ):
+ main.step( "Check flow entry number in " + switch )
+ main.log.info( "Flow number expected:" )
+ main.log.info( flowNumExpected )
+ main.log.info( "Flow number actual:" )
+ flowNumActual = main.Mininet.getSwitchFlowCount( switch )
+ main.log.info( flowNumActual )
+ utilities.assertEquals( \
+ expect = flowNumExpected, actual = flowNumActual,
+ onpass = "***Flow number in " + switch + " is correct!***",
+ onfail = "***Flow number in " + switch + " is wrong!***" )
+
diff --git a/TestON/tests/USECASE_SdnipI2/USECASE_SdnipI2.params b/TestON/tests/USECASE_SdnipI2/USECASE_SdnipI2.params
index fd65488..0396a2b 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, 7, 8, 1, 4</testcases>
+ <testcases>100, 101, 102, 7, 8, 9, 10, 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 c1ff688..45ea369 100644
--- a/TestON/tests/USECASE_SdnipI2/USECASE_SdnipI2.py
+++ b/TestON/tests/USECASE_SdnipI2/USECASE_SdnipI2.py
@@ -232,12 +232,20 @@
onfail = "***MultiPointToSinglePoint Intent Num in SDN-IP is \
wrong!***" )
+ main.step( "Check whether all flow status are ADDED" )
+ utilities.assertEquals( \
+ expect = main.TRUE,
+ actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ),
+ onpass = "***Flow status is correct!***",
+ onfail = "***Flow status is wrong!***" )
+
def CASE4( self, main ):
'''
Ping test in data plane for each route
'''
main.case( "This case is to check ping for each route" )
+ main.step( "Start ping tests between hosts behind BGP peers" )
result1 = main.Mininet.pingHost( src = "host64514", target = "host64515" )
result2 = main.Mininet.pingHost( src = "host64515", target = "host64516" )
result3 = main.Mininet.pingHost( src = "host64514", target = "host64516" )
@@ -291,6 +299,13 @@
main.log.info( "Bring down link failed!!!" )
main.exit();
+ main.step( "Check whether all flow status are ADDED" )
+ utilities.assertEquals( \
+ expect = main.TRUE,
+ actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ),
+ onpass = "***Flow status is correct!***",
+ onfail = "***Flow status is wrong!***" )
+
def CASE6(self, main):
'''
@@ -330,6 +345,13 @@
else:
main.log.info( "Bring up link failed!!!" )
main.exit();
+
+ main.step( "Check whether all flow status are ADDED" )
+ utilities.assertEquals( \
+ expect = main.TRUE,
+ actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ),
+ onpass = "***Flow status is correct!***",
+ onfail = "***Flow status is wrong!***" )
'''
Note: at the end of this test case, we should carry out ping test.
So we run CASE4 again after CASE6
@@ -354,6 +376,13 @@
main.log.info( "Stop switch failed!!!" )
main.exit();
+ main.step( "Check whether all flow status are ADDED" )
+ utilities.assertEquals( \
+ expect = main.TRUE,
+ actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ),
+ onpass = "***Flow status is correct!***",
+ onfail = "***Flow status is wrong!***" )
+
'''
main.step( "Stop sw8" )
result = main.Mininet.switch( SW = "sw8", OPTION = "stop" )
@@ -407,12 +436,99 @@
main.cleanup()
main.exit();
+ main.step( "Check whether all flow status are ADDED" )
+ utilities.assertEquals( \
+ expect = main.TRUE,
+ actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ),
+ onpass = "***Flow status is correct!***",
+ onfail = "***Flow status is wrong!***" )
+
+
+ def CASE9(self, main):
+ '''
+ Bring down a switch in best path, check:
+ route number, P2P intent number, M2S intent number, ping test
+ '''
+ main.case( "This case is to stop switch in best path, \
+ check route number, P2P intent number, M2S intent number, ping test" )
+
+ main.step( "Check the flow status before stopping sw11" )
+ main.Functions.checkFlowNum( main, "sw11", 13 )
+ main.Functions.checkFlowNum( main, "sw1", 3 )
+ main.Functions.checkFlowNum( main, "sw7", 3 )
+ main.log.info( main.Mininet.checkFlows( "sw11" ) )
+ main.log.info( main.Mininet.checkFlows( "sw1" ) )
+ main.log.info( main.Mininet.checkFlows( "sw7" ) )
+
+ main.step( "Stop sw11" )
+ result = main.Mininet.switch( SW = "sw11", OPTION = "stop" )
+ if result:
+ time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
+ main.Functions.checkRouteNum( main, 3 )
+ main.Functions.checkM2SintentNum( main, 3 )
+ main.Functions.checkP2PintentNum( main, 18 )
+
+ else:
+ main.log.info( "Stop switch failed!!!" )
+ main.cleanup()
+ main.exit();
+
+ main.step( "Check whether all flow status are ADDED" )
+ utilities.assertEquals( \
+ expect = main.TRUE,
+ actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ),
+ onpass = "***Flow status is correct!***",
+ onfail = "***Flow status is wrong!***" )
+ '''
+ Note: this test case should be followed by ping test, CASE1 and CASE4
+ '''
+
+
+ def CASE10( self, main ):
+ '''
+ Bring up the switch which was stopped in CASE9, check:
+ route number, P2P intent number, M2S intent number, ping test
+ '''
+ main.case( "This case is to start switch which was stopped in CASE9, \
+ check route number, P2P intent number, M2S intent number, ping test" )
+ main.step( "Start sw11" )
+ result = main.Mininet.switch( SW = "sw11", OPTION = "start" )
+ if result:
+ time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
+ main.Functions.checkRouteNum( main, 3 )
+ main.Functions.checkM2SintentNum( main, 3 )
+ main.Functions.checkP2PintentNum( main, 18 )
+
+ main.step( "Check the flow status after stop and start sw11" )
+ main.Functions.checkFlowNum( main, "sw11", 3 )
+ main.Functions.checkFlowNum( main, "sw1", 11 )
+ main.Functions.checkFlowNum( main, "sw7", 5 )
+ main.log.info( main.Mininet.checkFlows( "sw11" ) )
+ main.log.info( main.Mininet.checkFlows( "sw1" ) )
+ main.log.info( main.Mininet.checkFlows( "sw7" ) )
+ else:
+ main.log.info( "Start switch failed!!!" )
+ main.cleanup()
+ main.exit();
+
+ main.step( "Check whether all flow status are ADDED" )
+ utilities.assertEquals( \
+ expect = main.TRUE,
+ actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ),
+ onpass = "***Flow status is correct!***",
+ onfail = "***Flow status is wrong!***" )
+ '''
+ Note: this test case should be followed by ping test, CASE1 and CASE4
+ '''
+
def CASE20( self, main ):
'''
ping test from 3 bgp peers to BGP speaker
'''
- main.case( "This case is to check ping between BGP peers and speakers" )
+ main.case( "This case is to check ping between BGP peers and speakers, \
+ and expect all ping tests to fail." )
+ main.step( "Start ping tests between BGP speaker and BGP peers" )
result1 = main.Mininet.pingHost( src = "speaker1", target = "peer64514" )
result2 = main.Mininet.pingHost( src = "speaker1", target = "peer64515" )
result3 = main.Mininet.pingHost( src = "speaker1", target = "peer64516" )
@@ -432,7 +548,9 @@
'''
Ping test in data plane for each route
'''
- main.case( "This case is to check ping for each route" )
+ main.case( "This case is to check ping for each route, and expect \
+ all ping tests to fail." )
+ main.step( "Start ping tests between hosts behind BGP peers" )
result1 = main.Mininet.pingHost( src = "host64514", target = "host64515" )
result2 = main.Mininet.pingHost( src = "host64515", target = "host64516" )
result3 = main.Mininet.pingHost( src = "host64514", target = "host64516" )