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/check_swap.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/check_swap.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/check_swap.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