diff options
Diffstat (limited to 'plugins-root/t/check_icmp.t')
-rw-r--r-- | plugins-root/t/check_icmp.t | 61 |
1 files changed, 54 insertions, 7 deletions
diff --git a/plugins-root/t/check_icmp.t b/plugins-root/t/check_icmp.t index 96addd3..de1d88d 100644 --- a/plugins-root/t/check_icmp.t +++ b/plugins-root/t/check_icmp.t | |||
@@ -12,14 +12,14 @@ my $allow_sudo = getTestParameter( "NP_ALLOW_SUDO", | |||
12 | "no" ); | 12 | "no" ); |
13 | 13 | ||
14 | if ($allow_sudo eq "yes" or $> == 0) { | 14 | if ($allow_sudo eq "yes" or $> == 0) { |
15 | plan tests => 20; | 15 | plan tests => 40; |
16 | } else { | 16 | } else { |
17 | plan skip_all => "Need sudo to test check_icmp"; | 17 | plan skip_all => "Need sudo to test check_icmp"; |
18 | } | 18 | } |
19 | my $sudo = $> == 0 ? '' : 'sudo'; | 19 | my $sudo = $> == 0 ? '' : 'sudo'; |
20 | 20 | ||
21 | my $successOutput = '/OK - .*?: rta (?:[\d\.]+ms)|(?:nan), lost \d+%/'; | 21 | my $successOutput = '/OK - .*? rta (?:[\d\.]+ms)|(?:nan), lost \d+%/'; |
22 | my $failureOutput = '/(WARNING|CRITICAL) - .*?: rta [\d\.]+ms, lost \d%/'; | 22 | my $failureOutput = '/(WARNING|CRITICAL) - .*? rta (?:[\d\.]+ms > [\d\.]+ms|nan)/'; |
23 | 23 | ||
24 | my $host_responsive = getTestParameter( "NP_HOST_RESPONSIVE", | 24 | my $host_responsive = getTestParameter( "NP_HOST_RESPONSIVE", |
25 | "The hostname of system responsive to network requests", | 25 | "The hostname of system responsive to network requests", |
@@ -54,10 +54,11 @@ is( $res->return_code, 2, "Syntax ok, with forced critical" ); | |||
54 | like( $res->output, $failureOutput, "Output OK" ); | 54 | like( $res->output, $failureOutput, "Output OK" ); |
55 | 55 | ||
56 | $res = NPTest->testCmd( | 56 | $res = NPTest->testCmd( |
57 | "$sudo ./check_icmp -H $host_nonresponsive -w 10000ms,100% -c 10000ms,100%" | 57 | "$sudo ./check_icmp -H $host_nonresponsive -w 10000ms,100% -c 10000ms,100% -t 2" |
58 | ); | 58 | ); |
59 | is( $res->return_code, 2, "Timeout - host nonresponsive" ); | 59 | is( $res->return_code, 2, "Timeout - host nonresponsive" ); |
60 | like( $res->output, '/100%/', "Error contains '100%' string (for 100% packet loss)" ); | 60 | like( $res->output, '/pl=100%/', "Error contains 'pl=100%' string (for 100% packet loss)" ); |
61 | like( $res->output, '/rta=U/', "Error contains 'rta=U' string" ); | ||
61 | 62 | ||
62 | $res = NPTest->testCmd( | 63 | $res = NPTest->testCmd( |
63 | "$sudo ./check_icmp -w 10000ms,100% -c 10000ms,100%" | 64 | "$sudo ./check_icmp -w 10000ms,100% -c 10000ms,100%" |
@@ -66,13 +67,13 @@ is( $res->return_code, 3, "No hostname" ); | |||
66 | like( $res->output, '/No hosts to check/', "Output with appropriate error message"); | 67 | like( $res->output, '/No hosts to check/', "Output with appropriate error message"); |
67 | 68 | ||
68 | $res = NPTest->testCmd( | 69 | $res = NPTest->testCmd( |
69 | "$sudo ./check_icmp -H $host_nonresponsive -w 10000ms,100% -c 10000ms,100% -n 1 -m 0" | 70 | "$sudo ./check_icmp -H $host_nonresponsive -w 10000ms,100% -c 10000ms,100% -n 1 -m 0 -t 2" |
70 | ); | 71 | ); |
71 | is( $res->return_code, 0, "One host nonresponsive - zero required" ); | 72 | is( $res->return_code, 0, "One host nonresponsive - zero required" ); |
72 | like( $res->output, $successOutput, "Output OK" ); | 73 | like( $res->output, $successOutput, "Output OK" ); |
73 | 74 | ||
74 | $res = NPTest->testCmd( | 75 | $res = NPTest->testCmd( |
75 | "$sudo ./check_icmp -H $host_responsive -H $host_nonresponsive -w 10000ms,100% -c 10000ms,100% -n 1 -m 1" | 76 | "$sudo ./check_icmp -H $host_responsive -H $host_nonresponsive -w 10000ms,100% -c 10000ms,100% -n 1 -m 1 -t 2" |
76 | ); | 77 | ); |
77 | is( $res->return_code, 0, "One of two host nonresponsive - one required" ); | 78 | is( $res->return_code, 0, "One of two host nonresponsive - one required" ); |
78 | like( $res->output, $successOutput, "Output OK" ); | 79 | like( $res->output, $successOutput, "Output OK" ); |
@@ -94,3 +95,49 @@ $res = NPTest->testCmd( | |||
94 | ); | 95 | ); |
95 | is( $res->return_code, 0, "Try max packet size" ); | 96 | is( $res->return_code, 0, "Try max packet size" ); |
96 | like( $res->output, $successOutput, "Output OK - Didn't overflow" ); | 97 | like( $res->output, $successOutput, "Output OK - Didn't overflow" ); |
98 | |||
99 | $res = NPTest->testCmd( | ||
100 | "$sudo ./check_icmp -H $host_responsive -R 100,100 -n 1 -t 2" | ||
101 | ); | ||
102 | is( $res->return_code, 0, "rta works" ); | ||
103 | like( $res->output, $successOutput, "Output OK" ); | ||
104 | $res = NPTest->testCmd( | ||
105 | "$sudo ./check_icmp -H $host_responsive -P 80,90 -n 1 -t 2" | ||
106 | ); | ||
107 | is( $res->return_code, 0, "pl works" ); | ||
108 | like( $res->output, '/lost 0%/', "Output OK" ); | ||
109 | |||
110 | $res = NPTest->testCmd( | ||
111 | "$sudo ./check_icmp -H $host_responsive -J 80,90 -t 2" | ||
112 | ); | ||
113 | is( $res->return_code, 0, "jitter works" ); | ||
114 | like( $res->output, '/jitter \d/', "Output OK" ); | ||
115 | |||
116 | $res = NPTest->testCmd( | ||
117 | "$sudo ./check_icmp -H $host_responsive -M 4,3 -t 2" | ||
118 | ); | ||
119 | is( $res->return_code, 0, "mos works" ); | ||
120 | like( $res->output, '/MOS \d/', "Output OK" ); | ||
121 | |||
122 | $res = NPTest->testCmd( | ||
123 | "$sudo ./check_icmp -H $host_responsive -S 80,70 -t 2" | ||
124 | ); | ||
125 | is( $res->return_code, 0, "score works" ); | ||
126 | like( $res->output, '/Score \d/', "Output OK" ); | ||
127 | |||
128 | $res = NPTest->testCmd( | ||
129 | "$sudo ./check_icmp -H $host_responsive -O -t 2" | ||
130 | ); | ||
131 | is( $res->return_code, 0, "order works" ); | ||
132 | like( $res->output, '/Packets in order/', "Output OK" ); | ||
133 | |||
134 | $res = NPTest->testCmd( | ||
135 | "$sudo ./check_icmp -H $host_responsive -O -S 80,70 -M 4,3 -J 80,90 -P 80,90 -R 100,100 -t 2" | ||
136 | ); | ||
137 | is( $res->return_code, 0, "order works" ); | ||
138 | like( $res->output, '/Packets in order/', "Output OK" ); | ||
139 | like( $res->output, '/Score \d/', "Output OK" ); | ||
140 | like( $res->output, '/MOS \d/', "Output OK" ); | ||
141 | like( $res->output, '/jitter \d/', "Output OK" ); | ||
142 | like( $res->output, '/lost 0%/', "Output OK" ); | ||
143 | like( $res->output, $successOutput, "Output OK" ); | ||