[nagiosplug] check_ssh: added test case
"Nagios Plugin Development" <[email protected]> Tue, 17 Sep 2013 21:40:22 +0000
| Newsgroups | gmane.network.nagios.plugins.cvs |
|---|---|
| Message-ID | <[email protected]> |
Module: nagiosplug
Branch: master
Commit: 9090beb058739f24930c27a3864daa773985144d
Author: Sven Nierlein <[email protected]>
Committer: Sven Nierlein <[email protected]>
Date: Tue Sep 17 11:43:22 2013 +0200
URL: http://nagiosplug.git.sf.net/git/gitweb.cgi?p=nagiosplug/nagiosplug;a=commit;h=9090beb
check_ssh: added test case
---
plugins/t/check_ssh.t | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 49 insertions(+), 0 deletions(-)
diff --git a/plugins/t/check_ssh.t b/plugins/t/check_ssh.t
new file mode 100644
index 0000000..8008349
--- /dev/null
+++ b/plugins/t/check_ssh.t
@@ -0,0 +1,49 @@
+#! /usr/bin/perl -w -I ..
+#
+# check_ssh tests
+#
+#
+
+use strict;
+use Test::More;
+use NPTest;
+
+# Required parameters
+my $ssh_host = getTestParameter("NP_SSH_HOST",
+ "A host providing SSH service",
+ "localhost");
+
+my $host_nonresponsive = getTestParameter("NP_HOST_NONRESPONSIVE",
+ "The hostname of system not responsive to network requests",
+ "10.0.0.1" );
+
+my $hostname_invalid = getTestParameter("NP_HOSTNAME_INVALID",
+ "An invalid (not known to DNS) hostname",
+ "nosuchhost" );
+
+
+plan skip_all => "SSH_HOST must be defined" unless $ssh_host;
+plan tests => 6;
+
+
+my $result = NPTest->testCmd(
+ "./check_ssh -H $ssh_host"
+ );
+cmp_ok($result->return_code, '==', 0, "Exit with return code 0 (OK)");
+like($result->output, '/^SSH OK - /', "Status text if command returned none (OK)");
+
+
+$result = NPTest->testCmd(
+ "./check_ssh -H $host_nonresponsive -t 2"
+ );
+cmp_ok($result->return_code, '==', 2, "Exit with return code 0 (OK)");
+like($result->output, '/^CRITICAL - Socket timeout after 2 seconds/', "Status text if command returned none (OK)");
+
+
+
+$result = NPTest->testCmd(
+ "./check_ssh -H $hostname_invalid -t 2"
+ );
+cmp_ok($result->return_code, '==', 3, "Exit with return code 0 (OK)");
+like($result->output, '/^check_ssh: Invalid hostname/', "Status text if command returned none (OK)");
+
------------------------------------------------------------------------------
LIMITED TIME SALE - Full Year of Microsoft Training For Just $49.99!
1,500+ hours of tutorials including VisualStudio 2012, Windows 8, SharePoint
2013, SQL 2012, MVC 4, more. BEST VALUE: New Multi-Library Power Pack includes
Mobile, Cloud, Java, and UX Design. Lowest price ever! Ends 9/20/13.
http://pubads.g.doubleclick.net/gampad/clk?id=58041151&iu=/4140/ostg.clktrk