From 396bcf50ce23fc34d14e4ef8fb6d9843b977f95c Mon Sep 17 00:00:00 2001 From: Danijel Tasov Date: Wed, 4 Oct 2023 10:21:41 +0200 Subject: adjust check_icmp tests --- plugins-root/t/check_icmp.t | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'plugins-root/t') diff --git a/plugins-root/t/check_icmp.t b/plugins-root/t/check_icmp.t index 96addd3b..07e175e9 100644 --- a/plugins-root/t/check_icmp.t +++ b/plugins-root/t/check_icmp.t @@ -18,8 +18,8 @@ if ($allow_sudo eq "yes" or $> == 0) { } my $sudo = $> == 0 ? '' : 'sudo'; -my $successOutput = '/OK - .*?: rta (?:[\d\.]+ms)|(?:nan), lost \d+%/'; -my $failureOutput = '/(WARNING|CRITICAL) - .*?: rta [\d\.]+ms, lost \d%/'; +my $successOutput = '/OK - .*? rta (?:[\d\.]+ms)|(?:nan), lost \d+%/'; +my $failureOutput = '/(WARNING|CRITICAL) - .*? rta [\d\.]+ms > [\d\.]+ms/'; my $host_responsive = getTestParameter( "NP_HOST_RESPONSIVE", "The hostname of system responsive to network requests", @@ -54,7 +54,7 @@ is( $res->return_code, 2, "Syntax ok, with forced critical" ); like( $res->output, $failureOutput, "Output OK" ); $res = NPTest->testCmd( - "$sudo ./check_icmp -H $host_nonresponsive -w 10000ms,100% -c 10000ms,100%" + "$sudo ./check_icmp -H $host_nonresponsive -w 10000ms,100% -c 10000ms,100% -t 2" ); is( $res->return_code, 2, "Timeout - host nonresponsive" ); like( $res->output, '/100%/', "Error contains '100%' string (for 100% packet loss)" ); @@ -66,13 +66,13 @@ is( $res->return_code, 3, "No hostname" ); like( $res->output, '/No hosts to check/', "Output with appropriate error message"); $res = NPTest->testCmd( - "$sudo ./check_icmp -H $host_nonresponsive -w 10000ms,100% -c 10000ms,100% -n 1 -m 0" + "$sudo ./check_icmp -H $host_nonresponsive -w 10000ms,100% -c 10000ms,100% -n 1 -m 0 -t 2" ); is( $res->return_code, 0, "One host nonresponsive - zero required" ); like( $res->output, $successOutput, "Output OK" ); $res = NPTest->testCmd( - "$sudo ./check_icmp -H $host_responsive -H $host_nonresponsive -w 10000ms,100% -c 10000ms,100% -n 1 -m 1" + "$sudo ./check_icmp -H $host_responsive -H $host_nonresponsive -w 10000ms,100% -c 10000ms,100% -n 1 -m 1 -t 2" ); is( $res->return_code, 0, "One of two host nonresponsive - one required" ); like( $res->output, $successOutput, "Output OK" ); -- cgit v1.2.3-74-g34f1 From df57a23e0ace0c1d1c19038fd3834b20742ef24a Mon Sep 17 00:00:00 2001 From: Danijel Tasov Date: Wed, 4 Oct 2023 10:39:30 +0200 Subject: update failure regex --- plugins-root/t/check_icmp.t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins-root/t') diff --git a/plugins-root/t/check_icmp.t b/plugins-root/t/check_icmp.t index 07e175e9..9fb8fa06 100644 --- a/plugins-root/t/check_icmp.t +++ b/plugins-root/t/check_icmp.t @@ -19,7 +19,7 @@ if ($allow_sudo eq "yes" or $> == 0) { my $sudo = $> == 0 ? '' : 'sudo'; my $successOutput = '/OK - .*? rta (?:[\d\.]+ms)|(?:nan), lost \d+%/'; -my $failureOutput = '/(WARNING|CRITICAL) - .*? rta [\d\.]+ms > [\d\.]+ms/'; +my $failureOutput = '/(WARNING|CRITICAL) - .*? rta (?:[\d\.]+ms > [\d\.]+ms|nan)/'; my $host_responsive = getTestParameter( "NP_HOST_RESPONSIVE", "The hostname of system responsive to network requests", -- cgit v1.2.3-74-g34f1 From 4e7eb550791afdb5d3e496a84be00286ccb6fb5b Mon Sep 17 00:00:00 2001 From: Danijel Tasov Date: Wed, 4 Oct 2023 11:34:25 +0200 Subject: add some basic tests for the new modes Signed-off-by: Danijel Tasov --- plugins-root/t/check_icmp.t | 48 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) (limited to 'plugins-root/t') diff --git a/plugins-root/t/check_icmp.t b/plugins-root/t/check_icmp.t index 9fb8fa06..4f9db868 100644 --- a/plugins-root/t/check_icmp.t +++ b/plugins-root/t/check_icmp.t @@ -12,7 +12,7 @@ my $allow_sudo = getTestParameter( "NP_ALLOW_SUDO", "no" ); if ($allow_sudo eq "yes" or $> == 0) { - plan tests => 20; + plan tests => 39; } else { plan skip_all => "Need sudo to test check_icmp"; } @@ -94,3 +94,49 @@ $res = NPTest->testCmd( ); is( $res->return_code, 0, "Try max packet size" ); like( $res->output, $successOutput, "Output OK - Didn't overflow" ); + +$res = NPTest->testCmd( + "$sudo ./check_icmp -H $host_responsive -R 100,100 -n 1 -t 2" + ); +is( $res->return_code, 0, "rta works" ); +like( $res->output, $successOutput, "Output OK" ); +$res = NPTest->testCmd( + "$sudo ./check_icmp -H $host_responsive -P 80,90 -n 1 -t 2" + ); +is( $res->return_code, 0, "pl works" ); +like( $res->output, '/lost 0%/', "Output OK" ); + +$res = NPTest->testCmd( + "$sudo ./check_icmp -H $host_responsive -J 80,90 -t 2" + ); +is( $res->return_code, 0, "jitter works" ); +like( $res->output, '/jitter \d/', "Output OK" ); + +$res = NPTest->testCmd( + "$sudo ./check_icmp -H $host_responsive -M 4,3 -t 2" + ); +is( $res->return_code, 0, "mos works" ); +like( $res->output, '/MOS \d/', "Output OK" ); + +$res = NPTest->testCmd( + "$sudo ./check_icmp -H $host_responsive -S 80,70 -t 2" + ); +is( $res->return_code, 0, "score works" ); +like( $res->output, '/Score \d/', "Output OK" ); + +$res = NPTest->testCmd( + "$sudo ./check_icmp -H $host_responsive -O -t 2" + ); +is( $res->return_code, 0, "order works" ); +like( $res->output, '/Packets in order/', "Output OK" ); + +$res = NPTest->testCmd( + "$sudo ./check_icmp -H $host_responsive -O -S 80,70 -M 4,3 -J 80,90 -P 80,90 -R 100,100 -t 2" + ); +is( $res->return_code, 0, "order works" ); +like( $res->output, '/Packets in order/', "Output OK" ); +like( $res->output, '/Score \d/', "Output OK" ); +like( $res->output, '/MOS \d/', "Output OK" ); +like( $res->output, '/jitter \d/', "Output OK" ); +like( $res->output, '/lost 0%/', "Output OK" ); +like( $res->output, $successOutput, "Output OK" ); -- cgit v1.2.3-74-g34f1