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
):
31 self
.setup_with_file('etc/nagios_host_without_cmd.cfg')
34 def test_host_is_pending(self
):
36 # first of all, a host without check_command must be valid
37 self
.assert_(self
.conf
.conf_is_correct
)
38 # service always ok, host stays pending
40 host
= self
.sched
.hosts
.find_by_name("test_host_0")
41 for c
in host
.checks_in_progress
:
42 # hurry up, we need an immediate result
44 # scheduler.schedule() always schedules a check, even for this
46 #host.checks_in_progress = []
47 host
.act_depend_of
= [] # ignore the router
48 host
.checks_in_progress
= []
49 host
.in_checking
= False
50 svc
= self
.sched
.services
.find_srv_by_name_and_hostname("test_host_0", "test_ok_0")
51 svc
.checks_in_progress
= []
52 # this time we need the dependency from service to host
53 #svc.act_depend_of = [] # no hostchecks on critical checkresults
55 # initially the host is pending
56 self
.assert_(host
.state
== 'PENDING')
57 self
.assert_(svc
.state
== 'PENDING')
58 # now force a dependency check of the host
59 self
.scheduler_loop(2, [[svc
, 2, 'BAD | value1=0 value2=0']])
61 # and now the host is magically UP
62 self
.assert_(host
.state
== 'UP')
63 self
.assert_(host
.state_type
== 'HARD')
64 self
.assert_(host
.output
== 'Host assumed to be UP')
68 if __name__
== '__main__':