summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLorenz Kästle <12514511+RincewindsHat@users.noreply.github.com>2025-02-21 13:40:09 +0100
committerLorenz Kästle <12514511+RincewindsHat@users.noreply.github.com>2025-02-21 13:57:17 +0100
commit7c8c9d9b3e7bb6c29d82788d05d74e3f18f01aa5 (patch)
tree8c69270ace6038168c4c79717eb2d9fb3034a960
parent1d590a0efe4193ac9298d3eba448ab8bc3bb665b (diff)
downloadmonitoring-plugins-7c8c9d9b3e7bb6c29d82788d05d74e3f18f01aa5.tar.gz
Remove check_swap tests with one-line format
-rw-r--r--plugins/t/check_swap.t39
1 files changed, 2 insertions, 37 deletions
diff --git a/plugins/t/check_swap.t b/plugins/t/check_swap.t
index 93e481c3..7e61b766 100644
--- a/plugins/t/check_swap.t
+++ b/plugins/t/check_swap.t
@@ -6,47 +6,12 @@
6 6
7use strict; 7use strict;
8use warnings; 8use warnings;
9use Test::More tests => 35; 9use Test::More tests => 21;
10use NPTest; 10use NPTest;
11use JSON; 11use JSON;
12 12
13my $successOutput = '/^OK.* - [0-9]+\% free \([0-9]+MiB out of [0-9]+MiB\)/';
14my $failureOutput = '/^CRITICAL: .*- [0-9]+\% free \([0-9]+MiB out of [0-9]+MiB\)/';
15my $warnOutput = '/^WARNING: .*- [0-9]+\% free \([0-9]+MiB out of [0-9]+MiB\)/';
16
17my $outputFormat = '--output-format one-line';
18my $result; 13my $result;
19 14my $outputFormat = '--output-format mp-test-json';
20$result = NPTest->testCmd( "./check_swap $outputFormat" ); # Always OK
21cmp_ok( $result->return_code, "==", 0, "Always OK" );
22like( $result->output, $successOutput, "Right output" );
23
24$result = NPTest->testCmd( "./check_swap -w 1048576 -c 1048576 $outputFormat" ); # 1 MB free
25cmp_ok( $result->return_code, "==", 0, "At least 1MB free" );
26like( $result->output, $successOutput, "Right output" );
27
28$result = NPTest->testCmd( "./check_swap -w 1% -c 1% $outputFormat" ); # 1% free
29cmp_ok( $result->return_code, "==", 0, 'At least 1% free' );
30like( $result->output, $successOutput, "Right output" );
31
32$result = NPTest->testCmd( "./check_swap -w 100% -c 100% $outputFormat" ); # 100% (always critical)
33cmp_ok( $result->return_code, "==", 2, 'Get critical because not 100% free' );
34like( $result->output, $failureOutput, "Right output" );
35
36$result = NPTest->testCmd( "./check_swap -w 100% -c 1% $outputFormat" ); # 100% (always warn)
37cmp_ok( $result->return_code, "==", 1, 'Get warning because not 100% free' );
38like( $result->output, $warnOutput, "Right output" );
39
40$result = NPTest->testCmd( "./check_swap -w 100% $outputFormat" ); # 100% (single threshold, always warn)
41cmp_ok( $result->return_code, "==", 1, 'Get warning because not 100% free' );
42like( $result->output, $warnOutput, "Right output" );
43
44$result = NPTest->testCmd( "./check_swap -c 100% $outputFormat" ); # 100% (single threshold, always critical)
45cmp_ok( $result->return_code, "==", 2, 'Get critical because not 100% free' );
46like( $result->output, $failureOutput, "Right output" );
47
48
49$outputFormat = '--output-format mp-test-json';
50my $output; 15my $output;
51my $message = '/^[0-9]+\% free \([0-9]+MiB out of [0-9]+MiB\)/'; 16my $message = '/^[0-9]+\% free \([0-9]+MiB out of [0-9]+MiB\)/';
52 17