Dynamic configuration of SR

Change-Id: I847d1cf66f146f213947a336ca0619a3e28ace36
diff --git a/TestON/tests/USECASE/SegmentRouting/SRDynamic/README.md b/TestON/tests/USECASE/SegmentRouting/SRDynamic/README.md
new file mode 100755
index 0000000..e84af0b
--- /dev/null
+++ b/TestON/tests/USECASE/SegmentRouting/SRDynamic/README.md
@@ -0,0 +1,22 @@
+This test verifies connectivity in face of dynamic configuration and Onos failures using SegmentRouting
+
+It consists of
+
+1) Configure and Install ONOS
+2) Start Mininet and check flow state
+3) Connectivity test
+4) Add Hosts dynamically
+5) Connectivity test
+6) Onos Failure
+7) Remove host configuration
+
+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 test runs for different topologies:
+ - 2x2 Leaf-Spine and 3-node ONOS cluster
+ - 4x4 Leaf-Spine and 3-node ONOS cluster
+ - Single switch and 3-node ONOS cluster
\ No newline at end of file
diff --git a/TestON/tests/USECASE/SegmentRouting/SRDynamic/SRDynamic.params b/TestON/tests/USECASE/SegmentRouting/SRDynamic/SRDynamic.params
new file mode 100755
index 0000000..a757a48
--- /dev/null
+++ b/TestON/tests/USECASE/SegmentRouting/SRDynamic/SRDynamic.params
@@ -0,0 +1,46 @@
+<PARAMS>
+
+    <testcases>1,2,3,4,5,6</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/SRDynamic/SRDynamic.py b/TestON/tests/USECASE/SegmentRouting/SRDynamic/SRDynamic.py
new file mode 100755
index 0000000..9d84bb4
--- /dev/null
+++ b/TestON/tests/USECASE/SegmentRouting/SRDynamic/SRDynamic.py
@@ -0,0 +1,173 @@
+# CASE1: 2x2 Leaf-Spine topo and test IP connectivity
+# CASE2: 4x4 topo + IP connectivity test
+# CASE3: Single switch topo + IP connectivity test
+# CASE4: 2x2 topo + 3-node ONOS CLUSTER + IP connectivity test
+# CASE5: 4x4 topo + 3-node ONOS CLUSTER + IP connectivity test
+# CASE6: Single switch + 3-node ONOS CLUSTER + IP connectivity test
+
+class SRDynamic:
+    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, vlanCfg=False )
+        run.startMininet( main, 'cord_fabric.py' )
+        # pre-configured routing and bridging test
+        run.checkFlows( main, minFlowCount=116 )
+        run.pingAll( main, dumpflows=False, )
+        run.addHostCfg( main )
+        run.checkFlows( main, minFlowCount=140, dumpflows=False )
+        run.pingAll( main, "CASE1" )
+        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, vlanCfg=False )
+        run.startMininet( main, 'cord_fabric.py',
+                          args="--leaf=4 --spine=4" )
+        # pre-configured routing and bridging test
+        run.checkFlows( main, minFlowCount=350 )
+        run.pingAll( main, dumpflows=False )
+        run.addHostCfg( main )
+        run.checkFlows( main, minFlowCount=380, dumpflows=False )
+        run.pingAll( main, 'CASE2' )
+        run.cleanup( main )
+
+    def CASE3( self, main ):
+        """
+        Sets up 1-node Onos-cluster
+        Start single switch 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 single switch "
+        main.case( description )
+        main.cfgName = '0x1'
+        main.numCtrls = 1
+        run.installOnos( main, vlanCfg=False )
+        run.startMininet( main, 'cord_fabric.py',
+                          args="--leaf=1 --spine=0" )
+        # pre-configured routing and bridging test
+        run.checkFlows( main, minFlowCount=15 )
+        run.pingAll( main, dumpflows=False )
+        run.addHostCfg( main )
+        run.checkFlows( main, minFlowCount=18, dumpflows=False )
+        run.pingAll( main, 'CASE3' )
+        run.cleanup( main )
+
+    def CASE4( 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, vlanCfg=False )
+        run.startMininet( main, 'cord_fabric.py' )
+        # pre-configured routing and bridging test
+        run.checkFlows( main, minFlowCount=116 )
+        run.pingAll( main, dumpflows=False )
+        run.addHostCfg( main )
+        run.checkFlows( main, minFlowCount=140, dumpflows=False )
+        run.pingAll( main, "CASE4" )
+        run.killOnos( main, [ 0 ], '4', '8', '2' )
+        run.delHostCfg( main )
+        run.checkFlows( main, minFlowCount=116, dumpflows=False )
+        run.pingAll( main, "CASE4_after" )
+        run.cleanup( main )
+
+    def CASE5( self, main ):
+        """
+        Sets up 3-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 = 3
+        run.installOnos( main, vlanCfg=False )
+        run.startMininet( main, 'cord_fabric.py',
+                          args="--leaf=4 --spine=4" )
+        # pre-configured routing and bridging test
+        run.checkFlows( main, minFlowCount=350 )
+        run.pingAll( main, dumpflows=False )
+        run.addHostCfg( main )
+        run.checkFlows( main, minFlowCount=380, dumpflows=False )
+        run.pingAll( main, 'CASE5' )
+        run.killOnos( main, [ 0 ], '8', '32', '2' )
+        run.delHostCfg( main )
+        run.checkFlows( main, minFlowCount=350, dumpflows=False )
+        run.pingAll( main, "CASE5_After" )
+        run.cleanup( main )
+
+    def CASE6( self, main ):
+        """
+        Sets up 3-node Onos-cluster
+        Start single switch 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 single switch "
+        main.case( description )
+        main.cfgName = '0x1'
+        main.numCtrls = 3
+        run.installOnos( main, vlanCfg=False )
+        run.startMininet( main, 'cord_fabric.py',
+                          args="--leaf=1 --spine=0" )
+        # pre-configured routing and bridging test
+        run.checkFlows( main, minFlowCount=15 )
+        run.pingAll( main, dumpflows=False )
+        run.addHostCfg( main )
+        run.checkFlows( main, minFlowCount=20, dumpflows=False )
+        run.pingAll( main, 'CASE6' )
+        run.killOnos( main, [ 0 ], '1', '0', '2' )
+        run.delHostCfg( main )
+        run.checkFlows( main, minFlowCount=15, dumpflows=False )
+        run.pingAll( main, "CASE6_After" )
+        run.cleanup( main )
diff --git a/TestON/tests/USECASE/SegmentRouting/SRDynamic/SRDynamic.topo b/TestON/tests/USECASE/SegmentRouting/SRDynamic/SRDynamic.topo
new file mode 100755
index 0000000..c531f7d
--- /dev/null
+++ b/TestON/tests/USECASE/SegmentRouting/SRDynamic/SRDynamic.topo
@@ -0,0 +1,90 @@
+<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>
+
+        <ONOSrest1>
+            <host>OC1</host>
+            <port>8181</port>
+            <user>onos</user>
+            <password>rocks</password>
+            <type>OnosRestDriver</type>
+            <connect_order>5</connect_order>
+            <COMPONENTS>
+            </COMPONENTS>
+        </ONOSrest1>
+
+        <ONOSrest2>
+            <host>OC2</host>
+            <port>8181</port>
+            <user>onos</user>
+            <password>rocks</password>
+            <type>OnosRestDriver</type>
+            <connect_order>6</connect_order>
+            <COMPONENTS>
+            </COMPONENTS>
+        </ONOSrest2>
+
+        <ONOSrest3>
+            <host>OC3</host>
+            <port>8181</port>
+            <user>onos</user>
+            <password>rocks</password>
+            <type>OnosRestDriver</type>
+            <connect_order>6</connect_order>
+            <COMPONENTS>
+            </COMPONENTS>
+        </ONOSrest3>
+
+        <Mininet1>
+            <host>OCN</host>
+            <user>sdn</user>
+            <password>rocks</password>
+            <type>MininetCliDriver</type>
+            <connect_order>7</connect_order>
+            <COMPONENTS>
+                <home>~/mininet/custom/</home>
+            </COMPONENTS>
+        </Mininet1>
+
+    </COMPONENT>
+</TOPOLOGY>
diff --git a/TestON/tests/USECASE/SegmentRouting/SRDynamic/__init__.py b/TestON/tests/USECASE/SegmentRouting/SRDynamic/__init__.py
new file mode 100755
index 0000000..e69de29
--- /dev/null
+++ b/TestON/tests/USECASE/SegmentRouting/SRDynamic/__init__.py