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