add test case 5, 6 for Internet2 deployment

Change-Id: I6ab2c3c7ceb5e9ee90005bb93734b96815fbd26f
diff --git a/TestON/tests/USECASE_SdnipI2/Dependency/Functions.py b/TestON/tests/USECASE_SdnipI2/Dependency/Functions.py
new file mode 100644
index 0000000..16c8bf1
--- /dev/null
+++ b/TestON/tests/USECASE_SdnipI2/Dependency/Functions.py
@@ -0,0 +1,26 @@
+
+def checkRouteNum( main, routeNumExpected ):
+    main.step( "Check routes installed" )
+    main.log.info( "Route number expected:" )
+    main.log.info( routeNumExpected )
+    main.log.info( "Route number from ONOS CLI:" )
+
+    routeNumActual = main.ONOScli.ipv4RouteNumber()
+    main.log.info( routeNumActual )
+    utilities.assertEquals( \
+        expect = routeNumExpected, actual = routeNumActual,
+        onpass = "***Route number is correct!***",
+        onfail = "***Routes 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()
+    main.log.info( intentNumActual )
+    utilities.assertEquals( \
+        expect = intentNumExpected, actual = intentNumActual,
+        onpass = "***Intents number is correct!***",
+        onfail = "***Intents number is wrong!***" )
+
diff --git a/TestON/tests/USECASE_SdnipI2/USECASE_SdnipI2.params b/TestON/tests/USECASE_SdnipI2/USECASE_SdnipI2.params
index b13806a..15a4941 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, 1, 4</testcases>
+    <testcases>100, 101, 102, 5, 6</testcases>
 
     #Environment variables
     <ENV>
@@ -27,6 +27,7 @@
     <DEPENDENCY>
         <path>/USECASE_SdnipI2/Dependency/</path>
         <topology>USECASE_SdnipI2MN.py</topology>
+        <wrapper1>Functions</wrapper1>
     </DEPENDENCY>
 
     <config>
diff --git a/TestON/tests/USECASE_SdnipI2/USECASE_SdnipI2.py b/TestON/tests/USECASE_SdnipI2/USECASE_SdnipI2.py
index d7b8802..b5b520b 100644
--- a/TestON/tests/USECASE_SdnipI2/USECASE_SdnipI2.py
+++ b/TestON/tests/USECASE_SdnipI2/USECASE_SdnipI2.py
@@ -11,6 +11,7 @@
             Start mininet
         """
         import os
+        import imp
         main.log.case( "Start Mininet topology" )
         main.dependencyPath = main.testDir + \
                               main.params[ 'DEPENDENCY' ][ 'path' ]
@@ -123,6 +124,19 @@
         time.sleep( int( main.params[ 'timers' ][ 'PathAvailable' ] ) )
 
 
+    def CASE102( self, main ):
+        '''
+        This test case is to load the methods from other Python files.
+        '''
+        main.case( "Loading the methods from other Python file" )
+        # load the methods from other file
+        wrapperFile = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
+        main.Functions = imp.load_source( wrapperFile,
+                                          main.dependencyPath +
+                                          wrapperFile +
+                                          ".py" )
+
+
     def CASE1( self, main ):
         '''
         ping test from 3 bgp peers to BGP speaker
@@ -235,3 +249,84 @@
         if caseResult == main.FALSE:
             main.cleanup()
             main.exit()
+
+
+    def CASE5( self, main ):
+        '''
+        Cut links to peers one by one, check routes/intents
+        '''
+        import time
+        main.case( "This case is to bring down links and check routes/intents" )
+        main.step( "Bring down the link between sw32 and peer64514" )
+        result = main.Mininet.link( END1 = "sw32", END2 = "peer64514",
+                                    OPTION = "down" )
+        if result == main.TRUE:
+            time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
+            main.Functions.checkRouteNum( main, 2 )
+            main.Functions.checkM2SintentNum( main, 2 )
+        else:
+            main.log.info( "Bring down link failed!!!" )
+            main.exit();
+
+        main.step( "Bring down the link between sw8 and peer64515" )
+        result = main.Mininet.link( END1 = "sw8", END2 = "peer64515",
+                                    OPTION = "down" )
+        if result == main.TRUE:
+            time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
+            main.Functions.checkRouteNum( main, 1 )
+            main.Functions.checkM2SintentNum( main, 1 )
+        else:
+            main.log.info( "Bring down link failed!!!" )
+            main.exit();
+
+        main.step( "Bring down the link between sw28 and peer64516" )
+        result = main.Mininet.link( END1 = "sw28", END2 = "peer64516",
+                                    OPTION = "down" )
+        if result == main.TRUE:
+            time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
+            main.Functions.checkRouteNum( main, 0 )
+            main.Functions.checkM2SintentNum( main, 0 )
+        else:
+            main.log.info( "Bring down link failed!!!" )
+            main.exit();
+
+
+    def CASE6(self, main):
+        '''
+        Recover links to peers one by one, check routes/intents
+        '''
+        import time
+        main.case( "This case is to bring up links and check routes/intents" )
+        main.step( "Bring up the link between sw32 and peer64514" )
+        result = main.Mininet.link( END1 = "sw32", END2 = "peer64514",
+                                    OPTION = "up" )
+        if result == main.TRUE:
+            time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
+            main.Functions.checkRouteNum( main, 1 )
+            main.Functions.checkM2SintentNum( main, 1 )
+        else:
+            main.log.info( "Bring up link failed!!!" )
+            main.exit();
+
+        main.step( "Bring up the link between sw8 and peer64515" )
+        result = main.Mininet.link( END1 = "sw8", END2 = "peer64515",
+                                    OPTION = "up" )
+        if result == main.TRUE:
+            time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
+            main.Functions.checkRouteNum( main, 2 )
+            main.Functions.checkM2SintentNum( main, 2 )
+        else:
+            main.log.info( "Bring up link failed!!!" )
+            main.exit();
+
+        main.step( "Bring up the link between sw28 and peer64516" )
+        result = main.Mininet.link( END1 = "sw28", END2 = "peer64516",
+                                    OPTION = "up" )
+        if result == main.TRUE:
+            time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
+            main.Functions.checkRouteNum( main, 3 )
+            main.Functions.checkM2SintentNum( main, 3 )
+        else:
+            main.log.info( "Bring up link failed!!!" )
+            main.exit();
+