You Wang | db927a5 | 2016-02-26 11:03:28 -0800 | [diff] [blame] | 1 | """ |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 2 | Copyright 2016 Open Networking Foundation ( ONF ) |
Jeremy Ronquillo | b27ce4c | 2017-07-17 12:41:28 -0700 | [diff] [blame] | 3 | |
| 4 | Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>, |
| 5 | the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>, |
| 6 | or 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 Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 11 | ( at your option ) any later version. |
Jeremy Ronquillo | b27ce4c | 2017-07-17 12:41:28 -0700 | [diff] [blame] | 12 | |
| 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 Ronquillo | b27ce4c | 2017-07-17 12:41:28 -0700 | [diff] [blame] | 21 | """ |
You Wang | db927a5 | 2016-02-26 11:03:28 -0800 | [diff] [blame] | 22 | This file contains the Event class for CHOTestMonkey |
| 23 | Author: you@onlab.us |
| 24 | """ |
| 25 | from threading import Lock |
| 26 | |
Jon Hall | 2bb3e21 | 2017-05-24 17:07:25 -0700 | [diff] [blame] | 27 | |
You Wang | db927a5 | 2016-02-26 11:03:28 -0800 | [diff] [blame] | 28 | class EventType: |
Jon Hall | 2bb3e21 | 2017-05-24 17:07:25 -0700 | [diff] [blame] | 29 | |
You Wang | db927a5 | 2016-02-26 11:03:28 -0800 | [diff] [blame] | 30 | def __init__( self ): |
| 31 | self.map = {} |
Jon Hall | 2bb3e21 | 2017-05-24 17:07:25 -0700 | [diff] [blame] | 32 | # Group events ( >100 ) should be divided into individual events by the generator before going to the scheduler |
You Wang | db927a5 | 2016-02-26 11:03:28 -0800 | [diff] [blame] | 33 | 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 Hall | 2bb3e21 | 2017-05-24 17:07:25 -0700 | [diff] [blame] | 40 | |
You Wang | db927a5 | 2016-02-26 11:03:28 -0800 | [diff] [blame] | 41 | class EventStates: |
Jon Hall | 2bb3e21 | 2017-05-24 17:07:25 -0700 | [diff] [blame] | 42 | |
You Wang | db927a5 | 2016-02-26 11:03:28 -0800 | [diff] [blame] | 43 | 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 Hall | 2bb3e21 | 2017-05-24 17:07:25 -0700 | [diff] [blame] | 52 | |
You Wang | db927a5 | 2016-02-26 11:03:28 -0800 | [diff] [blame] | 53 | class Event: |
Jon Hall | 2bb3e21 | 2017-05-24 17:07:25 -0700 | [diff] [blame] | 54 | |
You Wang | db927a5 | 2016-02-26 11:03:28 -0800 | [diff] [blame] | 55 | """ |
| 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 |