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 classes for CHOTestMonkey that are related to check event |
| 23 | Author: you@onlab.us |
| 24 | """ |
| 25 | from tests.CHOTestMonkey.dependencies.events.Event import EventType, EventStates, Event |
| 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 TestEvent( Event ): |
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 | Event.__init__( self ) |
| 32 | |
| 33 | def startTestEvent( self ): |
| 34 | return EventStates().PASS |
| 35 | |
| 36 | def startEvent( self, args ): |
| 37 | with self.eventLock: |
| 38 | main.log.info( "%s - starting event" % ( self.typeString ) ) |
| 39 | result = self.startTestEvent( args ) |
| 40 | return result |
| 41 | |
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 | class TestPause( TestEvent ): |
Jon Hall | 2bb3e21 | 2017-05-24 17:07:25 -0700 | [diff] [blame] | 44 | |
You Wang | db927a5 | 2016-02-26 11:03:28 -0800 | [diff] [blame] | 45 | def __init__( self ): |
| 46 | TestEvent.__init__( self ) |
| 47 | self.typeString = main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeString' ] |
| 48 | self.typeIndex = int( main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeIndex' ] ) |
| 49 | |
| 50 | def startTestEvent( self, args=None ): |
| 51 | result = EventStates().PASS |
| 52 | main.eventScheduler.setRunningState( False ) |
| 53 | return result |
| 54 | |
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 | class TestResume( TestEvent ): |
Jon Hall | 2bb3e21 | 2017-05-24 17:07:25 -0700 | [diff] [blame] | 57 | |
You Wang | db927a5 | 2016-02-26 11:03:28 -0800 | [diff] [blame] | 58 | def __init__( self ): |
| 59 | TestEvent.__init__( self ) |
| 60 | self.typeString = main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeString' ] |
| 61 | self.typeIndex = int( main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeIndex' ] ) |
| 62 | |
| 63 | def startTestEvent( self, args=None ): |
| 64 | result = EventStates().PASS |
| 65 | main.eventScheduler.setRunningState( True ) |
| 66 | return result |
| 67 | |
Jon Hall | 2bb3e21 | 2017-05-24 17:07:25 -0700 | [diff] [blame] | 68 | |
You Wang | db927a5 | 2016-02-26 11:03:28 -0800 | [diff] [blame] | 69 | class TestSleep( TestEvent ): |
Jon Hall | 2bb3e21 | 2017-05-24 17:07:25 -0700 | [diff] [blame] | 70 | |
You Wang | db927a5 | 2016-02-26 11:03:28 -0800 | [diff] [blame] | 71 | def __init__( self ): |
| 72 | TestEvent.__init__( self ) |
| 73 | self.typeString = main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeString' ] |
| 74 | self.typeIndex = int( main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeIndex' ] ) |
| 75 | |
| 76 | def startTestEvent( self, args ): |
| 77 | import time |
| 78 | result = EventStates().PASS |
| 79 | if len( args ) < 1: |
| 80 | main.log.warn( "%s - Not enough arguments: %s" % ( self.typeString, args ) ) |
| 81 | result = EventStates().ABORT |
| 82 | elif len( args ) > 1: |
| 83 | main.log.warn( "%s - Too many arguments: %s" % ( self.typeString, args ) ) |
| 84 | result = EventStates().ABORT |
| 85 | sleepTime = int( args[ 0 ] ) |
| 86 | time.sleep( sleepTime ) |
| 87 | return result |