[icinga-checkins] icinga.org: icinga-core/mfriedrich/cgis: Rewrite and enhance 900-configparsing.t

git at icinga.org git at icinga.org
Sat Feb 25 15:48:05 CET 2012


Module: icinga-core
Branch: mfriedrich/cgis
Commit: b7b778246843054c66d98040d77927f74e378a5d
URL:    https://git.icinga.org/?p=icinga-core.git;a=commit;h=b7b778246843054c66d98040d77927f74e378a5d

Author: Alexander Wirt <formorer at debian.org>
Date:   Sat Feb 25 10:44:47 2012 +0100

Rewrite and enhance 900-configparsing.t

---

 t/900-configparsing.t |   44 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 44 insertions(+), 0 deletions(-)

diff --git a/t/900-configparsing.t b/t/900-configparsing.t
new file mode 100644
index 0000000..2756e30
--- /dev/null
+++ b/t/900-configparsing.t
@@ -0,0 +1,44 @@
+#!/usr/bin/perl
+# 
+# Taking a known icinga configuration directory, will check that the objects.cache is as expected
+
+use warnings;
+use strict;
+use Test::Most;
+use FindBin qw($Bin);
+use Icinga::Test qw ( run_cmd );
+use Perl6::Slurp;
+
+chdir $Bin or die "Cannot chdir";
+
+my $topdir = "$Bin/..";
+my $icinga = "$topdir/base/icinga";
+my $etc = "$Bin/etc";
+my $precache = "$Bin/var/objects.precache";
+
+plan tests => 3;
+
+my $output = run_cmd([$icinga, '-v', "$etc/icinga.cfg"]);
+if ($? == 0) {
+	pass("Icinga validated test configuration successfully");
+} else {
+	fail("Icinga validation failed:\n$output");
+}
+
+unlink $precache if -e $precache ;
+$output = run_cmd ([ $icinga, '-vp', "$etc/icinga.cfg" ]);
+if ($? == 0) {
+	pass("Icinga precache generated successfully");
+} else {
+	fail("Could not create Icinga precache:\n$output");
+}
+
+system("grep -v 'Created:' $precache > '$precache.generated'");
+
+my $generated = slurp("$precache.generated");
+my $expected = slurp("$precache.expected");
+eq_or_diff($generated, $expected,'Icinga precached objects file matches expected');
+
+#cleanup
+unlink("$precache.generated") if -e "$precache.generated";
+unlink $precache if -e $precache;





More information about the icinga-checkins mailing list