1 #!/usr/bin/env python2.6
2 #Copyright (C) 2009-2010 :
3 # Gabes Jean, naparuba@gmail.com
4 # Gerhard Lausser, Gerhard.Lausser@consol.de
6 #This file is part of Shinken.
8 #Shinken is free software: you can redistribute it and/or modify
9 #it under the terms of the GNU Affero General Public License as published by
10 #the Free Software Foundation, either version 3 of the License, or
11 #(at your option) any later version.
13 #Shinken 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 Affero General Public License for more details.
18 #You should have received a copy of the GNU Affero General Public License
19 #along with Shinken. If not, see <http://www.gnu.org/licenses/>.
22 # This file is used to test reading and processing of config files
26 from shinken_test
import *
29 class TestConfig(ShinkenTest
):
30 #setUp is in shinken_test
33 def test_satellite_failed_check(self
):
34 print "Create a Scheduler dummy"
35 creation_tab
= {'scheduler_name' : 'scheduler-1', 'address' : '0.0.0.0', 'spare' : '0', 'port' : '9999'}
36 s
= SchedulerLink(creation_tab
)
40 s
.max_check_attempts
= 4
41 #Lie : we start at true here
44 #Should be attempt = 0
45 self
.assert_(s
.attempt
== 0)
46 #Now make bad ping, sould be unreach and dead (but not dead
48 self
.assert_(s
.attempt
== 1)
49 self
.assert_(s
.alive
== True)
50 self
.assert_(s
.reachable
== False)
52 #Now make bad ping, sould be unreach and dead (but not dead
54 self
.assert_(s
.attempt
== 2)
55 self
.assert_(s
.alive
== True)
56 self
.assert_(s
.reachable
== False)
58 #Now make bad ping, sould be unreach and dead (but not dead
60 self
.assert_(s
.attempt
== 3)
61 self
.assert_(s
.alive
== True)
62 self
.assert_(s
.reachable
== False)
64 #Ok, this time we go DEAD!
66 self
.assert_(s
.attempt
== 4)
67 self
.assert_(s
.alive
== False)
68 self
.assert_(s
.reachable
== False)
70 #Now set a OK ping (false because we won't open the port here...)
72 self
.assert_(s
.attempt
== 0)
73 self
.assert_(s
.alive
== True)
74 self
.assert_(s
.reachable
== True)
78 if __name__
== '__main__':