Merge "WIP Added topology and topo dependency. Implemented the add flow case."
diff --git a/TestON/tests/FUNCflow/Dependency/flow-2sw.py b/TestON/tests/FUNCflow/Dependency/flow-2sw.py
new file mode 100755
index 0000000..2299d9e
--- /dev/null
+++ b/TestON/tests/FUNCflow/Dependency/flow-2sw.py
@@ -0,0 +1,50 @@
+#!/usr/bin/python
+
+"""
+Custom topology for Mininet
+"""
+from mininet.topo import Topo
+from mininet.net import Mininet
+from mininet.node import Host, RemoteController
+from mininet.node import Node
+from mininet.node import CPULimitedHost
+from mininet.link import TCLink
+from mininet.cli import CLI
+from mininet.log import setLogLevel
+from mininet.util import dumpNodeConnections
+from mininet.node import ( UserSwitch, OVSSwitch, IVSSwitch )
+
+class MyTopo( Topo ):
+
+    def __init__( self ):
+        # Initialize topology
+        Topo.__init__( self )
+        # Switch S5 Hosts
+        host1=self.addHost( 'h1', ip='10.1.0.1/24' )
+        host2=self.addHost( 'h2', ip='10.1.0.2/24' )
+        #host3=self.addHost( 'h3', ip='10.1.0.3/24', v6Addr='1000::3/64' )
+        #host4=self.addHost( 'h4', ip='10.1.0.4/24', v6Addr='1000::4/64' )
+
+        s1 = self.addSwitch( 's1' )
+        #s2 = self.addSwitch( 's2' )
+
+        self.addLink(s1, host1)
+        self.addLink(s1, host2)
+        #self.addLink(s1, host3)
+        #self.addLink(s1, host4)
+
+
+        topos = { 'mytopo': ( lambda: MyTopo() ) }
+
+def setupNetwork():
+    "Create network"
+    topo = MyTopo()
+    network = Mininet(topo=topo, autoSetMacs=True, controller=None)
+    network.start()
+    CLI( network )
+    network.stop()
+
+if __name__ == '__main__':
+    setLogLevel('info')
+    #setLogLevel('debug')
+    setupNetwork()
diff --git a/TestON/tests/FUNCflow/Dependency/topo.py b/TestON/tests/FUNCflow/Dependency/topo.py
new file mode 100644
index 0000000..b44e3fc
--- /dev/null
+++ b/TestON/tests/FUNCflow/Dependency/topo.py
@@ -0,0 +1,100 @@
+"""
+    These functions can be used for topology comparisons
+"""
+
+import time
+import os
+import json
+
+def getAllDevices( main ):
+    """
+        Return a list containing the devices output from each ONOS node
+    """
+    devices = []
+    threads = []
+    for i in range( main.numCtrls ):
+        t = main.Thread( target=main.CLIs[i].devices,
+                         name="devices-" + str( i ),
+                         args=[ ] )
+        threads.append( t )
+        t.start()
+
+    for t in threads:
+        t.join()
+        devices.append( t.result )
+    return devices
+
+def getAllHosts( main ):
+    """
+        Return a list containing the hosts output from each ONOS node
+    """
+    hosts = []
+    ipResult = main.TRUE
+    threads = []
+    for i in range( main.numCtrls ):
+        t = main.Thread( target=main.CLIs[i].hosts,
+                         name="hosts-" + str( i ),
+                         args=[ ] )
+        threads.append( t )
+        t.start()
+
+    for t in threads:
+        t.join()
+        hosts.append( t.result )
+    return hosts
+
+def getAllPorts( main ):
+    """
+        Return a list containing the ports output from each ONOS node
+    """
+    ports = []
+    threads = []
+    for i in range( main.numCtrls ):
+        t = main.Thread( target=main.CLIs[i].ports,
+                         name="ports-" + str( i ),
+                         args=[ ] )
+        threads.append( t )
+        t.start()
+
+    for t in threads:
+        t.join()
+        ports.append( t.result )
+    return ports
+
+def getAllLinks( main ):
+    """
+        Return a list containing the links output from each ONOS node
+    """
+    links = []
+    threads = []
+    for i in range( main.numCtrls ):
+        t = main.Thread( target=main.CLIs[i].links,
+                         name="links-" + str( i ),
+                         args=[ ] )
+        threads.append( t )
+        t.start()
+
+    for t in threads:
+        t.join()
+        links.append( t.result )
+    return links
+
+def getAllClusters( main ):
+    """
+        Return a list containing the clusters output from each ONOS node
+    """
+    clusters = []
+    threads = []
+    for i in range( main.numCtrls ):
+        t = main.Thread( target=main.CLIs[i].clusters,
+                         name="clusters-" + str( i ),
+                         args=[ ] )
+        threads.append( t )
+        t.start()
+
+    for t in threads:
+        t.join()
+        clusters.append( t.result )
+    return clusters
+
+
diff --git a/TestON/tests/FUNCflow/FUNCflow.params b/TestON/tests/FUNCflow/FUNCflow.params
index d6312b3..396686e 100755
--- a/TestON/tests/FUNCflow/FUNCflow.params
+++ b/TestON/tests/FUNCflow/FUNCflow.params
@@ -12,7 +12,7 @@
     # 4000 - Modify flow rule treatments
     # 5000 - flow rule controller
     # 100 - Compare switch flow table with ONOS
-    <testcases>1,2,10,8</testcases>
+    <testcases>1,2,10,8,1000</testcases>
 
     <SCALE>
         <max>3</max>
@@ -25,15 +25,20 @@
         <topology>flow-2sw.py</topology>
     </DEPENDENCY>
 
+
     <TOPO>
-        <numSwitches>2</numSwitches>
-        <numHosts>4</numHosts>
+        <numSwitches>1</numSwitches>
+        <numHosts>2</numHosts>
         <numLinks>2</numLinks>
+        <deviceId>of:0000000000000001</deviceId>
+        <hostMac1>00:00:00:00:00:01</hostMac1>
+        <hostMac2>00:00:00:00:00:02</hostMac2>
+        <ethType>IPV4</ethType>
     </TOPO>
 
     <ENV>
         <cellName>productionCell</cellName>
-        <cellApps>drivers,openflow,proxyarp,mobility,fwd</cellApps>
+        <cellApps>drivers,openflow,fwd</cellApps>
     </ENV>
 
     <GIT>
diff --git a/TestON/tests/FUNCflow/FUNCflow.py b/TestON/tests/FUNCflow/FUNCflow.py
index 74c3464..30608a6 100644
--- a/TestON/tests/FUNCflow/FUNCflow.py
+++ b/TestON/tests/FUNCflow/FUNCflow.py
@@ -271,7 +271,17 @@
                                      onpass="ONOS" + controllerStr +
                                      " hosts exist in Mininet",
                                      onfail="ONOS" + controllerStr +
-                                     " hosts don't match Mininet" )
+                                     " hosts don't match Mininet")
+
+        main.step( "Deactiviate reactive fwd" )
+        stepResult = main.CLIs[0].deactivateApp( 'org.onosproject.fwd' )
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="Successfully deactived fwd app",
+                                 onfail="Failed to deactivate fwd app" )
+
+        main.log.info("Wait for the flows to dissappear")
+        time.sleep(5)
 
     def CASE9( self, main ):
         '''
@@ -289,7 +299,7 @@
 
     def CASE10( self, main ):
         '''
-            Start Mininet with
+            Start Mininet
         '''
         main.case( "Setup mininet and assign switches to controllers" )
         main.step( "Setup Mininet Topology" )
@@ -335,6 +345,52 @@
             Add flows
         '''
 
+        main.step("Add some flows")
+
+        deviceId = main.params['TOPO']['deviceId']
+        host1_mac = main.params['TOPO']['hostMac1']
+        host2_mac = main.params['TOPO']['hostMac2']
+
+
+        flowResult1 = main.ONOSrest.addFlow( deviceId=deviceId,
+                                             egressPort=-3,
+                                             ethType="IPV4" )
+
+        flowResult2 = main.ONOSrest.addFlow( deviceId=deviceId,
+                                             egressPort=2,
+                                             ingressPort=1,
+                                             ethSrc=host1_mac,
+                                             ethDst=host2_mac)
+
+        flowResult3 = main.ONOSrest.addFlow( deviceId=deviceId,
+                                             egressPort=1,
+                                             ingressPort=2,
+                                             ethSrc=host2_mac,
+                                             ethDst=host1_mac)
+
+        flowResult = flowResult1 and flowResult2 and flowResult3
+
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=flowResult,
+                                 onpass="Successfully added flows",
+                                 onfail="Failed add flows" )
+
+        main.step("Verify flows with pingall")
+        main.log.info("wait for flows to install")
+        time.sleep(5)
+
+        pingResult = main.Mininet1.pingall()
+        if not pingResult:
+            main.log.warn("First pingall failed. Retrying")
+            pingResult = main.Mininet1.pingall()
+
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=pingResult,
+                                 onpass="Pingall successfull",
+                                 onfail="Pingall failed" )
+
+        time.sleep(100)
+
     def CASE2000( self, main ):
         '''
             Delete flows
@@ -359,4 +415,3 @@
         '''
             Compare switch flow table with ONOS
         '''
-
diff --git a/TestON/tests/FUNCflow/FUNCflow.topo b/TestON/tests/FUNCflow/FUNCflow.topo
index cfb3fb8..7c17bcb 100755
--- a/TestON/tests/FUNCflow/FUNCflow.topo
+++ b/TestON/tests/FUNCflow/FUNCflow.topo
@@ -53,8 +53,8 @@
         <ONOSrest>
             <host>OC1</host>
             <port>8181</port>
-            <user>admin</user>
-            <password>onos_test</password>
+            <user>onos</user>
+            <password>rocks</password>
             <type>OnosRestDriver</type>
             <connect_order>6</connect_order>
             <COMPONENTS>