You Wang | db927a5 | 2016-02-26 11:03:28 -0800 | [diff] [blame] | 1 | """ |
Jeremy Ronquillo | b27ce4c | 2017-07-17 12:41:28 -0700 | [diff] [blame] | 2 | Copyright 2016 Open Networking Foundation (ONF) |
| 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 |
| 11 | (at your option) any later version. |
| 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 | """ |
| 21 | |
| 22 | """ |
You Wang | db927a5 | 2016-02-26 11:03:28 -0800 | [diff] [blame] | 23 | This file contains the Event class for CHOTestMonkey |
| 24 | Author: you@onlab.us |
| 25 | """ |
| 26 | from threading import Lock |
| 27 | |
Jon Hall | 2bb3e21 | 2017-05-24 17:07:25 -0700 | [diff] [blame] | 28 | |
You Wang | db927a5 | 2016-02-26 11:03:28 -0800 | [diff] [blame] | 29 | class EventType: |
Jon Hall | 2bb3e21 | 2017-05-24 17:07:25 -0700 | [diff] [blame] | 30 | |
You Wang | db927a5 | 2016-02-26 11:03:28 -0800 | [diff] [blame] | 31 | def __init__( self ): |
| 32 | self.map = {} |
Jon Hall | 2bb3e21 | 2017-05-24 17:07:25 -0700 | [diff] [blame] | 33 | # 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] | 34 | self.NULL = 0 |
| 35 | for eventName in main.params[ 'EVENT' ].keys(): |
| 36 | typeString = main.params[ 'EVENT' ][ eventName ][ 'typeString' ] |
| 37 | typeIndex = int( main.params[ 'EVENT' ][ eventName ][ 'typeIndex' ] ) |
| 38 | setattr( self, typeString, typeIndex ) |
| 39 | self.map[ typeIndex ] = typeString |
| 40 | |
Jon Hall | 2bb3e21 | 2017-05-24 17:07:25 -0700 | [diff] [blame] | 41 | |
You Wang | db927a5 | 2016-02-26 11:03:28 -0800 | [diff] [blame] | 42 | class EventStates: |
Jon Hall | 2bb3e21 | 2017-05-24 17:07:25 -0700 | [diff] [blame] | 43 | |
You Wang | db927a5 | 2016-02-26 11:03:28 -0800 | [diff] [blame] | 44 | def __init__( self ): |
| 45 | self.map = {} |
| 46 | self.FAIL = 0 |
| 47 | self.map[ 0 ] = 'FAIL' |
| 48 | self.PASS = 1 |
| 49 | self.map[ 1 ] = 'PASS' |
| 50 | self.ABORT = -1 |
| 51 | self.map[ -1 ] = 'ABORT' |
| 52 | |
Jon Hall | 2bb3e21 | 2017-05-24 17:07:25 -0700 | [diff] [blame] | 53 | |
You Wang | db927a5 | 2016-02-26 11:03:28 -0800 | [diff] [blame] | 54 | class Event: |
Jon Hall | 2bb3e21 | 2017-05-24 17:07:25 -0700 | [diff] [blame] | 55 | |
You Wang | db927a5 | 2016-02-26 11:03:28 -0800 | [diff] [blame] | 56 | """ |
| 57 | Event class for CHOTestMonkey |
| 58 | It is the super class for CheckEvent and NetworkEvent |
| 59 | """ |
| 60 | def __init__( self ): |
| 61 | self.typeString = main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeString' ] |
| 62 | self.typeIndex = int( main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeIndex' ] ) |
| 63 | self.eventLock = Lock() |
| 64 | self.variableLock = Lock() |
| 65 | |
| 66 | def startEvent( self, args=None ): |
| 67 | """ |
| 68 | Start running the event |
| 69 | """ |
| 70 | return EventStates().PASS |