Record events scheduled in CHOTestMonkey and enable replay from
recorded event file
Change-Id: If73eb743e19565ff8a91ac0b54eb18d8706be831
diff --git a/TestON/tests/CHOTestMonkey/dependencies/EventTrigger.py b/TestON/tests/CHOTestMonkey/dependencies/EventTrigger.py
index 0c3e0e0..27b8166 100644
--- a/TestON/tests/CHOTestMonkey/dependencies/EventTrigger.py
+++ b/TestON/tests/CHOTestMonkey/dependencies/EventTrigger.py
@@ -15,7 +15,7 @@
address = ( host, port )
conn = Client( address )
request = []
- request.append( 2 )
+ request.append( 1 )
request.append( type )
request.append( scheduleMethod )
for arg in args:
@@ -23,7 +23,9 @@
conn.send( request )
response = conn.recv()
while response == 11:
+ conn.close()
time.sleep( 1 )
+ conn = Client( address )
conn.send( request )
response = conn.recv()
if response == 10:
@@ -64,5 +66,19 @@
else:
pass
+def replayFromFile( filePath='/home/admin/event-list', sleepTime=1 ):
+ try:
+ f = open( filePath, 'r' )
+ for line in f.readlines():
+ event = line.split()
+ if event[ 3 ].startswith( 'CHECK' ):
+ continue
+ triggerEvent( event[ 3 ], 'RUN_BLOCK', *event[ 4: ] )
+ time.sleep( sleepTime )
+ f.close()
+ except Exception as e:
+ print e
+
if __name__ == '__main__':
- testLoop( 2 )
+ #testLoop( 2 )
+ replayFromFile()
diff --git a/TestON/tests/CHOTestMonkey/dependencies/events/AppEvent.py b/TestON/tests/CHOTestMonkey/dependencies/events/AppEvent.py
index 07c8cb6..4283ff6 100644
--- a/TestON/tests/CHOTestMonkey/dependencies/events/AppEvent.py
+++ b/TestON/tests/CHOTestMonkey/dependencies/events/AppEvent.py
@@ -63,7 +63,7 @@
def startEvent( self, args ):
with self.eventLock:
- main.log.info( "%s - starting event" % ( self.typeString ) )
+ #main.log.info( "%s - starting event" % ( self.typeString ) )
if self.typeIndex == EventType().APP_INTENT_HOST_ADD or self.typeIndex == EventType().APP_INTENT_HOST_DEL:
if len( args ) < 3:
main.log.warn( "%s - Not enough arguments: %s" % ( self.typeString, args ) )
@@ -138,6 +138,7 @@
intent.hostB == self.hostA and intent.hostA == self.hostB:
main.log.warn( self.typeString + " - find an exiting intent for the host pair, abort installation" )
return EventStates().ABORT
+ main.log.info( "Event recorded: {} {} {} {} {}".format( self.typeIndex, self.typeString, self.hostA.name, self.hostB.name, self.CLIIndex ) )
controller = main.controllers[ self.CLIIndex - 1 ]
with controller.CLILock:
id = controller.CLI.addHostIntent( self.hostA.id, self.hostB.id )
@@ -179,6 +180,7 @@
if targetIntent == None:
main.log.warn( self.typeString + " - intent does not exist" )
return EventStates().FAIL
+ main.log.info( "Event recorded: {} {} {} {} {}".format( self.typeIndex, self.typeString, self.hostA.name, self.hostB.name, self.CLIIndex ) )
controller = main.controllers[ self.CLIIndex - 1 ]
with controller.CLILock:
result = controller.CLI.removeIntent( targetIntent.id, purge=True )
@@ -204,7 +206,7 @@
def startEvent( self, args ):
with self.eventLock:
- main.log.info( "%s - starting event" % ( self.typeString ) )
+ #main.log.info( "%s - starting event" % ( self.typeString ) )
if self.typeIndex == EventType().APP_INTENT_POINT_ADD or self.typeIndex == EventType().APP_INTENT_POINT_DEL:
if len( args ) < 3:
main.log.warn( "%s - Not enough arguments: %s" % ( self.typeString, args ) )
@@ -290,6 +292,7 @@
if intent.deviceA == self.deviceA and intent.deviceB == self.deviceB:
main.log.warn( self.typeString + " - find an exiting intent for the device pair, abort installation" )
return EventStates().ABORT
+ main.log.info( "Event recorded: {} {} {} {} {}".format( self.typeIndex, self.typeString, self.deviceA.name, self.deviceB.name, self.CLIIndex ) )
controller = main.controllers[ self.CLIIndex - 1 ]
with controller.CLILock:
srcMAC = ""
@@ -336,6 +339,7 @@
if targetIntent == None:
main.log.warn( self.typeString + " - intent does not exist" )
return EventStates().FAIL
+ main.log.info( "Event recorded: {} {} {} {} {}".format( self.typeIndex, self.typeString, self.deviceA.name, self.deviceB.name, self.CLIIndex ) )
controller = main.controllers[ self.CLIIndex - 1 ]
with controller.CLILock:
result = controller.CLI.removeIntent( targetIntent.id, purge=True )
diff --git a/TestON/tests/CHOTestMonkey/dependencies/events/CheckEvent.py b/TestON/tests/CHOTestMonkey/dependencies/events/CheckEvent.py
index fcbf23d..fa42e12 100755
--- a/TestON/tests/CHOTestMonkey/dependencies/events/CheckEvent.py
+++ b/TestON/tests/CHOTestMonkey/dependencies/events/CheckEvent.py
@@ -13,7 +13,7 @@
def startEvent( self, args ):
with self.eventLock:
- main.log.info( "%s - starting event" % ( self.typeString ) )
+ main.log.info( "Event recorded: {} {}".format( self.typeIndex, self.typeString ) )
result = self.startCheckEvent()
return result
diff --git a/TestON/tests/CHOTestMonkey/dependencies/events/NetworkEvent.py b/TestON/tests/CHOTestMonkey/dependencies/events/NetworkEvent.py
index 8ec62a1..ccab8a1 100644
--- a/TestON/tests/CHOTestMonkey/dependencies/events/NetworkEvent.py
+++ b/TestON/tests/CHOTestMonkey/dependencies/events/NetworkEvent.py
@@ -19,7 +19,7 @@
args are the names of the two link ends, e.g. ['s1', 's2']
"""
with self.eventLock:
- main.log.info( "%s - starting event" % ( self.typeString ) )
+ #main.log.info( "%s - starting event" % ( self.typeString ) )
if len( args ) < 2:
main.log.warn( "%s - Not enough arguments: %s" % ( self.typeString, args ) )
return EventStates().ABORT
@@ -84,6 +84,7 @@
elif self.linkA.isRemoved() or self.linkB.isRemoved():
main.log.warn( "Link Down - link has been removed" )
return EventStates().ABORT
+ main.log.info( "Event recorded: {} {} {} {}".format( self.typeIndex, self.typeString, self.linkA.deviceA.name, self.linkA.deviceB.name ) )
with main.mininetLock:
'''
result = main.Mininet1.link( END1=self.linkA.deviceA.name,
@@ -118,6 +119,7 @@
if self.linkA.isRemoved() or self.linkB.isRemoved():
main.log.warn( "Link Up - link has been removed" )
return EventStates().ABORT
+ main.log.info( "Event recorded: {} {} {} {}".format( self.typeIndex, self.typeString, self.linkA.deviceA.name, self.linkA.deviceB.name ) )
with main.mininetLock:
'''
result = main.Mininet1.link( END1=self.linkA.deviceA.name,
@@ -147,7 +149,7 @@
args are the names of the device, e.g. 's1'
"""
with self.eventLock:
- main.log.info( "%s - starting event" % ( self.typeString ) )
+ #main.log.info( "%s - starting event" % ( self.typeString ) )
if len( args ) < 1:
main.log.warn( "%s - Not enough arguments: %s" % ( self.typeString, args ) )
return EventStates().ABORT
@@ -199,6 +201,7 @@
if self.device.isRemoved():
main.log.warn( "Device Down - device has been removed" )
return EventStates().ABORT
+ main.log.info( "Event recorded: {} {} {}".format( self.typeIndex, self.typeString, self.device.name ) )
with main.mininetLock:
result = main.Mininet1.delSwitch( self.device.name )
if not result:
@@ -232,6 +235,7 @@
main.log.warn( "Device Up - device already up" )
return EventStates().ABORT
# Re-add the device
+ main.log.info( "Event recorded: {} {} {}".format( self.typeIndex, self.typeString, self.device.name ) )
with main.mininetLock:
result = main.Mininet1.addSwitch( self.device.name, dpid=self.device.dpid[3:] )
if not result:
diff --git a/TestON/tests/CHOTestMonkey/dependencies/events/ONOSEvent.py b/TestON/tests/CHOTestMonkey/dependencies/events/ONOSEvent.py
index f4e2a89..28960d2 100644
--- a/TestON/tests/CHOTestMonkey/dependencies/events/ONOSEvent.py
+++ b/TestON/tests/CHOTestMonkey/dependencies/events/ONOSEvent.py
@@ -11,7 +11,7 @@
def startEvent( self, args ):
with self.eventLock:
- main.log.info( "%s - starting event" % ( self.typeString ) )
+ #main.log.info( "%s - starting event" % ( self.typeString ) )
result = EventStates().PASS
if self.typeIndex == EventType().ONOS_ONOS_DOWN or self.typeIndex == EventType().ONOS_ONOS_UP:
if len( args ) < 1:
@@ -42,6 +42,7 @@
if not main.controllers[ self.ONOSIndex - 1 ].isUp():
main.log.warn( "ONOS Down - ONOS already down" )
return EventStates().ABORT
+ main.log.info( "Event recorded: {} {} {}".format( self.typeIndex, self.typeString, self.ONOSIndex ) )
with main.ONOSbenchLock:
result = main.ONOSbench.onosStop( main.controllers[ self.ONOSIndex - 1 ].ip )
if not result:
@@ -63,6 +64,7 @@
if main.controllers[ self.ONOSIndex - 1 ].isUp():
main.log.warn( "ONOS Up - ONOS already up" )
return EventStates().ABORT
+ main.log.info( "Event recorded: {} {} {}".format( self.typeIndex, self.typeString, self.ONOSIndex ) )
with main.ONOSbenchLock:
startResult = main.ONOSbench.onosStart( main.controllers[ self.ONOSIndex - 1 ].ip )
if not startResult:
@@ -92,7 +94,7 @@
def startEvent( self, args ):
with self.eventLock:
- main.log.info( "%s - starting event" % ( self.typeString ) )
+ #main.log.info( "%s - starting event" % ( self.typeString ) )
result = self.startCfgEvent( args )
return result
@@ -121,6 +123,7 @@
if index == -1:
main.log.warn( "%s - No available controllers" %s ( self.typeString ) )
return EventStates().ABORT
+ main.log.info( "Event recorded: {} {} {} {} {}".format( self.typeIndex, self.typeString, self.component, self.propName, self.value ) )
controller = main.controllers[ index - 1 ]
with controller.CLILock:
result = controller.CLI.setCfg( component=self.component,
@@ -158,6 +161,7 @@
if index == -1:
main.log.warn( "%s - No available controllers" %s ( self.typeString ) )
return EventStates().ABORT
+ main.log.info( "Event recorded: {} {} {} {} {}".format( self.typeIndex, self.typeString, self.component, self.propName, self.value ) )
controller = main.controllers[ index - 1 ]
with controller.CLILock:
result = controller.CLI.setCfg( component=self.component,
@@ -184,6 +188,7 @@
if index == -1:
main.log.warn( "%s - No available controllers" %s ( self.typeString ) )
return EventStates().ABORT
+ main.log.info( "Event recorded: {} {}".format( self.typeIndex, self.typeString ) )
controller = main.controllers[ index - 1 ]
with controller.CLILock:
result = controller.CLI.balanceMasters()