[ONOS-6905] Adujust the number of retrying and sleep time to the FUNCintent

Change-Id: I4e8d1002e4915e1bbd8635c7a2a6660adf64d129
diff --git a/TestON/core/utilities.py b/TestON/core/utilities.py
index ed37ae3..2f7e5bb 100644
--- a/TestON/core/utilities.py
+++ b/TestON/core/utilities.py
@@ -295,7 +295,8 @@
             return 0
 
     def retry( self, f, retValue, args=(), kwargs={},
-               sleep=1, attempts=2, randomTime=False ):
+               sleep=1, attempts=2, randomTime=False,
+               getRetryingTime=False ):
         """
         Given a function and bad return values, retry will retry a function
         until successful or give up after a certain number of attempts.
@@ -321,6 +322,8 @@
             assert sleep >= 0, "sleep must be >= 0"
             if not isinstance( retValue, list ):
                 retValue = [ retValue ]
+            if getRetryingTime:
+                startTime = time.time()
             for i in range( 0, attempts ):
                 ret = f( *args, **kwargs )
                 if ret not in retValue:
@@ -333,6 +336,8 @@
                 time.sleep( sleeptime )
             if i > 0:
                 main.log.debug( str( f ) + " was retried " + str( i ) + " times." )
+                if getRetryingTime:
+                    main.log.debug( "Took " + str( time.time() - startTime ) + " seconds for retrying." )
             return ret
         except AssertionError:
             main.log.exception( "Invalid arguements for retry: " )
diff --git a/TestON/tests/FUNC/FUNCintent/FUNCintent.params b/TestON/tests/FUNC/FUNCintent/FUNCintent.params
index 1215e16..bff8823 100644
--- a/TestON/tests/FUNC/FUNCintent/FUNCintent.params
+++ b/TestON/tests/FUNC/FUNCintent/FUNCintent.params
@@ -47,17 +47,24 @@
     <SLEEP>
         <startup>15</startup>
         <reroute>5</reroute>
-        <removeintent>10</removeintent>
+        <removeintent>5</removeintent>
         <checkintent>5</checkintent>
         <fwd>10</fwd>
         <topoAttempts>3</topoAttempts>
         <flowDuration>10</flowDuration>
-        <checkConnection>30</checkConnection>
-        <checkFlowCount>20</checkFlowCount>
+        <checkConnection>1</checkConnection> # because the scapyCheckConnection itself takes 12 seconds.
+        <checkFlowCount>5</checkFlowCount>
         <checkIntentHost>5</checkIntentHost>
         <checkIntentPoint>5</checkIntentPoint>
     </SLEEP>
 
+    <RETRY>
+        <generalAttempts>36</generalAttempts>
+        <middleAttempts>5</middleAttempts>
+        <minimumAttempts>1</minimumAttempts>
+        <checkConnectionAtt>15</checkConnectionAtt> # because the scapyCheckConnection itself takes 12 seconds.
+        <removeIntentAtt>20</removeIntentAtt>
+    </RETRY>
     <MININET>
         <switch>7</switch>
         <links>20</links>
diff --git a/TestON/tests/FUNC/FUNCintent/FUNCintent.py b/TestON/tests/FUNC/FUNCintent/FUNCintent.py
index 2b85fc2..c0374f8 100644
--- a/TestON/tests/FUNC/FUNCintent/FUNCintent.py
+++ b/TestON/tests/FUNC/FUNCintent/FUNCintent.py
@@ -71,6 +71,11 @@
             main.checkIntentPointSleep = int( main.params[ 'SLEEP' ][ 'checkIntentPoint' ] )
             main.checkTopoAttempts = int( main.params[ 'SLEEP' ][ 'topoAttempts' ] )
             main.flowDurationSleep = int( main.params[ 'SLEEP' ][ 'flowDuration' ] )
+            main.generalAttemptsNum = int( main.params[ 'RETRY' ][ 'generalAttempts' ] )
+            main.middleAttemptsNum = int( main.params[ 'RETRY' ][ 'middleAttempts' ] )
+            main.minimumAttemptsNum = int( main.params[ 'RETRY' ][ 'minimumAttempts' ] )
+            main.checkConnectionAttNum = int( main.params[ 'RETRY' ][ 'checkConnectionAtt' ] )
+            main.removeIntentAttNum = int( main.params[ 'RETRY' ][ 'removeIntentAtt' ] )
             main.numSwitch = int( main.params[ 'MININET' ][ 'switch' ] )
             main.numLinks = int( main.params[ 'MININET' ][ 'links' ] )
             main.hostsData = {}
diff --git a/TestON/tests/FUNC/FUNCintent/dependencies/FuncIntentFunction.py b/TestON/tests/FUNC/FUNCintent/dependencies/FuncIntentFunction.py
index 6299ac2..bdd0e74 100644
--- a/TestON/tests/FUNC/FUNCintent/dependencies/FuncIntentFunction.py
+++ b/TestON/tests/FUNC/FUNCintent/dependencies/FuncIntentFunction.py
@@ -243,9 +243,9 @@
 
     # Check intent state
     if hostIntentFailFlag:
-        attempts = 1
+        attempts = main.minimumAttemptsNum
     else:
-        attempts = 50
+        attempts = main.generalAttemptsNum
     if utilities.retry( f=checkIntentState,
                         retValue=main.FALSE,
                         args=( main, [ intentId ] ),
@@ -255,7 +255,7 @@
     else:
         main.assertReturnString += 'Initial Intent State Failed\n'
         testResult = main.FALSE
-        attempts = 1
+        attempts = main.minimumAttemptsNum
 
     # Check flows count in each node
     if utilities.retry( f=checkFlowsCount,
@@ -275,9 +275,10 @@
     # Check Connectivity
     if utilities.retry( f=scapyCheckConnection,
                         retValue=main.FALSE,
-                        attempts=attempts,
+                        attempts=main.checkConnectionAttNum,
                         sleep=main.checkConnectionSleep,
-                        args=( main, senderNames, recipientNames, vlanId ) ):
+                        args=( main, senderNames, recipientNames, vlanId ),
+                        getRetryingTime=True ):
         main.assertReturnString += 'Initial Ping Passed\n'
     else:
         main.assertReturnString += 'Initial Ping Failed\n'
@@ -334,7 +335,8 @@
                             retValue=main.FALSE,
                             args=( main, senderNames, recipientNames, vlanId ),
                             sleep=main.checkConnectionSleep,
-                            attempts=attempts ):
+                            attempts=main.checkConnectionAttNum,
+                            getRetryingTime=True ):
             main.assertReturnString += 'Link Down Pingall Passed\n'
         else:
             main.assertReturnString += 'Link Down Pingall Failed\n'
@@ -391,7 +393,8 @@
         # Check Connection
         if utilities.retry( f=scapyCheckConnection,
                             retValue=main.FALSE,
-                            args=( main, senderNames, recipientNames, vlanId ) ):
+                            args=( main, senderNames, recipientNames, vlanId ),
+                            getRetryingTime=True ):
             main.assertReturnString += 'Link Up Pingall Passed\n'
         else:
             main.assertReturnString += 'Link Up Pingall Failed\n'
@@ -400,7 +403,7 @@
     # Remove all intents
     if utilities.retry( f=removeAllIntents,
                         retValue=main.FALSE,
-                        attempts=10,
+                        attempts=main.removeIntentAttNum,
                         args=( main, [ intentId ] ) ):
         main.assertReturnString += 'Remove Intents Passed'
     else:
@@ -973,9 +976,9 @@
 
     # Check intents state
     if singleToMultiFailFlag:
-        attempts = 5
+        attempts = main.middleAttemptsNum
     else:
-        attempts = 50
+        attempts = main.generalAttemptsNum
 
     if utilities.retry( f=checkIntentState,
                         retValue=main.FALSE,
@@ -1122,9 +1125,9 @@
 
     # Check intents state
     if multiToSingleFailFlag:
-        attempts = 5
+        attempts = main.middleAttemptsNum
     else:
-        attempts = 50
+        attempts = main.generalAttemptsNum
 
     if utilities.retry( f=checkIntentState,
                         retValue=main.FALSE,
@@ -1261,9 +1264,9 @@
     main.log.info( itemName + ": Adding single point to multi point intents" )
 
     if pointIntentFailFlag or singleToMultiFailFlag or multiToSingleFailFlag:
-        attempts = 1
+        attempts = main.minimumAttemptsNum
     else:
-        attempts = 50
+        attempts = main.generalAttemptsNum
 
     # Check intent state
     if utilities.retry( f=checkIntentState,
@@ -1275,7 +1278,7 @@
     else:
         main.assertReturnString += 'Initial Intent State Failed\n'
         testResult = main.FALSE
-        attempts = 1
+        attempts = main.minimumAttemptsNum
 
     # Check flows count in each node
     if utilities.retry( f=checkFlowsCount,
@@ -1296,8 +1299,9 @@
     if utilities.retry( f=scapyCheckConnection,
                         retValue=main.FALSE,
                         args=( main, senderNames, recipientNames, vlanId, useTCP ),
-                        attempts=attempts,
-                        sleep=main.checkConnectionSleep ):
+                        attempts=main.checkConnectionAttNum,
+                        sleep=main.checkConnectionSleep,
+                        getRetryingTime=True ):
         main.assertReturnString += 'Initial Ping Passed\n'
     else:
         main.assertReturnString += 'Initial Ping Failed\n'
@@ -1309,7 +1313,8 @@
         if utilities.retry( f=scapyCheckConnection,
                             retValue=main.FALSE,
                             args=( main, badSenderNames, recipientNames ),
-                            kwargs={ "expectFailure": True } ):
+                            kwargs={ "expectFailure": True },
+                            getRetryingTime=True ):
             main.assertReturnString += 'Bad Sender Ping Passed\n'
         else:
             main.assertReturnString += 'Bad Sender Ping Failed\n'
@@ -1320,7 +1325,8 @@
         if utilities.retry( f=scapyCheckConnection,
                             retValue=main.FALSE,
                             args=( main, senderNames, badRecipientNames ),
-                            kwargs={ "expectFailure": True } ):
+                            kwargs={ "expectFailure": True },
+                            getRetryingTime=True ):
             main.assertReturnString += 'Bad Recipient Ping Passed\n'
         else:
             main.assertReturnString += 'Bad Recipient Ping Failed\n'
@@ -1341,7 +1347,8 @@
             # Check Connection
             if utilities.retry( f=scapyCheckConnection,
                                 retValue=main.FALSE,
-                                args=( main, senderNames, recipientNames, vlanId, useTCP ) ):
+                                args=( main, senderNames, recipientNames, vlanId, useTCP ),
+                                getRetryingTime=True ):
                 main.assertReturnString += 'Link down Scapy Packet Received Passed\n'
             else:
                 main.assertReturnString += 'Link down Scapy Packet Recieved Failed\n'
@@ -1393,7 +1400,8 @@
                             retValue=main.FALSE,
                             args=( main, senderNames, recipientNames, vlanId, useTCP ),
                             sleep=main.checkConnectionSleep,
-                            attempts=attempts ):
+                            attempts=main.checkConnectionAttNum,
+                            getRetryingTime=True ):
             main.assertReturnString += 'Link Down Pingall Passed\n'
         else:
             main.assertReturnString += 'Link Down Pingall Failed\n'
@@ -1451,8 +1459,9 @@
         if utilities.retry( f=scapyCheckConnection,
                             retValue=main.FALSE,
                             sleep=main.checkConnectionSleep,
-                            attempts=attempts,
-                            args=( main, senderNames, recipientNames, vlanId, useTCP ) ):
+                            attempts=main.checkConnectionAttNum,
+                            args=( main, senderNames, recipientNames, vlanId, useTCP ),
+                            getRetryingTime=True ):
             main.assertReturnString += 'Link Up Scapy Packet Received Passed\n'
         else:
             main.assertReturnString += 'Link Up Scapy Packet Recieved Failed\n'
@@ -1461,7 +1470,7 @@
     # Remove all intents
     if utilities.retry( f=removeAllIntents,
                         retValue=main.FALSE,
-                        attempts=10,
+                        attempts=main.removeIntentAttNum,
                         args=( main, [ intentId ] ) ):
         main.assertReturnString += 'Remove Intents Passed'
     else:
@@ -1537,9 +1546,9 @@
 
     # Check intent state
     if singleToMultiFailFlag or multiToSingleFailFlag:
-        attempts = 1
+        attempts = main.minimumAttemptsNum
     else:
-        attempts = 50
+        attempts = main.generalAttemptsNum
 
     if utilities.retry( f=checkIntentState,
                         retValue=main.FALSE,
@@ -1550,7 +1559,7 @@
     else:
         main.assertReturnString += 'Initial Intent State Failed\n'
         testResult = main.FALSE
-        attempts = 1
+        attempts = main.minimumAttemptsNum
 
     # Check flows count in each node
     if utilities.retry( f=checkFlowsCount,
@@ -1568,7 +1577,8 @@
     # Check Connectivity
     if utilities.retry( f=scapyCheckConnection,
                         retValue=main.FALSE,
-                        args=( main, senderNames, recipientNames ) ):
+                        args=( main, senderNames, recipientNames ),
+                        getRetryingTime=True ):
         main.assertReturnString += 'Initial Connectivity Check Passed\n'
     else:
         main.assertReturnString += 'Initial Connectivity Check Failed\n'
@@ -1631,7 +1641,8 @@
     # Check Connection
     if utilities.retry( f=scapyCheckConnection,
                         retValue=main.FALSE,
-                        args=( main, senderNames, recipientNames ) ):
+                        args=( main, senderNames, recipientNames ),
+                        getRetryingTime=True ):
         main.assertReturnString += 'Link Down Connectivity Check Passed\n'
     else:
         main.assertReturnString += 'Link Down Connectivity Check Failed\n'
@@ -1714,8 +1725,9 @@
         # Next check connectivity of connected senders and recipients
         if utilities.retry( f=scapyCheckConnection,
                             retValue=main.FALSE,
-                            attempts=attempts,
-                            args=( main, connectedSenderNames, connectedRecipientNames ) ):
+                            attempts=main.checkConnectionAttNum,
+                            args=( main, connectedSenderNames, connectedRecipientNames ),
+                            getRetryingTime=True ):
             main.assertReturnString += 'Partial failure isolation link Down Connectivity Check Passed\n'
         else:
             main.assertReturnString += 'Partial failure isolation link Down Connectivity Check Failed\n'
@@ -1788,7 +1800,8 @@
         # Next check connectivity of connected senders and recipients
         if utilities.retry( f=scapyCheckConnection,
                             retValue=main.TRUE,
-                            args=( main, connectedSenderNames, connectedRecipientNames, None, None, None, None, main.TRUE ) ):
+                            args=( main, connectedSenderNames, connectedRecipientNames, None, None, None, None, main.TRUE ),
+                            getRetryingTime=True ):
             main.assertReturnString += 'Isolation link Down Connectivity Check Passed\n'
         else:
             main.assertReturnString += 'Isolation link Down Connectivity Check Failed\n'
@@ -1865,8 +1878,9 @@
     if utilities.retry( f=scapyCheckConnection,
                         retValue=main.FALSE,
                         sleep=main.checkConnectionSleep,
-                        attempts=attempts,
-                        args=( main, senderNames, recipientNames ) ):
+                        attempts=main.checkConnectionAttNum,
+                        args=( main, senderNames, recipientNames ),
+                        getRetryingTime=True ):
         main.assertReturnString += 'Link Up Scapy Packet Received Passed\n'
     else:
         main.assertReturnString += 'Link Up Scapy Packet Recieved Failed\n'
@@ -1875,7 +1889,7 @@
     # Remove all intents
     if utilities.retry( f=removeAllIntents,
                         retValue=main.FALSE,
-                        attempts=10,
+                        attempts=main.removeIntentAttNum,
                         args=( main, [ intentId ] ) ):
         main.assertReturnString += 'Remove Intents Passed'
     else:
diff --git a/TestON/tests/SCPF/SCPFflowTp1g/SCPFflowTp1g.py b/TestON/tests/SCPF/SCPFflowTp1g/SCPFflowTp1g.py
index 4244d79..72e8e59 100644
--- a/TestON/tests/SCPF/SCPFflowTp1g/SCPFflowTp1g.py
+++ b/TestON/tests/SCPF/SCPFflowTp1g/SCPFflowTp1g.py
@@ -309,4 +309,4 @@
 
         main.log.report( "Result line to file: " + resultString )
 
-        main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress, [ "ERROR", "WARNING", "EXCEPT" ], outputMode="d" )
+        main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress, [ "ERROR", "WARNING", "EXCEPT" ], outputMode="d" )
\ No newline at end of file