summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRincewindsHat <12514511+RincewindsHat@users.noreply.github.com>2021-12-03 08:56:24 (GMT)
committerRincewindsHat <12514511+RincewindsHat@users.noreply.github.com>2022-03-15 20:04:30 (GMT)
commit22f7b41d9138f6e69395a8d7da894a50d95f5abf (patch)
tree029bec612e019fb382f9abb7505d9a73a39546da
parent525c9026a7df47675ae3104a25231f6c35fb0b13 (diff)
downloadmonitoring-plugins-22f7b41.tar.gz
Fix tests (hopefully)
-rw-r--r--plugins-root/t/check_icmp.t16
1 files changed, 15 insertions, 1 deletions
diff --git a/plugins-root/t/check_icmp.t b/plugins-root/t/check_icmp.t
index 71cc5b3..1a75586 100644
--- a/plugins-root/t/check_icmp.t
+++ b/plugins-root/t/check_icmp.t
@@ -12,7 +12,11 @@ my $allow_sudo = getTestParameter( "NP_ALLOW_SUDO",
12 "no" ); 12 "no" );
13 13
14if ($allow_sudo eq "yes" or $> == 0) { 14if ($allow_sudo eq "yes" or $> == 0) {
15<<<<<<< HEAD
15 plan tests => 18; 16 plan tests => 18;
17=======
18 plan tests => 20;
19>>>>>>> 44f19e79 (Fix tests (hopefully))
16} else { 20} else {
17 plan skip_all => "Need sudo to test check_icmp"; 21 plan skip_all => "Need sudo to test check_icmp";
18} 22}
@@ -35,54 +39,63 @@ my $hostname_invalid = getTestParameter( "NP_HOSTNAME_INVALID",
35 39
36my $res; 40my $res;
37 41
42# 1
38$res = NPTest->testCmd( 43$res = NPTest->testCmd(
39 "$sudo ./check_icmp -H $host_responsive -w 10000ms,100% -c 10000ms,100%" 44 "$sudo ./check_icmp -H $host_responsive -w 10000ms,100% -c 10000ms,100%"
40 ); 45 );
41is( $res->return_code, 0, "Syntax ok" ); 46is( $res->return_code, 0, "Syntax ok" );
42like( $res->output, $successOutput, "Output OK" ); 47like( $res->output, $successOutput, "Output OK" );
43 48
49# 2
44$res = NPTest->testCmd( 50$res = NPTest->testCmd(
45 "$sudo ./check_icmp -H $host_responsive -w 0ms,0% -c 10000ms,100%" 51 "$sudo ./check_icmp -H $host_responsive -w 0ms,0% -c 10000ms,100%"
46 ); 52 );
47is( $res->return_code, 1, "Syntax ok, with forced warning" ); 53is( $res->return_code, 1, "Syntax ok, with forced warning" );
48like( $res->output, $failureOutput, "Output OK" ); 54like( $res->output, $failureOutput, "Output OK" );
49 55
56# 3
50$res = NPTest->testCmd( 57$res = NPTest->testCmd(
51 "$sudo ./check_icmp -H $host_responsive -w 0,0% -c 0,0%" 58 "$sudo ./check_icmp -H $host_responsive -w 0,0% -c 0,0%"
52 ); 59 );
53is( $res->return_code, 2, "Syntax ok, with forced critical" ); 60is( $res->return_code, 2, "Syntax ok, with forced critical" );
54like( $res->output, $failureOutput, "Output OK" ); 61like( $res->output, $failureOutput, "Output OK" );
55 62
63# 4
56$res = NPTest->testCmd( 64$res = NPTest->testCmd(
57 "$sudo ./check_icmp -H $host_nonresponsive -w 10000ms,100% -c 10000ms,100%" 65 "$sudo ./check_icmp -H $host_nonresponsive -w 10000ms,100% -c 10000ms,100%"
58 ); 66 );
59is( $res->return_code, 2, "Timeout - host nonresponsive" ); 67is( $res->return_code, 2, "Timeout - host nonresponsive" );
60like( $res->output, '/100%/', "Error contains '100%' string (for 100% packet loss)" ); 68like( $res->output, '/100%/', "Error contains '100%' string (for 100% packet loss)" );
61 69
70# 4
62$res = NPTest->testCmd( 71$res = NPTest->testCmd(
63 "$sudo ./check_icmp -w 10000ms,100% -c 10000ms,100%" 72 "$sudo ./check_icmp -w 10000ms,100% -c 10000ms,100%"
64 ); 73 );
65is( $res->return_code, 3, "No hostname" ); 74is( $res->return_code, 3, "No hostname" );
66like( $res->output, '/No hosts to check/', "Output with appropriate error message"); 75like( $res->output, '/No hosts to check/', "Output with appropriate error message");
67 76
77# 5
68$res = NPTest->testCmd( 78$res = NPTest->testCmd(
69 "$sudo ./check_icmp -H $host_nonresponsive -w 10000ms,100% -c 10000ms,100% -n 1 -m 0" 79 "$sudo ./check_icmp -H $host_nonresponsive -w 10000ms,100% -c 10000ms,100% -n 1 -m 0"
70 ); 80 );
71is( $res->return_code, 0, "One host nonresponsive - zero required" ); 81is( $res->return_code, 0, "One host nonresponsive - zero required" );
72like( $res->output, $successOutput, "Output OK" ); 82like( $res->output, $successOutput, "Output OK" );
73 83
84# 6
74$res = NPTest->testCmd( 85$res = NPTest->testCmd(
75 "$sudo ./check_icmp -H $host_responsive -H $host_nonresponsive -w 10000ms,100% -c 10000ms,100% -n 1 -m 1" 86 "$sudo ./check_icmp -H $host_responsive -H $host_nonresponsive -w 10000ms,100% -c 10000ms,100% -n 1 -m 1"
76 ); 87 );
77is( $res->return_code, 0, "One of two host nonresponsive - one required" ); 88is( $res->return_code, 0, "One of two host nonresponsive - one required" );
78like( $res->output, $successOutput, "Output OK" ); 89like( $res->output, $successOutput, "Output OK" );
79 90
91# 7
80$res = NPTest->testCmd( 92$res = NPTest->testCmd(
81 "$sudo ./check_icmp -H $host_responsive -H $host_nonresponsive -w 10000ms,100% -c 10000ms,100% -n 1 -m 2" 93 "$sudo ./check_icmp -H $host_responsive -H $host_nonresponsive -w 10000ms,100% -c 10000ms,100% -n 1 -m 2"
82 ); 94 );
83is( $res->return_code, 2, "One of two host nonresponsive - two required" ); 95is( $res->return_code, 2, "One of two host nonresponsive - two required" );
84like( $res->output, $failureOutput, "Output OK" ); 96like( $res->output, $failureOutput, "Output OK" );
85 97
98# 8
86$res = NPTest->testCmd( 99$res = NPTest->testCmd(
87 "$sudo ./check_icmp -H $host_responsive -s 127.0.15.15 -w 10000ms,100% -c 10000ms,100% -n 1 -m 2" 100 "$sudo ./check_icmp -H $host_responsive -s 127.0.15.15 -w 10000ms,100% -c 10000ms,100% -n 1 -m 2"
88 ); 101 );
@@ -90,11 +103,12 @@ is( $res->return_code, 0, "IPv4 source_ip accepted" );
90like( $res->output, $successOutput, "Output OK" ); 103like( $res->output, $successOutput, "Output OK" );
91 104
92$res = NPTest->testCmd( 105$res = NPTest->testCmd(
93 "$sudo ./check_icmp -H ::1 -b 65507" 106 "$sudo ./check_icmp -H $host_responsive -b 65507"
94 ); 107 );
95is( $res->return_code, 0, "Try max paket size" ); 108is( $res->return_code, 0, "Try max paket size" );
96like( $res->output, $successOutput, "Output OK - Didn't overflow" ); 109like( $res->output, $successOutput, "Output OK - Didn't overflow" );
97 110
111# 9
98$res = NPTest->testCmd( 112$res = NPTest->testCmd(
99 "$sudo ./check_icmp -H ::1 -vvv" 113 "$sudo ./check_icmp -H ::1 -vvv"
100 ); 114 );