Merge "Improve SCPFintentEventTp test"
diff --git a/TestON/tests/CHOTestMonkey/dependencies/elements/ONOSElement.py b/TestON/tests/CHOTestMonkey/dependencies/elements/ONOSElement.py
index 6831811..17e9e73 100644
--- a/TestON/tests/CHOTestMonkey/dependencies/elements/ONOSElement.py
+++ b/TestON/tests/CHOTestMonkey/dependencies/elements/ONOSElement.py
@@ -33,7 +33,7 @@
self.default = ''
self.type = 'INTENT'
self.id = id
- self.expectedState = 'INSTALLED'
+ self.expectedState = 'UNKNOWN'
def isHostIntent( self ):
return self.type == 'INTENT_HOST'
@@ -47,12 +47,6 @@
def isInstalled( self ):
return self.expectedState == 'INSTALLED'
- def setFailed( self ):
- self.expectedState = 'FAILED'
-
- def setInstalled( self ):
- self.expectedState = 'INSTALLED'
-
class HostIntent( Intent ):
def __init__( self, id, hostA, hostB ):
Intent.__init__( self, id )
@@ -62,6 +56,28 @@
self.deviceA = hostA.device
self.deviceB = hostB.device
+ def setWithdrawn( self ):
+ self.expectedState = 'WITHDRAWN'
+ # TODO: should we check whether hostA and hostB are made correspondents by other intents/flows?
+ if self.hostB in self.hostA.correspondents:
+ self.hostA.correspondents.remove( self.hostB )
+ if self.hostA in self.hostB.correspondents:
+ self.hostB.correspondents.remove( self.hostA )
+
+ def setFailed( self ):
+ self.expectedState = 'FAILED'
+ # TODO: should we check whether hostA and hostB are made correspondents by other intents/flows?
+ if self.hostB in self.hostA.correspondents:
+ self.hostA.correspondents.remove( self.hostB )
+ if self.hostA in self.hostB.correspondents:
+ self.hostB.correspondents.remove( self.hostA )
+
+ def setInstalled( self ):
+ self.expectedState = 'INSTALLED'
+ # TODO: should we check whether hostA and hostB are already correspondents?
+ self.hostA.correspondents.append( self.hostB )
+ self.hostB.correspondents.append( self.hostA )
+
def __str__( self ):
return "ID: " + self.id
@@ -72,5 +88,25 @@
self.deviceA = deviceA
self.deviceB = deviceB
+ def setWithdrawn( self ):
+ self.expectedState = 'WITHDRAWN'
+ for hostA in self.deviceA.hosts:
+ for hostB in self.deviceB.hosts:
+ if hostB in hostA.correspondents:
+ hostA.correspondents.remove( hostB )
+
+ def setFailed( self ):
+ self.expectedState = 'FAILED'
+ for hostA in self.deviceA.hosts:
+ for hostB in self.deviceB.hosts:
+ if hostB in hostA.correspondents:
+ hostA.correspondents.remove( hostB )
+
+ def setInstalled( self ):
+ self.expectedState = 'INSTALLED'
+ for hostA in self.deviceA.hosts:
+ for hostB in self.deviceB.hosts:
+ hostA.correspondents.append( hostB )
+
def __str__( self ):
return "ID: " + self.id
diff --git a/TestON/tests/CHOTestMonkey/dependencies/events/AppEvent.py b/TestON/tests/CHOTestMonkey/dependencies/events/AppEvent.py
index 8113b09..adcbfdc 100644
--- a/TestON/tests/CHOTestMonkey/dependencies/events/AppEvent.py
+++ b/TestON/tests/CHOTestMonkey/dependencies/events/AppEvent.py
@@ -144,11 +144,9 @@
newHostIntent = HostIntent( id, self.hostA, self.hostB )
if self.hostA.isDown() or self.hostA.isRemoved() or self.hostB.isDown() or self.hostB.isRemoved():
newHostIntent.setFailed()
+ else:
+ newHostIntent.setInstalled()
main.intents.append( newHostIntent )
- # Update host connectivity status
- # TODO: should we check whether hostA and hostB are already correspondents?
- self.hostB.correspondents.append( self.hostA )
- self.hostA.correspondents.append( self.hostB )
return EventStates().PASS
except Exception:
main.log.warn( "Caught exception, aborting event" )
@@ -184,10 +182,8 @@
main.log.warn( self.typeString + " - delete host intent failed" )
return EventStates().FAIL
with main.variableLock:
+ targetIntent.setWithdrawn()
main.intents.remove( targetIntent )
- # Update host connectivity status
- self.hostB.correspondents.remove( self.hostA )
- self.hostA.correspondents.remove( self.hostB )
return EventStates().PASS
except Exception:
main.log.warn( "Caught exception, aborting event" )
@@ -304,11 +300,9 @@
newPointIntent = PointIntent( id, self.deviceA, self.deviceB )
if self.deviceA.isDown() or self.deviceB.isDown() or self.deviceA.isRemoved() or self.deviceB.isRemoved():
newPointIntent.setFailed()
+ else:
+ newPointIntent.setInstalled()
main.intents.append( newPointIntent )
- # Update host connectivity status
- for hostA in self.deviceA.hosts:
- for hostB in self.deviceB.hosts:
- hostA.correspondents.append( hostB )
return EventStates().PASS
except Exception:
main.log.warn( "Caught exception, aborting event" )
@@ -343,11 +337,8 @@
main.log.warn( self.typeString + " - delete point intent failed" )
return EventStates().FAIL
with main.variableLock:
+ targetIntent.setWithdrawn()
main.intents.remove( targetIntent )
- # Update host connectivity status
- for hostA in self.deviceA.hosts:
- for hostB in self.deviceB.hosts:
- hostA.correspondents.remove( hostB )
return EventStates().PASS
except Exception:
main.log.warn( "Caught exception, aborting event" )
diff --git a/TestON/tests/FUNC/FUNCintent/FUNCintent.py b/TestON/tests/FUNC/FUNCintent/FUNCintent.py
index ba0f2a9..167a847 100644
--- a/TestON/tests/FUNC/FUNCintent/FUNCintent.py
+++ b/TestON/tests/FUNC/FUNCintent/FUNCintent.py
@@ -670,9 +670,8 @@
stepResult = main.TRUE
scpResult = main.TRUE
copyResult = main.TRUE
- i = 0
- for cli in main.CLIs:
- main.node = cli
+ for i in range( main.numCtrls ):
+ main.node = main.CLIs[ i ]
ip = main.ONOSip[ i ]
main.node.ip_address = ip
scpResult = scpResult and main.ONOSbench.scp( main.node ,
@@ -685,7 +684,6 @@
stepResult = main.TRUE and stepResult
else:
stepResult = main.FALSE and stepResult
- i += 1
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
onpass="Successfully copied remote ONOS logs",
diff --git a/TestON/tests/FUNC/FUNCintentRest/FUNCintentRest.py b/TestON/tests/FUNC/FUNCintentRest/FUNCintentRest.py
index 51ad5b1..3824ea3 100644
--- a/TestON/tests/FUNC/FUNCintentRest/FUNCintentRest.py
+++ b/TestON/tests/FUNC/FUNCintentRest/FUNCintentRest.py
@@ -785,9 +785,8 @@
stepResult = main.TRUE
scpResult = main.TRUE
copyResult = main.TRUE
- i = 0
- for cli in main.CLIs2:
- main.node = cli
+ for i in range( main.numCtrls ):
+ main.node = main.CLIs2[ i ]
ip = main.ONOSip[ i ]
main.node.ip_address = ip
scpResult = scpResult and main.ONOSbench.scp( main.node ,
@@ -800,7 +799,6 @@
stepResult = main.TRUE and stepResult
else:
stepResult = main.FALSE and stepResult
- i += 1
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
onpass="Successfully copied remote ONOS logs",
diff --git a/TestON/tests/FUNC/FUNCnetconf/FUNCnetconf.py b/TestON/tests/FUNC/FUNCnetconf/FUNCnetconf.py
index 94fd0ef..967dea5 100644
--- a/TestON/tests/FUNC/FUNCnetconf/FUNCnetconf.py
+++ b/TestON/tests/FUNC/FUNCnetconf/FUNCnetconf.py
@@ -269,9 +269,8 @@
stepResult = main.TRUE
scpResult = main.TRUE
copyResult = main.TRUE
- i = 0
- for cli in main.CLIs2:
- main.node = cli
+ for i in range( main.numCtrls ):
+ main.node = main.CLIs[ i ]
ip = main.ONOSip[ i ]
main.node.ip_address = ip
scpResult = scpResult and main.ONOSbench.scp( main.node ,
@@ -284,9 +283,6 @@
stepResult = main.TRUE and stepResult
else:
stepResult = main.FALSE and stepResult
- i += 1
- if main.numCtrls == 1:
- break
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
onpass="Successfully copied remote ONOS logs",
diff --git a/TestON/tests/FUNC/FUNCoptical/FUNCoptical.py b/TestON/tests/FUNC/FUNCoptical/FUNCoptical.py
index 137ce44..2c4b0ca 100644
--- a/TestON/tests/FUNC/FUNCoptical/FUNCoptical.py
+++ b/TestON/tests/FUNC/FUNCoptical/FUNCoptical.py
@@ -327,9 +327,8 @@
stepResult = main.TRUE
scpResult = main.TRUE
copyResult = main.TRUE
- i = 0
- for cli in main.CLIs:
- main.node = cli
+ for i in range( main.numCtrls ):
+ main.node = main.CLIs[ i ]
ip = main.ONOSip[ i ]
main.node.ip_address = ip
scpResult = scpResult and main.ONOSbench.scp( main.node ,
@@ -342,7 +341,6 @@
stepResult = main.TRUE and stepResult
else:
stepResult = main.FALSE and stepResult
- i += 1
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
onpass="Successfully copied remote ONOS logs",
diff --git a/TestON/tests/USECASE/SegmentRouting/dependencies/Testcaselib.py b/TestON/tests/USECASE/SegmentRouting/dependencies/Testcaselib.py
index 37c68c0..c1efd93 100755
--- a/TestON/tests/USECASE/SegmentRouting/dependencies/Testcaselib.py
+++ b/TestON/tests/USECASE/SegmentRouting/dependencies/Testcaselib.py
@@ -84,7 +84,6 @@
apps = main.apps + "," + main.diff
else:
main.log.error( "App list is empty" )
- main.case( "Package and start ONOS using apps:" + apps )
print "NODE COUNT = ", main.numCtrls
print main.ONOSip
tempOnosIp = [ ]