[icinga-checkins] icinga.org: icinga-core/dev/cgis: Rewrite and enhance 705icingastats.t

git at icinga.org git at icinga.org
Sat Feb 25 15:43:47 CET 2012


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

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

Rewrite and enhance 705icingastats.t

---

 t/705icingastats.t |   36 ++++++++++++++++++++++++++++++++++++
 1 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/t/705icingastats.t b/t/705icingastats.t
new file mode 100644
index 0000000..2870dac
--- /dev/null
+++ b/t/705icingastats.t
@@ -0,0 +1,36 @@
+#!/usr/bin/perl
+
+# Checks icingastats
+
+use warnings;
+use strict;
+use Test::More;
+use Icinga::Test qw ( run_cmd );
+use FindBin qw($Bin);
+
+my $topdir = "$Bin/..";
+my $icingastats = "$topdir/base/icingastats";
+my $etc = "$Bin/etc";
+
+plan tests => 9;
+
+my $output = run_cmd([$icingastats, '-c',  "$etc/icnga-does-not-exit.cfg"]);
+isnt( $?, 0, "Bad return code with no config file" );
+like( $output, "/Error processing config file/", "No config file" );
+
+$output = run_cmd([$icingastats, '-c', "$etc/icinga-no-status.cfg"]);
+isnt( $?, 0, "Bad return code with no status file" );
+like( $output, "/Error reading status file 'var/status.dat.no.such.file': No such file or directory/", "No config file" );
+
+$output = run_cmd([$icingastats, '-c', "$etc/icinga-no-status.cfg", '-m', 'NUMHSTUP']);
+isnt( $?, 0, "Bad return code with no status file in MRTG mode" );
+
+$output = run_cmd([$icingastats, '-c', "$etc/icinga.cfg"]);
+is($?, 0, "No error with working config");
+
+like($output, qr/Icinga PID.*48451\s/, 'Should include icinga pid');
+
+like($output, qr/Total Hosts.*2\s/, 'We have two hosts in this config');
+like($output, qr/Total Services.*2\s/, 'We have two hosts in this config');
+
+





More information about the icinga-checkins mailing list