Improving SR 2x2 test

Change-Id: I85b644c5b630d5e547042bbcade95839e3ee13d3
diff --git a/TestON/tests/USECASE_SegmentRouting/2x2.json b/TestON/tests/USECASE_SegmentRouting/2x2.json
index c6c2eb8..31b2cc8 100644
--- a/TestON/tests/USECASE_SegmentRouting/2x2.json
+++ b/TestON/tests/USECASE_SegmentRouting/2x2.json
@@ -76,25 +76,25 @@
         }
     },
     "hosts" : {
-        "00:00:00:00:00:01/4093" : {
+        "00:00:00:00:00:01/-1" : {
             "basic": {
                 "ips": ["10.0.1.1"],
                 "location": "of:0000000000000001/3"
             }
         },
-        "00:00:00:00:00:02/4093" : {
+        "00:00:00:00:00:02/-1" : {
             "basic": {
                 "ips": ["10.0.1.2"],
                 "location": "of:0000000000000001/4"
             }
         },
-        "00:00:00:00:00:03/4093" : {
+        "00:00:00:00:00:03/-1" : {
             "basic": {
                 "ips": ["10.0.2.1"],
                 "location": "of:0000000000000002/3"
             }
         },
-        "00:00:00:00:00:04/4093" : {
+        "00:00:00:00:00:04/-1" : {
             "basic": {
                 "ips": ["10.0.2.2"],
                 "location": "of:0000000000000002/4"
diff --git a/TestON/tests/USECASE_SegmentRouting/Dependency/cord_fabric.py b/TestON/tests/USECASE_SegmentRouting/Dependency/cord_fabric.py
index b710b12..a2a8a8e 100755
--- a/TestON/tests/USECASE_SegmentRouting/Dependency/cord_fabric.py
+++ b/TestON/tests/USECASE_SegmentRouting/Dependency/cord_fabric.py
@@ -39,7 +39,7 @@
         for s in range(spine):
             spines[s] = self.addSwitch('spine10%s' % (s + 1), dpid="00000000010%s" % (s + 1))
         # Set link speeds to 100Mb/s
-        linkopts = dict(bw=10)
+        linkopts = dict(bw=100)
 
         # Add Leaf switches
         for ls in range(leaf):
diff --git a/TestON/tests/USECASE_SegmentRouting/USECASE_SegmentRouting.params b/TestON/tests/USECASE_SegmentRouting/USECASE_SegmentRouting.params
index 93c957f..dfa3d5f 100755
--- a/TestON/tests/USECASE_SegmentRouting/USECASE_SegmentRouting.params
+++ b/TestON/tests/USECASE_SegmentRouting/USECASE_SegmentRouting.params
@@ -1,6 +1,6 @@
 <PARAMS>
 
-    <testcases>1,2,11,9</testcases>
+    <testcases>1,2,11,9, 2,11,9</testcases>
 
     <SCALE>
         <size>1</size>
@@ -15,7 +15,8 @@
 
     <ENV>
         <cellName>productionCell</cellName>
-        <cellApps>drivers,openflow-base,netcfghostprovider,netcfglinksprovider,segmentrouting,vrouter,hostprovider</cellApps>
+        <cellApps>drivers,segmentrouting</cellApps>
+        <diffApps>openflow-base,netcfghostprovider,netcfglinksprovider;openflow</diffApps>
         <cellUser>sdn</cellUser>
     </ENV>
 
@@ -29,7 +30,7 @@
     </CTRL>
 
     <SLEEP>
-        <startup>15</startup>
+        <startup>10</startup>
     </SLEEP>
 
 </PARAMS>
diff --git a/TestON/tests/USECASE_SegmentRouting/USECASE_SegmentRouting.py b/TestON/tests/USECASE_SegmentRouting/USECASE_SegmentRouting.py
index 292f990..8635b79 100644
--- a/TestON/tests/USECASE_SegmentRouting/USECASE_SegmentRouting.py
+++ b/TestON/tests/USECASE_SegmentRouting/USECASE_SegmentRouting.py
@@ -22,7 +22,7 @@
             - Build ONOS package
         """
 
-        main.case( "Constructing test variables and building ONOS package" )
+        main.case( "Constructing test variables and building ONOS" )
         main.step( "Constructing test variables" )
         stepResult = main.FALSE
 
@@ -30,10 +30,15 @@
         main.testOnDirectory = re.sub( "(/tests)$", "", main.testDir )
         main.cellName = main.params[ 'ENV' ][ 'cellName' ]
         main.apps = main.params[ 'ENV' ][ 'cellApps' ]
+        main.diff = ( main.params[ 'ENV' ][ 'diffApps' ] ).split(";")
         gitBranch = main.params[ 'GIT' ][ 'branch' ]
         main.dependencyPath = main.testOnDirectory + \
                               main.params[ 'DEPENDENCY' ][ 'path' ]
         main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ]
+        #main.json = ["4x4"]
+        main.json = ["2x2", "2x2"]
+        main.args = [" ", " "]
+        #main.args = [" --spine 4 --leaf 4 "]
         main.scale = ( main.params[ 'SCALE' ][ 'size' ] ).split( "," )
         main.maxNodes = int( main.params[ 'SCALE' ][ 'max' ] )
         main.ONOSport = main.params[ 'CTRL' ][ 'port' ]
@@ -86,7 +91,7 @@
         else:
             main.log.warn( "Did not pull new code so skipping mvn " +
                            "clean install" )
-
+         
     def CASE2( self, main ):
         """
         - Set up cell
@@ -103,8 +108,7 @@
         # main.scale[ 0 ] determines the current number of ONOS controller
         main.numCtrls = int( main.scale[ 0 ] )
 
-        main.case( "Starting up " + str( main.numCtrls ) +
-                   " node(s) ONOS cluster" )
+        main.case( "Package and start ONOS")
 
         #kill off all onos processes
         main.log.info( "Safety check, killing all ONOS processes" +
@@ -118,14 +122,17 @@
         tempOnosIp = []
         for i in range( main.numCtrls ):
             tempOnosIp.append( main.ONOSip[i] )
-
+        apps=main.apps
+        if main.diff:
+            apps = main.apps+","+main.diff.pop(0)
+        else: main.log.error( "App list is empty" )
         onosUser = main.params[ 'ENV' ][ 'cellUser' ]
         main.ONOSbench.createCellFile( main.ONOSbench.ip_address,
                                        "temp",
                                        main.Mininet1.ip_address,
-                                       main.apps,
+                                       apps,
                                        tempOnosIp,
-                                       onosUser)
+                                       main.ONOSbench.user_name)
 
         main.step( "Apply cell to environment" )
         cellResult = main.ONOSbench.setCell( "temp" )
@@ -138,7 +145,7 @@
                                  onfail="Failed to apply cell to environment " )
 
         main.step( "Creating ONOS package" )
-        main.ONOSbench.handle.sendline( "cp ~/OnosSystemTest/TestON/tests/USECASE_SegmentRouting/2x2.json ~/onos/tools/package/config/network-cfg.json")
+        main.ONOSbench.handle.sendline( "cp ~/OnosSystemTest/TestON/tests/USECASE_SegmentRouting/"+main.json.pop(0)+".json ~/onos/tools/package/config/network-cfg.json")
         packageResult = main.ONOSbench.onosPackage()
         stepResult = packageResult
         utilities.assert_equals( expect=main.TRUE,
@@ -147,6 +154,7 @@
                                  onfail="Failed to create ONOS package" )
 
         time.sleep( main.startUpSleep )
+
         main.step( "Installing ONOS package" )
         onosInstallResult = main.TRUE
         for i in range( main.numCtrls ):
@@ -181,12 +189,13 @@
                                  actual=stepResult,
                                  onpass="ONOS service is ready",
                                  onfail="ONOS service did not start properly" )
-        time.sleep( main.startUpSleep )
+        time.sleep( 2*main.startUpSleep )
 
     def CASE9( self, main ):
         '''
             Report errors/warnings/exceptions
         '''
+        main.log.case( "Logging test" )
         #main.ONOSbench.logReport( main.ONOSip[ 0 ],
         #                          [ "INFO" ],
         #                          "a" )
@@ -200,16 +209,23 @@
                                     "Except" ],
                                   "s" )
 
-
     def CASE11( self, main ):
         """
             Start mininet
         """
+        main.log.case( "Start Leaf-Spine 2x2 Mininet Topology" )
         main.log.report( "Start Mininet topology" )
-        main.log.case( "Start Mininet topology" )
 
         main.step( "Starting Mininet Topology" )
-        topoResult = main.Mininet1.startNet( topoFile= main.dependencyPath + main.topology, args="--onos 1" )
+        args,topo=" "," "
+        #if main.topology:
+        #    topo = main.topology.pop(0)
+        #else: main.log.error( "Topo list is empty" )
+        if main.args:
+            args = "--onos 1 " + main.args.pop(0)
+        else: main.log.error( "Argument list is empty" )
+
+        topoResult = main.Mininet1.startNet( topoFile= main.dependencyPath + main.topology, args=args )
         stepResult = topoResult
         utilities.assert_equals( expect=main.TRUE,
                                  actual=stepResult,
@@ -220,16 +236,14 @@
             main.cleanup()
             main.exit()
         main.step("Waiting for switch initialization and configuration")
-        time.sleep( main.startUpSleep )
+        time.sleep( 3*main.startUpSleep)
         pa = main.Mininet1.pingall()
         utilities.assert_equals( expect=main.TRUE, actual=pa,
                                  onpass="Full connectivity successfully tested",
                                  onfail="Full connectivity failed" )
         # cleanup mininet
-        main.CLIs[0].logout()
         main.ONOSbench.onosStop( main.ONOSip[0] )
         main.Mininet1.stopNet()
-        main.Mininet1.disconnect()