Merge "Added try catches in dependency functions"
diff --git a/TestON/tests/SCPFmaxIntents/Dependency/maxIntentFunctions.py b/TestON/tests/SCPFmaxIntents/Dependency/maxIntentFunctions.py
index 55a5478..128ef6b 100644
--- a/TestON/tests/SCPFmaxIntents/Dependency/maxIntentFunctions.py
+++ b/TestON/tests/SCPFmaxIntents/Dependency/maxIntentFunctions.py
@@ -4,35 +4,47 @@
import json
import time
+import pexpect
def __init__( self ):
self.default = ""
def getIntents( main, state="INSTALLED", sleep=1, timeout=120 ):
- cmd = "intents | grep " + state + " | wc -l"
- main.log.info("Sending: " + cmd)
- main.CLIs[0].handle.sendline(cmd)
+ intents = 0
+ try:
+ cmd = "intents | grep " + state + " | wc -l"
+ main.log.info("Sending: " + cmd)
+ main.CLIs[0].handle.sendline(cmd)
- time.sleep(sleep)
+ time.sleep(sleep)
- main.CLIs[0].handle.expect("onos>", timeout=timeout)
- raw = main.CLIs[0].handle.before
- intents = int(main.CLIs[0].handle.before.split()[7])
- main.log.info(state + "intents: " + str(intents))
+ main.CLIs[0].handle.expect("onos>", timeout=timeout)
+ raw = main.CLIs[0].handle.before
+ intents = int(main.CLIs[0].handle.before.split()[7])
+ main.log.info(state + "intents: " + str(intents))
+ except pexpect.TIMEOUT:
+ main.log.exception("Timeout exception found")
+ except pexpect.EOF:
+ main.log.error("EOF exception found")
return intents
-
def getFlows( main, state="ADDED", sleep=1, timeout=120 ):
- cmd = "flows | grep " + state + " | wc -l"
- main.log.info("Sending: " + cmd)
- main.CLIs[0].handle.sendline(cmd)
+ flows = 0
+ try:
+ cmd = "flows | grep " + state + " | wc -l"
+ main.log.info("Sending: " + cmd)
+ main.CLIs[0].handle.sendline(cmd)
- time.sleep(sleep)
+ time.sleep(sleep)
- main.CLIs[0].handle.expect("onos>", timeout=timeout)
- raw = main.CLIs[0].handle.before
- flows = int(main.CLIs[0].handle.before.split()[7])
- main.log.info(state + "flows: " + str(flows))
+ main.CLIs[0].handle.expect("onos>", timeout=timeout)
+ raw = main.CLIs[0].handle.before
+ flows = int(main.CLIs[0].handle.before.split()[7])
+ main.log.info(state + "flows: " + str(flows))
+ except pexpect.TIMEOUT:
+ main.log.exception("Timeout exception found")
+ except pexpect.EOF:
+ main.log.error("EOF exception found")
return flows
@@ -46,20 +58,25 @@
options="",
timeout=120):
'''
- Description
+ Pushes intents using the push-test-intents cli command.
'''
- cmd = "push-test-intents " + options + " " + switch + ingress + " " +\
- switch + egress + " " + str(batch) + " " + str(offset)
- main.log.info("Installing " + str(offset+batch) + " intents")
- main.log.debug("Sending: " + cmd)
- main.CLIs[0].handle.sendline(cmd)
- time.sleep(sleep)
- main.CLIs[0].handle.expect("onos>", timeout=timeout)
+ try:
+ cmd = "push-test-intents " + options + " " + switch + ingress + " " +\
+ switch + egress + " " + str(batch) + " " + str(offset)
+ main.log.info("Installing " + str(offset+batch) + " intents")
+ main.log.debug("Sending: " + cmd)
+ main.CLIs[0].handle.sendline(cmd)
+ time.sleep(sleep)
+ main.CLIs[0].handle.expect("onos>", timeout=timeout)
- raw = main.CLIs[0].handle.before
- if "Failure:" in raw or "GC" in raw:
- return main.FALSE
- return main.TRUE
+ raw = main.CLIs[0].handle.before
+ if "Failure:" not in raw and "GC" not in raw:
+ return main.TRUE
+ except pexpect.TIMEOUT:
+ main.log.exception("Timeout exception found")
+ except pexpect.EOF:
+ main.log.error("EOF exception found")
+ return main.FALSE
def verifyFlows( main, expectedFlows, state="ADDED", sleep=1, timeout=120):
'''
diff --git a/TestON/tests/SCPFmaxIntents/SCPFmaxIntents.params b/TestON/tests/SCPFmaxIntents/SCPFmaxIntents.params
index 325ca7f..b0df3e9 100755
--- a/TestON/tests/SCPFmaxIntents/SCPFmaxIntents.params
+++ b/TestON/tests/SCPFmaxIntents/SCPFmaxIntents.params
@@ -49,7 +49,7 @@
<TEST>
<batch_size>1000</batch_size>
<min_intents>500000</min_intents>
- <max_intents>1000000</max_intents>
+ <max_intents>3000</max_intents>
<check_interval>10000</check_interval>
</TEST>
diff --git a/TestON/tests/SCPFmaxIntents/SCPFmaxIntents.py b/TestON/tests/SCPFmaxIntents/SCPFmaxIntents.py
index 2fafc1e..9766db0 100644
--- a/TestON/tests/SCPFmaxIntents/SCPFmaxIntents.py
+++ b/TestON/tests/SCPFmaxIntents/SCPFmaxIntents.py
@@ -54,6 +54,8 @@
main.rerouteSleep = int ( main.params['SLEEP']['reroute'] )
gitPull = main.params[ 'GIT' ][ 'pull' ]
main.batchSize = int(main.params['TEST']['batch_size'])
+ nic = main.params['DATABASE']['nic']
+ node = main.params['DATABASE']['node']
main.cellData = {} # for creating cell file
main.CLIs = []
main.ONOSip = []
@@ -157,6 +159,7 @@
main.log.info("Creating DB file")
nic = main.params['DATABASE']['nic']
node = main.params['DATABASE']['node']
+
try:
dbFileName="/tmp/MaxIntentDB"
dbfile = open(dbFileName, "w+")
@@ -344,64 +347,61 @@
expectedFlows = main.defaultFlows
# limit for the number of intents that can be installed
limit = main.maxIntents / main.batchSize
- try:
- for i in range(limit):
- # Push intents
- main.log.step("Pushing intents")
- stepResult = main.intentFunctions.pushIntents( main,
- main.switch,
- main.ingress,
- main.egress,
- main.batchSize,
- offset,
- sleep=main.installSleep,
- timeout=main.timeout,
- options="-i" )
+
+ for i in range(limit):
+ # Push intents
+ main.log.step("Pushing intents")
+ stepResult = main.intentFunctions.pushIntents( main,
+ main.switch,
+ main.ingress,
+ main.egress,
+ main.batchSize,
+ offset,
+ sleep=main.installSleep,
+ timeout=main.timeout,
+ options="-i" )
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully pushed intents",
+ onfail="Failed to push intents")
+ if stepResult == main.FALSE:
+ break
+
+ offset += main.batchSize
+ expectedIntents = offset
+ expectedFlows += main.batchSize*2
+
+ if offset >= main.minIntents and offset % main.checkInterval == 0:
+ # Verifying intents
+ main.log.step("Verifying intents")
+ main.log.info("Expected intents: " + str(expectedIntents))
+ stepResult = main.intentFunctions.verifyIntents( main,
+ expectedIntents,
+ sleep=main.verifySleep,
+ timeout=main.timeout)
utilities.assert_equals( expect=main.TRUE,
- actual=stepResult,
- onpass="Successfully pushed intents",
- onfail="Failed to push intents")
+ actual=stepResult,
+ onpass="Successfully verified intents",
+ onfail="Failed to verify intents")
+
if stepResult == main.FALSE:
break
- offset += main.batchSize
- expectedIntents = offset
- expectedFlows += main.batchSize*2
+ # Verfying flows
+ main.log.step("Verifying flows")
+ main.log.info("Expected Flows: " + str(expectedFlows))
+ stepResult = main.intentFunctions.verifyFlows( main,
+ expectedFlows,
+ sleep=main.verifySleep,
+ timeout=main.timeout)
- if offset >= main.minIntents and offset % main.checkInterval == 0:
- # Verifying intents
- main.log.step("Verifying intents")
- main.log.info("Expected intents: " + str(expectedIntents))
- stepResult = main.intentFunctions.verifyIntents( main,
- expectedIntents,
- sleep=main.verifySleep,
- timeout=main.timeout)
- utilities.assert_equals( expect=main.TRUE,
- actual=stepResult,
- onpass="Successfully verified intents",
- onfail="Failed to verify intents")
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully verified flows",
+ onfail="Failed to verify flows")
- if stepResult == main.FALSE:
- break
-
- # Verfying flows
- main.log.step("Verifying flows")
- main.log.info("Expected Flows: " + str(expectedFlows))
- stepResult = main.intentFunctions.verifyFlows( main,
- expectedFlows,
- sleep=main.verifySleep,
- timeout=main.timeout)
-
- utilities.assert_equals( expect=main.TRUE,
- actual=stepResult,
- onpass="Successfully verified flows",
- onfail="Failed to verify flows")
-
- if stepResult == main.FALSE:
- break
-
- except pexpect.TIMEOUT:
- main.log.exception("Timeout exception caught")
+ if stepResult == main.FALSE:
+ break
maxIntents = main.intentFunctions.getIntents( main )
maxFlows = main.intentFunctions.getFlows( main )
@@ -441,104 +441,101 @@
expectedFlows = main.defaultFlows
# limit for the number of intents that can be installed
limit = main.maxIntents / main.batchSize
- try:
- for i in range(limit):
- # Push intents
- main.log.step("Pushing intents")
- stepResult = main.intentFunctions.pushIntents( main,
- main.switch,
- main.ingress,
- main.egress,
- main.batchSize,
- offset,
- sleep=main.installSleep,
- options="-i",
- timeout=main.timeout )
- utilities.assert_equals( expect=main.TRUE,
+
+ for i in range(limit):
+ # Push intents
+ main.log.step("Pushing intents")
+ stepResult = main.intentFunctions.pushIntents( main,
+ main.switch,
+ main.ingress,
+ main.egress,
+ main.batchSize,
+ offset,
+ sleep=main.installSleep,
+ options="-i",
+ timeout=main.timeout )
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully pushed intents",
+ onfail="Failed to push intents")
+ if stepResult == main.FALSE:
+ break
+
+ offset += main.batchSize
+ expectedIntents = offset
+ expectedFlows += main.batchSize*2
+
+ # Verifying intents
+ main.log.step("Verifying intents")
+ main.log.info("Expected intents: " + str(expectedIntents))
+ stepResult = main.intentFunctions.verifyIntents( main,
+ expectedIntents,
+ sleep=main.verifySleep,
+ timeout=main.timeout )
+ utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
- onpass="Successfully pushed intents",
- onfail="Failed to push intents")
- if stepResult == main.FALSE:
- break
+ onpass="Successfully verified intents",
+ onfail="Failed to verify intents")
- offset += main.batchSize
- expectedIntents = offset
- expectedFlows += main.batchSize*2
+ if stepResult == main.FALSE:
+ break
- # Verifying intents
- main.log.step("Verifying intents")
- main.log.info("Expected intents: " + str(expectedIntents))
- stepResult = main.intentFunctions.verifyIntents( main,
- expectedIntents,
- sleep=main.verifySleep,
- timeout=main.timeout )
- utilities.assert_equals( expect=main.TRUE,
- actual=stepResult,
- onpass="Successfully verified intents",
- onfail="Failed to verify intents")
+ # Verfying flows
+ main.log.step("Verifying flows")
+ main.log.info("Expected Flows: " + str(expectedFlows))
+ stepResult = main.intentFunctions.verifyFlows( main,
+ expectedFlows,
+ sleep=main.verifySleep,
+ timeout=main.timeout )
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully verified flows",
+ onfail="Failed to verify flows")
- if stepResult == main.FALSE:
- break
+ if stepResult == main.FALSE:
+ break
- # Verfying flows
- main.log.step("Verifying flows")
- main.log.info("Expected Flows: " + str(expectedFlows))
- stepResult = main.intentFunctions.verifyFlows( main,
- expectedFlows,
- sleep=main.verifySleep,
- timeout=main.timeout )
- utilities.assert_equals( expect=main.TRUE,
- actual=stepResult,
- onpass="Successfully verified flows",
- onfail="Failed to verify flows")
+ # tear down a link
+ main.log.step("Tearing down link")
+ if main.switch == "of":
+ main.log.info("Sending: " + main.linkDownCmd)
+ main.Mininet1.handle.sendline(main.linkDownCmd)
+ main.Mininet1.handle.expect('mininet>')
+ else:
+ main.log.info("Sending: " + main.linkDownCmd)
+ main.CLIs[0].handle.sendline(main.linkDownCmd)
+ main.CLIs[0].handle.expect('onos>')
+ time.sleep(main.rerouteSleep)
- if stepResult == main.FALSE:
- break
+ # rerouting adds a 1000 flows
+ expectedFlows += 1000
- # tear down a link
- main.log.step("Tearing down link")
- if main.switch == "of":
- main.log.info("Sending: " + main.linkDownCmd)
- main.Mininet1.handle.sendline(main.linkDownCmd)
- main.Mininet1.handle.expect('mininet>')
- else:
- main.log.info("Sending: " + main.linkDownCmd)
- main.CLIs[0].handle.sendline(main.linkDownCmd)
- main.CLIs[0].handle.expect('onos>')
- time.sleep(main.rerouteSleep)
+ # Verfying flows
+ main.log.step("Verifying flows")
+ main.log.info("Expected Flows: " + str(expectedFlows))
+ stepResult = main.intentFunctions.verifyFlows( main,
+ expectedFlows,
+ sleep=main.verifySleep,
+ timeout=main.timeout)
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully verified flows",
+ onfail="Failed to verify flows")
- # rerouting adds a 1000 flows
- expectedFlows += 1000
+ if stepResult == main.FALSE:
+ break
- # Verfying flows
- main.log.step("Verifying flows")
- main.log.info("Expected Flows: " + str(expectedFlows))
- stepResult = main.intentFunctions.verifyFlows( main,
- expectedFlows,
- sleep=main.verifySleep,
- timeout=main.timeout)
- utilities.assert_equals( expect=main.TRUE,
- actual=stepResult,
- onpass="Successfully verified flows",
- onfail="Failed to verify flows")
-
- if stepResult == main.FALSE:
- break
-
- # Bring link back up
- main.log.step("Tearing down link")
- if main.switch == "of":
- main.log.info("Sending: " + main.linkUpCmd)
- main.Mininet1.handle.sendline(main.linkUpCmd)
- main.Mininet1.handle.expect('mininet>')
- else:
- main.log.info("Sending: " + main.linkUpCmd)
- main.CLIs[0].handle.sendline(main.linkUpCmd)
- main.CLIs[0].handle.expect('onos>')
- time.sleep(main.rerouteSleep)
-
- except pexpect.TIMEOUT:
- main.log.exception("Timeout exception caught")
+ # Bring link back up
+ main.log.step("Tearing down link")
+ if main.switch == "of":
+ main.log.info("Sending: " + main.linkUpCmd)
+ main.Mininet1.handle.sendline(main.linkUpCmd)
+ main.Mininet1.handle.expect('mininet>')
+ else:
+ main.log.info("Sending: " + main.linkUpCmd)
+ main.CLIs[0].handle.sendline(main.linkUpCmd)
+ main.CLIs[0].handle.expect('onos>')
+ time.sleep(main.rerouteSleep)
maxIntents = main.intentFunctions.getIntents( main )
maxFlows = main.intentFunctions.getFlows( main )