Merge "Added more fix on key errors and add delay after activating fwd app"
diff --git a/TestON/tests/FUNCintent/Dependency/FuncIntentFunction.py b/TestON/tests/FUNCintent/Dependency/FuncIntentFunction.py
index db9f0cf..b73e9aa 100644
--- a/TestON/tests/FUNCintent/Dependency/FuncIntentFunction.py
+++ b/TestON/tests/FUNCintent/Dependency/FuncIntentFunction.py
@@ -112,17 +112,17 @@
             main.log.info( "There are no host IDs" )
             return main.FALSE
 
-        # Discover hosts using arping
-        if not main.hostsData:
-            main.log.info( itemName + ": Discover host using arping" )
-            main.Mininet1.arping( host=host1 )
-            main.Mininet1.arping( host=host2 )
-            host1 = main.CLIs[ 0 ].getHost( mac=h1Mac )
-            host2 = main.CLIs[ 0 ].getHost( mac=h2Mac )
     except KeyError:
         main.log.error( itemName + ": Key error Exception" )
         return main.FALSE
 
+    # Discover hosts using arping incase pingall discovery failed
+    main.log.info( itemName + ": Discover host using arping" )
+    main.Mininet1.arping( host=host1 )
+    main.Mininet1.arping( host=host2 )
+    host1 = main.CLIs[ 0 ].getHost( mac=h1Mac )
+    host2 = main.CLIs[ 0 ].getHost( mac=h2Mac )
+
     # Check flows count in each node
     checkFlowsCount( main )
 
@@ -921,6 +921,7 @@
     getDataResult = main.TRUE
     main.log.info( "Activating reactive forwarding app " )
     activateResult = main.CLIs[ 0 ].activateApp( "org.onosproject.fwd" )
+    time.sleep( main.fwdSleep )
 
     for i in range( main.numCtrls ):
         appCheck = appCheck and main.CLIs[ i ].appToIDCheck()
diff --git a/TestON/tests/FUNCintent/FUNCintent.params b/TestON/tests/FUNCintent/FUNCintent.params
index e34ac26..7b7040a 100644
--- a/TestON/tests/FUNCintent/FUNCintent.params
+++ b/TestON/tests/FUNCintent/FUNCintent.params
@@ -37,6 +37,7 @@
         <startup>15</startup>
         <reroute>5</reroute>
         <checkintent>5</checkintent>
+        <fwd>10</fwd>
     </SLEEP>
 
     <MININET>
diff --git a/TestON/tests/FUNCintent/FUNCintent.py b/TestON/tests/FUNCintent/FUNCintent.py
index 8aea103..b1577ad 100644
--- a/TestON/tests/FUNCintent/FUNCintent.py
+++ b/TestON/tests/FUNCintent/FUNCintent.py
@@ -45,6 +45,7 @@
         main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
         main.checkIntentSleep = int( main.params[ 'SLEEP' ][ 'checkintent' ] )
         main.rerouteSleep = int( main.params[ 'SLEEP' ][ 'reroute' ] )
+        main.fwdSleep = int( main.params[ 'SLEEP' ][ 'fwd' ] )
         gitPull = main.params[ 'GIT' ][ 'pull' ]
         main.numSwitch = int( main.params[ 'MININET' ][ 'switch' ] )
         main.numLinks = int( main.params[ 'MININET' ][ 'links' ] )
@@ -620,8 +621,15 @@
         stepResult = main.TRUE
         mac1 = main.hostsData[ 'h1' ][ 'mac' ]
         mac2 = main.hostsData[ 'h9' ][ 'mac' ]
-        ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/24"
-        ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/24"
+        try:
+            ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/24"
+            ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/24"
+        except KeyError:
+            main.log.debug( "Key Error getting IP addresses of h1 | h9 in" +
+                            "main.hostsData" )
+            ip1 = main.Mininet1.getIPAddress( 'h1')
+            ip2 = main.Mininet1.getIPAddress( 'h9')
+
         ipProto = main.params[ 'SDNIP' ][ 'icmpProto' ]
         tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
         tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]