[ONOS-7369] Proof-of-concept testing for network driver to manage physical switches/hosts

Change-Id: If35298e29af22307d65f8f38546b0a21271ae333
diff --git a/TestON/tests/SAMP/SAMPstartTemplate_3node/SAMPstartTemplate_3node.params b/TestON/tests/SAMP/SAMPstartTemplate_3node/SAMPstartTemplate_3node.params
index 0eead29..73759e5 100755
--- a/TestON/tests/SAMP/SAMPstartTemplate_3node/SAMPstartTemplate_3node.params
+++ b/TestON/tests/SAMP/SAMPstartTemplate_3node/SAMPstartTemplate_3node.params
@@ -5,12 +5,14 @@
         CASE2: get onos warnings, errors from log
         CASE10: start a 3-node ONOS Cluster
         CASE11: Start Mininet and assign controllers
-        CASE12: Sample case of using onos cli
-        CASE22: Sample case of using onos rest
-        CASE32: Configure fwd apps
+        CASE12: Connect to a physical network and assign controllers
+        CASE20: Sample case of using onos cli
+        CASE30: Sample case of using onos rest
+        CASE40: Configure fwd apps and run pingall
+        Sample testcases for physical network: 0,1,10,12,20,30,40,2
    -->
 
-    <testcases>0,1,10,11,12,22,2,32</testcases>
+    <testcases>0,1,10,11,20,30,40,2</testcases>
     <GIT>
         <pull>False</pull>
         <branch>master</branch>
diff --git a/TestON/tests/SAMP/SAMPstartTemplate_3node/SAMPstartTemplate_3node.py b/TestON/tests/SAMP/SAMPstartTemplate_3node/SAMPstartTemplate_3node.py
index 21d86d4..a8634ae 100644
--- a/TestON/tests/SAMP/SAMPstartTemplate_3node/SAMPstartTemplate_3node.py
+++ b/TestON/tests/SAMP/SAMPstartTemplate_3node/SAMPstartTemplate_3node.py
@@ -137,7 +137,7 @@
         main.case( "Start Mininet topology" )
 
         main.step( "Starting Mininet Topology" )
-        topoResult = main.Network.startNet( mnCmd=topology )
+        topoResult = main.Mininet1.startNet( mnCmd=topology )
         stepResult = topoResult
         utilities.assert_equals( expect=main.TRUE,
                                  actual=stepResult,
@@ -150,7 +150,7 @@
         main.step( "Assign switches to controllers." )
         assignResult = main.TRUE
         for i in range( 1, 8 ):
-            assignResult = assignResult & main.Network.assignSwController( sw="s" + str( i ),
+            assignResult = assignResult & main.Mininet1.assignSwController( sw="s" + str( i ),
                                                                             ip=main.Cluster.getIps(),
                                                                             port='6653' )
         time.sleep( main.mnCfgSleep )
@@ -161,13 +161,42 @@
 
     def CASE12( self, main ):
         """
+            Connect to a physical network and assign controllers
+        """
+        main.case( "Connecting to physical network" )
+
+        main.step( "Connecting to physical network" )
+        topoResult = main.NetworkBench.connectToNet()
+        stepResult = topoResult
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="Successfully loaded topology",
+                                 onfail="Failed to load topology" )
+        # Exit if topology did not load properly
+        if not topoResult:
+            main.cleanAndExit()
+
+        main.step( "Assign switches to controllers." )
+        assignResult = main.TRUE
+        for i in range( 1, 2 ):
+            assignResult = assignResult & main.NetworkBench.assignSwController( sw="s" + str( i ),
+                                                                                ip=main.Cluster.getIps(),
+                                                                                port='6653' )
+        time.sleep( main.mnCfgSleep )
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="Successfully assign switches to controllers",
+                                 onfail="Failed to assign switches to controllers" )
+
+    def CASE20( self, main ):
+        """
             Tests using through ONOS CLI handles
         """
         main.case( "Test some onos commands through CLI. " )
         main.log.debug( main.Cluster.active( 0 ).CLI.sendline( "summary" ) )
         main.log.debug( main.Cluster.active( 1 ).CLI.sendline( "devices" ) )
 
-    def CASE22( self, main ):
+    def CASE30( self, main ):
         """
             Tests using ONOS REST API handles
         """
@@ -175,7 +204,7 @@
         main.log.debug( main.Cluster.active( 0 ).REST.send( "/devices" ) )
         main.log.debug( main.Cluster.active( 2 ).REST.apps() )
 
-    def CASE32( self, main ):
+    def CASE40( self, main ):
         """
             Configure fwd app from .params json string with parameter configured
             Check if configuration successful
diff --git a/TestON/tests/SAMP/SAMPstartTemplate_3node/SAMPstartTemplate_3node.topo.physical b/TestON/tests/SAMP/SAMPstartTemplate_3node/SAMPstartTemplate_3node.topo.physical
new file mode 100755
index 0000000..5409afd
--- /dev/null
+++ b/TestON/tests/SAMP/SAMPstartTemplate_3node/SAMPstartTemplate_3node.topo.physical
@@ -0,0 +1,82 @@
+<TOPOLOGY>
+    <COMPONENT>
+    <!--
+        This is a list of all components and their handles in the test setup.
+        Even with some handles not used in test cases, we want to define
+        all onos cells here, for cases to set up onos cluster.
+    -->
+        <ONOScell>
+            <host>localhost</host>  # ONOS "bench" machine
+            <user>sdn</user>
+            <password>rocks</password>
+            <type>OnosClusterDriver</type>
+            <connect_order>1</connect_order>
+            <COMPONENTS>
+                <cluster_name></cluster_name>  # Used as a prefix for cluster components. Defaults to 'ONOS'
+                <diff_clihost></diff_clihost> # if it has different host other than localhost for CLI. True or empty. OC# will be used if True.
+                <karaf_username></karaf_username>
+                <karaf_password></karaf_password>
+                <web_user></web_user>
+                <web_pass></web_pass>
+                <rest_port></rest_port>
+                <prompt></prompt>  # TODO: we technically need a few of these, one per component
+                <onos_home></onos_home>  # defines where onos home is
+                <nodes> 3 </nodes>  # number of nodes in the cluster
+            </COMPONENTS>
+        </ONOScell>
+
+        <MininetSwitch1>
+            <host>OCN</host>
+            <user>sdn</user>
+            <password>rocks</password>
+            <type>MininetSwitchDriver</type>
+            <connect_order>2</connect_order>
+            <COMPONENTS>
+                <shortName>s1</shortName>
+                <port1>1</port1>
+                <link1>MininetHost1</link1>
+                <port2>2</port2>
+                <link2>MininetHost2</link2>
+            </COMPONENTS>
+        </MininetSwitch1>
+
+        <MininetHost1>
+            <host>OCN</host>
+            <user>sdn</user>
+            <password>rocks</password>
+            <type>MininetHostDriver</type>
+            <connect_order>3</connect_order>
+            <COMPONENTS>
+                <ip>10.0.0.1</ip>
+                <shortName>h1</shortName>
+                <port1>0</port1>
+                <link1>MininetSwitch1</link1>
+            </COMPONENTS>
+        </MininetHost1>
+
+        <MininetHost2>
+            <host>OCN</host>
+            <user>sdn</user>
+            <password>rocks</password>
+            <type>MininetHostDriver</type>
+            <connect_order>4</connect_order>
+            <COMPONENTS>
+                <ip>10.0.0.2</ip>
+                <shortName>h2</shortName>
+                <port1>0</port1>
+                <link1>MininetSwitch1</link1>
+            </COMPONENTS>
+        </MininetHost2>
+
+        <NetworkBench>
+            <host>OCN</host>
+            <user>sdn</user>
+            <password>rocks</password>
+            <type>NetworkDriver</type>
+            <connect_order>5</connect_order>
+            <COMPONENTS>
+            </COMPONENTS>
+        </NetworkBench>
+
+    </COMPONENT>
+</TOPOLOGY>