blob: e6b9e25ed3b807171cdde41053072692aa104f47 [file] [log] [blame]
You Wangdb927a52016-02-26 11:03:28 -08001"""
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -07002Copyright 2016 Open Networking Foundation ( ONF )
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -07003
4Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
5the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
6or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg>
7
8 TestON is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 2 of the License, or
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070011 ( at your option ) any later version.
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -070012
13 TestON is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with TestON. If not, see <http://www.gnu.org/licenses/>.
20"""
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -070021"""
You Wangdb927a52016-02-26 11:03:28 -080022This file contains the Event class for CHOTestMonkey
23Author: you@onlab.us
24"""
25from threading import Lock
26
Jon Hall2bb3e212017-05-24 17:07:25 -070027
You Wangdb927a52016-02-26 11:03:28 -080028class EventType:
Jon Hall2bb3e212017-05-24 17:07:25 -070029
You Wangdb927a52016-02-26 11:03:28 -080030 def __init__( self ):
31 self.map = {}
Jon Hall2bb3e212017-05-24 17:07:25 -070032 # Group events ( >100 ) should be divided into individual events by the generator before going to the scheduler
You Wangdb927a52016-02-26 11:03:28 -080033 self.NULL = 0
34 for eventName in main.params[ 'EVENT' ].keys():
35 typeString = main.params[ 'EVENT' ][ eventName ][ 'typeString' ]
36 typeIndex = int( main.params[ 'EVENT' ][ eventName ][ 'typeIndex' ] )
37 setattr( self, typeString, typeIndex )
38 self.map[ typeIndex ] = typeString
39
Jon Hall2bb3e212017-05-24 17:07:25 -070040
You Wangdb927a52016-02-26 11:03:28 -080041class EventStates:
Jon Hall2bb3e212017-05-24 17:07:25 -070042
You Wangdb927a52016-02-26 11:03:28 -080043 def __init__( self ):
44 self.map = {}
45 self.FAIL = 0
46 self.map[ 0 ] = 'FAIL'
47 self.PASS = 1
48 self.map[ 1 ] = 'PASS'
49 self.ABORT = -1
50 self.map[ -1 ] = 'ABORT'
51
Jon Hall2bb3e212017-05-24 17:07:25 -070052
You Wangdb927a52016-02-26 11:03:28 -080053class Event:
Jon Hall2bb3e212017-05-24 17:07:25 -070054
You Wangdb927a52016-02-26 11:03:28 -080055 """
56 Event class for CHOTestMonkey
57 It is the super class for CheckEvent and NetworkEvent
58 """
59 def __init__( self ):
60 self.typeString = main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeString' ]
61 self.typeIndex = int( main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeIndex' ] )
62 self.eventLock = Lock()
63 self.variableLock = Lock()
64
65 def startEvent( self, args=None ):
66 """
67 Start running the event
68 """
69 return EventStates().PASS