[omd-commits] OMD Git: omd: tests: adjusted tests to new apache config

git version control git at mathias-kettner.de
Wed Jul 16 22:22:46 CEST 2014


Module:   omd
Branch:   master
Commit:   9eb5c3fe8cbd42e9c6421e19d38046bbf7e11368
URL:      http://omdistro.org/projects/omd/repository/revisions/9eb5c3fe8cbd42e9c6421e19d38046bbf7e11368

Author:   Sven Nierlein <Sven.Nierlein at consol.de>
Date:     Mon Jul 14 14:15:53 2014 +0200
Commiter: Sven Nierlein <Sven.Nierlein at consol.de>
Date:     Wed Jul 16 13:32:45 2014 +0200

tests: adjusted tests to new apache config

---

 distros/Makefile.CENTOS_7.0 |    2 +-
 t/20-package_check_multi.t  |    2 +-
 t/20-package_omd.t          |    2 +-
 t/20-package_thruk.t        |    8 ++++----
 t/TestUtils.pm              |   16 ++++++++++++++++
 5 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/distros/Makefile.CENTOS_7.0 b/distros/Makefile.CENTOS_7.0
index 8d399ac..cb6457d 100644
--- a/distros/Makefile.CENTOS_7.0
+++ b/distros/Makefile.CENTOS_7.0
@@ -86,4 +86,4 @@ PHP_FCGI_BIN      = /usr/bin/php-cgi
 APACHE_ENMOD      = true %s
 BECOME_ROOT       = su -c
 MOUNT_OPTIONS     =
-INIT_CMD          = systemctl %(action)s %(name)s.service
+INIT_CMD          = /usr/bin/systemctl %(action)s %(name)s.service
diff --git a/t/20-package_check_multi.t b/t/20-package_check_multi.t
index 1c04a40..7fcab1b 100644
--- a/t/20-package_check_multi.t
+++ b/t/20-package_check_multi.t
@@ -177,5 +177,5 @@ for my $core (qw/nagios/) {
 	}
 }
 
-TestUtils::test_command({ cmd => TestUtils::config('APACHE_CTL')." restart" });
+TestUtils::restart_system_apache();
 TestUtils::remove_test_site($site);
diff --git a/t/20-package_omd.t b/t/20-package_omd.t
index 5fbfad1..85cc516 100644
--- a/t/20-package_omd.t
+++ b/t/20-package_omd.t
@@ -42,7 +42,7 @@ for my $test (@{$tests}) {
 
 # switch webserver to shared mode
 TestUtils::test_command({ cmd => $omd_bin." config $site set APACHE_MODE shared" });
-TestUtils::test_command({ cmd => TestUtils::config('APACHE_CTL')." restart" });
+TestUtils::restart_system_apache();
 
 # then run tests again
 for my $test (@{$tests}) {
diff --git a/t/20-package_thruk.t b/t/20-package_thruk.t
index 25885e7..ce8a22c 100644
--- a/t/20-package_thruk.t
+++ b/t/20-package_thruk.t
@@ -218,7 +218,7 @@ for my $core (qw/nagios shinken icinga/) {
     TestUtils::test_command({ cmd => $omd_bin." stop $site" });
     TestUtils::test_command({ cmd => $omd_bin." config $site set CORE $core" });
     TestUtils::test_command({ cmd => $omd_bin." config $site set APACHE_MODE own" });
-    TestUtils::test_command({ cmd => TestUtils::config('APACHE_CTL')." restart" });
+    TestUtils::restart_system_apache();
     TestUtils::test_command({ cmd => $omd_bin." start $site" }) or TestUtils::bail_out_clean("No need to test Thruk without proper startup");
     TestUtils::wait_for_file("/omd/sites/$site/tmp/run/live")   or TestUtils::bail_out_clean("No need to test Thruk without livestatus connection");
     unlink("/omd/sites/$site/tmp/thruk/thruk.cache");
@@ -246,7 +246,7 @@ for my $core (qw/nagios shinken icinga/) {
     # switch webserver to shared mode
     TestUtils::test_command({ cmd => $omd_bin." stop $site" });
     TestUtils::test_command({ cmd => $omd_bin." config $site set APACHE_MODE shared" });
-    TestUtils::test_command({ cmd => TestUtils::config('APACHE_CTL')." restart" });
+    TestUtils::restart_system_apache();
     TestUtils::test_command({ cmd => $omd_bin." start $site" });
 
     ##################################################
@@ -282,7 +282,7 @@ TestUtils::test_command({ cmd => $omd_bin." config $site set CORE nagios" });
 TestUtils::test_command({ cmd => $omd_bin." config $site set APACHE_MODE own" });
 TestUtils::test_command({ cmd => $omd_bin." config $site set THRUK_COOKIE_AUTH on" });
 TestUtils::test_command({ cmd => $omd_bin." start $site", like => '/OK/' });
-TestUtils::test_command({ cmd => TestUtils::config('APACHE_CTL')." restart" });
+TestUtils::restart_system_apache();
 TestUtils::test_command({ cmd => $omd_bin." start $site thruk", like => '/OK/' });
 sleep(3);
 TestUtils::test_command({ cmd => $omd_bin." status $site apache", like => '/running/' });
@@ -292,7 +292,7 @@ for my $url ( @{$cookie_urls} ) {
 
 ##################################################
 # cleanup test site
-TestUtils::test_command({ cmd => TestUtils::config('APACHE_CTL')." restart" });
+TestUtils::restart_system_apache();
 TestUtils::remove_test_site($site);
 
 
diff --git a/t/TestUtils.pm b/t/TestUtils.pm
index ab926c3..a05cf8a 100644
--- a/t/TestUtils.pm
+++ b/t/TestUtils.pm
@@ -842,6 +842,22 @@ sub _tail_apache_logs {
 
 ##################################################
 
+=head2 restart_system_apache
+
+  restart system apache
+
+=cut
+sub restart_system_apache {
+    my $name = TestUtils::config('APACHE_INIT_NAME');
+    my $init = TestUtils::config('INIT_CMD');
+    my $cmd  = $init;
+    $cmd     =~ s/\Q%(name)s\E/$name/mx;
+    $cmd     =~ s/\Q%(action)s\E/restart/mx;
+    TestUtils::test_command({ cmd => $cmd });
+}
+
+##################################################
+
 END {
     if(defined $omd_symlink_created and $omd_symlink_created == 1) {
         unlink('/omd');



More information about the omd-commits mailing list