Last refactoring

Change-Id: I45de55b8e648fab0d61b5c3d08eddfb4edb61b87
diff --git a/TestON/tests/USECASE/SegmentRouting/SRLinkDown/README.md b/TestON/tests/USECASE/SegmentRouting/SRLinkDown/README.md
new file mode 100755
index 0000000..59c1214
--- /dev/null
+++ b/TestON/tests/USECASE/SegmentRouting/SRLinkDown/README.md
@@ -0,0 +1,16 @@
+This test verifies basic connectivity using SegmentRouting via pingall,
+it should not fail.
+
+It consists of 
+
+1) Configure and Install ONOS
+2) Start Mininet and check flow state
+3) Pingall
+
+Requirements
+
+ - An updated version of the CPQD switch has to be running to make sure it supports group chaining.
+
+The test is executed using the netcfg subsystem:
+    1) APPS=openflow-base,netcfghostprovider,netcfglinksprovider
+The topology is a 2x2 Leaf-spine
diff --git a/TestON/tests/USECASE/SegmentRouting/SRLinkDown/SRLinkDown.params b/TestON/tests/USECASE/SegmentRouting/SRLinkDown/SRLinkDown.params
new file mode 100755
index 0000000..1a58556
--- /dev/null
+++ b/TestON/tests/USECASE/SegmentRouting/SRLinkDown/SRLinkDown.params
@@ -0,0 +1,46 @@
+<PARAMS>
+
+    <testcases>1,2,3</testcases>
+
+    <SCALE>
+        <size>3</size>
+        <max>3</max>
+    </SCALE>
+
+    <DEPENDENCY>
+        <wrapper1>startUp</wrapper1>
+        <topology>cord_fabric.py</topology>
+    </DEPENDENCY>
+
+    <ENV>
+        <cellName>productionCell</cellName>
+        <cellApps>drivers,segmentrouting</cellApps>
+        <diffApps>openflow-base,netcfghostprovider,netcfglinksprovider</diffApps>
+        <cellUser>sdn</cellUser>
+    </ENV>
+
+    <GIT>
+        <pull>False</pull>
+        <branch>master</branch>
+    </GIT>
+
+    <CTRL>
+        <port>6653</port>
+    </CTRL>
+
+    <timers>
+        <LinkDiscovery>12</LinkDiscovery>
+        <SwitchDiscovery>12</SwitchDiscovery>
+    </timers>
+
+    <kill>
+        <switch> spine101 </switch>
+        <dpid> 000000000101 </dpid>
+        <links> leaf1 leaf2 </links>
+    </kill>
+
+    <SLEEP>
+        <startup>10</startup>
+    </SLEEP>
+
+</PARAMS>
diff --git a/TestON/tests/USECASE/SegmentRouting/SRLinkDown/SRLinkDown.py b/TestON/tests/USECASE/SegmentRouting/SRLinkDown/SRLinkDown.py
new file mode 100755
index 0000000..db5469d
--- /dev/null
+++ b/TestON/tests/USECASE/SegmentRouting/SRLinkDown/SRLinkDown.py
@@ -0,0 +1,107 @@
+# This test should always succeed. it runs cases 1,2,3,4
+#CASE1: Get and Build ONOS
+#CASE2: Package and Install ONOS
+#CASE3: Start Mininet and check flows
+#CASE4: Ping all
+#CASE5: Link Failure
+#CASE6: Switch Failure
+#CASE7: ONOS Failure
+#CASE8: CLUSTER Failure
+#CASE10: Logging
+
+class SRLinkDown:
+
+    def __init__( self ):
+        self.default = ''
+
+    def CASE1( self, main ):
+        """
+        Sets up 1-node Onos-cluster
+        Start 2x2 Leaf-Spine topology
+        Pingall
+        """
+        from tests.USECASE.SegmentRouting.dependencies.Testcaselib import Testcaselib as run
+        if not hasattr(main,'apps'):
+            run.initTest(main)
+
+        description = "Bridging and Routing sanity test with 2x2 Leaf-spine "
+        main.case( description )
+
+        main.cfgName = '2x2'
+        main.numCtrls = 1
+        run.installOnos(main)
+        run.startMininet(main, 'cord_fabric.py')
+        #pre-configured routing and bridging test
+        run.checkFlows(main, flowCount=116)
+        run.pingAll(main)
+        run.killLink(main, 'spine101', 'leaf2', switches='4', links='6')
+        run.pingAll(main, "CASE1_AfterLinkDown")
+        run.restoreLink(main, 'spine101', 'leaf2','of:0000000000000101',
+                        'of:0000000000000002', '2', '1', '4', '8')
+        run.pingAll(main, "CASE1_AfterLinkUp")
+        #TODO Dynamic config of hosts in subnet
+        #TODO Dynamic config of host not in subnet
+        #TODO Dynamic config of vlan xconnect
+        #TODO Vrouter integration
+        #TODO Mcast integration
+        run.cleanup(main)
+
+    def CASE2( self, main ):
+        """
+        Sets up 1-node Onos-cluster
+        Start 4x4 Leaf-Spine topology
+        Pingall
+        """
+        from tests.USECASE.SegmentRouting.dependencies.Testcaselib import Testcaselib as run
+        if not hasattr(main,'apps'):
+            run.initTest(main)
+        description = "Bridging and Routing sanity test with 4x4 Leaf-spine "
+        main.case( description )
+        main.cfgName = '4x4'
+        main.numCtrls = 1
+        run.installOnos(main)
+        run.startMininet(main, 'cord_fabric.py', args="--leaf=4 --spine=4")
+        #pre-configured routing and bridging test
+        run.checkFlows(main, flowCount=350)
+        run.pingAll(main)
+        run.killLink(main, 'spine101', 'leaf2', switches='8', links='30')
+        run.pingAll(main, "CASE2_AfterLinkDown")
+        run.restoreLink(main, 'spine101', 'leaf2','of:0000000000000101',
+                    'of:0000000000000002', '2', '1', '8', '32')
+        run.pingAll(main, "CASE2_AfterLinkUp")
+        #TODO Dynamic config of hosts in subnet
+        #TODO Dynamic config of host not in subnet
+        #TODO preconfigured xconnect
+        #TODO Vrouter integration
+        #TODO Mcast integration
+        run.cleanup(main)
+
+    def CASE3( self, main ):
+        """
+        Sets up 3-node Onos-cluster
+        Start 2x2 Leaf-Spine topology
+        Pingall
+        """
+        from tests.USECASE.SegmentRouting.dependencies.Testcaselib import Testcaselib as run
+        if not hasattr(main,'apps'):
+            run.initTest(main)
+        description = "Bridging and Routing sanity test with 2x2 Leaf-spine "
+        main.case( description )
+        main.cfgName = '2x2'
+        main.numCtrls = 3
+        run.installOnos(main)
+        run.startMininet(main, 'cord_fabric.py')
+        #pre-configured routing and bridging test
+        run.checkFlows(main, flowCount=116)
+        run.pingAll(main)
+        run.killLink(main, 'spine101', 'leaf2', switches='4', links='6')
+        run.pingAll(main, "CASE3_AfterLinkDown")
+        run.restoreLink(main, 'spine101', 'leaf2','of:0000000000000101',
+                        'of:0000000000000002', '2', '1', '4', '8')
+        run.pingAll(main, "CASE3_AfterLinkUp")
+        #TODO Dynamic config of hosts in subnet
+        #TODO Dynamic config of host not in subnet
+        #TODO Dynamic config of vlan xconnect
+        #TODO Vrouter integration
+        #TODO Mcast integration
+        run.cleanup(main)
\ No newline at end of file
diff --git a/TestON/tests/USECASE/SegmentRouting/SRLinkDown/SRLinkDown.topo b/TestON/tests/USECASE/SegmentRouting/SRLinkDown/SRLinkDown.topo
new file mode 100755
index 0000000..546a023
--- /dev/null
+++ b/TestON/tests/USECASE/SegmentRouting/SRLinkDown/SRLinkDown.topo
@@ -0,0 +1,58 @@
+<TOPOLOGY>
+    <COMPONENT>
+
+        <ONOSbench>
+            <host>localhost</host>
+            <user>sdn</user>
+            <password>rocks</password>
+            <type>OnosDriver</type>
+            <connect_order>1</connect_order>
+            <COMPONENTS>
+                <nodes>1</nodes>
+            </COMPONENTS>
+        </ONOSbench>
+
+        <ONOScli1>
+            <host>OC1</host>
+            <user>sdn</user>
+            <password>rocks</password>
+            <type>OnosCliDriver</type>
+            <connect_order>2</connect_order>
+            <COMPONENTS>
+            </COMPONENTS>
+        </ONOScli1>
+        
+        <ONOScli2>
+            <host>OC2</host>
+            <user>sdn</user>
+            <password>rocks</password>
+            <type>OnosCliDriver</type>
+            <connect_order>3</connect_order>
+            <COMPONENTS>
+            </COMPONENTS>
+        </ONOScli2>
+
+        <ONOScli3>
+            <host>OC3</host>
+            <user>sdn</user>
+            <password>rocks</password>
+            <type>OnosCliDriver</type>
+            <connect_order>4</connect_order>
+            <COMPONENTS>
+            </COMPONENTS>
+        </ONOScli3>
+
+
+        <Mininet1>
+            <host>OCN</host>
+            <user>sdn</user>
+            <password>rocks</password>
+            <type>MininetCliDriver</type>
+            <connect_order>5</connect_order>
+            <COMPONENTS>
+                <home>~/mininet/custom/</home>
+            </COMPONENTS>
+        </Mininet1>
+
+    </COMPONENT>
+</TOPOLOGY>
diff --git a/TestON/tests/USECASE/SegmentRouting/SRLinkDown/__init__.py b/TestON/tests/USECASE/SegmentRouting/SRLinkDown/__init__.py
new file mode 100755
index 0000000..e69de29
--- /dev/null
+++ b/TestON/tests/USECASE/SegmentRouting/SRLinkDown/__init__.py