Disable traffic check for hosts under disconnected devices in CHO Test
Change-Id: I20f93f3b309154677563537eb7b78f06bbc56450
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" )