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/>.
24 echo "Begining test END TO END"
27 DIR
=$
(cd $
(dirname "$0"); pwd)
28 echo "Going to dir $DIR/.."
35 #check for a process existance with good number
36 function check_process_nb
{
37 NB
=`ps -fu shinken | grep python | grep -v grep | grep $1 | wc -l`
40 echo "Error : There is not enouth $1 launched (only $NB)."
47 function is_file_present
{
50 echo "File $1 is present."
52 echo "Error : File $1 is missing!"
57 function string_in_file
{
61 echo "Error : the file $2 is missing string $1 !"
64 echo "The string $1 is in $2"
73 function check_good_run
{
75 echo "Check for $NB_SCHEDULERS Scheduler"
76 check_process_nb scheduler
$NB_SCHEDULERS
77 is_file_present
$VAR/schedulerd.pid
79 echo "Check for $NB_POLLERS pollers (1 master, 1 for multiporcess module (queue manager), 4 workers)"
80 check_process_nb poller
$NB_POLLERS
81 is_file_present
$VAR/pollerd.pid
83 echo "Check for $NB_REACTIONNERS reactionners (1 master, 1 for multiporcess module (queue manager) 1 worker)"
84 check_process_nb reactionner
$NB_REACTIONNERS
85 is_file_present
$VAR/reactionnerd.pid
87 echo "Check for $NB_BROKERS brokers (one master, one for livestatus.dat, one for log)"
88 check_process_nb broker
$NB_BROKERS
89 is_file_present
$VAR/brokerd.pid
91 echo "Check for $NB_ARBITERS arbiter"
92 check_process_nb arbiter
$NB_ARBITERS
93 is_file_present
$VAR/arbiterd.pid
95 echo "Now checking for good file prensence"
97 is_file_present
$VAR/nagios.log
98 string_in_file
"Waiting for initial configuration" $VAR/nagios.log
99 string_in_file
"First scheduling" $VAR/nagios.log
100 string_in_file
"OK, all schedulers configurations are dispatched :)" $VAR/nagios.log
101 string_in_file
"OK, no more reactionner sent need" $VAR/nagios.log
102 string_in_file
"OK, no more poller sent need" $VAR/nagios.log
103 string_in_file
"OK, no more broker sent need" $VAR/nagios.log
107 #Standard launch process packets
116 echo "Clean old tests and kill remaining processes"
120 echo "####################################################################################"
122 echo "# SIMPLE START #"
124 echo "####################################################################################"
126 echo "Now we can start some launch tests"
127 bin
/launch_all_debug.sh
130 echo "Now checking for existing apps"
132 echo "we can sleep 5sec for conf dispatching and so good number of process"
135 #Now check if the run looks good with var in the direct directory
138 echo "First launch check OK"
140 echo "####################################################################################"
141 echo "Now check bad start"
143 for mod
in arbiter scheduler broker poller reactionner
145 SHINKEN_DEFAULT_FILE
=test
/etc
/bad_start
/shinken_default .
/bin
/init.d
/shinken
-d start
"$mod"
149 echo "ERROR: $mod should not have started twice but we got successfull returncode from it !"
154 echo "####################################################################################"
156 echo "Now we clean it and test an install"
159 echo "####################################################################################"
161 echo "# DUMMY INSTALL #"
163 echo "####################################################################################"
165 echo "Now installing the application in DUMMY mode"
166 python setup.py
install --root=/tmp
/moncul
--record=INSTALLED_FILES
--install-scripts=/usr
/bin
170 echo "Error : the dummy install failed."
173 echo "Dummy install OK"
175 echo "I reclean all for a real install"
179 echo "####################################################################################"
181 echo "# REAL INSTALL #"
183 echo "####################################################################################"
185 echo "Now a REAL install"
186 sudo python setup.py
install --install-scripts=/usr
/bin
189 echo "Error : the real install failed."
192 echo "Real install OK"
194 #Useful to take it from setup_parameter? It's just for coding here
196 is_file_present
$ETC/nagios.cfg
197 is_file_present
$ETC/shinken-specific.cfg
198 string_in_file
"servicegroups.cfg" $ETC/nagios.cfg
199 is_file_present
/usr
/bin
/shinken-arbiter
204 echo "Now we can test a real run guy"
205 /etc
/init.d
/shinken-scheduler
-d start
206 /etc
/init.d
/shinken-poller
-d start
207 /etc
/init.d
/shinken-reactionner
-d start
208 /etc
/init.d
/shinken-broker
-d start
209 /etc
/init.d
/shinken-arbiter
-d start
211 echo "We will sleep again 5sec so every one is quite stable...."
213 check_good_run
/var
/lib
/shinken
215 sudo
/etc
/init.d
/shinken-arbiter status
216 sudo
/etc
/init.d
/shinken-scheduler status
217 sudo
/etc
/init.d
/shinken-poller status
218 sudo
/etc
/init.d
/shinken-reactionner status
219 sudo
/etc
/init.d
/shinken-broker status
221 sudo
/etc
/init.d
/shinken-arbiter stop
222 sudo
/etc
/init.d
/shinken-scheduler stop
223 sudo
/etc
/init.d
/shinken-poller stop
224 sudo
/etc
/init.d
/shinken-reactionner stop
225 sudo
/etc
/init.d
/shinken-broker stop
230 check_process_nb arbiter
0
231 check_process_nb scheduler
0
232 check_process_nb broker
0
233 check_process_nb poller
0
234 check_process_nb reactionner
0
238 echo "OK Great. Even the real launch test pass. Great. I can clean after me."
244 echo "####################################################################################"
248 echo "####################################################################################"
250 echo "Now we can start some launch tests"
251 test
/bin
/launch_all_debug2.sh
254 echo "Now checking for existing apps"
256 echo "we can sleep 5sec for conf dispatching and so good number of process"
259 #The number of process changed, we mush look for it
262 #Standard launch process packets
264 #6 for stack 1, and 2 for 2 (not active, so no worker)
266 #3 for stack1, 2 for stack2 (no worker from now)
268 #3 for stack 1, 1 for stack2 (no livesatus.dat nor log worker launch)
273 #Now check if the run looks good with var in the direct directory
276 echo "All launch of HA daemons is OK"
278 #Now we kill and see if all is OK :)
279 #We clean the log file
283 #We kill the most important thing first : the scheduler-Master
284 bin
/stop_scheduler.sh
286 #We sleep to be sruethe scheduler see us
291 #First we look is the arbiter saw the scheduler as dead
292 string_in_file
"Warning : Scheduler scheduler-Master had the configuration 0 but is dead, I am not happy." $VAR/nagios.log
293 #Then we look if the scheduler-spare got a conf from arbiter (here, view from the arbiter)
294 string_in_file
"Dispatch OK of for conf in scheduler scheduler-Spare" $VAR/nagios.log
296 #then is the broker know it and try to connect to the new scheduler-spare
297 string_in_file
"\[broker-Master\] Connexion OK to the scheduler scheduler-Spare" $VAR/nagios.log
300 echo "Now stop the poller-Master"
301 #Now we stop the poller. We will see the sapre take the job (we hope in fact :) )
307 #The master should be look dead
308 string_in_file
"Warning : The poller poller-Master seems to be down, I must re-dispatch its role to someone else." $VAR/nagios.log
309 #The spare should got the conf
310 string_in_file
"\[All\] Dispatch OK of for configuration 0 to poller poller-Slave" $VAR/nagios.log
311 #And he should got the scheduler link (the sapre one)
312 string_in_file
"\[poller-Slave\] Connexion OK with scheduler scheduler-Spare" $VAR/nagios.log
315 echo "Now stop the reactionner"
316 bin
/stop_reactionner.sh
321 #The master should be look dead
322 string_in_file
"\[All\] Warning : The reactionner reactionner-Master seems to be down, I must re-dispatch its role to someone else." $VAR/nagios.log
323 #The spare should got the conf
324 string_in_file
"\[All\] Dispatch OK of for configuration 0 to reactionner reactionner-Spare" $VAR/nagios.log
325 #And he should got the scheduler link (the sapre one)
326 string_in_file
"\[reactionner-Spare\] Connexion OK with scheduler scheduler-Spare" $VAR/nagios.log
329 echo "Now we stop... the Broker!"
335 #The master should be look dead
336 string_in_file
"\[All\] Warning : The broker broker-Master seems to be down, I must re-dispatch its role to someone else." $VAR/nagios.log
337 #The spare should got the conf
338 string_in_file
"\[All\] Dispatch OK of for configuration 0 to broker broker-Slave" $VAR/nagios.log
339 #And he should got the scheduler link (the spare one)
340 string_in_file
"\[broker-Slave\] Connexion OK to the scheduler scheduler-Spare" $VAR/nagios.log
341 #And to other satellites
342 string_in_file
"\[broker-Slave\] Connexion OK to the reactionner reactionner-Spare" $VAR/nagios.log
343 string_in_file
"\[broker-Slave\] Connexion problem to the poller poller-Master : connection failed" $VAR/nagios.log
344 #And should have load the modules
345 string_in_file
"\[broker-Slave\] I correctly load the modules : \['Simple-log', 'Livestatus'\]" $VAR/nagios.log
348 echo "Now we clean it"
353 echo "####################################################################################"
355 echo "# Load balancing launch #"
357 echo "####################################################################################"
359 echo "Now we can start some launch tests"
360 test
/bin
/launch_all_debug3.sh
363 echo "Now checking for existing apps"
365 echo "we can sleep 5sec for conf dispatching and so good number of process"
368 #The number of process changed, we mush look for it
371 #Standard launch process packets
373 #6 for stack 1, and 6 for stack 2
375 #3 for stack1, same for stack 2
377 #3 for stack 1, 1 for stack2 (no livestatus nor log worker launch)
382 #Now check if the run looks good with var in the direct directory
385 echo "All launch of LB daemons is OK"
388 #Now look if it's also good in the log file too
389 string_in_file
"Dispatch OK of for conf in scheduler scheduler-Master-2" $VAR/nagios.log
390 string_in_file
"Dispatch OK of for conf in scheduler scheduler-Master-1" $VAR/nagios.log
391 string_in_file
"OK, no more reactionner sent need" $VAR/nagios.log
392 string_in_file
"OK, no more poller sent need" $VAR/nagios.log
393 string_in_file
"OK, no more broker sent need" $VAR/nagios.log
395 echo "Now we clean it"
401 echo "All check are OK. Congrats! You can go take a Beer ;)"