Stable SR app again

Change-Id: I48998957095c9c6522805fb857b9368747f45219
diff --git a/TestON/tests/USECASE/USECASE_SegmentRouting/2x2.json b/TestON/tests/USECASE/USECASE_SegmentRouting/2x2.json
index 31b2cc8..a5ec00d 100644
--- a/TestON/tests/USECASE/USECASE_SegmentRouting/2x2.json
+++ b/TestON/tests/USECASE/USECASE_SegmentRouting/2x2.json
@@ -36,7 +36,7 @@
                 "name" : "Leaf-R1",
                 "nodeSid" : 1,
                 "routerIp" : "192.168.0.1",
-                "routerMac" : "00:00:00:00:00:01",
+                "routerMac" : "10:00:00:00:00:01",
                 "isEdgeRouter" : true,
                 "adjacencySids" : []
             }
@@ -47,7 +47,7 @@
                 "name" : "Leaf-R2",
                 "nodeSid" : 2,
                 "routerIp" : "192.168.0.2",
-                "routerMac" : "00:00:00:00:00:02",
+                "routerMac" : "10:00:00:00:00:02",
                 "isEdgeRouter" : true,
                 "adjacencySids" : []
             }
@@ -58,7 +58,7 @@
                 "name" : "Spine-R1",
                 "nodeSid" : 101,
                 "routerIp" : "192.168.0.101",
-                "routerMac" : "00:00:00:00:01:01",
+                "routerMac" : "10:00:00:00:01:01",
                 "isEdgeRouter" : false,
                 "adjacencySids" : []
             }
@@ -69,7 +69,7 @@
                 "name" : "Spine-R2",
                 "nodeSid" : 102,
                 "routerIp" : "192.168.0.102",
-                "routerMac" : "00:00:00:00:01:02",
+                "routerMac" : "10:00:00:00:01:02",
                 "isEdgeRouter" : false,
                 "adjacencySids" : []
             }
diff --git a/TestON/tests/USECASE/USECASE_SegmentRouting/4x4.json b/TestON/tests/USECASE/USECASE_SegmentRouting/4x4.json
index dee6bc3..7442359 100644
--- a/TestON/tests/USECASE/USECASE_SegmentRouting/4x4.json
+++ b/TestON/tests/USECASE/USECASE_SegmentRouting/4x4.json
@@ -64,7 +64,7 @@
                 "name" : "Leaf-R1",
                 "nodeSid" : 1,
                 "routerIp" : "192.168.0.1",
-                "routerMac" : "00:00:00:00:00:01",
+                "routerMac" : "10:00:00:00:00:01",
                 "isEdgeRouter" : true,
                 "adjacencySids" : []
             }
@@ -75,7 +75,7 @@
                 "name" : "Leaf-R2",
                 "nodeSid" : 2,
                 "routerIp" : "192.168.0.2",
-                "routerMac" : "00:00:00:00:00:02",
+                "routerMac" : "10:00:00:00:00:02",
                 "isEdgeRouter" : true,
                 "adjacencySids" : []
             }
@@ -86,7 +86,7 @@
                 "name" : "Leaf-R3",
                 "nodeSid" : 3,
                 "routerIp" : "192.168.0.3",
-                "routerMac" : "00:00:00:00:00:03",
+                "routerMac" : "10:00:00:00:00:03",
                 "isEdgeRouter" : true,
                 "adjacencySids" : []
             }
@@ -97,7 +97,7 @@
                 "name" : "Leaf-R4",
                 "nodeSid" : 4,
                 "routerIp" : "192.168.0.4",
-                "routerMac" : "00:00:00:00:00:04",
+                "routerMac" : "10:00:00:00:00:04",
                 "isEdgeRouter" : true,
                 "adjacencySids" : []
             }
@@ -108,7 +108,7 @@
                 "name" : "Spine-R1",
                 "nodeSid" : 101,
                 "routerIp" : "192.168.0.101",
-                "routerMac" : "00:00:00:00:01:01",
+                "routerMac" : "10:00:00:00:01:01",
                 "isEdgeRouter" : false,
                 "adjacencySids" : []
             }
@@ -119,7 +119,7 @@
                 "name" : "Spine-R2",
                 "nodeSid" : 102,
                 "routerIp" : "192.168.0.102",
-                "routerMac" : "00:00:00:00:01:02",
+                "routerMac" : "10:00:00:00:01:02",
                 "isEdgeRouter" : false,
                 "adjacencySids" : []
             }
@@ -130,7 +130,7 @@
                 "name" : "Spine-R3",
                 "nodeSid" : 103,
                 "routerIp" : "192.168.0.103",
-                "routerMac" : "00:00:00:00:01:03",
+                "routerMac" : "10:00:00:00:01:03",
                 "isEdgeRouter" : false,
                 "adjacencySids" : []
             }
@@ -141,7 +141,7 @@
                 "name" : "Spine-R4",
                 "nodeSid" : 104,
                 "routerIp" : "192.168.0.104",
-                "routerMac" : "00:00:00:00:01:04",
+                "routerMac" : "10:00:00:00:01:04",
                 "isEdgeRouter" : false,
                 "adjacencySids" : []
             }
diff --git a/TestON/tests/USECASE/USECASE_SegmentRouting/USECASE_SegmentRouting.params b/TestON/tests/USECASE/USECASE_SegmentRouting/USECASE_SegmentRouting.params
index 1ef9eea..15ce439 100755
--- a/TestON/tests/USECASE/USECASE_SegmentRouting/USECASE_SegmentRouting.params
+++ b/TestON/tests/USECASE/USECASE_SegmentRouting/USECASE_SegmentRouting.params
@@ -1,6 +1,6 @@
 <PARAMS>
 
-    <testcases>1,[2,3,4,10]*4</testcases>
+    <testcases>1,[2,3,4,4,10]*2</testcases>
 
     <SCALE>
         <size>1</size>
diff --git a/TestON/tests/USECASE/USECASE_SegmentRouting/USECASE_SegmentRouting.py b/TestON/tests/USECASE/USECASE_SegmentRouting/USECASE_SegmentRouting.py
index 9d96a43..f44966b 100755
--- a/TestON/tests/USECASE/USECASE_SegmentRouting/USECASE_SegmentRouting.py
+++ b/TestON/tests/USECASE/USECASE_SegmentRouting/USECASE_SegmentRouting.py
@@ -36,10 +36,10 @@
         main.path = os.path.dirname( main.testFile )
         main.dependencyPath = main.path + "/dependencies/"
         main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ]
-        #main.json = ["4x4"]
+        #main.json = ["0x1","0x1"]
         main.json = ["2x2", "2x2","4x4","4x4"]
         main.args = [" ", " ", " --spine 4 --leaf 4 ", " --spine 4 --leaf 4 "]
-        #main.args = [" --spine 4 --leaf 4 "]
+        #main.args = [" --spine 0 --leaf 1 "," --spine 0 --leaf 1 "]
         main.scale = ( main.params[ 'SCALE' ][ 'size' ] ).split( "," )
         main.maxNodes = int( main.params[ 'SCALE' ][ 'max' ] )
         main.ONOSport = main.params[ 'CTRL' ][ 'port' ]
@@ -114,18 +114,12 @@
         else: main.log.error( "App list is empty" )
         main.case( "Package and start ONOS using apps:" + apps)
 
-        #kill off all onos processes
-        main.log.info( "Safety check, killing all ONOS processes" +
-                       " before initiating environment setup" )
-
-        for i in range( main.maxNodes ):
-            main.ONOSbench.onosDie( main.ONOSip[ i ] )
-
         print "NODE COUNT = ", main.numCtrls
 
         tempOnosIp = []
         for i in range( main.numCtrls ):
             tempOnosIp.append( main.ONOSip[i] )
+
         onosUser = main.params[ 'ENV' ][ 'cellUser' ]
         main.step("Create and Apply cell file")
         main.ONOSbench.createCellFile( main.ONOSbench.ip_address,
@@ -143,6 +137,12 @@
                                  onpass="Successfully applied cell to " + \
                                         "environment",
                                  onfail="Failed to apply cell to environment " )
+        #kill off all onos processes
+        main.log.info( "Safety check, killing all ONOS processes" +
+                       " before initiating environment setup" )
+
+        for i in range( main.maxNodes ):
+            main.ONOSbench.onosDie( main.ONOSip[ i ] )
 
         main.step( "Create and Install ONOS package" )
         main.jsonFile=main.json.pop(0)
@@ -193,8 +193,10 @@
         #time.sleep( 2*main.startUpSleep )
         #main.ONOSbench.handle.sendline( "onos-secure-ssh")
         main.step( "Checking if ONOS CLI is ready" )
+        cellResult = main.CLIs[0].setCell( "temp" )
+
         cliResult = main.CLIs[0].startOnosCli( main.ONOSip[ 0 ],
-                                           commandlineTimeout=100, onosStartTimeout=600 )
+                                           commandlineTimeout=60, onosStartTimeout=100 )
         utilities.assert_equals( expect=main.TRUE,
                              actual=cliResult,
                              onpass="ONOS CLI is ready",
@@ -216,27 +218,6 @@
             main.cleanup()
             main.exit()
 
-    def CASE10( self, main ):
-        '''
-            Report errors/warnings/exceptions
-        '''
-        main.case( "Logging test for " + main.jsonFile )
-        #if len(main.json) > 0 :
-        main.ONOSbench.cpLogsToDir("/opt/onos/log/karaf.log",main.logdir, 
-                           copyFileName="karaf.log."+main.jsonFile+str(len(main.json)))
-        #main.ONOSbench.logReport( main.ONOSip[ 0 ],
-        #                          [ "INFO" ],
-        #                          "a" )
-        #main.log.info("Error report: \n" )
-        main.ONOSbench.logReport( main.ONOSip[ 0 ],
-                                  [ "INFO",
-                                    "FOLLOWER",
-                                    "WARN",
-                                    "flow",
-                                    "ERROR",
-                                    "Except" ],
-                                  "s" )
-
     def CASE3( self, main ):
         """
             Start mininet
@@ -267,7 +248,7 @@
         main.step(" Check whether the flow count is bigger than 80" )
         count =  utilities.retry( main.CLIs[0].checkFlowCount,
                                  main.FALSE,
-                                 kwargs={'min':80},
+                                 kwargs={'min':10},
                                  attempts=10 )
         utilities.assertEquals( \
             expect=True,
@@ -290,37 +271,45 @@
         main.ONOSbench.dumpGroups( main.ONOSip[0],
                                    main.logdir, "groupsBefore" + main.jsonFile)
         #time.sleep( 3*main.startUpSleep)
+        main.count=1
 
     def CASE4( self, main ):
         main.case( "Check full connectivity" )
         main.log.report( "Check full connectivity" )
 
-        main.step("1st Check full connectivity")
+        main.step("Check full connectivity"+str(main.count))
         pa = main.Mininet1.pingall()
         utilities.assert_equals( expect=main.TRUE, actual=pa,
                                  onpass="Full connectivity successfully tested",
                                  onfail="Full connectivity failed" )
         # cleanup mininet
         main.ONOSbench.dumpFlows( main.ONOSip[0],
-                 main.logdir, "flowsAfter" + main.jsonFile)
+                 main.logdir, "flowsAfter" + str(main.count) + main.jsonFile)
         main.ONOSbench.dumpGroups( main.ONOSip[0],
-                           main.logdir, "groupsAfter" + main.jsonFile)
-        main.step("2nd Check full connectivity")
-        pa = main.Mininet1.pingall()
-        utilities.assert_equals( expect=main.TRUE, actual=pa,
-                                 onpass="Full connectivity successfully tested",
-                                 onfail="Full connectivity failed" )
+                           main.logdir, "groupsAfter" + str(main.count) + main.jsonFile)
 
-        main.ONOSbench.dumpFlows( main.ONOSip[0],
-                 main.logdir, "flowsAfter2nd" + main.jsonFile)
-
-        main.ONOSbench.dumpGroups( main.ONOSip[0],
-                                  main.logdir, "groupsAfter2nd" + main.jsonFile)
-
+    def CASE10( self, main ):
+        '''
+            Report errors/warnings/exceptions
+        '''
+        main.case( "Logging test for " + main.jsonFile )
+        #if len(main.json) > 0 :
         main.ONOSbench.onosStop( main.ONOSip[0] )
         main.Mininet1.stopNet()
-
-
+        main.ONOSbench.cpLogsToDir("/opt/onos/log/karaf.log",main.logdir,
+                                   copyFileName="karaf.log."+main.jsonFile+str(len(main.json)))
+        #main.ONOSbench.logReport( main.ONOSip[ 0 ],
+        #                          [ "INFO" ],
+        #                          "a" )
+        #main.log.info("Error report: \n" )
+        main.ONOSbench.logReport( main.ONOSip[ 0 ],
+                                  [ "INFO",
+                                    "FOLLOWER",
+                                    "WARN",
+                                    "flow",
+                                    "ERROR",
+                                    "Except" ],
+                                  "s" )