blob: a7f99b90c4e796b5ca45ade54130cda08023b234 [file] [log] [blame]
You Wangdb927a52016-02-26 11:03:28 -08001"""
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -07002Copyright 2016 Open Networking Foundation (ONF)
3
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
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 Wangdb927a52016-02-26 11:03:28 -080023This file contains classes for CHOTestMonkey that are related to check event
24Author: you@onlab.us
25"""
26from tests.CHOTestMonkey.dependencies.events.Event import EventType, EventStates, Event
27
Jon Hall2bb3e212017-05-24 17:07:25 -070028
You Wangdb927a52016-02-26 11:03:28 -080029class TestEvent( Event ):
Jon Hall2bb3e212017-05-24 17:07:25 -070030
You Wangdb927a52016-02-26 11:03:28 -080031 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 Hall2bb3e212017-05-24 17:07:25 -070043
You Wangdb927a52016-02-26 11:03:28 -080044class TestPause( TestEvent ):
Jon Hall2bb3e212017-05-24 17:07:25 -070045
You Wangdb927a52016-02-26 11:03:28 -080046 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 Hall2bb3e212017-05-24 17:07:25 -070056
You Wangdb927a52016-02-26 11:03:28 -080057class TestResume( TestEvent ):
Jon Hall2bb3e212017-05-24 17:07:25 -070058
You Wangdb927a52016-02-26 11:03:28 -080059 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 Hall2bb3e212017-05-24 17:07:25 -070069
You Wangdb927a52016-02-26 11:03:28 -080070class TestSleep( TestEvent ):
Jon Hall2bb3e212017-05-24 17:07:25 -070071
You Wangdb927a52016-02-26 11:03:28 -080072 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