13 use lib
"$FindBin::Bin/lib/lib/perl5";
16 unless($ENV{THRUK_AUTHOR
}) {
17 plan
( skip_all
=> 'Thruk Author test. Set $ENV{THRUK_AUTHOR} to a true value to run.' );
22 ##################################################
23 # create our test site
24 my $omd_bin = TestUtils
::get_omd_bin
();
25 my $site = TestUtils
::create_test_site
() or TestUtils
::bail_out_clean
("no further testing without site");
26 my $auth = 'OMD Monitoring Site '.$site.':omdadmin:omd';
28 # decrease pnp interval
29 TestUtils
::test_command
({ cmd
=> "/usr/bin/env sed -i -e 's/^perfdata_file_processing_interval = 15/perfdata_file_processing_interval = 2/g' -e 's/^sleep_time = 15/sleep_time = 2/g' /opt/omd/sites/$site/etc/pnp4nagios/npcd.cfg" });
31 # set thruk as default
32 TestUtils
::test_command
({ cmd
=> $omd_bin." config $site set DEFAULT_GUI thruk" });
34 ok
(copy
("t/data/thruk/test_conf1.cfg", "/omd/sites/$site/etc/nagios/conf.d/test.cfg"), "copy test config to site dir");
36 TestUtils
::test_command
({ cmd
=> "/bin/su - $site -c './etc/init.d/nagios checkconfig'", like
=> '/Running configuration check\.\.\.\ done/' });
37 TestUtils
::test_command
({ cmd
=> $omd_bin." start $site" }) or TestUtils
::bail_out_clean
("No need to test Thruk without proper startup");
38 TestUtils
::wait_for_file
("/omd/sites/$site/tmp/run/live") or TestUtils
::bail_out_clean
("No need to test Thruk without livestatus connection");
41 { url
=> '/thruk/cgi-bin/status.cgi?view_mode=xls&host=all', 'like' => [ '/Arial/' ] },
45 for my $url ( @
{$urls} ) {
46 $url->{'url'} = "http://localhost/".$site.$url->{'url'};
47 $url->{'auth'} = $auth;
48 $url->{'unlike'} = [ '/internal server error/', '/"\/thruk\//', '/\'\/thruk\//' ];
51 for my $core (qw
/nagios shinken/) {
52 ##################################################
54 TestUtils
::test_command
({ cmd
=> $omd_bin." stop $site" });
55 TestUtils
::test_command
({ cmd
=> $omd_bin." config $site set CORE $core" });
56 TestUtils
::test_command
({ cmd
=> $omd_bin." start $site" }) or TestUtils
::bail_out_clean
("No need to test Thruk without proper startup");
57 TestUtils
::wait_for_file
("/omd/sites/$site/tmp/run/live") or TestUtils
::bail_out_clean
("No need to test Thruk without livestatus connection");
59 # request force command to create a rrd file
60 TestUtils
::test_command
({ cmd
=> "/bin/su - $site -c './lib/nagios/plugins/check_http -H localhost -a omdadmin:omd -u /$site/nagios/cgi-bin/cmd.cgi -e 200 -P \"cmd_typ=7&cmd_mod=2&host=test_host&service=test_echo&start_time=2010-11-06+09%3A46%3A02&force_check=on&btnSubmit=Commit\" -r \"Your command request was successfully submitted\"'", like
=> '/HTTP OK:/' });
61 TestUtils
::test_command
({ cmd
=> "/bin/su - $site -c './lib/nagios/plugins/check_http -H localhost -a omdadmin:omd -u /$site/nagios/cgi-bin/cmd.cgi -e 200 -P \"cmd_typ=7&cmd_mod=2&host=omd-$site&service=Dummy+Service&start_time=2010-11-06+09%3A46%3A02&force_check=on&btnSubmit=Commit\" -r \"Your command request was successfully submitted\"'", like
=> '/HTTP OK:/' });
62 TestUtils
::wait_for_file
("/omd/sites/$site/var/pnp4nagios/perfdata/omd-$site/Dummy_Service_omd-dummy.rrd");
64 ##################################################
65 # and request some pages
66 for my $url ( @
{$urls} ) {
67 TestUtils
::test_url
($url);
71 ##################################################
73 TestUtils
::remove_test_site
($site);