diff options
| author | Sven Nierlein <Sven.Nierlein@consol.de> | 2013-09-17 11:43:22 +0200 |
|---|---|---|
| committer | Sven Nierlein <sven@consol.de> | 2013-09-17 12:13:51 +0200 |
| commit | 9090beb058739f24930c27a3864daa773985144d (patch) | |
| tree | 9755665c3d5acef0c448389f1ea40d0974783d07 /plugins/t | |
| parent | b83904c528d98a6eaed570cf82e0595107bab53e (diff) | |
| download | monitoring-plugins-9090beb058739f24930c27a3864daa773985144d.tar.gz | |
check_ssh: added test case
Diffstat (limited to 'plugins/t')
| -rw-r--r-- | 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 00000000..80083492 --- /dev/null +++ b/plugins/t/check_ssh.t | |||
| @@ -0,0 +1,49 @@ | |||
| 1 | #! /usr/bin/perl -w -I .. | ||
| 2 | # | ||
| 3 | # check_ssh tests | ||
| 4 | # | ||
| 5 | # | ||
| 6 | |||
| 7 | use strict; | ||
| 8 | use Test::More; | ||
| 9 | use NPTest; | ||
| 10 | |||
| 11 | # Required parameters | ||
| 12 | my $ssh_host = getTestParameter("NP_SSH_HOST", | ||
| 13 | "A host providing SSH service", | ||
| 14 | "localhost"); | ||
| 15 | |||
| 16 | my $host_nonresponsive = getTestParameter("NP_HOST_NONRESPONSIVE", | ||
| 17 | "The hostname of system not responsive to network requests", | ||
| 18 | "10.0.0.1" ); | ||
| 19 | |||
| 20 | my $hostname_invalid = getTestParameter("NP_HOSTNAME_INVALID", | ||
| 21 | "An invalid (not known to DNS) hostname", | ||
| 22 | "nosuchhost" ); | ||
| 23 | |||
| 24 | |||
| 25 | plan skip_all => "SSH_HOST must be defined" unless $ssh_host; | ||
| 26 | plan tests => 6; | ||
| 27 | |||
| 28 | |||
| 29 | my $result = NPTest->testCmd( | ||
| 30 | "./check_ssh -H $ssh_host" | ||
| 31 | ); | ||
| 32 | cmp_ok($result->return_code, '==', 0, "Exit with return code 0 (OK)"); | ||
| 33 | like($result->output, '/^SSH OK - /', "Status text if command returned none (OK)"); | ||
| 34 | |||
| 35 | |||
| 36 | $result = NPTest->testCmd( | ||
| 37 | "./check_ssh -H $host_nonresponsive -t 2" | ||
| 38 | ); | ||
| 39 | cmp_ok($result->return_code, '==', 2, "Exit with return code 0 (OK)"); | ||
| 40 | like($result->output, '/^CRITICAL - Socket timeout after 2 seconds/', "Status text if command returned none (OK)"); | ||
| 41 | |||
| 42 | |||
| 43 | |||
| 44 | $result = NPTest->testCmd( | ||
| 45 | "./check_ssh -H $hostname_invalid -t 2" | ||
| 46 | ); | ||
| 47 | cmp_ok($result->return_code, '==', 3, "Exit with return code 0 (OK)"); | ||
| 48 | like($result->output, '/^check_ssh: Invalid hostname/', "Status text if command returned none (OK)"); | ||
| 49 | |||
