blob: 866c21919cd1a447f1d46262a40147cb9eeafe79 [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 classes for CHOTestMonkey that are related to check event
23Author: you@onlab.us
24"""
25from tests.CHOTestMonkey.dependencies.events.Event import EventType, EventStates, Event
26
Jon Hall2bb3e212017-05-24 17:07:25 -070027
You Wangdb927a52016-02-26 11:03:28 -080028class TestEvent( Event ):
Jon Hall2bb3e212017-05-24 17:07:25 -070029
You Wangdb927a52016-02-26 11:03:28 -080030 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 Hall2bb3e212017-05-24 17:07:25 -070042
You Wangdb927a52016-02-26 11:03:28 -080043class TestPause( TestEvent ):
Jon Hall2bb3e212017-05-24 17:07:25 -070044
You Wangdb927a52016-02-26 11:03:28 -080045 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 Hall2bb3e212017-05-24 17:07:25 -070055
You Wangdb927a52016-02-26 11:03:28 -080056class TestResume( TestEvent ):
Jon Hall2bb3e212017-05-24 17:07:25 -070057
You Wangdb927a52016-02-26 11:03:28 -080058 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 Hall2bb3e212017-05-24 17:07:25 -070068
You Wangdb927a52016-02-26 11:03:28 -080069class TestSleep( TestEvent ):
Jon Hall2bb3e212017-05-24 17:07:25 -070070
You Wangdb927a52016-02-26 11:03:28 -080071 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