Run codecheck script on CHOTestMonkey
Change-Id: I11047f1b4c6ecd8273695c230d3a4a99475a6db6
diff --git a/TestON/tests/CHOTestMonkey/CHOTestMonkey.py b/TestON/tests/CHOTestMonkey/CHOTestMonkey.py
index 9d8e0d6..7113508 100644
--- a/TestON/tests/CHOTestMonkey/CHOTestMonkey.py
+++ b/TestON/tests/CHOTestMonkey/CHOTestMonkey.py
@@ -2,7 +2,6 @@
CHOTestMonkey class
Author: you@onlab.us
"""
-
import sys
import os
import re
@@ -10,6 +9,7 @@
import json
import itertools
+
class CHOTestMonkey:
def __init__( self ):
@@ -49,7 +49,7 @@
main.AllONOSip = main.ONOSbench.getOnosIps()
main.controllers = []
for i in range( 1, main.numCtrls + 1 ):
- main.ONOSip.append( main.AllONOSip[ i-1 ] )
+ main.ONOSip.append( main.AllONOSip[ i - 1 ] )
newController = Controller( i )
newController.setCLI( getattr( main, 'ONOScli' + str( i ) ) )
main.controllers.append( newController )
@@ -131,8 +131,8 @@
main.step( "Uninstall ONOS package on all Nodes" )
uninstallResult = main.TRUE
for i in range( main.numCtrls ):
- main.log.info( "Uninstalling package on ONOS Node IP: " + main.ONOSip[i] )
- uResult = main.ONOSbench.onosUninstall( main.ONOSip[i] )
+ main.log.info( "Uninstalling package on ONOS Node IP: " + main.ONOSip[ i ] )
+ uResult = main.ONOSbench.onosUninstall( main.ONOSip[ i ] )
utilities.assert_equals( expect=main.TRUE,
actual=uResult,
onpass="Test step PASS",
@@ -142,8 +142,8 @@
main.step( "Install ONOS package on all Nodes" )
installResult = main.TRUE
for i in range( main.numCtrls ):
- main.log.info( "Installing package on ONOS Node IP: " + main.ONOSip[i] )
- iResult = main.ONOSbench.onosInstall( node=main.ONOSip[i] )
+ main.log.info( "Installing package on ONOS Node IP: " + main.ONOSip[ i ] )
+ iResult = main.ONOSbench.onosInstall( node=main.ONOSip[ i ] )
utilities.assert_equals( expect=main.TRUE,
actual=iResult,
onpass="Test step PASS",
@@ -153,7 +153,7 @@
main.step( "Set up ONOS secure SSH" )
secureSshResult = main.TRUE
for i in range( main.numCtrls ):
- secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=main.ONOSip[i] )
+ secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=main.ONOSip[ i ] )
utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
onpass="Test step PASS",
onfail="Test step FAIL" )
@@ -184,14 +184,14 @@
main.step( "Start ONOS CLI on all nodes" )
cliResult = main.TRUE
- startCliResult = main.TRUE
+ startCliResult = main.TRUE
pool = []
for controller in main.controllers:
t = main.Thread( target=controller.startCLI,
threadID=main.threadID,
name="startOnosCli",
- args=[ ] )
- pool.append(t)
+ args=[] )
+ pool.append( t )
t.start()
main.threadID = main.threadID + 1
for t in pool:
@@ -268,7 +268,7 @@
import time
import copy
- main.topoIndex = "topo" + str ( main.params[ 'TEST' ][ 'topo' ] )
+ main.topoIndex = "topo" + str( main.params[ 'TEST' ][ 'topo' ] )
main.log.report( "Load Mininet topology and Balance all Mininet switches across controllers" )
main.log.report( "________________________________________________________________________" )
@@ -277,10 +277,10 @@
main.step( "Start Mininet topology" )
newTopo = main.params[ 'TOPO' ][ main.topoIndex ][ 'fileName' ]
mininetDir = main.Mininet1.home + "/custom/"
- topoPath = main.testDir + "/" + main.TEST + "/dependencies/topologies/" + newTopo
+ topoPath = main.testDir + "/" + main.TEST + "/dependencies/topologies/" + newTopo
main.ONOSbench.secureCopy( main.Mininet1.user_name, main.Mininet1.ip_address, topoPath, mininetDir, direction="to" )
topoPath = mininetDir + newTopo
- startStatus = main.Mininet1.startNet( topoFile = topoPath )
+ startStatus = main.Mininet1.startNet( topoFile=topoPath )
main.mininetSwitches = main.Mininet1.getSwitches()
main.mininetHosts = main.Mininet1.getHosts()
main.mininetLinks = main.Mininet1.getLinks( timeout=60 )
@@ -366,7 +366,7 @@
deviceA = device
elif device.dpid == link[ 'dst' ][ 'device' ]:
deviceB = device
- assert deviceA != None and deviceB != None
+ assert deviceA is not None and deviceB is not None
newLink = Link( linkInitIndex, deviceA, link[ 'src' ][ 'port' ], deviceB, link[ 'dst' ][ 'port' ] )
print newLink
main.links.append( newLink )
@@ -374,15 +374,15 @@
# Set backward links and outgoing links of devices
for linkA in main.links:
linkA.deviceA.outgoingLinks.append( linkA )
- if linkA.backwardLink != None:
+ if linkA.backwardLink is not None:
continue
for linkB in main.links:
- if linkB.backwardLink != None:
+ if linkB.backwardLink is not None:
continue
if linkA.deviceA == linkB.deviceB and\
- linkA.deviceB == linkB.deviceA and\
- linkA.portA == linkB.portB and\
- linkA.portB == linkB.portA:
+ linkA.deviceB == linkB.deviceA and\
+ linkA.portA == linkB.portB and\
+ linkA.portB == linkB.portA:
linkA.setBackwardLink( linkB )
linkB.setBackwardLink( linkA )
utilities.assert_equals( expect=main.TRUE,
@@ -401,7 +401,7 @@
onfail="Saving ONOS topology data test FAIL" )
if not caseResult:
- main.log.info("Topology does not match, exiting test...")
+ main.log.info( "Topology does not match, exiting test..." )
main.cleanup()
main.exit()
@@ -877,7 +877,7 @@
main.eventGenerator.triggerEvent( EventType().NETWORK_DEVICE_UP, EventScheduleMethod().RUN_BLOCK, 'random' )
downDeviceNum -= 1
elif event == 'toggle-flowobj':
- if flowObj == False:
+ if not flowObj:
main.eventGenerator.triggerEvent( EventType().ONOS_SET_FLOWOBJ, EventScheduleMethod().RUN_BLOCK, 'true' )
else:
main.eventGenerator.triggerEvent( EventType().ONOS_SET_FLOWOBJ, EventScheduleMethod().RUN_BLOCK, 'false' )
@@ -921,9 +921,9 @@
eventName = line[ 10 ]
args = line[ 11: ]
assert eventName.startswith( 'CHECK' )\
- or eventName.startswith( 'NETWORK' )\
- or eventName.startswith( 'APP' )\
- or eventName.startswith( 'ONOS' )
+ or eventName.startswith( 'NETWORK' )\
+ or eventName.startswith( 'APP' )\
+ or eventName.startswith( 'ONOS' )
if main.params[ 'CASE80' ][ 'skipChecks' ] == 'on' and eventName.startswith( 'CHECK' ):
continue
with main.eventScheduler.idleCondition:
diff --git a/TestON/tests/CHOTestMonkey/dependencies/EventGenerator.py b/TestON/tests/CHOTestMonkey/dependencies/EventGenerator.py
index dd53238..03aafd3 100644
--- a/TestON/tests/CHOTestMonkey/dependencies/EventGenerator.py
+++ b/TestON/tests/CHOTestMonkey/dependencies/EventGenerator.py
@@ -6,7 +6,9 @@
from tests.CHOTestMonkey.dependencies.events.Event import EventType, EventStates, Event
from tests.CHOTestMonkey.dependencies.EventScheduler import EventScheduleMethod
+
class MessageType:
+
def __init__( self ):
self.map = {}
# This message type is used for requesting an event injection from outside CHOTestMonkey
@@ -32,7 +34,9 @@
self.NOT_ENOUGH_ARGUMENT = 23
self.map[ 23 ] = 'NOT_ENOUGH_ARGUMENT'
+
class EventGenerator:
+
def __init__( self ):
self.default = ''
self.eventGeneratorLock = Lock()
@@ -50,12 +54,12 @@
listener = Listener( address )
main.log.info( "Event Generator - Event listener start listening on %s:%s" % ( host, port ) )
- while 1:
+ while True:
conn = listener.accept()
t = main.Thread( target=self.handleConnection,
threadID=main.threadID,
name="handleConnection",
- args=[ conn ])
+ args=[ conn ] )
t.start()
with main.variableLock:
main.threadID += 1
@@ -124,7 +128,7 @@
main.log.warn( "Event Generator - event type %s not enabled" % ( typeIndex ) )
return
function = getattr( self, main.enabledEvents[ typeIndex ] )
- assert function != None, "Event Generator - funtion for group event " + typeIndex + " not found"
+ assert function is not None, "Event Generator - funtion for group event " + typeIndex + " not found"
function( scheduleMethod, args )
else:
# Add individual events to the scheduler
@@ -156,7 +160,7 @@
The function randomly adds a link down-up event pair into the scheduler
After each individual link event, all checks are inserted into the scheduler
param:
- args[0] is the average interval between link down and link up events
+ args[ 0 ] is the average interval between link down and link up events
blocking means blocking other events from being scheduled between link down and link up
"""
import random
@@ -199,9 +203,9 @@
The function randomly adds a group of link down-up events into the scheduler
After each link down or up, all checks are inserted into the scheduler
param:
- args[0] is the number of links that are to be brought down
- args[1] is the average interval between link down events
- args[2] is the average interval between link group down and group up events
+ args[ 0 ] is the number of links that are to be brought down
+ args[ 1 ] is the average interval between link down events
+ args[ 2 ] is the average interval between link group down and group up events
blocking means blocking other events from being scheduled between link events
"""
import random
@@ -265,7 +269,7 @@
The function randomly removes a device and then adds it back
After each individual device event, all checks are inserted into the scheduler
param:
- args[0] is the average interval between device down and device up events
+ args[ 0 ] is the average interval between device down and device up events
blocking means blocking other events from being scheduled between device down and device up
"""
import random
@@ -308,9 +312,9 @@
The function randomly adds a group of device down-up events into the scheduler
After each device down or up, all checks are inserted into the scheduler
param:
- args[0] is the number of devices that are to be brought down
- args[1] is the average interval between device down events
- args[2] is the average interval between device group down and group up events
+ args[ 0 ] is the number of devices that are to be brought down
+ args[ 1 ] is the average interval between device down events
+ args[ 2 ] is the average interval between device group down and group up events
blocking means blocking other events from being scheduled between device events
"""
import random
diff --git a/TestON/tests/CHOTestMonkey/dependencies/EventScheduler.py b/TestON/tests/CHOTestMonkey/dependencies/EventScheduler.py
index ae32932..480fb9a 100644
--- a/TestON/tests/CHOTestMonkey/dependencies/EventScheduler.py
+++ b/TestON/tests/CHOTestMonkey/dependencies/EventScheduler.py
@@ -10,7 +10,9 @@
from tests.CHOTestMonkey.dependencies.events.AppEvent import *
from tests.CHOTestMonkey.dependencies.events.ONOSEvent import *
+
class EventScheduleMethod:
+
def __init__( self ):
self.map = {}
self.RUN_NON_BLOCK = 1
@@ -18,7 +20,9 @@
self.RUN_BLOCK = -1
self.map[ -1 ] = 'RUN_BLOCK'
+
class EventTuple:
+
def __init__( self, id, className, typeString, typeIndex, scheduleMethod, args, rerunInterval, maxRerunNum ):
self.default = ''
self.id = 0
@@ -35,7 +39,9 @@
event = globals()[ self.className ]
return event().startEvent( self.args )
+
class EventScheduler:
+
def __init__( self ):
self.default = ''
self.pendingEvents = []
@@ -68,8 +74,8 @@
with main.variableLock:
main.eventID += 1
main.log.debug( "Event Scheduler - Event added: %s, %s, %s" % ( typeIndex,
- scheduleMethod,
- args ) )
+ scheduleMethod,
+ args ) )
with self.pendingEventsCondition:
if index == -1:
self.pendingEvents.append( eventTuple )
@@ -86,14 +92,14 @@
"""
import time
- while 1:
+ while True:
with self.pendingEventsCondition:
while len( self.pendingEvents ) == 0:
self.pendingEventsCondition.wait()
eventTuple = self.pendingEvents[ 0 ]
main.log.debug( "Event Scheduler - Scheduling event: %s, %s, %s" % ( eventTuple.typeIndex,
- eventTuple.scheduleMethod,
- eventTuple.args ) )
+ eventTuple.scheduleMethod,
+ eventTuple.args ) )
if eventTuple.scheduleMethod == EventScheduleMethod().RUN_NON_BLOCK:
# Run NON_BLOCK events using threads
with self.pendingEventsCondition:
@@ -101,7 +107,7 @@
t = main.Thread( target=self.startEvent,
threadID=main.threadID,
name="startEvent",
- args=[ eventTuple ])
+ args=[ eventTuple ] )
t.start()
with main.variableLock:
main.threadID += 1
@@ -192,6 +198,5 @@
self.pendingEventsCapacity = capacity
def setRunningState( self, state ):
- assert state == True or state == False
+ assert state or state == False
self.isRunning = state
-
diff --git a/TestON/tests/CHOTestMonkey/dependencies/EventTrigger.py b/TestON/tests/CHOTestMonkey/dependencies/EventTrigger.py
index 27b8166..7e912d0 100644
--- a/TestON/tests/CHOTestMonkey/dependencies/EventTrigger.py
+++ b/TestON/tests/CHOTestMonkey/dependencies/EventTrigger.py
@@ -6,6 +6,7 @@
import random
from multiprocessing.connection import Client
+
def triggerEvent( type, scheduleMethod, *args ):
"""
This function inserts an event into CHOTestMonkey
@@ -42,6 +43,7 @@
print "Unknown response from server:", response
conn.close()
+
def testLoop( sleepTime=5 ):
downLinkNum = 0
downDeviceNum = 0
@@ -66,6 +68,7 @@
else:
pass
+
def replayFromFile( filePath='/home/admin/event-list', sleepTime=1 ):
try:
f = open( filePath, 'r' )
diff --git a/TestON/tests/CHOTestMonkey/dependencies/GraphHelper.py b/TestON/tests/CHOTestMonkey/dependencies/GraphHelper.py
index 13f110b..a61676e 100644
--- a/TestON/tests/CHOTestMonkey/dependencies/GraphHelper.py
+++ b/TestON/tests/CHOTestMonkey/dependencies/GraphHelper.py
@@ -3,10 +3,11 @@
Author: you@onlab.us
"""
class GraphHelper:
+
"""
This class implements graph algorithms for CHOTestMonkey.
It reads main.devices and main.links as vertices and edges.
- Currently it offers functions for finding (non-)cut-edges and vertices,
+ Currently it offers functions for finding ( non- )cut-edges and vertices,
which is realized based on chain-decomposition algorithm
"""
def __init__( self ):
@@ -50,13 +51,13 @@
key = self.DFI[ neighbor.index ]
if key in self.backEdges.keys():
if not link in self.backEdges[ key ] and\
- not backwardLink in self.backEdges[ key ]:
+ not backwardLink in self.backEdges[ key ]:
self.backEdges[ key ].append( backwardLink )
else:
tempKey = self.DFI[ device.index ]
if tempKey in self.backEdges.keys():
if not link in self.backEdges[ tempKey ] and\
- not backwardLink in self.backEdges[ tempKey ]:
+ not backwardLink in self.backEdges[ tempKey ]:
self.backEdges[ key ] = [ backwardLink ]
else:
self.backEdges[ key ] = [ backwardLink ]
@@ -65,8 +66,7 @@
"""
This function finds all the 'chains' for chain-decomposition algorithm
"""
- keyList = self.backEdges.keys()
- keyList.sort()
+ keyList = sorted( self.backEdges.keys() )
deviceIsVisited = []
for i in range( len( main.devices ) ):
deviceIsVisited.append( 0 )
diff --git a/TestON/tests/CHOTestMonkey/dependencies/cli.py b/TestON/tests/CHOTestMonkey/dependencies/cli.py
index a3fb18e..2c6412c 100644
--- a/TestON/tests/CHOTestMonkey/dependencies/cli.py
+++ b/TestON/tests/CHOTestMonkey/dependencies/cli.py
@@ -7,6 +7,7 @@
commandMap = {}
paramNum = {}
+
def triggerEvent( debugMode, name, scheduleMethod, args ):
"""
This function inserts an event from CLI to CHOTestMonkey
@@ -28,14 +29,15 @@
response = conn.recv()
return response
+
def startCLI():
debugMode = False
- while 1:
+ while True:
try:
if debugMode:
- cmd = raw_input("CHOTestMonkey-debug>")
+ cmd = raw_input( "CHOTestMonkey-debug>" )
else:
- cmd = raw_input("CHOTestMonkey>")
+ cmd = raw_input( "CHOTestMonkey>" )
except EOFError:
print "exit"
return
@@ -64,13 +66,13 @@
if cmdList[ 0 ] in commandMap.keys():
num = paramNum[ cmdList[ 0 ] ]
name = commandMap[ cmdList[ 0 ] ]
- '''
+ """
if len( cmdList ) < num + 1:
print 'not enough arguments'
elif len( cmdList ) > num + 1:
print 'Too many arguments'
else:
- '''
+ """
result = triggerEvent( debugMode, name, 'RUN_BLOCK', cmdList[ 1: ] )
if result == 10:
pass
@@ -108,4 +110,3 @@
commandMap[ CLI ] = name
paramNum[ CLI ] = num
startCLI()
-
diff --git a/TestON/tests/CHOTestMonkey/dependencies/elements/NetworkElement.py b/TestON/tests/CHOTestMonkey/dependencies/elements/NetworkElement.py
index 31a4084..4c60f4a 100644
--- a/TestON/tests/CHOTestMonkey/dependencies/elements/NetworkElement.py
+++ b/TestON/tests/CHOTestMonkey/dependencies/elements/NetworkElement.py
@@ -2,8 +2,8 @@
This file contains device, host and link class for CHOTestMonkey
Author: you@onlab.us
"""
-
class NetworkElement:
+
def __init__( self, index ):
self.default = ''
self.index = index
@@ -27,7 +27,9 @@
def bringUp( self ):
self.status = 'up'
+
class Device( NetworkElement ):
+
def __init__( self, index, name, dpid ):
NetworkElement.__init__( self, index )
self.name = name
@@ -39,7 +41,9 @@
def __str__( self ):
return "name: " + self.name + ", dpid: " + self.dpid + ", status: " + self.status
+
class Host( NetworkElement ):
+
def __init__( self, index, name, id, mac, device, devicePort, vlan, ipAddresses ):
NetworkElement.__init__( self, index )
self.name = name
@@ -58,7 +62,9 @@
def setHandle( self, handle ):
self.handle = handle
+
class Link( NetworkElement ):
+
"""
Unidirectional link
"""
diff --git a/TestON/tests/CHOTestMonkey/dependencies/elements/ONOSElement.py b/TestON/tests/CHOTestMonkey/dependencies/elements/ONOSElement.py
index aa3a7a3..aed7a5b 100644
--- a/TestON/tests/CHOTestMonkey/dependencies/elements/ONOSElement.py
+++ b/TestON/tests/CHOTestMonkey/dependencies/elements/ONOSElement.py
@@ -4,7 +4,9 @@
"""
from threading import Lock
+
class Controller:
+
def __init__( self, index ):
self.default = ''
self.index = index
@@ -28,7 +30,9 @@
def bringUp( self ):
self.status = 'up'
+
class Intent:
+
def __init__( self, id ):
self.default = ''
self.type = 'INTENT'
@@ -47,7 +51,9 @@
def isInstalled( self ):
return self.expectedState == 'INSTALLED'
+
class HostIntent( Intent ):
+
def __init__( self, id, hostA, hostB ):
Intent.__init__( self, id )
self.type = 'INTENT_HOST'
@@ -75,7 +81,9 @@
def __str__( self ):
return "ID: " + self.id
+
class PointIntent( Intent ):
+
def __init__( self, id, deviceA, deviceB ):
Intent.__init__( self, id )
self.type = 'INTENT_POINT'
diff --git a/TestON/tests/CHOTestMonkey/dependencies/events/AppEvent.py b/TestON/tests/CHOTestMonkey/dependencies/events/AppEvent.py
index 4283ff6..2661a07 100644
--- a/TestON/tests/CHOTestMonkey/dependencies/events/AppEvent.py
+++ b/TestON/tests/CHOTestMonkey/dependencies/events/AppEvent.py
@@ -5,7 +5,9 @@
from tests.CHOTestMonkey.dependencies.events.Event import EventType, EventStates, Event
from tests.CHOTestMonkey.dependencies.elements.ONOSElement import HostIntent, PointIntent
+
class IntentEvent( Event ):
+
def __init__( self ):
Event.__init__( self )
# The index of the ONOS CLI that is going to run the command
@@ -19,7 +21,7 @@
candidates = [ host for host in main.hosts if host not in hostA.correspondents and host != hostA ]
if len( candidates ) == 0:
return None
- hostB = random.sample( candidates, 1 )[0]
+ hostB = random.sample( candidates, 1 )[ 0 ]
return hostB
def getRandomHostPair( self, connected=True ):
@@ -28,11 +30,11 @@
with main.variableLock:
for host in main.hosts:
correspondent = self.getRandomCorrespondent( host, connected=connected )
- if correspondent != None:
+ if correspondent is not None:
candidateDict[ host ] = correspondent
if candidateDict == {}:
return None
- hostA = random.sample( candidateDict.keys(), 1 )[0]
+ hostA = random.sample( candidateDict.keys(), 1 )[ 0 ]
hostB = candidateDict[ hostA ]
return [ hostA, hostB ]
@@ -52,7 +54,9 @@
intent = random.sample( intents, 1 )[ 0 ]
return intent
+
class HostIntentEvent( IntentEvent ):
+
def __init__( self ):
IntentEvent.__init__( self )
self.hostA = None
@@ -75,14 +79,14 @@
if args[ 0 ] == 'random' or args[ 1 ] == 'random':
if self.typeIndex == EventType().APP_INTENT_HOST_ADD:
hostPairRandom = self.getRandomHostPair( connected=False )
- if hostPairRandom == None:
+ if hostPairRandom is None:
main.log.warn( "All host pairs are connected, aborting event" )
return EventStates().ABORT
self.hostA = hostPairRandom[ 0 ]
self.hostB = hostPairRandom[ 1 ]
elif self.typeIndex == EventType().APP_INTENT_HOST_DEL:
intent = self.getRandomIntentByType( 'INTENT_HOST' )
- if intent == None:
+ if intent is None:
main.log.warn( "No host intent for deletion, aborting event" )
return EventStates().ABORT
self.hostA = intent.hostA
@@ -96,12 +100,12 @@
self.hostA = host
elif host.name == args[ 1 ]:
self.hostB = host
- if self.hostA != None and self.hostB != None:
+ if self.hostA is not None and self.hostB is not None:
break
- if self.hostA == None:
+ if self.hostA is None:
main.log.warn( "Host %s does not exist: " % ( args[ 0 ] ) )
return EventStates().ABORT
- if self.hostB == None:
+ if self.hostB is None:
main.log.warn( "Host %s does not exist: " % ( args[ 1 ] ) )
return EventStates().ABORT
index = int( args[ 2 ] )
@@ -117,32 +121,34 @@
main.log.warn( "Caught exception, aborting event" )
return EventStates().ABORT
+
class AddHostIntent( HostIntentEvent ):
+
"""
- Add a host-to-host intent (bidirectional)
+ Add a host-to-host intent ( bidirectional )
"""
def __init__( self ):
HostIntentEvent.__init__( self )
self.typeString = main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeString' ]
- self.typeIndex= int( main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeIndex' ] )
+ self.typeIndex = int( main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeIndex' ] )
def startHostIntentEvent( self ):
try:
- assert self.hostA != None and self.hostB != None
+ assert self.hostA is not None and self.hostB is not None
# Check whether there already exists some intent for the host pair
# For now we should avoid installing overlapping intents
for intent in main.intents:
if not intent.type == 'INTENT_HOST':
continue
if intent.hostA == self.hostA and intent.hostB == self.hostB or\
- intent.hostB == self.hostA and intent.hostA == self.hostB:
+ 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 )
- if id == None:
+ if id is None:
main.log.warn( self.typeString + " - add host intent failed" )
return EventStates().FAIL
with main.variableLock:
@@ -157,34 +163,36 @@
main.log.warn( "Caught exception, aborting event" )
return EventStates().ABORT
+
class DelHostIntent( HostIntentEvent ):
+
"""
- Delete a host-to-host intent (bidirectional)
+ Delete a host-to-host intent ( bidirectional )
"""
def __init__( self ):
HostIntentEvent.__init__( self )
self.typeString = main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeString' ]
- self.typeIndex= int( main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeIndex' ] )
+ self.typeIndex = int( main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeIndex' ] )
def startHostIntentEvent( self ):
try:
- assert self.hostA != None and self.hostB != None
+ assert self.hostA is not None and self.hostB is not None
targetIntent = None
for intent in main.intents:
if not intent.type == 'INTENT_HOST':
continue
if intent.hostA == self.hostA and intent.hostB == self.hostB or\
- intent.hostB == self.hostA and intent.hostA == self.hostB:
+ intent.hostB == self.hostA and intent.hostA == self.hostB:
targetIntent = intent
break
- if targetIntent == None:
+ if targetIntent is 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 )
- if result == None or result == main.FALSE:
+ if result is None or result == main.FALSE:
main.log.warn( self.typeString + " - delete host intent failed" )
return EventStates().FAIL
with main.variableLock:
@@ -195,7 +203,9 @@
main.log.warn( "Caught exception, aborting event" )
return EventStates().ABORT
+
class PointIntentEvent( IntentEvent ):
+
def __init__( self ):
IntentEvent.__init__( self )
self.deviceA = None
@@ -218,14 +228,14 @@
if args[ 0 ] == 'random' or args[ 1 ] == 'random':
if self.typeIndex == EventType().APP_INTENT_POINT_ADD:
hostPairRandom = self.getRandomHostPair( connected=False )
- if hostPairRandom == None:
+ if hostPairRandom is None:
main.log.warn( "All host pairs are connected, aborting event" )
return EventStates().ABORT
self.deviceA = hostPairRandom[ 0 ].device
self.deviceB = hostPairRandom[ 1 ].device
elif self.typeIndex == EventType().APP_INTENT_POINT_DEL:
intent = self.getRandomIntentByType( 'INTENT_POINT' )
- if intent == None:
+ if intent is None:
main.log.warn( "No point intent for deletion, aborting event" )
return EventStates().ABORT
self.deviceA = intent.deviceA
@@ -239,12 +249,12 @@
self.deviceA = device
elif device.name == args[ 1 ]:
self.deviceB = device
- if self.deviceA != None and self.deviceB != None:
+ if self.deviceA is not None and self.deviceB is not None:
break
- if self.deviceA == None:
+ if self.deviceA is None:
main.log.warn( "Device %s does not exist: " % ( args[ 0 ] ) )
return EventStates().ABORT
- if self.deviceB == None:
+ if self.deviceB is None:
main.log.warn( "Device %s does not exist: " % ( args[ 1 ] ) )
return EventStates().ABORT
index = int( args[ 2 ] )
@@ -270,18 +280,20 @@
main.log.warn( "Caught exception, aborting event" )
return EventStates().ABORT
+
class AddPointIntent( PointIntentEvent ):
+
"""
Add a point-to-point intent
"""
def __init__( self ):
PointIntentEvent.__init__( self )
self.typeString = main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeString' ]
- self.typeIndex= int( main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeIndex' ] )
+ self.typeIndex = int( main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeIndex' ] )
def startPointIntentEvent( self ):
try:
- assert self.deviceA != None and self.deviceB != None
+ assert self.deviceA is not None and self.deviceB is not None
controller = main.controllers[ self.CLIIndex - 1 ]
# TODO: support multiple hosts under one device
# Check whether there already exists some intent for the device pair
@@ -302,7 +314,7 @@
if len( self.deviceB.hosts ) > 0:
dstMAC = self.deviceB.hosts[ 0 ].mac
id = controller.CLI.addPointIntent( self.deviceA.dpid, self.deviceB.dpid, 1, 1, '', srcMAC, dstMAC )
- if id == None:
+ if id is None:
main.log.warn( self.typeString + " - add point intent failed" )
return EventStates().FAIL
with main.variableLock:
@@ -317,18 +329,20 @@
main.log.warn( "Caught exception, aborting event" )
return EventStates().ABORT
+
class DelPointIntent( PointIntentEvent ):
+
"""
Delete a point-to-point intent
"""
def __init__( self ):
PointIntentEvent.__init__( self )
self.typeString = main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeString' ]
- self.typeIndex= int( main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeIndex' ] )
+ self.typeIndex = int( main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeIndex' ] )
def startPointIntentEvent( self ):
try:
- assert self.deviceA != None and self.deviceB != None
+ assert self.deviceA is not None and self.deviceB is not None
targetIntent = None
for intent in main.intents:
if not intent.type == 'INTENT_POINT':
@@ -336,14 +350,14 @@
if intent.deviceA == self.deviceA and intent.deviceB == self.deviceB:
targetIntent = intent
break
- if targetIntent == None:
+ if targetIntent is 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 )
- if result == None or result == main.FALSE:
+ if result is None or result == main.FALSE:
main.log.warn( self.typeString + " - delete point intent failed" )
return EventStates().FAIL
with main.variableLock:
diff --git a/TestON/tests/CHOTestMonkey/dependencies/events/CheckEvent.py b/TestON/tests/CHOTestMonkey/dependencies/events/CheckEvent.py
old mode 100755
new mode 100644
index 8c85ff8..2c0cfc3
--- a/TestON/tests/CHOTestMonkey/dependencies/events/CheckEvent.py
+++ b/TestON/tests/CHOTestMonkey/dependencies/events/CheckEvent.py
@@ -4,7 +4,9 @@
"""
from tests.CHOTestMonkey.dependencies.events.Event import EventType, EventStates, Event
+
class CheckEvent( Event ):
+
def __init__( self ):
Event.__init__( self )
@@ -17,7 +19,9 @@
result = self.startCheckEvent()
return result
+
class IntentCheck( CheckEvent ):
+
def __init__( self ):
CheckEvent.__init__( self )
self.typeString = main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeString' ]
@@ -37,7 +41,9 @@
checkResult = EventStates().FAIL
return checkResult
+
class FlowCheck( CheckEvent ):
+
def __init__( self ):
CheckEvent.__init__( self )
self.typeString = main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeString' ]
@@ -58,7 +64,7 @@
if device.isRemoved():
continue
coreFlowNumOnos = controller.CLI.flowAddedCount( device.dpid, core=True )
- if coreFlowNumOnos == None:
+ if coreFlowNumOnos is None:
main.log.warn( "Flow Check - error when trying to get flow number of %s on ONOS%s" % ( device.dpid, controller.index ) )
checkResult = EventStates().FAIL
else:
@@ -94,7 +100,9 @@
checkResult = EventStates().FAIL
return checkResult
+
class TopoCheck( CheckEvent ):
+
def __init__( self ):
CheckEvent.__init__( self )
self.typeString = main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeString' ]
@@ -144,7 +152,7 @@
devices = json.loads( devices )
availableDeviceNum = 0
for device in devices:
- if device[ 'available' ] == True:
+ if device[ 'available' ]:
availableDeviceNum += 1
if not availableDeviceNum == upDeviceNum:
checkResult = EventStates().FAIL
@@ -166,11 +174,13 @@
return EventStates().FAIL
return checkResult
+
class ONOSCheck( CheckEvent ):
+
def __init__( self ):
CheckEvent.__init__( self )
self.typeString = main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeString' ]
- self.typeIndex= int( main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeIndex' ] )
+ self.typeIndex = int( main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeIndex' ] )
def startCheckEvent( self, args=None ):
import json
@@ -209,7 +219,7 @@
with controller.CLILock:
leaders = controller.CLI.leaders()
leaders = json.loads( leaders )
- ONOSTopics = [ j['topic'] for j in leaders ]
+ ONOSTopics = [ j[ 'topic' ] for j in leaders ]
for topic in topics:
if topic not in ONOSTopics:
checkResult = EventStates().FAIL
@@ -235,11 +245,13 @@
return EventStates().FAIL
return checkResult
+
class TrafficCheck( CheckEvent ):
+
def __init__( self ):
CheckEvent.__init__( self )
self.typeString = main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeString' ]
- self.typeIndex= int( main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeIndex' ] )
+ self.typeIndex = int( main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeIndex' ] )
def startCheckEvent( self, args=None ):
checkResult = EventStates().PASS
@@ -256,7 +268,7 @@
dstIPv4List[ host.index ] = []
dstIPv6List[ host.index ] = []
for correspondent in host.correspondents:
- if not correspondent in upHosts:
+ if correspondent not in upHosts:
continue
for ipAddress in correspondent.ipAddresses:
if ipAddress.startswith( str( main.params[ 'TEST' ][ 'ipv6Prefix' ] ) ):
@@ -295,4 +307,3 @@
checkResult = EventStates().FAIL
main.log.warn( "Traffic Check - ping6 failed" )
return checkResult
-
diff --git a/TestON/tests/CHOTestMonkey/dependencies/events/Event.py b/TestON/tests/CHOTestMonkey/dependencies/events/Event.py
index 2abd77f..9aa4ae6 100644
--- a/TestON/tests/CHOTestMonkey/dependencies/events/Event.py
+++ b/TestON/tests/CHOTestMonkey/dependencies/events/Event.py
@@ -4,10 +4,12 @@
"""
from threading import Lock
+
class EventType:
+
def __init__( self ):
self.map = {}
- # Group events (>100) should be divided into individual events by the generator before going to the scheduler
+ # Group events ( >100 ) should be divided into individual events by the generator before going to the scheduler
self.NULL = 0
for eventName in main.params[ 'EVENT' ].keys():
typeString = main.params[ 'EVENT' ][ eventName ][ 'typeString' ]
@@ -15,7 +17,9 @@
setattr( self, typeString, typeIndex )
self.map[ typeIndex ] = typeString
+
class EventStates:
+
def __init__( self ):
self.map = {}
self.FAIL = 0
@@ -25,7 +29,9 @@
self.ABORT = -1
self.map[ -1 ] = 'ABORT'
+
class Event:
+
"""
Event class for CHOTestMonkey
It is the super class for CheckEvent and NetworkEvent
diff --git a/TestON/tests/CHOTestMonkey/dependencies/events/NetworkEvent.py b/TestON/tests/CHOTestMonkey/dependencies/events/NetworkEvent.py
index f6e13cc..a601c42 100644
--- a/TestON/tests/CHOTestMonkey/dependencies/events/NetworkEvent.py
+++ b/TestON/tests/CHOTestMonkey/dependencies/events/NetworkEvent.py
@@ -5,7 +5,9 @@
from tests.CHOTestMonkey.dependencies.events.Event import EventType, EventStates, Event
from tests.CHOTestMonkey.dependencies.elements.NetworkElement import NetworkElement, Device, Host, Link
+
class LinkEvent( Event ):
+
def __init__( self ):
Event.__init__( self )
self.linkA = None
@@ -16,7 +18,7 @@
def startEvent( self, args ):
"""
- args are the names of the two link ends, e.g. ['s1', 's2']
+ args are the names of the two link ends, e.g. [ 's1', 's2' ]
"""
with self.eventLock:
#main.log.info( "%s - starting event" % ( self.typeString ) )
@@ -30,7 +32,7 @@
if self.typeIndex == EventType().NETWORK_LINK_DOWN:
with main.mininetLock:
linkRandom = main.Mininet1.getLinkRandom()
- if linkRandom == None:
+ if linkRandom is None:
main.log.warn( "No link available, aborting event" )
return EventStates().ABORT
args[ 0 ] = linkRandom[ 0 ]
@@ -51,21 +53,23 @@
elif args[ 0 ] == args[ 1 ]:
main.log.warn( "%s - invalid arguments: %s" % ( self.typeString, args ) )
return EventStates().ABORT
- if self.linkA == None or self.linkB == None:
+ if self.linkA is None or self.linkB is None:
for link in main.links:
if link.deviceA.name == args[ 0 ] and link.deviceB.name == args[ 1 ]:
self.linkA = link
elif link.deviceA.name == args[ 1 ] and link.deviceB.name == args[ 0 ]:
self.linkB = link
- if self.linkA != None and self.linkB != None:
+ if self.linkA is not None and self.linkB is not None:
break
- if self.linkA == None or self.linkB == None:
+ if self.linkA is None or self.linkB is None:
main.log.warn( "Bidirectional link %s - %s does not exist: " % ( args[ 0 ], args[ 1 ] ) )
return EventStates().ABORT
main.log.debug( "%s - %s" % ( self.typeString, self.linkA ) )
return self.startLinkEvent()
+
class LinkDown( LinkEvent ):
+
"""
Generate a link down event giving the two ends of the link
"""
@@ -76,7 +80,7 @@
def startLinkEvent( self ):
# TODO: do we need to handle a unidirectional link?
- assert self.linkA != None and self.linkB != None
+ assert self.linkA is not None and self.linkB is not None
with main.variableLock:
if self.linkA.isDown() or self.linkB.isDown():
main.log.warn( "Link Down - link already down" )
@@ -86,11 +90,11 @@
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,
END2=self.linkA.deviceB.name,
- OPTION="down")
- '''
+ OPTION="down" )
+ """
result = main.Mininet1.delLink( self.linkA.deviceA.name,
self.linkA.deviceB.name )
if not result:
@@ -101,7 +105,9 @@
self.linkB.bringDown()
return EventStates().PASS
+
class LinkUp( LinkEvent ):
+
"""
Generate a link up event giving the two ends of the link
"""
@@ -111,7 +117,7 @@
self.typeIndex = int( main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeIndex' ] )
def startLinkEvent( self ):
- assert self.linkA != None and self.linkB != None
+ assert self.linkA is not None and self.linkB is not None
with main.variableLock:
if self.linkA.isUp() or self.linkB.isUp():
main.log.warn( "Link Up - link already up" )
@@ -121,11 +127,11 @@
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,
END2=self.linkA.deviceB.name,
- OPTION="up")
- '''
+ OPTION="up" )
+ """
result = main.Mininet1.addLink( self.linkA.deviceA.name,
self.linkA.deviceB.name )
if not result:
@@ -136,7 +142,9 @@
self.linkB.bringUp()
return EventStates().PASS
+
class DeviceEvent( Event ):
+
def __init__( self ):
Event.__init__( self )
self.device = None
@@ -161,7 +169,7 @@
if self.typeIndex == EventType().NETWORK_DEVICE_DOWN:
with main.mininetLock:
switchRandom = main.Mininet1.getSwitchRandom()
- if switchRandom == None:
+ if switchRandom is None:
main.log.warn( "No switch available, aborting event" )
return EventStates().ABORT
args[ 0 ] = switchRandom
@@ -176,19 +184,21 @@
return EventStates().ABORT
deviceList = random.sample( removedDevices, 1 )
self.device = deviceList[ 0 ]
- if self.device == None:
+ if self.device is None:
for device in main.devices:
if device.name == args[ 0 ]:
self.device = device
- if self.device == None:
+ if self.device is None:
main.log.warn( "Device %s does not exist: " % ( args[ 0 ] ) )
return EventStates().ABORT
main.log.debug( "%s - %s" % ( self.typeString, self.device ) )
return self.startDeviceEvent()
+
class DeviceDown( DeviceEvent ):
+
"""
- Generate a device down event (which actually removes this device for now) giving its name
+ Generate a device down event ( which actually removes this device for now ) giving its name
"""
def __init__( self ):
DeviceEvent.__init__( self )
@@ -196,7 +206,7 @@
self.typeIndex = int( main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeIndex' ] )
def startDeviceEvent( self ):
- assert self.device != None
+ assert self.device is not None
with main.variableLock:
if self.device.isRemoved():
main.log.warn( "Device Down - device has been removed" )
@@ -219,9 +229,11 @@
intent.setFailed()
return EventStates().PASS
+
class DeviceUp( DeviceEvent ):
+
"""
- Generate a device up event (which re-adds this device in case the device is removed) giving its name
+ Generate a device up event ( which re-adds this device in case the device is removed ) giving its name
"""
def __init__( self ):
DeviceEvent.__init__( self )
@@ -229,7 +241,7 @@
self.typeIndex = int( main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeIndex' ] )
def startDeviceEvent( self ):
- assert self.device != None
+ assert self.device is not None
with main.variableLock:
if self.device.isUp():
main.log.warn( "Device Up - device already up" )
@@ -237,7 +249,7 @@
# 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:] )
+ result = main.Mininet1.addSwitch( self.device.name, dpid=self.device.dpid[ 3: ] )
if not result:
main.log.warn( "%s - failed to re-add device" % ( self.typeString ) )
return EventStates().FAIL
@@ -269,7 +281,7 @@
for intent in main.intents:
if intent.isFailed():
if intent.deviceA == self.device and intent.deviceB.isUp() or\
- intent.deviceB == self.device and intent.deviceA.isUp():
+ intent.deviceB == self.device and intent.deviceA.isUp():
intent.setInstalled()
# Re-assign mastership for the device
with main.mininetLock:
@@ -281,7 +293,7 @@
if h.isUp() and h != host:
correspondent = h
break
- if correspondent == None:
+ if correspondent is None:
with main.mininetLock:
main.Mininet1.pingall()
if main.enableIPv6:
@@ -290,14 +302,14 @@
ipv4Addr = None
ipv6Addr = None
for ipAddress in correspondent.ipAddresses:
- if ipAddress.startswith( str( main.params[ 'TEST' ][ 'ipv6Prefix' ] ) ) and ipv6Addr == None:
+ if ipAddress.startswith( str( main.params[ 'TEST' ][ 'ipv6Prefix' ] ) ) and ipv6Addr is None:
ipv6Addr = ipAddress
- elif ipAddress.startswith( str( main.params[ 'TEST' ][ 'ipv4Prefix' ] ) ) and ipv4Addr == None:
+ elif ipAddress.startswith( str( main.params[ 'TEST' ][ 'ipv4Prefix' ] ) ) and ipv4Addr is None:
ipv4Addr = ipAddress
- assert ipv4Addr != None
+ assert ipv4Addr is not None
host.handle.pingHostSetAlternative( [ ipv4Addr ], 1 )
if main.enableIPv6:
- assert ipv6Addr != None
+ assert ipv6Addr is not None
host.handle.pingHostSetAlternative( [ ipv6Addr ], 1, True )
with main.variableLock:
host.bringUp()
diff --git a/TestON/tests/CHOTestMonkey/dependencies/events/ONOSEvent.py b/TestON/tests/CHOTestMonkey/dependencies/events/ONOSEvent.py
index cafe800..d386c1b 100644
--- a/TestON/tests/CHOTestMonkey/dependencies/events/ONOSEvent.py
+++ b/TestON/tests/CHOTestMonkey/dependencies/events/ONOSEvent.py
@@ -4,7 +4,9 @@
"""
from tests.CHOTestMonkey.dependencies.events.Event import EventType, EventStates, Event
+
class ONOSEvent( Event ):
+
def __init__( self ):
Event.__init__( self )
self.ONOSIndex = -1
@@ -30,11 +32,13 @@
result = self.startONOSEvent()
return result
+
class ONOSDown( ONOSEvent ):
+
def __init__( self ):
ONOSEvent.__init__( self )
self.typeString = main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeString' ]
- self.typeIndex= int( main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeIndex' ] )
+ self.typeIndex = int( main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeIndex' ] )
def startONOSEvent( self ):
assert self.ONOSIndex != -1
@@ -52,11 +56,13 @@
main.controllers[ self.ONOSIndex - 1 ].bringDown()
return EventStates().PASS
+
class ONOSUp( ONOSEvent ):
+
def __init__( self ):
ONOSEvent.__init__( self )
self.typeString = main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeString' ]
- self.typeIndex= int( main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeIndex' ] )
+ self.typeIndex = int( main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeIndex' ] )
def startONOSEvent( self ):
assert self.ONOSIndex != -1
@@ -85,7 +91,9 @@
main.controllers[ self.ONOSIndex - 1 ].bringUp()
return EventStates().PASS
+
class CfgEvent( Event ):
+
def __init__( self ):
Event.__init__( self )
self.component = ''
@@ -98,11 +106,13 @@
result = self.startCfgEvent( args )
return result
+
class SetCfg( CfgEvent ):
+
def __init__( self ):
CfgEvent.__init__( self )
self.typeString = main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeString' ]
- self.typeIndex= int( main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeIndex' ] )
+ self.typeIndex = int( main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeIndex' ] )
def startCfgEvent( self, args ):
if len( args ) < 3:
@@ -121,7 +131,7 @@
if controller.isUp():
index = controller.index
if index == -1:
- main.log.warn( "%s - No available controllers" %s ( self.typeString ) )
+ 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 ]
@@ -134,11 +144,13 @@
return EventStates().FAIL
return EventStates().PASS
+
class SetFlowObj( CfgEvent ):
+
def __init__( self ):
CfgEvent.__init__( self )
self.typeString = main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeString' ]
- self.typeIndex= int( main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeIndex' ] )
+ self.typeIndex = int( main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeIndex' ] )
def startCfgEvent( self, args ):
if len( args ) < 1:
@@ -159,7 +171,7 @@
if controller.isUp():
index = controller.index
if index == -1:
- main.log.warn( "%s - No available controllers" %s ( self.typeString ) )
+ 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 ]
@@ -172,11 +184,13 @@
return EventStates().FAIL
return EventStates().PASS
+
class BalanceMasters( Event ):
+
def __init__( self ):
Event.__init__( self )
self.typeString = main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeString' ]
- self.typeIndex= int( main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeIndex' ] )
+ self.typeIndex = int( main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeIndex' ] )
def startEvent( self, args=None ):
with self.eventLock:
@@ -186,7 +200,7 @@
if controller.isUp():
index = controller.index
if index == -1:
- main.log.warn( "%s - No available controllers" %s ( self.typeString ) )
+ 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 ]
@@ -197,11 +211,13 @@
return EventStates().FAIL
return EventStates().PASS
+
class SetFlowObjCompiler( CfgEvent ):
+
def __init__( self ):
CfgEvent.__init__( self )
self.typeString = main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeString' ]
- self.typeIndex= int( main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeIndex' ] )
+ self.typeIndex = int( main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeIndex' ] )
def startCfgEvent( self, args ):
if len( args ) < 1:
@@ -219,7 +235,7 @@
if controller.isUp():
index = controller.index
if index == -1:
- main.log.warn( "%s - No available controllers" %s ( self.typeString ) )
+ 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 ]
@@ -231,4 +247,3 @@
main.log.warn( "%s - failed to set configuration" % ( self.typeString ) )
return EventStates().FAIL
return EventStates().PASS
-
diff --git a/TestON/tests/CHOTestMonkey/dependencies/events/TestEvent.py b/TestON/tests/CHOTestMonkey/dependencies/events/TestEvent.py
index 605e43f..07a8cf3 100644
--- a/TestON/tests/CHOTestMonkey/dependencies/events/TestEvent.py
+++ b/TestON/tests/CHOTestMonkey/dependencies/events/TestEvent.py
@@ -4,7 +4,9 @@
"""
from tests.CHOTestMonkey.dependencies.events.Event import EventType, EventStates, Event
+
class TestEvent( Event ):
+
def __init__( self ):
Event.__init__( self )
@@ -17,7 +19,9 @@
result = self.startTestEvent( args )
return result
+
class TestPause( TestEvent ):
+
def __init__( self ):
TestEvent.__init__( self )
self.typeString = main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeString' ]
@@ -28,7 +32,9 @@
main.eventScheduler.setRunningState( False )
return result
+
class TestResume( TestEvent ):
+
def __init__( self ):
TestEvent.__init__( self )
self.typeString = main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeString' ]
@@ -39,7 +45,9 @@
main.eventScheduler.setRunningState( True )
return result
+
class TestSleep( TestEvent ):
+
def __init__( self ):
TestEvent.__init__( self )
self.typeString = main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeString' ]