diff options
Diffstat (limited to 'plugins/t/check_by_ssh.t')
-rw-r--r-- | plugins/t/check_by_ssh.t | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/plugins/t/check_by_ssh.t b/plugins/t/check_by_ssh.t index 1d2939e9..b6479f1f 100644 --- a/plugins/t/check_by_ssh.t +++ b/plugins/t/check_by_ssh.t | |||
@@ -19,19 +19,19 @@ plan skip_all => "SSH_HOST and SSH_IDENTITY must be defined" unless ($ssh_servic | |||
19 | plan tests => 42; | 19 | plan tests => 42; |
20 | 20 | ||
21 | # Some random check strings/response | 21 | # Some random check strings/response |
22 | my @responce = ('OK: Everything is fine', | 22 | my @response = ('OK: Everything is fine', |
23 | 'WARNING: Hey, pick me, pick me', | 23 | 'WARNING: Hey, pick me, pick me', |
24 | 'CRITICAL: Shit happens', | 24 | 'CRITICAL: Shit happens', |
25 | 'UNKNOWN: What can I do for ya', | 25 | 'UNKNOWN: What can I do for ya', |
26 | 'WOOPS: What did I smoke', | 26 | 'WOOPS: What did I smoke', |
27 | ); | 27 | ); |
28 | my @responce_re; | 28 | my @response_re; |
29 | my @check; | 29 | my @check; |
30 | for (@responce) { | 30 | for (@response) { |
31 | push(@check, "echo $_"); | 31 | push(@check, "echo $_"); |
32 | my $re_str = $_; | 32 | my $re_str = $_; |
33 | $re_str =~ s{(.)} { "\Q$1" }ge; | 33 | $re_str =~ s{(.)} { "\Q$1" }ge; |
34 | push(@responce_re, $re_str); | 34 | push(@response_re, $re_str); |
35 | } | 35 | } |
36 | 36 | ||
37 | my $result; | 37 | my $result; |
@@ -47,7 +47,7 @@ for (my $i=0; $i<4; $i++) { | |||
47 | "./check_by_ssh -i $ssh_key -H $ssh_service -C '$check[$i]; exit $i'" | 47 | "./check_by_ssh -i $ssh_key -H $ssh_service -C '$check[$i]; exit $i'" |
48 | ); | 48 | ); |
49 | cmp_ok($result->return_code, '==', $i, "Exit with return code $i"); | 49 | cmp_ok($result->return_code, '==', $i, "Exit with return code $i"); |
50 | is($result->output, $responce[$i], "Status text is correct for check $i"); | 50 | is($result->output, $response[$i], "Status text is correct for check $i"); |
51 | } | 51 | } |
52 | 52 | ||
53 | $result = NPTest->testCmd( | 53 | $result = NPTest->testCmd( |
@@ -84,7 +84,7 @@ $result = NPTest->testCmd( | |||
84 | "./check_by_ssh -i $ssh_key -H $ssh_service -C '$check[4]; exit 8'" | 84 | "./check_by_ssh -i $ssh_key -H $ssh_service -C '$check[4]; exit 8'" |
85 | ); | 85 | ); |
86 | cmp_ok($result->return_code, '==', 8, "Exit with return code 8 (out of bounds)"); | 86 | cmp_ok($result->return_code, '==', 8, "Exit with return code 8 (out of bounds)"); |
87 | is($result->output, $responce[4], "Return proper status text even with unknown status codes"); | 87 | is($result->output, $response[4], "Return proper status text even with unknown status codes"); |
88 | 88 | ||
89 | $result = NPTest->testCmd( | 89 | $result = NPTest->testCmd( |
90 | "./check_by_ssh -i $ssh_key -H $ssh_service -F $ssh_conf -C 'exit 0'" | 90 | "./check_by_ssh -i $ssh_key -H $ssh_service -F $ssh_conf -C 'exit 0'" |
@@ -108,7 +108,7 @@ my %linemap = ( | |||
108 | foreach my $line (0, 2, 4, 6) { | 108 | foreach my $line (0, 2, 4, 6) { |
109 | my $code = $linemap{$line}; | 109 | my $code = $linemap{$line}; |
110 | my $statline = $line+1; | 110 | my $statline = $line+1; |
111 | is($lines[$line], "$responce[$code]", "multiple checks status text is correct for line $line"); | 111 | is($lines[$line], "$response[$code]", "multiple checks status text is correct for line $line"); |
112 | is($lines[$statline], "STATUS CODE: $code", "multiple check status code is correct for line $line"); | 112 | is($lines[$statline], "STATUS CODE: $code", "multiple check status code is correct for line $line"); |
113 | } | 113 | } |
114 | 114 | ||
@@ -124,7 +124,7 @@ close(PASV) or die("Unable to close '/tmp/check_by_ssh.$$': $!"); | |||
124 | cmp_ok(scalar(@pasv), '==', 1, 'One passive result for one check performed'); | 124 | cmp_ok(scalar(@pasv), '==', 1, 'One passive result for one check performed'); |
125 | for (0) { | 125 | for (0) { |
126 | if ($pasv[$_]) { | 126 | if ($pasv[$_]) { |
127 | like($pasv[$_], '/^\[\d+\] PROCESS_SERVICE_CHECK_RESULT;flint;serv;2;' . $responce_re[2] . '$/', 'proper result for passive check'); | 127 | like($pasv[$_], '/^\[\d+\] PROCESS_SERVICE_CHECK_RESULT;flint;serv;2;' . $response_re[2] . '$/', 'proper result for passive check'); |
128 | } else { | 128 | } else { |
129 | fail('proper result for passive check'); | 129 | fail('proper result for passive check'); |
130 | } | 130 | } |
@@ -144,7 +144,7 @@ for (0, 1, 2, 3, 4) { | |||
144 | if ($pasv[$_]) { | 144 | if ($pasv[$_]) { |
145 | my $ret = $_; | 145 | my $ret = $_; |
146 | $ret = 9 if ($_ == 4); | 146 | $ret = 9 if ($_ == 4); |
147 | like($pasv[$_], '/^\[\d+\] PROCESS_SERVICE_CHECK_RESULT;flint;c' . $_ . ';' . $ret . ';' . $responce_re[$_] . '$/', "proper result for passive check $_"); | 147 | like($pasv[$_], '/^\[\d+\] PROCESS_SERVICE_CHECK_RESULT;flint;c' . $_ . ';' . $ret . ';' . $response_re[$_] . '$/', "proper result for passive check $_"); |
148 | } else { | 148 | } else { |
149 | fail("proper result for passive check $_"); | 149 | fail("proper result for passive check $_"); |
150 | } | 150 | } |