From 675f208476628af192d1fdee9eeedcc76fbc8d43 Mon Sep 17 00:00:00 2001 From: Napsty Date: Fri, 12 Apr 2024 13:23:58 +0200 Subject: Adjust check_swap tests --- plugins/t/check_swap.t | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'plugins/t') diff --git a/plugins/t/check_swap.t b/plugins/t/check_swap.t index de9e0f05..f40d9ef6 100644 --- a/plugins/t/check_swap.t +++ b/plugins/t/check_swap.t @@ -14,6 +14,10 @@ my $warnOutput = '/^SWAP WARNING - [0-9]+\% free \([0-9]+MB out of [0-9]+MB\) my $result; +$result = NPTest->testCmd( "./check_swap" ); # Always OK +cmp_ok( $result->return_code, "==", 0, "Always OK" ); +like( $result->output, $successOutput, "Right output" ); + $result = NPTest->testCmd( "./check_swap -w 1048576 -c 1048576" ); # 1 MB free cmp_ok( $result->return_code, "==", 0, "At least 1MB free" ); like( $result->output, $successOutput, "Right output" ); @@ -29,3 +33,11 @@ like( $result->output, $failureOutput, "Right output" ); $result = NPTest->testCmd( "./check_swap -w 100% -c 1%" ); # 100% (always warn) cmp_ok( $result->return_code, "==", 1, 'Get warning because not 100% free' ); like( $result->output, $warnOutput, "Right output" ); + +$result = NPTest->testCmd( "./check_swap -w 100%" ); # 100% (single threshold, always warn) +cmp_ok( $result->return_code, "==", 1, 'Get warning because not 100% free' ); +like( $result->output, $warnOutput, "Right output" ); + +$result = NPTest->testCmd( "./check_swap -c 100%" ); # 100% (single threshold, always critical) +cmp_ok( $result->return_code, "==", 2, 'Get critical because not 100% free' ); +like( $result->output, $warnOutput, "Right output" ); -- cgit v1.2.3-74-g34f1 From 60614121d120b727831fa4201c277e626acb4057 Mon Sep 17 00:00:00 2001 From: Napsty Date: Fri, 12 Apr 2024 13:28:45 +0200 Subject: Adjust check_swap tests --- plugins/t/check_swap.t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/t') diff --git a/plugins/t/check_swap.t b/plugins/t/check_swap.t index f40d9ef6..f58c4120 100644 --- a/plugins/t/check_swap.t +++ b/plugins/t/check_swap.t @@ -40,4 +40,4 @@ like( $result->output, $warnOutput, "Right output" ); $result = NPTest->testCmd( "./check_swap -c 100%" ); # 100% (single threshold, always critical) cmp_ok( $result->return_code, "==", 2, 'Get critical because not 100% free' ); -like( $result->output, $warnOutput, "Right output" ); +like( $result->output, $failureOutput, "Right output" ); -- cgit v1.2.3-74-g34f1 From 3deea4cc630d9442b8e5f18c50c5929e7e61333b Mon Sep 17 00:00:00 2001 From: Napsty Date: Fri, 12 Apr 2024 13:35:55 +0200 Subject: Adjust check_swap tests --- plugins/t/check_swap.t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/t') diff --git a/plugins/t/check_swap.t b/plugins/t/check_swap.t index f58c4120..18780386 100644 --- a/plugins/t/check_swap.t +++ b/plugins/t/check_swap.t @@ -5,7 +5,7 @@ # use strict; -use Test::More tests => 8; +use Test::More tests => 14; use NPTest; my $successOutput = '/^SWAP OK - [0-9]+\% free \([0-9]+MB out of [0-9]+MB\)/'; -- cgit v1.2.3-74-g34f1 From 9e6361077b7fd690d00ab8f68ca9f2c435dd81a9 Mon Sep 17 00:00:00 2001 From: Sven Nierlein Date: Tue, 23 Jul 2024 16:22:12 +0200 Subject: check_http: replace www.mozilla.com with monitoring-plugins.org this makes tests more reliable if we test our own sites instead some 3rd party site. Signed-off-by: Sven Nierlein --- plugins/t/check_curl.t | 4 ++-- plugins/t/check_http.t | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'plugins/t') diff --git a/plugins/t/check_curl.t b/plugins/t/check_curl.t index eae98cc1..7a930a4e 100644 --- a/plugins/t/check_curl.t +++ b/plugins/t/check_curl.t @@ -205,9 +205,9 @@ SKIP: { like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' ); like ( $res->output, '/time_ssl=[\d\.]+/', 'Extended Performance Data SSL Output OK' ); - $res = NPTest->testCmd( "./$plugin -H www.mozilla.com -u /firefox -f curl" ); + $res = NPTest->testCmd( "./$plugin -H monitoring-plugins.org -u /download.html -f follow" ); is( $res->return_code, 0, "Redirection based on location is okay"); - $res = NPTest->testCmd( "./$plugin -H www.mozilla.com --extended-perfdata" ); + $res = NPTest->testCmd( "./$plugin -H monitoring-plugins.org --extended-perfdata" ); like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' ); } diff --git a/plugins/t/check_http.t b/plugins/t/check_http.t index 1f2fbdfd..6ab4a5b6 100644 --- a/plugins/t/check_http.t +++ b/plugins/t/check_http.t @@ -166,10 +166,10 @@ SKIP: { like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' ); like ( $res->output, '/time_ssl=[\d\.]+/', 'Extended Performance Data SSL Output OK' ); - $res = NPTest->testCmd( "./$plugin -H www.mozilla.com -u /firefox -f follow" ); + $res = NPTest->testCmd( "./$plugin -H monitoring-plugins.org -u /download.html -f follow" ); is( $res->return_code, 0, "Redirection based on location is okay"); - $res = NPTest->testCmd( "./$plugin -H www.mozilla.com --extended-perfdata" ); + $res = NPTest->testCmd( "./$plugin -H monitoring-plugins.org --extended-perfdata" ); like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' ); } -- cgit v1.2.3-74-g34f1