diff options
author | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2025-02-21 13:40:09 +0100 |
---|---|---|
committer | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2025-02-21 13:57:17 +0100 |
commit | 7c8c9d9b3e7bb6c29d82788d05d74e3f18f01aa5 (patch) | |
tree | 8c69270ace6038168c4c79717eb2d9fb3034a960 | |
parent | 1d590a0efe4193ac9298d3eba448ab8bc3bb665b (diff) | |
download | monitoring-plugins-7c8c9d9b3e7bb6c29d82788d05d74e3f18f01aa5.tar.gz |
Remove check_swap tests with one-line format
-rw-r--r-- | plugins/t/check_swap.t | 39 |
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 | ||
7 | use strict; | 7 | use strict; |
8 | use warnings; | 8 | use warnings; |
9 | use Test::More tests => 35; | 9 | use Test::More tests => 21; |
10 | use NPTest; | 10 | use NPTest; |
11 | use JSON; | 11 | use JSON; |
12 | 12 | ||
13 | my $successOutput = '/^OK.* - [0-9]+\% free \([0-9]+MiB out of [0-9]+MiB\)/'; | ||
14 | my $failureOutput = '/^CRITICAL: .*- [0-9]+\% free \([0-9]+MiB out of [0-9]+MiB\)/'; | ||
15 | my $warnOutput = '/^WARNING: .*- [0-9]+\% free \([0-9]+MiB out of [0-9]+MiB\)/'; | ||
16 | |||
17 | my $outputFormat = '--output-format one-line'; | ||
18 | my $result; | 13 | my $result; |
19 | 14 | my $outputFormat = '--output-format mp-test-json'; | |
20 | $result = NPTest->testCmd( "./check_swap $outputFormat" ); # Always OK | ||
21 | cmp_ok( $result->return_code, "==", 0, "Always OK" ); | ||
22 | like( $result->output, $successOutput, "Right output" ); | ||
23 | |||
24 | $result = NPTest->testCmd( "./check_swap -w 1048576 -c 1048576 $outputFormat" ); # 1 MB free | ||
25 | cmp_ok( $result->return_code, "==", 0, "At least 1MB free" ); | ||
26 | like( $result->output, $successOutput, "Right output" ); | ||
27 | |||
28 | $result = NPTest->testCmd( "./check_swap -w 1% -c 1% $outputFormat" ); # 1% free | ||
29 | cmp_ok( $result->return_code, "==", 0, 'At least 1% free' ); | ||
30 | like( $result->output, $successOutput, "Right output" ); | ||
31 | |||
32 | $result = NPTest->testCmd( "./check_swap -w 100% -c 100% $outputFormat" ); # 100% (always critical) | ||
33 | cmp_ok( $result->return_code, "==", 2, 'Get critical because not 100% free' ); | ||
34 | like( $result->output, $failureOutput, "Right output" ); | ||
35 | |||
36 | $result = NPTest->testCmd( "./check_swap -w 100% -c 1% $outputFormat" ); # 100% (always warn) | ||
37 | cmp_ok( $result->return_code, "==", 1, 'Get warning because not 100% free' ); | ||
38 | like( $result->output, $warnOutput, "Right output" ); | ||
39 | |||
40 | $result = NPTest->testCmd( "./check_swap -w 100% $outputFormat" ); # 100% (single threshold, always warn) | ||
41 | cmp_ok( $result->return_code, "==", 1, 'Get warning because not 100% free' ); | ||
42 | like( $result->output, $warnOutput, "Right output" ); | ||
43 | |||
44 | $result = NPTest->testCmd( "./check_swap -c 100% $outputFormat" ); # 100% (single threshold, always critical) | ||
45 | cmp_ok( $result->return_code, "==", 2, 'Get critical because not 100% free' ); | ||
46 | like( $result->output, $failureOutput, "Right output" ); | ||
47 | |||
48 | |||
49 | $outputFormat = '--output-format mp-test-json'; | ||
50 | my $output; | 15 | my $output; |
51 | my $message = '/^[0-9]+\% free \([0-9]+MiB out of [0-9]+MiB\)/'; | 16 | my $message = '/^[0-9]+\% free \([0-9]+MiB out of [0-9]+MiB\)/'; |
52 | 17 | ||